我的代码:
with sr.Microphone() as source:
audio = r.listen(source)
try:
print("You said: " + r.recognize_google(audio) + "in french")
except sr.UnknownValueError:
print("Google Speech Recognition could not understand audio")
except sr.RequestError as e:
print("Could not request results from Google Speech Recognition service")
我想将听力语言改为法语。我该怎么做?
答案 0 :(得分:3)
这里是the relevant line of documentataion.
尝试r.recognize_google(audio, language="fr-FR")
答案 1 :(得分:0)
好吧,但是如果我使用一种以上的语言(例如“ en-US”和“ ru-RU”),那么我该如何写相关行?
答案 2 :(得分:0)
try:
voise = r.recognize_google(audio, language="fr-FR")
except sr.UnknownValueError:
speak('understand')
return voise