1

'Here is my code:'

    import speech_recognition as sr  

    # get audio from the microphone                                                                       
    r = sr.Recognizer()                                                                                   
    with sr.Microphone() as source:                                                                       
        print("Please say response:")
        r.adjust_for_ambient_noise(source)                                                                                   
        audio = r.listen(source)   
        resp=r.recognize_google(audio)
    try:
        print("You said " + resp)
    except sr.UnknownValueError:
        print("Could not understand audio")
    except sr.RequestError as e:
        print("Could not request results; {0}".format(e))

'Here is the Error message:'

runfile('C:/Users/Owner/speechrecognition.py', wdir='C:/Users/Owner') Traceback (most recent call last):

File "", line 1, in runfile('C:/Users/Owner/speechrecognition.py', wdir='C:/Users/Owner')

File "C:\Users\Owner\anaconda3\envs\py27\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile execfile(filename, namespace)

File "C:\Users\Owner\anaconda3\envs\py27\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 95, in execfile exec(compile(scripttext, filename, 'exec'), glob, loc)

File "C:/Users/Owner/speechrecognition.py", line 11, in with sr.Microphone() as source:

File "C:\Users\Owner\anaconda3\envs\py27\lib\site-packages\speech_recognition_init_.py", line 141, in enter input=True, # stream is an input stream

File "C:\Users\Owner\anaconda3\envs\py27\lib\site-packages\pyaudio.py", line 750, in open stream = Stream(self, *args, **kwargs)

File "C:\Users\Owner\anaconda3\envs\py27\lib\site-packages\pyaudio.py", line 441, in init self._stream = pa.open(**arguments)

IOError: [Errno -9999] Unanticipated host error

  • Did you allow python to access your mic? New windows versions have access control built into `Settings > Privacy > Microphone`. [Check this](https://support.microsoft.com/en-us/windows/how-to-set-up-and-test-microphones-in-windows-10-ba9a4aab-35d1-12ee-5835-cccac7ee87a4). Possible dupe [here](https://stackoverflow.com/questions/41518905/pyaudio-oserror-errno-9999-unanticipated-host-error). – B_Dex_Float Nov 26 '20 at 17:49
  • Yeah I ran the same code a day before and it was accessing my mic fine, but then when I ran it the next day I started getting this error with PyAudio – Gia Mancini Nov 26 '20 at 23:27
  • I hope one of these helps you ( [1](https://stackoverflow.com/a/44730445/8560442) [2](https://stackoverflow.com/q/43841316/8560442) ). If that didn't work, let us know. – B_Dex_Float Nov 27 '20 at 08:41

1 Answers1

0

I had alot of issues using pyaudio my self what fixed it for me was pasting this in

if (not os.environ.get('PYTHONHTTPSVERIFY', '') and getattr(ssl, '_create_unverified_context', None)):