javaspeech-recognitionspeechsphinx4

How to add custom grammar in Sphinx4 for speech recognition in Java?


I am using sphinx4 1.0 beta 6 to make a voice recognizer in Java. In sphinx4 there is demo sample called HelloWorld. That demo runs well without any problem. But it recognize only few words. I have to change its hello.gram file. If I add some extra words in that grammar file it doesn't work for those word. How can I add my own grammar file and load in HelloWorld sample? I have studied a lot on JSGFGrammar. But I couldn't understand. I am using Netbeans IDE.


Solution

  • Open the helloworld.config.xml file. In this xml file you have to change the location of the grammar file. Just find and make this line <property value="resource:/edu/cmu/sphinx/demo/helloworld/" name="grammarLocation"/> to <property value="resource:/your/grammar/file/location" name="grammarLocation"/>. And if you want to change the name of your grammar file hello.gram to ssomething else you have to change this line <property value="your file name" name="grammarName"/>

    This should work.