Search code examples
pythonpython-3.xspeech-recognitionpyaudiopyaudioanalysis

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

Solution

  • The reason that this error occurs is because you do not have ‘pyaudio’ installed on your computer. This is a dependency of ‘speech_recognition’ and therefore you must have it if you wish to use ‘speech_recognition’.

    You can do this by typing this command into the command line:

    pip3 install pyaudio
    

    This requires you have pip set up on your computer.

    This should resolve the error you are having.