From e11bb528530de237235a04dc01275235bb731bbb Mon Sep 17 00:00:00 2001 From: "Matthew D. Scholefield" Date: Wed, 5 Jul 2017 16:20:13 -0500 Subject: [PATCH] Fix wake up --- mycroft/client/speech/listener.py | 12 +++++++----- mycroft/client/speech/mic.py | 3 ++- test/client/audio_consumer_test.py | 6 ++++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/mycroft/client/speech/listener.py b/mycroft/client/speech/listener.py index 6019986e71..b531cb75c8 100644 --- a/mycroft/client/speech/listener.py +++ b/mycroft/client/speech/listener.py @@ -27,7 +27,8 @@ from requests.exceptions import ConnectionError import mycroft.dialog from mycroft.client.speech.mic import MutableMicrophone, ResponsiveRecognizer -from mycroft.client.speech.recognizer.pocketsphinx_recognizer import PocketsphinxRecognizer +from mycroft.client.speech.recognizer.pocketsphinx_recognizer \ + import PocketsphinxRecognizer from mycroft.configuration import ConfigurationManager from mycroft.messagebus.message import Message from mycroft.metrics import MetricsAggregator @@ -113,8 +114,7 @@ class AudioConsumer(Thread): # TODO: Localization def wake_up(self, audio): - if self.wakeup_recognizer.is_recognized(audio.frame_data, - self.metrics): + if self.wakeup_recognizer.found_wake_word(audio.frame_data): SessionManager.touch() self.state.sleeping = False self.__speak(mycroft.dialog.get("i am awake", self.stt.lang)) @@ -217,13 +217,15 @@ class RecognizerLoop(EventEmitter): wake_word = self.config.get('wake_word') phonemes = self.config.get('phonemes') threshold = self.config.get('threshold') - return PocketsphinxRecognizer(wake_word, phonemes, threshold, rate, lang) + return PocketsphinxRecognizer(wake_word, phonemes, + threshold, rate, lang) def create_wakeup_recognizer(self, rate, lang): wake_word = self.config.get('standup_word', "wake up") phonemes = self.config.get('standup_phonemes', "W EY K . AH P") threshold = self.config.get('standup_threshold', 1e-10) - return PocketsphinxRecognizer(wake_word, phonemes, threshold, rate, lang) + return PocketsphinxRecognizer(wake_word, phonemes, + threshold, rate, lang) def start_async(self): """ diff --git a/mycroft/client/speech/mic.py b/mycroft/client/speech/mic.py index 444200aa0f..1e114a4b32 100644 --- a/mycroft/client/speech/mic.py +++ b/mycroft/client/speech/mic.py @@ -379,7 +379,8 @@ class ResponsiveRecognizer(speech_recognition.Recognizer): if buffers_since_check > buffers_per_check: buffers_since_check -= buffers_per_check audio_data = byte_data + silence - said_wake_word = self.wake_word_recognizer.found_wake_word(audio_data) + said_wake_word = \ + self.wake_word_recognizer.found_wake_word(audio_data) # if a wake word is success full then record audio in temp # file. if self.save_wake_words and said_wake_word: diff --git a/test/client/audio_consumer_test.py b/test/client/audio_consumer_test.py index 511741b186..1b5c3a52f1 100644 --- a/test/client/audio_consumer_test.py +++ b/test/client/audio_consumer_test.py @@ -24,7 +24,8 @@ from os.path import dirname, join from speech_recognition import WavFile, AudioData from mycroft.client.speech.listener import AudioConsumer, RecognizerLoop -from mycroft.client.speech.recognizer.pocketsphinx_recognizer import PocketsphinxRecognizer +from mycroft.client.speech.recognizer.pocketsphinx_recognizer \ + import PocketsphinxRecognizer from mycroft.stt import MycroftSTT __author__ = 'seanfitz' @@ -58,7 +59,8 @@ class AudioConsumerTest(unittest.TestCase): self.consumer = AudioConsumer( self.loop.state, self.queue, self.loop, MycroftSTT(), PocketsphinxRecognizer(self.loop.wakeup_recognizer.key_phrase, - self.loop.wakeup_recognizer.phonemes, "1e-16"), + self.loop.wakeup_recognizer.phonemes, + "1e-16"), self.loop.mycroft_recognizer) def __create_sample_from_test_file(self, sample_name):