ConfigurationManager cm;
cm = new ConfigurationManager(HelloWorld.class.getResource("helloworld.config.xml"));
Recognizer recognizer = (Recognizer) cm.lookup("recognizer");
recognizer.allocate();
// start the microphone or exit if the programm if this is not possible
Microphone microphone = (Microphone) cm.lookup("microphone");
if (!microphone.startRecording())
{
recognizer.deallocate();
System.exit(1);
}
while (true)
{
Result result = recognizer.recognize();
if (result != null)
{
String resultText = result.getBestFinalResultNoFiller();
// You will get the spoken word in "resultText" as a String
// Use this string and write your code according to your requirments
}
}
}
****************/
Rest of the code like creating GUI can be created according to the requirements
Given Grammar file can also be modified according to your choice of words to be recognized
Then to build this program install Apache Ant (unzip the Apache Ant freely available on internet in any directory)
Set enviroment variables as
CLASSPATH : "apache ant bin directory's path"; "java bin directory's path"
ANT HOME : "apache ant directory's path"
JAVA HOME : "java directory's path"
Open command prompt and go to sphinx directory
enter Command : ANT
This will build the whole sphinx and jar file of your program can be seen in BIN folder of Sphinx directory