Martin 10 лет назад
Родитель
Сommit
0303610ae0
1 измененных файлов с 5 добавлено и 1 удалено
  1. 5 1
      voice_control/ears.py

+ 5 - 1
voice_control/ears.py

@@ -7,7 +7,11 @@ def _get_recognizer(pause_threshold):
     recognizer = sr.Recognizer()
     recognizer = sr.Recognizer()
     recognizer.pause_threshold = pause_threshold
     recognizer.pause_threshold = pause_threshold
     recognizer.dynamic_energy_threshold = False
     recognizer.dynamic_energy_threshold = False
-    recognizer.energy_threshold = 500
+    #recognizer.energy_threshold = 500
+    recognizer.phrase_threshold = 0.15
+
+    with sr.Microphone() as source:
+        recognizer.adjust_for_ambient_noise(source)
 
 
     return recognizer    
     return recognizer