diff --git a/speech/speech.py b/speech/speech.py index f6926e8..6233e9c 100644 --- a/speech/speech.py +++ b/speech/speech.py @@ -9,10 +9,14 @@ class voiceInput(object): try: with sr.Microphone( deviceIndex ) as src: self.recognizer.adjust_for_ambient_noise( src, 0.2 ) - audio = self.recognizer.listen( src ) + print("Listening...") + audio = self.recognizer.listen( src, phrase_time_limit=5 ) + print("Thinking...") text = self.recognizer.recognize_google(audio) print(text) + return self.voiceToText(deviceIndex) + except sr.RequestError as err: print("Unable to request results: {0}".format(err))