August 18 - Speech Recognition

Post date: Aug 19, 2010 2:46:21 AM

Today I worked on the speech recognition part of my final. I used the voce library (http://voce.sourceforge.net/) to set up a simple test app which recognizes the two phrases required for the project and reads them back for confirmation. For this to run, a few things need to be done: the voce library must be unzipped to the "libraries" directory in the sketchbook folder, the sketch must be in a folder called SpeechRec in the sketchbook (or if it isn't the path in the code should be changed accordingly), and in the sketch folder, a folder named "grammar" must be created, with a file called "test.gram" inside it, containing the code in this post. Likewise, there is a setting in preferences to increase the memory that your sketch uses to 256 mb - this needs to be checked, otherwise your sketch will get an Out Of Memory error. Thanks to the nice folks in this thread at processing.org for supplying the info needed to get this library up and running. I attached a short swf video of myself saying the phrases into my laptop mic to demonstrate.

Processing Sketch:

import voce.*;

void setup() {

size(200,200);

background(0);

voce.SpeechInterface.init("../Users/Joseph/Documents/Processing/libraries/voce/lib", true, true,

"../Users/Joseph/Documents/Processing/SpeechRec/grammar", "test");

System.out.println("This is a speech recognition test. ");

}


void draw() {

stroke(255);

while (voce.SpeechInterface.getRecognizerQueueSize() > 0){

String s = voce.SpeechInterface.popRecognizedString();

println("You said: " + s);

voce.SpeechInterface.synthesize(s);

}

}

test.gram:

#JSGF V1.0;

grammar Test;

public <TEST> = (I solemnly swear that I am up to no good | mischief managed) * ;