OK,
I got voce to work with processing.
The "out of memory" exception arises when I try to run it from eclipse, but I managed to compile to bytecode and run on a VM outside of eclipse without any problem.
Edit:I got it working in eclipse. the trick was to pass it the memory argument as a VM argument ("-mx256m")
The program is simple: it displays a 200x200 black square. The words "let there be light" change the background to yellow, "lights out" changes it to black and "quit" exits the program.
The java file is the following:
Code:/// A sample application to test voce's voice recognition
/// capabilities.
import processing.core.*;
import voce.*;
public class recognitionTest extends PApplet
{
private boolean _quit;
private boolean _on;
public void setup() {
size(200,200);
background(0);
voce.SpeechInterface.init("../../../lib", false, true,
"./grammar", "ONOFF");
System.out.println("This is a speech recognition test. "
+ "Say ON or OFF in the microphone"
+ "Speak 'quit' to quit.");
_quit = false;
_on = false;
}
public void draw() {
stroke(255);
if (_on == true) {
background(255, 204, 0);
}
else {
background(0);
}
while (voce.SpeechInterface.getRecognizerQueueSize() > 0)
{
String s = voce.SpeechInterface.popRecognizedString();
if(-1 != s.indexOf("let there be light")){
_on = true;
}
else if(-1 != s.indexOf("lights off")){
_on = false;
}
// Check if the string contains 'quit'.
if (-1 != s.indexOf("quit"))
{
_quit = true;
}
System.out.println("You said: " + s);
//voce.SpeechInterface.synthesize(s);
}
if(_quit){
voce.SpeechInterface.destroy();
System.exit(0);
}
}
public static void main(String[] argv)
{
PApplet.main(new String[] { "--location=10,40", "recognitionTest" });
}
}
This requires a grammar file in ./grammar named "ONOFF.gram"
Code:
#JSGF V1.0;
/**
* JSGF OnOff Grammar file
*/
grammar OnOff;
public <miscellaneous> = (quit);
public <ONOFF> = (let there be light | lights off) * ;
I then compiled using
javac -classpath [path to voce];[path to processing] *.java
and run it with
java
java -classpath .;[path to voce];[path to processing] -mx512m recognitionTest
Hope this can help. I'm still trying to figure this whole thing out.
Francois.