Ver Fonte

snowbody debug code

Martin há 10 anos atrás
pai
commit
2a0dd3e75b

+ 2 - 31
voice_control/clips.py

@@ -23,34 +23,5 @@ def play(clip):
     """
 
     fname = os.path.join(_CLIP_FOLDER, clip)
-    tts._play(fname, False)
-    return
-
-    """
-    audio = pyaudio.PyAudio()
-
-    if clip not in _CLIP_DATA_CACHE:
-        fname = os.path.join(_CLIP_FOLDER, clip)
-        f = wave.open(fname, 'rb')
-
-        data = f.readframes(f.getnframes())
-        n_channels = f.getnchannels()
-        width = f.getsampwidth()
-        framerate = f.getframerate()
-
-        _CLIP_DATA_CACHE[clip] = (data, n_channels, width, framerate)
-
-    data, n_channels, width, framerate = _CLIP_DATA_CACHE[clip]
-
-    audio = pyaudio.PyAudio()
-    stream_out = audio.open(
-        format=audio.get_format_from_width(width),
-        channels=n_channels,
-        rate=framerate, input=False, output=True)
-    stream_out.start_stream()
-    stream_out.write(data)
-    time.sleep(0.2)
-    stream_out.stop_stream()
-    stream_out.close()
-    audio.terminate()
-    """
+    tts._play(fname, True)
+    return

+ 0 - 1
voice_control/functions/todo_wunderlist.py

@@ -39,7 +39,6 @@ class _WunderlistClient(object):
     def init(self):
         lists_res = self.call('GET', 'https://a.wunderlist.com/api/v1/lists')
         self.lists = {x['title'].lower(): x['id'] for x in lists_res}
-        print self.lists
     
 class Wunderlist(base.BaseFunction):
     client = None

+ 3 - 3
voice_control/main.py

@@ -15,7 +15,7 @@ _AUDIO_SERVICES = [{
         'email': functions.email_mailgun.Email(),
         'food': functions.todo_wunderlist.Wunderlist(True, 'food'),
         'todo': functions.todo_wunderlist.Wunderlist(False),
-        'play': functions.music.Music(),
+        #'play': functions.music.Music(),
     }
 }]
 
@@ -24,7 +24,7 @@ for service in _AUDIO_SERVICES[0]['callbacks'].values():
 
 if __name__ == "__main__":
     init()
-    #trigger.start(_AUDIO_SERVICES)
+    trigger.start(_AUDIO_SERVICES)
     #trigger.loop_model(_AUDIO_SERVICES[0])
 
-    trigger._callback(_AUDIO_SERVICES[0])
+    #trigger._callback(_AUDIO_SERVICES[0])

+ 9 - 3
voice_control/trigger.py

@@ -50,12 +50,18 @@ def start(models):
         if 'callbacks' in m:
             m['callbacks'] = {k.lower().strip(): v for k, v in m['callbacks'].iteritems()}
 
-        def c():
+        def c(): 
             _callback(m)
         callbacks.append(c)
 
     logging.info('Launching Snowboy hotword detector...')
     signal.signal(signal.SIGINT, _signal_handler)
-    detector = snowboy.snowboydecoder.HotwordDetector([m['model'] for m in models], sensitivity=[m.get('sensitivity', DEFAULT_SENSITIVITY) for m in models])
-    detector.start(detected_callback=callbacks, interrupt_check=_interrupt_callback, sleep_time=0.03)
+
+    detector = snowboy.snowboydecoder.HotwordDetector(decoder_model=models[0]['model'],
+                                                      resource='/home/martin/workspaces/visual-code/voice_control/resources/snowboy/common.res', 
+                                                      sensitivity=DEFAULT_SENSITIVITY)
+
+    logging.info('Stream opened.')
+
+    detector.start(detected_callback=callbacks[0], interrupt_check=_interrupt_callback, sleep_time=0.03)
     detector.terminate()