CMU Sphinx 4-5prealpha:"警告:语法缺少自我识别标题"

时间:2016-09-22 15:08:08

标签: java speech-recognition cmusphinx sphinx4

我试图习惯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";

1 个答案:

答案 0 :(得分:0)

实际上,它不是一个sphinx bug或者其他什么东西 - 只是我的无辜。我正在编辑另一个语法文件&#34; grammar.gram&#34;而不是&#34; hello.gram&#34;。错误已经完成,现在工作正常!