问题描述
我在 Intellij IDE 中编写了以下 java 代码。我还在我的项目中包含了这些 jar 文件:
- https://oss.sonatype.org/service/local/repositories/snapshots/content/edu/cmu/sphinx/sphinx4-data/5prealpha-SNAPSHOT/sphinx4-data-5prealpha-20160628.232535-10.jar
- https://oss.sonatype.org/service/local/repositories/snapshots/content/edu/cmu/sphinx/sphinx4-core/5prealpha-SNAPSHOT/sphinx4-core-5prealpha-20160628.232526-10.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 (将#修改为@)