cmusphinx / sphinx4

Pure Java speech recognition library
cmusphinx.sourceforge.net
Other
1.4k stars 586 forks source link

Unable to recognise the Live stream voice using sphinx4 #103

Open NaveenKumar997 opened 3 years ago

NaveenKumar997 commented 3 years ago

I have created code based on this tutorial https://cmusphinx.github.io/wiki/tutorialsphinx4/

performing Speech to text from a .wav file using StreamSpeechRecognizer works fine but I am facing issue with LiveSpeechRecognizer , In debug the code goes till recognizer.startRecognition(true); and never moves further , I am runnning this on intellij and using mac os Catalina

I suspect mac os or intellij is not allowing the file to use microphone

Code :

Configuration configuration = new Configuration();
configuration.setAcousticModelPath("resource:/edu/cmu/sphinx/models/en-us/en-us");
configuration.setDictionaryPath("resource:/edu/cmu/sphinx/models/en-us/cmudict-en-us.dict");
configuration.setLanguageModelPath("resource:/edu/cmu/sphinx/models/en-us/en-us.lm.bin");

LiveSpeechRecognizer recognizer = new LiveSpeechRecognizer(configuration);
recognizer.startRecognition(true);
SpeechResult result ;

while ((result = recognizer.getResult()) != null) {
    System.out.println("speech recognition started");
    System.out.println(result.getHypothesis());
}
recognizer.stopRecognition();
cailalex commented 2 years ago

I've been experiencing the same issue. Debugger never moves past recognizer.startRecognition();

However, when I place print statements in my code to confirm which statements have successfully executed, I've found that the recognizer.startRecognition() is successful, but the line where the program stops for me is while ((result = recognizer.getResult()) != null). The program does not move inside the while loop, nor does it pass it. It seems to be stuck on .getResult().

Came to the same conclusion - could be an issue with accessing my device's microphone? Question to the team: is there any way for developers to set/test this?

petercwallis commented 1 year ago

Same issue ... 6 months later. And yes some indication that the microphone is (not) working would be good.