gpt4 book ai didi

java - getComponentNames 没有这样的方法错误

转载 作者:行者123 更新时间:2023-11-30 07:05:00 24 4
gpt4 key购买 nike

我是这个主题的新手,我尝试按照本教程逐步使用 Sphinx4 库构建一个示例项目: Tutorial link

然后我一直在 (run.xml) 中遇到相同的错误

我使用的代码:

public static void main(String[] args) {
// TODO code application logic here
//configuration obj
Configuration configuration = new Configuration();

//path to acoustic model
configuration.setAcousticModelPath("resource:/edu/cmu/sphinx/models/en-us/es-us");
//path to dictionary model
configuration.setDictionaryPath("/dictionary.dic");
//path to the language model
configuration.setLanguageModelPath("/languagemodel.lm");

//recognizer object, pass configuration object

try{

LiveSpeechRecognizer recognize = new LiveSpeechRecognizer(configuration);
recognize.startRecognition(true);

//create SpeechResult Obj
SpeechResult result;

//checking if recognizer jas recognized the speech

while((result = recognize.getResult())!=null){

//get the recognized speech
String command = result.getHypothesis();
//Match recognized speech with our commands
switch(command){

case "open file manager":
System.out.println("File manager Opened");
break;

case "close file manager":
System.out.println("File manager Closed");
break;

case "open browser":
System.out.println("Browser Opened");
break;

case "close browser":
System.out.println("Browser Closed");
break;


}

}
}catch(IOException e){}



}

我不断收到的错误:

 run:
Exception in thread "main" java.lang.NoSuchMethodError: edu.cmu.sphinx.util.props.ConfigurationManager.getComponentNames()Ljava/util/Set;
at edu.cmu.sphinx.util.props.ConfigurationManagerUtils.listAllsPropNames(ConfigurationManagerUtils.java:553)
at edu.cmu.sphinx.util.props.ConfigurationManagerUtils.setProperty(ConfigurationManagerUtils.java:610)
at edu.cmu.sphinx.api.Context.setLocalProperty(Context.java:191)
at edu.cmu.sphinx.api.Context.setAcousticModel(Context.java:88)
at edu.cmu.sphinx.api.Context.<init>(Context.java:61)
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 speechrecognizer.SpeechRecognizer.main(SpeechRecognizer.java:40)
C:\Users\Sadeem\AppData\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:54: Java returned: 1
BUILD FAILED (total time: 0 seconds)

我从这个网站下载了jar文件oss.sonatype.org

我将 file.dic、file.lm 添加到/src 文件夹和一个单独的文件夹中,以确定这是否是原因,但没有新结果。

最佳答案

您可能只想切换到基于 gradle 或 maven 的项目。您可以摆脱许多有关库的问题。

我有一个 Sphinx4 项目当前使用以下 Gradle.build:

apply plugin: 'java'

repositories {
jcenter()
mavenLocal()
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
maven {url "https://mvnrepository.com/artifact/commons-io/commons-io"}
}

dependencies {
compile 'org.slf4j:slf4j-api:1.7.21'
compile group: 'edu.cmu.sphinx', name: 'sphinx4-core', version:'5prealpha-SNAPSHOT'
compile group: 'edu.cmu.sphinx', name: 'sphinx4-data', version:'5prealpha-SNAPSHOT'
compile group: 'commons-io', name: 'commons-io', version: '2.4'
testCompile 'junit:junit:4.12'
}

如果您从未使用过 Gradle:https://docs.gradle.org/3.0/userguide/tutorial_java_projects.html

而且它在大多数 IDE 中都可用,例如 Eclipse、Netbeans 或 IntelliJ

关于java - getComponentNames 没有这样的方法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40288952/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com