首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在StreamSpeechRecognizer中配置CMUSphinx语法

如何在StreamSpeechRecognizer中配置CMUSphinx语法
EN

Stack Overflow用户
提问于 2015-06-08 14:51:20
回答 1查看 947关注 0票数 1

我有这样的语法:

代码语言:javascript
复制
#JSGF V1.0;

grammar music;

public <command> = play | pause | next | previous;

当我在LiveSpeechRegconizer中使用这个语法时,它工作得很好。

现在我想在StreamSpeechRegconizer中使用这个。在使用CMUSphinx的github上的源StreamSpeechRecognizer示例上的转录器演示中,它只显示了用整个字典检测语音的方法。有办法配置我自己的语法吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-06-08 17:51:50

要使用语法,需要正确地创建一个配置对象:

代码语言:javascript
复制
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);
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30712408

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档