Menu

PyAudio Input Overflowed

Help
2015-11-21
2015-11-23
  • Shawn Murray

    Shawn Murray - 2015-11-21

    I've been checking out the latest pocketsphinx with the default acoustic model and was using a custom dict with about 10 words. This was working fine. I changed the dic to cmudict.dict and and now getting the pyaudio input overflowed every time (IOError: [Errno Input overflowed] -9981) I try to run the kws_test.py. I tried changing the buffer size but this didn't help. I'm not running on the latest hardware but using a core 2 duo with 2GB as my test machine with Ubuntu. Do you think it's a pyaudio problem? Was hoping to use a keyword search to enable someone to ask a question that would then be send to wolfram alpha to be answered. My brains pretty burnt out been reading everything I can find on pocketsphinx to learn more about it so any help is welcomed.

     

    Last edit: Shawn Murray 2015-11-21
    • Shawn Murray

      Shawn Murray - 2015-11-21

      Well I might have gotten it resolved. Seems like it might be working with this but still need to keep testing.

       

      Last edit: Nickolay V. Shmyrev 2015-11-21
      • Nickolay V. Shmyrev

        Your audio overflowed because cpu is too slow to process audio requests. You need to speedup decoding, not zero the data which will drop accuracy. For that you need to use smaller vocabulary of the language model and not the dictionary.

        To learn more about language models read our tutorial.

         
        • Shawn Murray

          Shawn Murray - 2015-11-21

          Thanks Nickolay I've been reading a lot and have learned a lot the past couple days. If you could help me with one more thing. I have keyword recognition working which then loads a jsgf with a simple "hello world". I've tried getting it to recognize the phrase through pyaudio but if I leave " if decoder.hyp() != None:" in the code it will recognize hello and finish the script. If I take it out as it is in the example I dont get any recognition. I'd appreciate any help. Thanks

          jsgf = Jsgf(os.path.join(modeldir, 'lm/simple.gram'))
          rule = jsgf.get_rule('test.simple')
          fsg = jsgf.build_fsg(rule, decoder.get_logmath(), 7.5)
          fsg.writefile('test.fsg')

          decoder.set_fsg("test", fsg)
          decoder.set_search("test")

          decoder.start_utt()
          stream = p.open(format=pyaudio.paInt16, channels=1,
          rate=16000, input=True, frames_per_buffer=1024)
          while True:
          buf = stream.read(1024)
          if buf:
          decoder.process_raw(buf, False, False)
          else:
          break
          if decoder.hyp() != None:
          decoder.end_utt()
          print ('Decoding with customized language:', decoder.hyp().hypstr)
          print ("Phrase Search")
          break

           
          • Nickolay V. Shmyrev

            Also, there is no need to do passes around fsg, there is decoder.set_jsgf method you can use to load jsgf file directly.

             
  • Nickolay V. Shmyrev

    Decoding with voice activity detection is demonstrated here:

    https://mattze96.safe-ws.de/blog/?p=640

    It should be something like

    in_speech_bf = True
    while True:
        buf = stream.read(1024)
        if buf:
            decoder.process_raw(buf, False, False)
            if decoder.get_in_speech() != in_speech_bf:
                in_speech_bf = decoder.get_in_speech()
                if not in_speech_bf:
                    decoder.end_utt()
                    try:
                        if  decoder.hyp().hypstr != '':
                            print 'Stream decoding result:', decoder.hyp().hypstr
                    except AttributeError:
                        pass
                    decoder.start_utt('')
        else:
            break
    decoder.end_utt()
    print 'An Error occured:', decoder.hyp().hypstr
    
     
    • Shawn Murray

      Shawn Murray - 2015-11-23

      You the man. Appreciate it. It's working now.

       

Log in to post a comment.