【发布时间】:2017-01-31 05:55:47
【问题描述】:
我正在努力适应 CMU sphinx 4-5prealpha。 没有语法的识别一切都很好,但我需要处理的命令/单词/短语并不多。所以,这里有一些代码和错误堆栈:
public static void main(String[] args) throws Exception {
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");
configuration.setLanguageModelPath("resource:/edu/cmu/sphinx/models/en-us/en-us.lm.bin");
configuration.setGrammarPath("/home/enchanting/records");
configuration.setGrammarName("hello");
configuration.setUseGrammar(true);
LiveSpeechRecognizer recognizer = new LiveSpeechRecognizer(configuration);
// 开始识别过程修剪之前缓存的数据。
while(true){
recognizer.startRecognition(true);
System.out.println("go!");
String utterance = recognizer.getResult().getHypothesis();
System.out.println(utterance);
recognizer.stopRecognition();
System.out.println("done");
}
}
所以,我完全确定我的语法文件位置没问题,错误是:
> WARNING: Grammar missing self identifying header
> Exception in thread "main" java.lang.RuntimeException: Allocation of search manager resources failed
> Caused by: java.io.IOException: edu.cmu.sphinx.jsgf.JSGFGrammarParseException
更新: 我的错,忘了粘贴我的语法:D
> hello.gram
#JSGF V1.0;
grammar hello;
public <intro> = "Computer";
【问题讨论】:
-
如果您的语法文件不是那么大,发布它可能是有意义的。
标签: java speech-recognition cmusphinx sphinx4