小编Zha*_*Fan的帖子

语音识别 Python 出现奇怪的请求错误

使用以下代码进行语音识别根本不起作用

with sr.Microphone() as source:
# read the audio data from the default microphone
audio = r.record(source, duration=4)
print("Recognizing...")
# convert speech to text
# recognize speech using Google Speech Recognition
try:
    # 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 in English: -  " + r.recognize_google(audio, language = "en-US"))
except sr.UnknownValueError:
    print("Google Speech Recognition could not understand audio") …
Run Code Online (Sandbox Code Playgroud)

python speech-recognition speech google-speech-to-text-api

5
推荐指数
1
解决办法
3635
查看次数