Unable to recognise the Live stream voice using sphinx4

155 Views Asked by At

I have created code based on this tutorial

Performing Speech to text from a .wav file using StreamSpeechRecognizer works fine but I am facing an issue with LiveSpeechRecognizer, In debug the code goes till recognizer.startRecognition(true); and never moves further, I am running this on IntelliJ and using macOS Catalina

I suspect macOS or java is not allowing the file to use a 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();
0

There are 0 best solutions below