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();
        } }

With this code I got the following exception:

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

This error occurs when I run my program.

How can I solve this?

Byron
  • 1,313
  • 10
  • 22
ManojB
  • 45
  • 1
  • 5

1 Answers1

0

From the log it looks like you are using outdated config.xml file referring to the class edu.cmu.sphinx.model.acoustic.WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz.Model

This class was removed from Sphinx4 long time ago

Download latest sphinx4 sources and use demos from the latest Sphinx4 including config files and everything will work fine.

Nikolay Shmyrev
  • 24,897
  • 5
  • 43
  • 87