diff --git a/mycroft/client/speech/listener.py b/mycroft/client/speech/listener.py index 2b4fc6ef6f69..b0bc8481ebcd 100644 --- a/mycroft/client/speech/listener.py +++ b/mycroft/client/speech/listener.py @@ -81,7 +81,7 @@ class AudioConsumer(threading.Thread): """ # In seconds, the minimum audio size to be sent to remote STT - MIN_AUDIO_SIZE = 1.0 + MIN_AUDIO_SIZE = 0.5 def __init__(self, state, queue, emitter, wakeup_recognizer, mycroft_recognizer, remote_recognizer): diff --git a/test/client/audio_consumer_test.py b/test/client/audio_consumer_test.py index 8a6ba53843d4..db43531d22eb 100644 --- a/test/client/audio_consumer_test.py +++ b/test/client/audio_consumer_test.py @@ -190,3 +190,41 @@ def utterance_callback(message): self.assertIsNotNone(utterances) self.assertTrue(len(utterances) == 1) self.assertEquals("what's the weather next week", utterances[0]) + + def test_stop(self): + self.queue.put(self.__create_sample_from_test_file('mycroft')) + self.consumer.read_audio() + + self.queue.put(self.__create_sample_from_test_file('stop')) + self.recognizer.set_transcriptions(["stop"]) + monitor = {} + + def utterance_callback(message): + monitor['utterances'] = message.get('utterances') + + self.loop.once('recognizer_loop:utterance', utterance_callback) + self.consumer.read_audio() + + utterances = monitor.get('utterances') + self.assertIsNotNone(utterances) + self.assertTrue(len(utterances) == 1) + self.assertEquals("stop", utterances[0]) + + def test_record(self): + self.queue.put(self.__create_sample_from_test_file('mycroft')) + self.consumer.read_audio() + + self.queue.put(self.__create_sample_from_test_file('record')) + self.recognizer.set_transcriptions(["record"]) + monitor = {} + + def utterance_callback(message): + monitor['utterances'] = message.get('utterances') + + self.loop.once('recognizer_loop:utterance', utterance_callback) + self.consumer.read_audio() + + utterances = monitor.get('utterances') + self.assertIsNotNone(utterances) + self.assertTrue(len(utterances) == 1) + self.assertEquals("record", utterances[0]) diff --git a/test/client/data/record.wav b/test/client/data/record.wav new file mode 100644 index 000000000000..5062ebc0d32e Binary files /dev/null and b/test/client/data/record.wav differ diff --git a/test/client/data/stop.wav b/test/client/data/stop.wav new file mode 100644 index 000000000000..dcf10e66392e Binary files /dev/null and b/test/client/data/stop.wav differ