Browse Source

google stt test FR ok

nico 8 năm trước cách đây
mục cha
commit
379e501878
1 tập tin đã thay đổi với 3 bổ sung1 xóa
  1. 3 1
      core/OrderListener.py

+ 3 - 1
core/OrderListener.py

@@ -21,6 +21,8 @@ class OrderListener:
         # obtain audio from the microphone
         r = sr.Recognizer()
         with sr.Microphone() as source:
+            # listen for 1 second to calibrate the energy threshold for ambient noise levels
+            r.adjust_for_ambient_noise(source)
             print("Say something!")
             audio = r.listen(source)
 
@@ -29,7 +31,7 @@ class OrderListener:
             # for testing purposes, we're just using the default API key
             # to use another API key, use `r.recognize_google(audio, key="GOOGLE_SPEECH_RECOGNITION_API_KEY")`
             # instead of `r.recognize_google(audio)`
-            print("Google Speech Recognition thinks you said " + r.recognize_google(audio))
+            print("Google Speech Recognition thinks you said " + r.recognize_google(audio, key=None, language="fr-FR"))
         except sr.UnknownValueError:
             print("Google Speech Recognition could not understand audio")
         except sr.RequestError as e: