|
@@ -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()
|