0
public static void main(String[] args) {  try {
            URL url;
            if (args.length > 0) {
                url = new File(args[0]).toURI().toURL();
            } else {
                url = HelloWorld.class.getResource("helloworld.config.xml");
            }

            System.out.println("Loading...");

            ConfigurationManager cm = new ConfigurationManager(url);
            System.out.println("Configured Successfully");
        Recognizer recognizer = (Recognizer) cm.lookup("recognizer"); // I found exception in this line
        System.out.println("Recognizer Ready");
        Microphone microphone = (Microphone) cm.lookup("microphone");
        System.out.println("Microphone Ready");

            /* allocate the resource necessary for the recognizer */
            recognizer.allocate();

            /* the microphone will keep recording until the program exits */
        if (microphone.startRecording()) {

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

        while (true) {
            System.out.println          ("Start speaking. Press Ctrl-C to quit.\n");

                    /*
                     * This method will return when the end of speech
                     * is reached. Note that the endpointer will determine
                     * the end of speech.
                     */ 
            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");
            }       }
        } else {        System.out.println("Cannot start microphone.");         recognizer.deallocate();        System.exit(1);
        }
        } catch (IOException e) {
            System.err.println("Problem when loading HelloWorld: " + e);
            e.printStackTrace();
        } catch (PropertyException e) {
            System.err.println("Problem configuring HelloWorld: " + e);
            e.printStackTrace();
        } catch (Exception e) {
            System.err.println("Problem creating HelloWorld: " + e);
            e.printStackTrace();
        } }

使用此代码,我得到以下异常:

class not found !java.lang.ClassNotFoundException:
 edu.cmu.sphinx.model.acoustic.WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz.Model
 Problem configuring HelloWorld: Property Exception component:'flatLinguist'
 property:'acousticModel' - mandatory property is not set!
 edu.cmu.sphinx.util.props.InternalConfigurationException
 Property Exception component:'flatLinguist' property:'acousticModel' - mandatory
 property is not set!
 edu.cmu.sphinx.util.props.InternalConfigurationException

当我运行我的程序时会发生此错误。

我该如何解决这个问题?

4

1 回答 1

0

从日志看来,您正在使用引用类 edu.cmu.sphinx.model.acoustic.WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz.Model 的过时 config.xml 文件

这个类很久以前从 Sphinx4 中删除了

下载最新的 sphinx4 源代码并使用最新的 Sphinx4 的演示,包括配置文件,一切都会正常工作。

于 2013-03-21T11:08:02.680 回答