Python 3.x 如何在Rasp/Pi上修复python中的python语音识别
我玩了一轮代码游戏,并抓取了其他开发人员的一些代码。我有一个代码,它一直在打印错误消息:Python 3.x 如何在Rasp/Pi上修复python中的python语音识别,python-3.x,raspberry-pi3,Python 3.x,Raspberry Pi3,我玩了一轮代码游戏,并抓取了其他开发人员的一些代码。我有一个代码,它一直在打印错误消息: Traceback (most recent call last): File "/usr/local/lib/python3.5/dist-packages/speech_recognition/__init__.py", line 108, in get_pyaudio import pyaudio ImportError: No module named 'pyaudio' During
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/speech_recognition/__init__.py", line 108, in get_pyaudio
import pyaudio
ImportError: No module named 'pyaudio'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pi/Documents/SHADOW/tkinter.py", line 5, in <module>
with sr.Microphone() as source:
File "/usr/local/lib/python3.5/dist-packages/speech_recognition/__init__.py", line 79, in __init__
self.pyaudio_module = self.get_pyaudio()
File "/usr/local/lib/python3.5/dist-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
下面是一些关于如何安装
pyaudio
的说明:@mypetlion我刚刚尝试过,但没有成功,可能是因为如果您按照上面的说明安装了python 2,而您使用的是python 3。要为python3安装:python3-m pip install pyaudio
它被定义为python3没有以什么方式工作?
import speech_recognition as sr
r = sr.Recognizer()
with sr.Microphone() as source:
print("Speak")
audio = r.listen(source)
try:
text = r.recognize_google(audio)
print("You said {}".format(text))
except:
print("sorry")