Add Testcase to verify hotword fallback behaviour
@@ -51,7 +51,10 @@ class PocketSphinxRecognizerTest(unittest.TestCase):
class LocalRecognizerInitTest(unittest.TestCase):
@patch.object(Configuration, 'get')
- def testRecognizer(self, mock_config_get):
+ def testListenerConfig(self, mock_config_get):
+ """Ensure that the fallback method collecting phonemes etc.
+ from the listener config works.
+ """
test_config = base_config()
mock_config_get.return_value = test_config
@@ -71,3 +74,44 @@ class LocalRecognizerInitTest(unittest.TestCase):
test_config['listener']['phonemes'] = 'ZZZZZZZZZZZZ'
rl = RecognizerLoop()
self.assertEqual(rl.wakeword_recognizer.key_phrase, "hey mycroft")
+
+ @patch.object(Configuration, 'get')
+ def testHotwordConfig(self, mock_config_get):
+ """Ensure that the fallback method collecting phonemes etc.
+ from the listener config works.
+ """
+ test_config = base_config()
+ mock_config_get.return_value = test_config
+
+ # Set fallback values
+ test_config['listener']['phonemes'] = 'HH EY . V IH K T AO R IY AH'
+ test_config['listener']['threshold'] = 1e-90
+
+ steve_conf = {
+ 'model': 'pocketsphinx',
+ 'phonemes': 'S T IY V .',
+ 'threshold': 1e-42
+ }
+
+ test_config['hotwords']['steve'] = steve_conf
+ test_config['listener']['wake_word'] = 'steve'
+
+ rl = RecognizerLoop()
+ self.assertEqual(rl.wakeword_recognizer.key_phrase, 'steve')
+
+ # Ensure phonemes and threshold are poulated from listener config
+ # if they're missing
+
+ # Set fallback values
+ test_config['listener']['phonemes'] = 'S T IY V .'
+ test_config['listener']['threshold'] = 1e-90
+
+ steve_conf = {
+ 'model': 'pocketsphinx'
+ }
+
+ test_config['hotwords']['steve'] = steve_conf
+ test_config['listener']['wake_word'] = 'steve'
+ rl = RecognizerLoop()
+ self.assertEqual(rl.wakeword_recognizer.key_phrase, 'steve')
+ self.assertEqual(rl.wakeword_recognizer.phonemes, 'S T IY V .')
