本文介绍了属性错误:找不到 PyAudio;检查安装...无法使用语音识别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试制作一个基本的语音识别助手.当我运行代码时,它告诉我:
I'm trying to make a basic speech Recognition assistant. When I run the code, it tells me:
Traceback (most recent call last):
File "C:\Users\Mo.haytham\AppData\Local\Programs\Python\Python37\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/Mo.haytham/.PyCharmCE2018.3/config/scratches/ALPHA_BASIC.py", line 22, in <module>
hear()
File "C:/Users/Mo.haytham/.PyCharmCE2018.3/config/scratches/ALPHA_BASIC.py", line 13, in hear
with sr.Microphone() as sourse:
File "C:\Users\Mo.haytham\AppData\Local\Programs\Python\Python37\lib\site-packages\speech_recognition\__init__.py", line 79, in __init__
self.pyaudio_module = self.get_pyaudio()
File "C:\Users\Mo.haytham\AppData\Local\Programs\Python\Python37\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
但随后出现此错误:
I tried to pip install pyaudio
but then this error shows up:
Running setup.py clean for pyaudio
Failed to build pyaudio
Installing collected packages: pyaudio
Running setup.py install for pyaudio ... error
ERROR: Complete output from command 'c:\users\mo.haytham\appdata\local\programs\python\python37\python.exe' -u -c 'import setuptools, tokenize;__file__='"'"'C:\\Users\\MO2D8C~1.HAY\\AppData\\Local\\Temp\\pip-install-o2
10x3zl\\pyaudio\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\MO2
D8C~1.HAY\AppData\Local\Temp\pip-record-hr7kket1\install-record.txt' --single-version-externally-managed --compile:
ERROR: running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.7
copying src\pyaudio.py -> build\lib.win-amd64-3.7
running build_ext
building '_portaudio' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/
----------------------------------------
ERROR: Command "'c:\users\mo.haytham\appdata\local\programs\python\python37\python.exe' -u -c 'import setuptools, tokenize;__file__='"'"'C:\\Users\\MO2D8C~1.HAY\\AppData\\Local\\Temp\\pip-install-o210x3zl\\pyaudio\\setup.p
y'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\MO2D8C~1.HAY\AppData\Local\
Temp\pip-record-hr7kket1\install-record.txt' --single-version-externally-managed --compile" failed with error code 1 in C:\Users\MO2D8C~1.HAY\AppData\Local\Temp\pip-install-o210x3zl\pyaudio\
def hear():
import speech_recognition as sr
ear = sr.Recognizer()
with sr.Microphone() as sourse:
print("listening...")
audio = ear.listen(sourse)
try:
text = ear.recognize_google(audio)
print(text)
except:
print("i didn't get that...")
hear()
推荐答案
In Terminal type
In Terminal type
pip install pipwin
然后
pipwin install pyaudio
这篇关于属性错误:找不到 PyAudio;检查安装...无法使用语音识别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!