Skip to content
This repository has been archived by the owner on Sep 8, 2024. It is now read-only.

Commit

Permalink
Issues 61 - Adjusting silence threshold
Browse files Browse the repository at this point in the history
 - Prevent short words commands such as 'stop' and 'record' to be ignored
 - Adding unit tests for the new silence threshold
Jonathan D'Orleans committed Jun 2, 2016
1 parent 2dc3f85 commit 2698e14
Showing 4 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mycroft/client/speech/listener.py
Original file line number Diff line number Diff line change
@@ -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):
38 changes: 38 additions & 0 deletions test/client/audio_consumer_test.py
Original file line number Diff line number Diff line change
@@ -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])
Binary file added test/client/data/record.wav
Binary file not shown.
Binary file added test/client/data/stop.wav
Binary file not shown.

0 comments on commit 2698e14

Please sign in to comment.