SL4A: Speech Recognition and Transcription

SL4A gives you access to a simplified Android API, but it’s still got plenty of functionality to make some functional apps using small amounts of code. The following Python script starts a speech recognition dialogue, then outputs that as text in the terminal.

# SL4A Demos - Transcribe Speech
# http://blog.matthewashrafi.com/

import android

droid = android.Android()

print "########################################"
print "# SL4A Demos - Transcribe Speech       #"
print "# From http://blog.matthewashrafi.com/ #"
print "########################################"
print "nSay something at the prompt."

speech = droid.recognizeSpeech("Talk Now",None,None)
print "You said: "
print speech[1]

transcribe-speech.py

Alternatively, you can use a barcode scanner to scan in the script from the following QR code:

Screenshots

The editor view within SL4A.

transcribe-speech.py in the terminal.

The voice recognition dialogue processing speech.

After the script has run, the transcribed speech,  in this case “cheat sheet”, is displayed after the “You said:” line.