Menu

StreamSpeechRecognizer

Help
Leimiaoren
2016-01-14
2016-01-24
  • Leimiaoren

    Leimiaoren - 2016-01-14

    CMUSphinx tutorial said that

    You can retreive multiple results until the file end: (with the use of these codes)
    while ((result = recognizer.getResult()) != null) {
    System.out.println(result.getHypothesis());
    }

    So here is a snippet of my code from the program I am developing

          StreamSpeechRecognizer recognizer = new StreamSpeechRecognizer(
                                          configuration);
          InputStream stream = new FileInputStream(new File(selectedFile));
          recognizer.startRecognition(stream);
          SpeechResult result;
    
          while ((result = recognizer.getResult()) == null) {
         jTextArea2.setText(result.getHypothesis());
          recognizer.stopRecognition();
          }
    

    "selectedFile" here is the wav file that the user picked. The problem here is that when the recognizer detects silence, it automatically stops transcribing even if there are still utterances after the silence.

    I wanted to make the decoder transcribe till the end of the audio. Like if I have 5 minutes of audio

    If (Audio != 5 mins)
        {
        if (Audio != null)
            {
            show results for that part of audio
             }
         else
            {
            cout>>"."\n
             }
    }
     else
         {
         end of recognition
         }
    
     

    Last edit: Leimiaoren 2016-01-14
    • Nickolay V. Shmyrev

      This line:

          while ((result = recognizer.getResult()) == null) {
      

      must use !=, not ==. With your original code check indeed break and while loop terminates immediately after first utterance.

       

Log in to post a comment.