Speech To Text Library for Processing
Speech recognition library based on Google’s web service that enables speech input on HTML5 input fields in Google Chrome.
<input type="text" x-webkit-speech />
I was really surprised how good it works for several languages and decided to make it available as an open source library for Processing.
Download and install the library inside your libraries folder. The library listens to the microphone input of your computer and sends recordings of your voice to Google for further processing. If the transcription was successful, the transcribe method is called and you can do whatever you want with the result. You can find some more details in the very early JavaDoc.
- STT(PApplet p, boolean history) constructor takes the instance of PApplet (usually this) and an optional boolean value which is false by default. If you set it to true all recordings will be kept in the data folder
- begin() starts a record until end() is called
- disableAutoRecord() disables automatic records
- disableAutoThreshold() disables the analysis of the environmental volume after STT initialized
- enableDebug() enables console output with relevant information about the transcription process
- enableAutoRecord() analyzed the environment sound level and automatically records if anything louder than the average level is recognized
- enableAutoRecord(float threshold) automatically records if the given volume threshold is reached
- enableAutoThreshold() enables the analysis of the environmental sounds level after STT initialized
- end() ends a record and starts transcription process
- getLineIn() returns the Minim.AudioInput that STT is using. This is helpful when you want to do other things with the audio input besides voice recognition (e.g. FFT analysis). Use it instead of calling in = minim.getLineIn(Mono).
- getMinimInstance() returns the Minim instance that STT is using.
- setLanguage(String) en, de, fr, etc. If the language is not supported it will automatically fall back to English.
- setThreshold(float) sets the threshold that is used for speech recognition. If the input volume goes above the threshold it will be used for recognition
Basic Example (Press a Key to Record)
Using External Microphones
If you want to change the audio input source, you can pass a different mixer to the Minim instance that STT is using. If you don't know the id of the mixer, you can get a list as shown in this example:
CreditsThe library is based on some thoughts by Mike Pultz who wrote an article that shows how to use the technology offered by Google without a browser. The library has the following dependencies: Minim, Gson and Java FLAC Encoder.
Email me or follow me on Twitter. I’m a designer and I’m aware of bugs, errors and bad ways of coding. Anyway, as long as it works for me, I’m happy to share what I’ve got. Feel free to make any changes to the code.
Florian Schulz, June 2011