You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

树莓派2使用speech_recognition遇recognize_google属性及导入错误求助

树莓派2使用speech_recognition库的报错问题

初始代码与报错

运行以下代码调用Google语音识别:

import speech_recognition as sr
r = sr.Recognizer()
with sr.Microphone() as source:
    string = ""
    audio = r.listen(source)
    string = r.recognize_google(audio)
print(string)

触发错误:

AttributeError: 'Recognizer' object has no attribute 'recognize_google'

尝试修复后的新报错

添加指定导入代码后:

from speech_recognition.recognizers import google, whisper

出现新错误:

ImportError: cannot import name 'NotRequired' from 'typing_extentions'

已确认typing_extentions库已安装,但无法定位错误原因及解决办法。


内容的提问来源于stack exchange,提问作者Justin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.26 12:32:39