具有Google语音识别功能的ConnectionResetError

时间:2017-04-06 15:57:49

标签: python-3.x google-speech-api

我有一个音频文件,我想使用Google语音识别将其转换为文本。但我面临以下问题。

代码:

from os import path
AUDIO_FILE = path.join(path.dirname(path.realpath('C:\\Users\\anagha\\Documents\\Python Scripts')),"Python Scripts\\res1.wav")

r = sr.Recognizer()
with sr.AudioFile(AUDIO_FILE) as source:
    audio = r.record(source)

try:
    print("Google Speech Recognition thinks you said " + 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))

我遇到的错误:

 ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host

0 个答案:

没有答案