tags:

views:

60

answers:

5

i have configured sphinx with netbeans and its wroking fine. but im using a button to do the process. but after it recognisers. i want to do the process again. but then it gives a error saying the "logmath instance is already present" and saying cannot open the microphone.

can someone give me a solution. what i want to do is use speech recogntion in several times in the same form. till it gives the correct answer.

please help me

this is the error i get

"Creating new instance of LogMath while another instance is already present 10:53:27.833 SEVERE microphone Can't open microphone line with format PCM_SIGNED 16000.0 Hz, 16 bit, mono, 2 bytes/frame, big-endian not supported."

A: 

finally got it working. its the Recogniser problem

Nubkadiya
A: 

Hi.. This is Anurag. I am doing the same thing and getting the same error. Please help me out. how did you manage to get it working several times ?? Reply soon.

Anurag
A: 

you are using the Recognizer again and again each time you done the speech recognition.

Nubkadiya
A: 

This is what my code looks like.. which i have to call multiple time on a mouse click event... kindly help me out.. i dont know where am i wrong...

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 SpeechToText {

public void Speech2Text() {

    ConfigurationManager cm;

    //Detect the Grammar File
    cm = new ConfigurationManager(
            SpeechToText.class.getResource("SpeechToText.config.xml"));
    Recognizer recognizer = (Recognizer) cm.lookup("recognizer");

    //Allocate the Recognizer
    recognizer.allocate();

    //Start the microphone or exit if the program 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);
    }

    //Recognition loop until the Stop button is Clicked.
    while (true) {
        microphone.startRecording();
        System.out.println("Start Speaking....");

        //Get the spoken text
        Result result = recognizer.recognize();

        //Check if the spoken text is null or not
        if (result != null) {

            //Gets the best word after matching the grammar file
            String resultText = result.getBestFinalResultNoFiller();

            System.out.println("You said: " + resultText);
        }
        else {
            System.out.println("I can't hear what you said.\n");
        }
    }
}

}

Anurag
A: 

make sure to " //Get the spoken text Result result = recognizer.recognize(); "

call this above result only one time. if you call again and again in the same event. it will give a error. so make it public to call only once and do the process. then it should work

Nubkadiya

related questions