From 7f07c1301eb58301037dc4169d258f7e2d6ede03 Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Sun, 4 Oct 2020 17:58:26 +0200 Subject: [PATCH] Added base for speech recog --- speech/speech.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/speech/speech.py b/speech/speech.py index 65a3a86..fa70c3c 100644 --- a/speech/speech.py +++ b/speech/speech.py @@ -5,8 +5,9 @@ class sr_microphone(object): muted = True - def start(self): # use the object as a generator - while( not self.muted ): + def getInput(self): # use the object as a generator + print("Awaiting input") + if( not self.muted ): try: with sr.Microphone() as src: self.recognizer.adjust_for_ambient_noise( src, duration=0.2 ) # adjust for ambient noise @@ -32,4 +33,4 @@ class sr_microphone(object): # Small test voice = sr_microphone() voice.setMuted(False) -voice.start() +print( voice.getInput() )