gpt4 book ai didi

python - 尝试使用 pyaudio 运行代码时出现错误

转载 作者:行者123 更新时间:2023-12-04 03:34:25 27 4
gpt4 key购买 nike

<分区>

我正在尝试使用 pyaudio 运行代码,但出现了一些错误

# import library

import speech_recognition as sr
# Initialize recognizer class (for recognizing the speech)

r = sr.Recognizer()

# Reading Microphone as source
# listening the speech and store in audio_text variable

with sr.Microphone() as source:
print("Talk")
audio_text = r.listen(source)
print("Time over, thanks")
# recoginize_() method will throw a request error if the API is unreachable, hence using exception handling

try:
# using google speech recognition
print("Text: " + r.recognize_google(audio_text))
except:
print("Sorry, I did not get that")

错误是:

Traceback (most recent call last):
File "C:\Users\PycharmProjects\pythonProject\venv\lib\site-packages\speech_recognition\__init__.py", line 108, in get_pyaudio
import pyaudio
ModuleNotFoundError: No module named 'pyaudio'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\PycharmProjects\pythonProject\hello_world.py", line 11, in <module>
with sr.Microphone() as source:
File "C:\Users\PycharmProjects\pythonProject\venv\lib\site-packages\speech_recognition\__init__.py", line 79, in __init__
self.pyaudio_module = self.get_pyaudio()
File "C:\Users\PycharmProjects\pythonProject\venv\lib\site-packages\speech_recognition\__init__.py", line 110, in get_pyaudio
raise AttributeError("Could not find PyAudio; check installation")
AttributeError: Could not find PyAudio; check installation

我已经使用 pip install PyAudio-0.2.11-cp39-cp39m-win_amd64.whl 手动安装了 pyaudio,还执行了 curl https://bootstrap.pypa.io/ez_setup。 py| python

我也尝试将 pyaudio 安装到 pycharm 中,但也出现了错误。

C:\Users>pip freeze
comtypes==1.1.9
PyAudio @ file:///C:/Users/Downloads/PyAudio-0.2.11-cp39-cp39-win_amd64.whl


C:\Users>python -m pip install pyaudio
Requirement already satisfied: pyaudio in c:\users\appdata\local\programs\python\python39\lib\site-packages (0.2.11)

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com