2

我的代码:

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")

我想将听力语言更改为法语。我该怎么做?

4

2 回答 2

9

是相关的文档行。

尝试r.recognize_google(audio, language="fr-FR")

于 2018-04-09T17:12:17.897 回答
0
try:
    voise = r.recognize_google(audio, language="fr-FR")
except sr.UnknownValueError:
    speak('understand')
return voise
于 2020-04-21T12:30:25.557 回答