Can't access microphone while running Dialog demo in sphinx4 5prealpha

前端 未结 4 1710
长发绾君心
长发绾君心 2021-01-12 04:23

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

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-12 05:00

    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

提交回复
热议问题