From df5301d0b62b445ad8cf8600f53c17c96d8e2429 Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Tue, 6 Oct 2020 18:38:56 +0200 Subject: [PATCH] Added recursive listening hehe --- speech/speech.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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))