Martin преди 10 години
родител
ревизия
6c35a5890e

+ 8 - 5
voice_control/output/__init__.py

@@ -1,5 +1,5 @@
-import audio_output
 import logging
+import audio_output
 
 def success():
     audio_output.play_clip(audio_output.Clips.SUCCESS)
@@ -7,10 +7,10 @@ def success():
 
 def failure(s=None):
     audio_output.play_clip(audio_output.Clips.FAILURE)
-    if s:
-        logging.info('Failed.')
+    if s is None:
+        logging.error('Failed.')
     else:
-        logging.info(s)
+        logging.error(s)
 
 def cancelled():
     tts('cancelled')
@@ -22,4 +22,7 @@ def tts(s):
 
 def text(s):
     audio_output.tts(s)
-    logging.info(s)
+    logging.info(s)
+
+def debug(s):
+    logging.debug(s)

+ 0 - 2
voice_control/output/audio_output.py

@@ -37,8 +37,6 @@ def tts(text, lang='en', block=True):
     if not text:
         return
 
-    logging.info('> %s', text)
-
     if not _SOUND_ENABLED:
         return
 

+ 2 - 2
voice_control/services/__init__.py

@@ -25,7 +25,7 @@ def launch_services(interrupted):
     while not interrupted():
         t = input_sources.get_token(5)
         if t is not None and t in services and services[t].initialized:
-            output.text('Entering %s' % t)
+            output.debug('Entering %s' % t)
             services[t].call()
         elif t is not None:
-            output.failure()
+            output.failure('"%s" is not a valid service.' % t)

+ 2 - 2
voice_control/services/email_mailgun.py

@@ -33,7 +33,7 @@ class Email(base.BaseFunction):
         return _RECIPIENTS.keys()
 
     def _send(self, recipient):
-        output.text('email _send: %s' % recipient)
+        output.debug('email _send: %s' % recipient)
         tokens, terminator = input_sources.get_until_terminated()
 
         if terminator == 'done':
@@ -48,7 +48,7 @@ class Email(base.BaseFunction):
             output.cancelled()
 
     def call(self):
-        output.text('to whom?')
+        output.text('Specify recipient')
         recipient = input_sources.get_token(preferred_phrases=self.preferred_phrases())
         if recipient in _RECIPIENTS:
             self._send(recipient)

+ 2 - 4
voice_control/services/music.py

@@ -1,8 +1,6 @@
 import subprocess
 import os
-import logging
 import base
-import ears
 import output
 
 _FOLDER = '/mnt/nas/music/albums'
@@ -43,12 +41,12 @@ class Music(base.BaseFunction):
         if additional_tokens:
             f = self._search(additional_tokens)
         if not f:
-            output.text('ready')
+            output.debug('ready')
             tokens = ears.listen(pause_threshold=3, preferred_phrases=self.folders.keys()[:300])
             f = self._search(tokens)
 
         if f:
-            output.text('playing %s' % f)
+            output.debug('playing %s' % f)
             self.current_process = subprocess.Popen(['cvlc', '-Z', f, ]) 
 
         else:

+ 3 - 3
voice_control/services/todo_wunderlist.py

@@ -51,7 +51,7 @@ class Wunderlist(base.BaseFunction):
     def init(self):
         self.client.init()
         if self.list_name and self.list_name not in self.client.lists:
-            logging.error('Could not find list %s', self.list_name)
+            output.failure('Could not find list %s' % self.list_name)
             return
         self.initialized = True
 
@@ -63,7 +63,7 @@ class Wunderlist(base.BaseFunction):
             if not input_sources.token_available():
                 output.text('Select list.')
             list_name = input_sources.get_token(preferred_phrases=self.client.lists.keys())
-            output.text('Selected list: %s' % list_name)
+            output.debug('Selected list: %s' % list_name)
             if list_name in self.client.lists:
                 return list_name
             else:
@@ -72,7 +72,7 @@ class Wunderlist(base.BaseFunction):
     def call(self, **_):
         list_name = self._get_list()
         if list_name is None:
-            output.failure()
+            output.failure('No list available.')
             return
 
         tasks = []