Traceback AttributeError: โมดูล 'pyaudio' ไม่มีแอตทริบิวต์ '__version__'

Sep 05 2020

ฉันพูดถึง 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' ไม่มีแอตทริบิวต์ '__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__'

คำตอบ

SamarPratapSingh Sep 11 2020 at 16:40

เมื่อฉันติดตั้งแพ็คเกจจากแพ็คเกจ Python ที่ไม่เป็นทางการและรันโค้ดในเทอร์มินัล มันได้ผล!