AttributeError:'Recognizer' 对象没有属性

我正在尝试使 Uberi 识别语音(python)工作,但recognize_azure给了我错误。


import speech_recognition as sr


r = sr.Recognizer()

m = sr.Microphone()


AZURE_SPEECH_KEY = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"


with m as source: r.adjust_for_ambient_noise(source)


print("Say something!")

with m as source: audio = r.listen(source)


try:

    print("Microsoft Azure Speech thinks you said " + r.recognize_azure(audio, key=AZURE_SPEECH_KEY))

except sr.UnknownValueError:

    print("Microsoft Azure Speech could not understand audio")

except sr.RequestError as e:

    print("Could not request results from Microsoft Azure Speech service; {0}".format(e))

这是结果:


AttributeError:'Recognizer' 对象没有属性'recognize_azure'


30秒到达战场
浏览 128回答 1
1回答

偶然的你

您正在使用speech_recognition包的过期版本。recognize_azure它还没有提供。特别是目前在 pypi.org 上列出的包太旧了。您可能需要从源代码安装它,请参阅下面的 github 链接。据我所知,自从 pypi 版本上市以来没有任何版本,所以你唯一的机会似乎是从 git master 安装。见https://github.com/Uberi/speech_recognition/issues/385
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python