Open faxe1008 opened 6 years ago
Yes, I am also getting the same issue.
Hi @faxe1008,
your code looks wrong the recognized_text = self.Recognizer.recognize_google(audio)
part must be outside of the with sr.Microphone(self.MICROPHONE_INDEX) as source:
. The correct code would then be
with sr.Microphone(self.MICROPHONE_INDEX) as source:
audio = self.Recognizer.listen()
recognized_text = self.Recognizer.recognize_google(audio)
Also it may be resonable to check if you have actually recorded any audio with
if(audio is not None):
recognized_text = self.Recognizer.recognize_google(audio)
I am building a speech recognition (https://github.com/Uberi/speech_recognition) using the following method:
self.Recognizer = sr.Recognizer() self.Recognizer.energy_threshold = 8000
That works just perfectly if I am testing right after I started to run the application but it stops working right after a few seconds of saying nothing I get this error:
Traceback (most recent call last):
How do I fix this behaviour?