I am trying to get sphinx 4 to work with my desktop application and it gets it right 0% of the time also I'm using the default language models and all that stuff from the sphinx4 data.jar
code:
import edu.cmu.sphinx.api.Configuration;
import edu.cmu.sphinx.api.Microphone;
import edu.cmu.sphinx.api.SpeechResult;
import edu.cmu.sphinx.api.StreamSpeechRecognizer;
public class Speechy {
public static void main(String[] args) throws Exception {
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");
Microphone micro = new Microphone(8000, 16, true, false);
micro.startRecording();
StreamSpeechRecognizer recognizer = new StreamSpeechRecognizer(configuration);
// Start recognition process pruning previously cached data.
recognizer.startRecognition(micro.getStream());
while(true){
SpeechResult result = recognizer.getResult();
System.out.println(result.getHypothesis());
}
}
}
Default acoustic model requires 16khz audio, your configuration 8000 is wrong.
See also the tutorial