使用 CMU Sphinx 的 Java 实时语音识别器中的 IllegalArgumentException

问题描述

我在 Intellij IDE 中编写了以下 java 代码。我还在我的项目中包含了这些 jar 文件

代码如下:

package com.company;
import edu.cmu.sphinx.api.Configuration;
import edu.cmu.sphinx.api.LiveSpeechRecognizer;
import edu.cmu.sphinx.api.SpeechResult;
import java.io.IOException;

public class VV {

    public static void main(String[] args) throws IOException {

        Configuration config = new Configuration();
        config.setAcousticModelPath("resource:/edu/cmu/sphinx/models/en-us/en-us");
       config.setDictionaryPath("D:\\Voice");
        config.setLanguageModelPath("D:\\Voice");
        LiveSpeechRecognizer recognize = new LiveSpeechRecognizer(config);
        recognize.startRecognition(true);
        SpeechResult speechResult;
        while((speechResult = recognize.getResult()) != null){
            String command = speechResult.getHypothesis();
            String work = null;
            System.out.println("Input command is: " + command);
            if(command.equalsIgnoreCase("Open Google")){
                work = "open -a Google http://www.google.com";
            }else if (command.equalsIgnoreCase("Close Google")){
                work = "killall Google";
            }

            if(work != null){
                Runtime.getRuntime().exec(work);
            }
        }
    }

}

我一直面临以下错误

Exception in thread "main" java.lang.IllegalArgumentException: UnkNown format extension: D:\Voice
    at edu.cmu.sphinx.api.Context.setLanguageModel(Context.java:158)
    at edu.cmu.sphinx.api.Context.<init>(Context.java:67)
    at edu.cmu.sphinx.api.Context.<init>(Context.java:45)
    at edu.cmu.sphinx.api.AbstractSpeechRecognizer.<init>(AbstractSpeechRecognizer.java:44)
    at edu.cmu.sphinx.api.LiveSpeechRecognizer.<init>(LiveSpeechRecognizer.java:34)
    at com.company.VV.main(VV.java:15)

有人可以帮我吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...