cmusphinx / sphinx4

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

frontend.util.Microphone needs to clean up before (re)starting recording #82

Open timobaumann opened 6 years ago

timobaumann commented 6 years ago

frontend.util.Microphone does not clean its queue of data objects to be output when (re)starting recording.

When using that Microphone DataSource with endpointing, recognition may stop after SpeechEndSignal and leaves data objects in the queue when I then call stopRecording(). In particular, the old DataEndSignal is still there (before a new DataStartSignal appears followed by the new audio once recording resumes). The old DataEndSignal breaks recognition (or maybe already VAD?) even before the new data can be processed further down the pipeline.

The fix is to add

audioList.clear();

somewhere around line 444 (i.e., before creating the new recordingThread or before starting it). I'm happy to provide such a fix.

On another note: I filed this as https://sourceforge.net/p/cmusphinx/bugs/482/ but I'm unsure which of the bug trackers is currently used, so re-filing.