Java 运行helloworld sphinx时出错

Java 运行helloworld sphinx时出错,java,exception,voice-recognition,sphinx4,Java,Exception,Voice Recognition,Sphinx4,嗨,我正在用java制作一个软件,我想在其中开发一个语音软件。。。我正在用java运行“Hello”sphinx代码: import edu.cmu.sphinx.frontend.util.Microphone; import edu.cmu.sphinx.recognizer.Recognizer; import edu.cmu.sphinx.result.Result; import edu.cmu.sphinx.util.props.ConfigurationManager; p

嗨,我正在用java制作一个软件,我想在其中开发一个语音软件。。。我正在用java运行“Hello”sphinx代码:

import edu.cmu.sphinx.frontend.util.Microphone; 
import edu.cmu.sphinx.recognizer.Recognizer; 
import edu.cmu.sphinx.result.Result; 
import edu.cmu.sphinx.util.props.ConfigurationManager;

public class HelloWorld {

public static void main(String[] args) {
    ConfigurationManager cm;

    if (args.length > 0) {
        cm = new ConfigurationManager(args[0]);
    } else {
        cm = new ConfigurationManager(HelloWorld.class.getResource("helloworld.config.xml"));
    }

    Recognizer recognizer = (Recognizer) cm.lookup("recognizer");
    recognizer.allocate();

    // start the microphone or exit if the programm if this is not possible
    Microphone microphone = (Microphone) cm.lookup("microphone");
    if (!microphone.startRecording()) {
        System.out.println("Cannot start microphone.");
        recognizer.deallocate();
        System.exit(1);
    }

    System.out.println("Say: (Good morning | Hello) ( Bhiksha | Evandro | Paul | Philip | Rita | Will )");

    // loop the recognition until the programm exits.
    while (true) {
        System.out.println("Start speaking. Press Ctrl-C to quit.\n");

        Result result = recognizer.recognize();

        if (result != null) {
            String resultText = result.getBestFinalResultNoFiller();
            System.out.println("You said: " + resultText + '\n');
        } else {
            System.out.println("I can't hear what you said.\n");
        }
    }
}

}
我犯了这个错误

Exception in thread "main" java.lang.NullPointerException at 
edu.cmu.sphinx.util.props.SaxLoader.load(SaxLoader.java:74) at 
edu.cmu.sphinx.util.props.ConfigurationManager.(ConfigurationManager.java:58) at 
HelloWorld.main(HelloWorld.java:22)

我已经将HelloWord.jar文件添加到我的项目中,但仍然得到相同的结果!请建议…

getResource(“helloworld.config.xml”)指向null。检查url指向的文件是否配置正确。确保它位于类路径上。

getResource(“helloworld.config.xml”)指向null。检查url指向的文件是否配置正确。确保它位于类路径上。

第22行:cm=new ConfigurationManager(HelloWorld.class.getResource(“HelloWorld.config.xml”);我认为代码
HelloWorld.class.getResource(“HelloWorld.config.xml”)
正在返回null是的,我知道,但正在返回null,因为找不到HelloWorld.jar,但我已经添加到我的项目中了!参考这个问题,您需要将它包含在类路径中。有关更多信息:第22行:cm=newConfigurationManager(HelloWorld.class.getResource(“HelloWorld.config.xml”);我认为代码
HelloWorld.class.getResource(“HelloWorld.config.xml”)
正在返回null是的,我知道,但正在返回null,因为找不到HelloWorld.jar,但我已经添加到我的项目中了!参考这个问题,您需要将它包含在类路径中。更多信息:对不起!我刚开始这么做,如何设置类路径。我正在使用Eclipse IDE?对于Eclipse,请阅读以下内容:对不起!我刚开始这么做,如何设置类路径。我正在使用Eclipse IDE?对于Eclipse,请阅读以下内容: