Skip to content

Commit

Permalink
Put hotword answer in settings
Browse files Browse the repository at this point in the history
  • Loading branch information
titilambert committed Aug 31, 2016
1 parent 311de5e commit 5c443c7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 18 deletions.
35 changes: 19 additions & 16 deletions tuxeatpi-conf.yml.sample
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
tux:
name: TuxDroid
gender: male
speech:
language: eng-USA
voice: tom
speex: False
opus: False
app_id: FAKE_APP_ID
app_key: FAKE_APP_KEY
url: https://ws.dev.nuance.com
log_level: DEBUG
fake: True
advanced:
fake: true
log_level: DEBUG
global:
gender: male
name: TuxDroid
hotword:
answer: yes
hotword: hello
model_dir: pocketsphinx-data
pins:
wings:
left_switch: 17
right_switch: 4
position: 25
movement: 22


position: 25
right_switch: 4
speech:
app_id: FAKE_APP_ID
app_key: FAKE_APP_KEY
codec: wav
language: eng-USA
url: https://ws.dev.nuance.com
voice: tom
8 changes: 7 additions & 1 deletion tuxeatpi/hotword/hotword.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,20 @@
import pyaudio
from pocketsphinx.pocketsphinx import Decoder

from tuxeatpi.libs.lang import gtt


class HotWord(Process):
"""Define hotword component
For now hotword uses pocketsphinx with speech_recognition
"""
def __init__(self, settings, logger):
def __init__(self, settings, tts_queue, logger):
Process.__init__(self)
# Set logger
self.logger = logger.getChild("Hotword")
self.logger.debug("Initialization")
self.tts_queue = tts_queue
# Init private attributes
self._settings = settings
self._must_run = True
Expand All @@ -28,6 +31,7 @@ def prepare_decoder(self):
"""Set decoder config"""
# prepare config
self._hotword = self._settings['hotword']['hotword']
self._answer = self._settings['hotword']['answer']
acoustic_model = os.path.join(self._settings['hotword']['model_dir'],
self._settings['speech']['language'],
'acoustic-model',
Expand Down Expand Up @@ -60,6 +64,7 @@ def stop(self):
def run(self):
"""Text to speech"""
rerun = True
self._must_run = True
self.logger.debug("starting listening hotword %s", self._hotword)
while rerun:
rerun = False
Expand All @@ -75,6 +80,7 @@ def run(self):
self._decoder.process_raw(buf, False, False)
if self._decoder.hyp() and self._decoder.hyp().hypstr == self._hotword:
self.logger.debug("Hotword detected")
self.tts_queue.put(gtt(self._answer))
# TODO run nlu audio detection
rerun = True
break
Expand Down
2 changes: 1 addition & 1 deletion tuxeatpi/tux.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def __init__(self, config_file):
self.logger)

# hotword
self.hotword = HotWord(self.settings, self.logger)
self.hotword = HotWord(self.settings, self.tts_queue, self.logger)
self.hotword.start()
# Init action
self.actionner = Actionner(self)
Expand Down

0 comments on commit 5c443c7

Please sign in to comment.