0

I get error -9999 on the following line:

with sr.Microphone() as source:

The confusing part is that this worked for several days without changing anything and now this happens

   r.dynamic_energy_threshold = False
   r.energy_threshold = 250
   print((r.energy_threshold))

   try:

    with sr.Microphone() as source:



        try:


            print("waiting for mic3") 

            audio = r.listen(source, timeout = 0.1)
            print(audio)
            print("waiting for mic4")
            if audio != "":
                gaudio = "11&%&" + r.recognize_google(audio)
                print("waiting for mic5")
                co = 1
                print(co)
                print(gaudio)
                s.sendall(gaudio.encode("utf-8"))

        except Exception as e:
            co = 0
            print(e)

   except Exception as e:
            co = 0
            print(e)    

Thanks for the help, I can't even imagine whats causing this.

  • Possible duplicate of [pyaudio-OSError: \[Errno -9999\] Unanticipated host error](https://stackoverflow.com/questions/41518905/pyaudio-oserror-errno-9999-unanticipated-host-error) – Nikolay Shmyrev Apr 11 '19 at 17:22
  • This has nothing to do with that issue. It's not on windows and it doesnt use Wave or its framerate. Just speech recognition (and pyaudio by extension) – James Henessy Apr 11 '19 at 18:29
  • Instead of arguing you'd better simply read the answer in detail. This answer https://stackoverflow.com/a/44730445/432021 tells you exactly what to do - you need to get additional error information from pyaudio. Most likely you have to properly configure your audio system to get this working. – Nikolay Shmyrev Apr 11 '19 at 20:17
  • Ok. Thanks for the answer. Do you know how I can properly use Pa_GetLastHostErrorInfo() to detect the problem? The usage of this function is a little too complex for me. – James Henessy Apr 12 '19 at 13:43
  • 1
    Try to install pulseaudio or alsa properly with proper configuration, it should work without a problem. Test that all recording sample rates are supported. – Nikolay Shmyrev Apr 12 '19 at 21:03
  • I had this same problem. What happened to me was that Python did not have permission to use the microphone, so it would not work – SomeMosa Apr 16 '20 at 14:50
  • I am having this problem as well but do not understand how to use the `Pa_GetLastHostErrorInfo() ` command suggested by the other thread #432021. – rfii Jun 29 '20 at 06:28

0 Answers0