使用自己的API密钥时,Google Speech API错误[32]管道中断

时间:2018-07-16 10:37:16

标签: google-cloud-speech

我尝试使用Google语音API将我的音频语音输入转换为具有树莓pi 0和python代码的文本。我添加了结算帐户并在Google控制台中启用了GOOGLE SPEECH API服务。我为Google Speech API生成了自己的API密钥,并尝试在python脚本中使用它,但是当我运行该脚本时,出现错误[32]管道中断,连接失败请让我知道无法访问API密钥的原因。Google Speech API是否需要任何身份验证过程或代码有任何问题。我的python代码如下

#!/usr/bin/env python3
import speech_recognition as sr
r = sr.Recognizer()
with sr.Microphone() as source:
     print("Say something!")
     audio = r.listen(source)
try:
     print (r.recognize_google(audio, key="my_api_key"))
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}".format(e))

错误是:

say something!
could not request results from google speech recognition services
recognition connection failed:[ERROR 32] broken pipe

0 个答案:

没有答案