Explorar o código

add preferred phrases for launch_services

Martin %!s(int64=10) %!d(string=hai) anos
pai
achega
d763d88c2e
Modificáronse 1 ficheiros con 9 adicións e 8 borrados
  1. 9 8
      voice_control/services/__init__.py

+ 9 - 8
voice_control/services/__init__.py

@@ -4,12 +4,12 @@ import todo_wunderlist
 import input_sources
 import output
 import current_time
-import help
+import services.help
 import echo
 import duckduckgo_answers
 
 def _get_services():
-    services = {
+    res = {
         'email': email_mailgun.Email(),
         'food': todo_wunderlist.Wunderlist(True, 'food'),
         'todo': todo_wunderlist.Wunderlist(False),
@@ -19,14 +19,14 @@ def _get_services():
         #'play': music.Music(),
     }
 
-    services['help'] = help.Help(services)
+    res['help'] = services.help.Help(services)
 
-    return services
+    return res
 
 def launch_services(interrupted):
-    services = _get_services()
+    _services = _get_services()
 
-    for s in services.values():
+    for s in _services.values():
         if not s.initialized:
             t = threading.Thread(target=s.init)
             t.start()
@@ -34,10 +34,11 @@ def launch_services(interrupted):
     output.text('Ready.')
 
     while not interrupted():
+        input_sources.PREFERRED_PHRASES = _services.keys() + ['quit']
         t = input_sources.get_token(1)
-        if t is not None and t in services and services[t].initialized:
+        if t is not None and t in _services and _services[t].initialized:
             output.debug('Entering %s' % t)
-            services[t].call()
+            _services[t].call()
         elif t == 'quit':
             return
         elif t is not None: