Last active
December 17, 2015 19:39
-
-
Save getflourish/5661943 to your computer and use it in GitHub Desktop.
Use STT with an External Microphone
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| // Using External Microphones with STT | |
| // www.getflourish.com/sst/ | |
| // | |
| // Florian Schulz 2013 | |
| */ | |
| import com.getflourish.stt.*; | |
| import ddf.minim.*; | |
| import javax.sound.sampled.*; | |
| STT stt; | |
| String result; | |
| void setup () | |
| { | |
| size(600, 200); | |
| // Init STT automatically starts listening | |
| stt = new STT(this); | |
| stt.enableDebug(); | |
| stt.setLanguage("en"); | |
| // Display available Inputs with id and name | |
| Mixer.Info[] mixerInfo = AudioSystem.getMixerInfo(); | |
| for(int i = 0; i < mixerInfo.length; i++) | |
| { | |
| println(i + ": " + mixerInfo[i].getName()); | |
| } | |
| // Set input (e.g. 0) | |
| Mixer mixer = AudioSystem.getMixer(mixerInfo[0]); | |
| // Update the Minim instance that STT is using | |
| Minim minim = stt.getMinimInstance(); | |
| minim.setInputMixer(mixer); | |
| } | |
| // Method is called if transcription was successfull | |
| void transcribe (String utterance, float confidence) | |
| { | |
| println(utterance); | |
| result = utterance; | |
| } | |
| public void keyPressed () { | |
| stt.begin(); | |
| } | |
| public void keyReleased () { | |
| stt.end(); | |
| } | |
| void draw () | |
| { | |
| background(0); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment