在 pyaudio 部分使用 speech_recognition 时出错

error in working with speech_recognition in section of pyaudio

Traceback (most recent call last):
  File "C:\Users\Anu Nema\AppData\Local\Programs\Python\Python38-32\lib\site-packages\speech_recognition\__init__.py", line 109, 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/Anu Nema/Desktop/New folder/alice/alice.py", line 49, in <module>
    takeCommand()
  File "c:/Users/Anu Nema/Desktop/New folder/alice/alice.py", line 30, in takeCommand
    with sr.Microphone() as source:
  File "C:\Users\Anu Nema\AppData\Local\Programs\Python\Python38-32\lib\site-packages\speech_recognition\__init__.py", line 80, in __init__
    self.pyaudio_module = self.get_pyaudio()
  File "C:\Users\Anu Nema\AppData\Local\Programs\Python\Python38-32\lib\site-packages\speech_recognition\__init__.py", line 111, in get_pyaudio
    raise AttributeError("Could not find PyAudio; check installation")
AttributeError: Could not find PyAudio; check installation

出现此错误的原因是您的计算机上没有安装“pyaudio”。这是'speech_recognition'的依赖项,因此如果你想使用'speech_recognition',你必须拥有它。

您可以通过在命令行中键入以下命令来执行此操作:

pip3 install pyaudio

这需要您在计算机上设置 pip。

这应该可以解决您遇到的错误。