Martin пре 7 година
родитељ
комит
f9df98889c
2 измењених фајлова са 48 додато и 12 уклоњено
  1. 48 0
      voice_control/test.py
  2. 0 12
      voice_control/test_mic.py

+ 48 - 0
voice_control/test.py

@@ -0,0 +1,48 @@
+import sys
+import logging
+
+
+def _test_audio_in():
+    import speech_recognition as sr
+    with sr.Microphone() as source:
+        recognizer = sr.Recognizer()
+        recognizer.energy_threshold = 2000
+        recognizer.listen(source)
+
+def _test_audio_out():
+    import output.audio_output
+
+    logging.info('Creating audio output service...')
+    service = output.audio_output.AudioOutput()
+
+    logging.info('Calling .success()...')
+    service.success()
+
+    logging.info('Calling .failure()...')
+    service.failure()
+
+    logging.info('Calling .tts("Hello World")...')
+    service.tts('Hello World')
+
+    logging.info('Done.')
+
+def run():
+    if len(sys.argv) == 1:
+        print '\n'.join([
+            '1. Audio output',
+            '2. Audio input',
+        ])
+        return
+    
+    choice = sys.argv[1]
+
+    if choice == '1': 
+        _test_audio_out()
+    elif choice == '2':
+        _test_audio_in()
+
+if __name__ == "__main__":
+    logging.basicConfig(stream=sys.stdout)
+    logging.getLogger().setLevel(logging.DEBUG)
+
+    run()

+ 0 - 12
voice_control/test_mic.py

@@ -1,12 +0,0 @@
-import sys
-import logging
-
-import speech_recognition as sr
-
-logging.basicConfig(stream=sys.stdout)
-logging.getLogger().setLevel(logging.DEBUG)
-
-with sr.Microphone() as source:
-    recognizer = sr.Recognizer()
-    recognizer.energy_threshold = 2000
-    recognizer.listen(source)