我有这样的语法:
#JSGF V1.0;
grammar music;
public <command> = play | pause | next | previous;当我在LiveSpeechRegconizer中使用这个语法时,它工作得很好。
现在我想在StreamSpeechRegconizer中使用这个。在使用CMUSphinx的github上的源StreamSpeechRecognizer示例上的转录器演示中,它只显示了用整个字典检测语音的方法。有办法配置我自己的语法吗?
发布于 2015-06-08 17:51:50
要使用语法,需要正确地创建一个配置对象:
Configuration configuration = new Configuration();
configuration.setAcousticModelPath("resource:/edu/cmu/sphinx/models/en-us/en-us");
configuration.setDictionaryPath("resource:/edu/cmu/sphinx/models/en-us/cmudict-en-us.dict");
// a folder in classpath or in filesystem containing the grammars
configuration.setGrammarPath("resource:/com/example/grammars");
// A grammar name corresponding to a file music.jsgf
configuration.setGrammarName("music");
configuration.setUseGrammar(true);
StreamSpeechRecognizer recognizer = new StreamSpeechRecognizer(configuration);https://stackoverflow.com/questions/30712408
复制相似问题