【问题标题】:Traceback AttributeError: module 'pyaudio' has no attribute '__version__'Traceback AttributeError: 模块 'pyaudio' 没有属性 '__version__'
【发布时间】:2020-09-11 17:40:53
【问题描述】:

我安装了 SppechRecognition 以及何时写字

import speech_recognition as sr

# obtain audio from the microphone
r = sr.Recognizer()
with sr.Microphone() as source:
    print("Say something!")
    audio = r.listen(source)
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 " + r.recognize_google(audio))
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))

出现上述问题。 在这里问了同样的问题,但解决方案对我没有帮助! AttributeError: module 'pyaudio' has no attribute '__version__' 请帮帮我!

我的终端输出:-

Traceback (most recent call last):

File "c:/Users/samar/OneDrive/Desktop/MAIN/projects/Jarvis/jarvis.py", line 4, in <module>
    with sr.Microphone() as source:

File "C:\Users\samar\AppData\Local\Programs\Python\Python38\lib\site-packages\speech_recognition\__init__.py", line 79, in __init__
    self.pyaudio_module = self.get_pyaudio()

File "C:\Users\samar\AppData\Local\Programs\Python\Python38\lib\site-packages\speech_recognition\__init__.py", line 112, in get_pyaudio
    if LooseVersion(pyaudio.__version__) < LooseVersion("0.2.11"):
AttributeError: module 'pyaudio' has no attribute '__version__'

【问题讨论】:

  • 显示堆栈跟踪
  • 我已经更新了我的问题@MadPhysicist。请检查它!
  • 请正确格式化。我看不懂
  • 什么解决方案结束了,为什么没有帮助
  • 请将其格式化为单个代码块,您可以使用三个反引号。 Python 堆栈跟踪被安排为提供对它们包含的信息的轻松访问。你最好保存它。

标签: python python-3.x speech-recognition pyaudio


【解决方案1】:

当我从 Unofficial Python Packages 安装软件包并在终端中运行代码时。成功了!

【讨论】:

    猜你喜欢
    • 2021-08-25
    • 2018-10-22
    • 2021-03-09
    • 2021-10-02
    • 2021-02-24
    • 2021-11-24
    • 2018-09-18
    • 2021-05-13
    • 2016-11-26
    相关资源
    最近更新 更多