'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
Settings > Privacy > Microphone
. Check this. Possible dupe here. – B_Dex_Float