I am trying to run the dialog demo of sphinx 4 pre aplha but it gives errors.
I am creating a live speech application.
I imported the project using maven and
For me with this change, the problem was as long as i was staying in a context of cmusphinx it was good the line can be reused many times. But if i begin to reuse the mic for another work (like recording) it was not available!
I see that the stream was open in Microphone class but never close!
So first I change in class Microphone the following attributes from static to dynamic :
private TargetDataLine line;
private InputStream inputStream;
After i change the method stopRecording for closing stream before line:
/**
* close the stream and line
*/
public void stopRecording() {
if (inputStream != null )
try {
inputStream.close();
} catch (IOException e) {
throw new IllegalStateException(e);
}
line.stop();
}
And now with no more change (class SpeechSourceProvider is original), i can reuse alternatively mic for cmupsphinx and another recording task