From b31c7b6647abc6cc1d69ce959ce3366422b85f35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85ke=20Forslund?= Date: Mon, 22 May 2017 19:12:00 +0200 Subject: [PATCH] Add docstrings. --- mycroft/client/speech/listener.py | 16 +++++++++++++--- mycroft/client/speech/mic.py | 3 +++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/mycroft/client/speech/listener.py b/mycroft/client/speech/listener.py index 59231d92c4..0019941b77 100644 --- a/mycroft/client/speech/listener.py +++ b/mycroft/client/speech/listener.py @@ -71,6 +71,9 @@ class AudioProducer(Thread): self.emitter.emit("recognizer_loop:ioerror", ex) def stop(self): + """ + Stop producer thread. + """ self.state.running = False self.recognizer.stop() @@ -181,6 +184,10 @@ class RecognizerLoopState(object): class RecognizerLoop(EventEmitter): + """ + EventEmitter loop running speech recognition. Local wake word + recognizer and remote general speech recognition. + """ def __init__(self): super(RecognizerLoop, self).__init__() self._load_config() @@ -197,9 +204,6 @@ class RecognizerLoop(EventEmitter): device_index = self.config.get('device_index') self.microphone = MutableMicrophone(device_index, rate) - # - # TODO:SSP On config change we need to rebuild these objects - # # FIXME - channels are not been used self.microphone.CHANNELS = self.config.get('channels') self.mycroft_recognizer = self.create_mycroft_recognizer(rate, lang) @@ -222,6 +226,9 @@ class RecognizerLoop(EventEmitter): return LocalRecognizer(wake_word, phonemes, threshold, rate, lang) def start_async(self): + """ + Start consumer and producer threads + """ self.state.running = True queue = Queue() self.producer = AudioProducer(self.state, queue, self.microphone, @@ -268,6 +275,9 @@ class RecognizerLoop(EventEmitter): self.stop() def reload(self): + """ + Reload configuration and restart consumer and producer + """ self.stop() # load config self._load_config() diff --git a/mycroft/client/speech/mic.py b/mycroft/client/speech/mic.py index d0232c2103..2addf1e083 100644 --- a/mycroft/client/speech/mic.py +++ b/mycroft/client/speech/mic.py @@ -293,6 +293,9 @@ class ResponsiveRecognizer(speech_recognition.Recognizer): return False def stop(self): + """ + Signal stop and exit waiting state. + """ self._stop_signaled = True def _wait_until_wake_word(self, source, sec_per_buffer):