【问题标题】:How to config grammar for StreamSpeechRecognizer in CMUSphinx如何在 CMUSphinx 中为 StreamSpeechRecognizer 配置语法
【发布时间】:2015-06-09 11:42:01
【问题描述】:
我有这样的语法:
#JSGF V1.0;
grammar music;
public <command> = play | pause | next | previous;
当我将此语法用于 LiveSpeechRegconizer 时,它运行良好。
现在我想在 StreamSpeechRegconizer 中使用它。在 Github 上使用 StreamSpeechRecognizer 的源 CMUSphinx 示例的转录器演示中,它仅显示了使用整个字典检测语音的方法。有没有办法只配置我自己的语法?
【问题讨论】:
标签:
speech-recognition
speech-to-text
cmusphinx
【解决方案1】:
要使用语法,您需要正确创建一个配置对象:
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);