顺便说一句,paFloat32表示portaudioFloat32
我正在尝试使用Speech_recognition库,安装了PyAudio,但是当我运行脚本时出现此错误:
Traceback (most recent call last):
File "C:\Users\User\!Python!\0.8.py", line 6, in <module>
with sr.Microphone() as source:
File "C:\Users\User\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\User\AppData\Local\Programs\Python\Python38\lib\site-packages\speech_recognition\__init__.py", line 108, in get_pyaudio
import pyaudio
File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\site-packages\pyaudio.py", line 127, in <module>
paFloat32 = pa.paFloat32 #: 32 bit float
AttributeError: module '_portaudio' has no attribute 'paFloat32'
我的代码:
r = sr.Recognizer()
with sr.Microphone() as source:
audio = r.listen(source)
said = ''
try:
said = r.recognize_google(audio, language="en-EN")
print(said)
except sr.UnknownValueError:
print("Unrecognised speech")
这很容易,而且必须能正常工作,但不能(我已经在Google搜索此错误,却一无所获
我在Windows 10上使用Python 3.8.5(64位)