Speech recognition java.lang.IllegalStateException:运行CMUSphinx示例时,预期状态就绪实际状态解除分配错误

Speech recognition java.lang.IllegalStateException:运行CMUSphinx示例时,预期状态就绪实际状态解除分配错误,speech-recognition,speech,cmusphinx,Speech Recognition,Speech,Cmusphinx,我 有 从以下位置运行StreamSpeechRecognizer示例: 但得到以下错误: Exception in thread "main" java.lang.IllegalStateException: Expected state READY actual state DEALLOCATED at edu.cmu.sphinx.recognizer.Recognizer.checkState(Recognizer.java:137) at edu.cmu.sphinx.re

我 有 从以下位置运行StreamSpeechRecognizer示例:

但得到以下错误:

Exception in thread "main" java.lang.IllegalStateException: Expected state READY actual state       DEALLOCATED
at edu.cmu.sphinx.recognizer.Recognizer.checkState(Recognizer.java:137)
at edu.cmu.sphinx.recognizer.Recognizer.recognize(Recognizer.java:106)
at edu.cmu.sphinx.recognizer.Recognizer.recognize(Recognizer.java:125)
at edu.cmu.sphinx.api.AbstractSpeechRecognizer.getResult(AbstractSpeechRecognizer.java:50)
at com.mbi.ciolab.vpa.speech.sphinx4.StreamSpeechRecognizerTest.main(StreamSpeechRecognizerTest.java:37)
代码如下:

public static void main(String[] args) throws IOException {
    Configuration configuration = new Configuration();

    // Set path to acoustic model.
    //configuration.setAcousticModelPath("resource:/WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz");
    // Set path to dictionary.
    //configuration.setDictionaryPath("resource:/WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz/dict/cmudict.0.6d");
    // Set language model.

    // Set path to acoustic model.
    configuration.setAcousticModelPath("models/acoustic/wsj_8kHz");
    // Set path to dictionary.
    configuration.setDictionaryPath("models/acoustic/wsj_8kHz/dict/cmudict.0.6d");
    configuration.setLanguageModelPath("models/language/en-us.lm.dmp");
    StreamSpeechRecognizer recognizer = new StreamSpeechRecognizer(configuration);
    recognizer.startRecognition(new FileInputStream(new File("data/test.wav")));
    //recognizer.startRecognition(new FileInputStream(new File("speech.wav")));
    SpeechResult result = recognizer.getResult();
    recognizer.stopRecognition();
    while ((result = recognizer.getResult()) != null) {
        System.out.println(result.getHypothesis());
    }
}

您可能应该提供您编写的代码。最有可能的情况是,您在不应该停止识别器时停止了识别器。因此,将最后一个stopRecognition移到末尾,它将解决您的问题。试着去了解那里发生了什么。