【问题标题】:CMU Sphinx 4-5prealpha : "WARNING: Grammar missing self identifying header"CMU Sphinx 4-5prealpha:“警告:语法缺少自我识别标头”
【发布时间】: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


【解决方案1】:

实际上,这不是狮身人面像之类的错误——只是我的本能。我正在编辑另一个语法文件“grammar.gram”而不是“hello.gram”。错误已完成,现在可以正常工作了!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多