speech_recognition
speech_recognition copied to clipboard
raise AttributeError("Could not find PyAudio; check installation") AttributeError: Could not find PyAudio; check installation
def takeCommand(): r = sr.Recognizer() with sr.Microphone() as source: print("Listening...") r.pause_threshold = 1 audio = r.listen(source)
try:
print("Recognizing..")
query = r.recognize_google(audio, language='en-in')
print(query)
except Exception as e:
print(e)
speak("Say that again please...")
return "None"
return query
takeCommand()
PS C:\Users\PattanshettiShraddha> & "F:/python 3.6/python.exe" c:/Users/PattanshettiShraddha/Downloads/jarvis.py PS C:\Users\PattanshettiShraddha> & "F:/python 3.6/python.exe" c:/Users/PattanshettiShraddha/Downloads/jarvis.py PS C:\Users\PattanshettiShraddha> & "F:/python 3.6/python.exe" c:/Users/PattanshettiShraddha/Downloads/jarvis.py PS C:\Users\PattanshettiShraddha> & "F:/python 3.6/python.exe" c:/Users/PattanshettiShraddha/Downloads/jarvis.py PS C:\Users\PattanshettiShraddha> & "F:/python 3.6/python.exe" c:/Users/PattanshettiShraddha/Downloads/jarvis.py Traceback (most recent call last): File "F:\python 3.6\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):
takeCommand()
File "c:/Users/PattanshettiShraddha/Downloads/jarvis.py", line 50, in takeCommand
with sr.Microphone() as source:
File "F:\python 3.6\lib\site-packages\speech_recognition_init_.py", line 79, in init
self.pyaudio_module = self.get_pyaudio()
File "F:\python 3.6\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
PS C:\Users\PattanshettiShraddha> & "F:/python 3.6/python.exe" c:/Users/PattanshettiShraddha/Downloads/jarvis.py
Traceback (most recent call last):
File "F:\python 3.6\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):
takeCommand()
File "c:/Users/PattanshettiShraddha/Downloads/jarvis.py", line 50, in takeCommand
with sr.Microphone() as source:
File "F:\python 3.6\lib\site-packages\speech_recognition_init_.py", line 79, in init
self.pyaudio_module = self.get_pyaudio()
File "F:\python 3.6\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
PS C:\Users\PattanshettiShraddha> & "F:/python 3.6/python.exe" c:/Users/PattanshettiShraddha/Downloads/jarvis.py
Traceback (most recent call last):
File "F:\python 3.6\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):
takeCommand()
File "c:/Users/PattanshettiShraddha/Downloads/jarvis.py", line 50, in takeCommand
with sr.Microphone() as source:
File "F:\python 3.6\lib\site-packages\speech_recognition_init_.py", line 79, in init
self.pyaudio_module = self.get_pyaudio()
File "F:\python 3.6\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
PS C:\Users\PattanshettiShraddha> & "F:/python 3.6/python.exe" c:/Users/PattanshettiShraddha/Downloads/jarvis.py
Traceback (most recent call last):
File "F:\python 3.6\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):
takeCommand()
File "c:/Users/PattanshettiShraddha/Downloads/jarvis.py", line 50, in takeCommand
with sr.Microphone() as source:
File "F:\python 3.6\lib\site-packages\speech_recognition_init_.py", line 79, in init
self.pyaudio_module = self.get_pyaudio()
File "F:\python 3.6\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
PS C:\Users\PattanshettiShraddha> & "F:/python 3.6/python.exe" c:/Users/PattanshettiShraddha/Downloads/jarvis.py
Traceback (most recent call last):
File "F:\python 3.6\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):
takeCommand()
File "c:/Users/PattanshettiShraddha/Downloads/jarvis.py", line 50, in takeCommand
with sr.Microphone() as source:
File "F:\python 3.6\lib\site-packages\speech_recognition_init_.py", line 79, in init
self.pyaudio_module = self.get_pyaudio()
File "F:\python 3.6\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
PS C:\Users\PattanshettiShraddha> & "F:/python 3.6/python.exe" c:/Users/PattanshettiShraddha/Downloads/jarvis.py
Traceback (most recent call last):
File "F:\python 3.6\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):
takeCommand()
File "c:/Users/PattanshettiShraddha/Downloads/jarvis.py", line 50, in takeCommand
with sr.Microphone() as source:
File "F:\python 3.6\lib\site-packages\speech_recognition_init_.py", line 79, in init
self.pyaudio_module = self.get_pyaudio()
File "F:\python 3.6\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
PS C:\Users\PattanshettiShraddha> & "F:/python 3.6/python.exe" c:/Users/PattanshettiShraddha/Downloads/jarvis.py
Traceback (most recent call last):
File "F:\python 3.6\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):
takeCommand()
File "c:/Users/PattanshettiShraddha/Downloads/jarvis.py", line 50, in takeCommand
with sr.Microphone() as source:
File "F:\python 3.6\lib\site-packages\speech_recognition_init_.py", line 79, in init
self.pyaudio_module = self.get_pyaudio()
io
raise AttributeError("Could not find PyAudio; check installation")
AttributeError: Could not find PyAudio; check installation
PS C:\Users\PattanshettiShraddha> & "F:/python 3.6/python.exe" c:/Users/PattanshettiShraddha/Downloads/jarvis.py
Traceback (most recent call last):
File "c:/Users/PattanshettiShraddha/Downloads/jarvis.py", line 4, in
During handling of the above exception, another exception occurred:
PS C:\Users\PattanshettiShraddha> & "F:/python 3.6/python.exe" c:/Users/PattanshettiShraddha/Downloads/jarvis.py Traceback (most recent call last): File "F:\python 3.6\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):
takeCommand()
File "c:/Users/PattanshettiShraddha/Downloads/jarvis.py", line 51, in takeCommand
with sr.Microphone() as source:
File "F:\python 3.6\lib\site-packages\speech_recognition_init_.py", line 79, in init
self.pyaudio_module = self.get_pyaudio()
File "F:\python 3.6\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
PS C:\Users\PattanshettiShraddha> & "F:/python 3.6/python.exe" c:/Users/PattanshettiShraddha/Downloads/jarvis.py
Traceback (most recent call last):
File "F:\python 3.6\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:
PS C:\Users\PattanshettiShraddha> & "F:/python 3.6/python.exe" c:/Users/PattanshettiShraddha/Downloads/jarvis.py Traceback (most recent call last): File "F:\python 3.6\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:
PS C:\Users\PattanshettiShraddha> & "F:/python 3.6/python.exe" c:/Users/PattanshettiShraddha/Downloads/jarvis.py Traceback (most recent call last): File "F:\python 3.6\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/PattanshettiShraddha/Downloads/jarvis.py", line 68, in
self.pyaudio_module = self.get_pyaudio()
File "F:\python 3.6\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
please someone help with this issue
Have you actually installed PyAudio? The README.md has some good instructions on how to do this. Running pip3 install pyaudio should install in most cases.
This is how I solved this problem on my local:
- Execute this:
sudo apt-get install portaudio19-dev python3-pyaudio - Now install pyaudio through pip:
pip install pyaudio - Now you should be able to use pyaudio!
This is for linux, tested in popOS (should work in ubuntu and other linux distrubtions too)
But tbh I don't know how to do it in windows, but maybe that should give you a hint on how to do it, but what basically helped me was installing portaudio19-dev and python3-pyaudio
Wheel file is not available to install pyaudio on windows using pip.
You can install it using conda and it will work: conda install pyaudio
You can download the right whl package from here. Use pip install assuming the package is in the Downloads folder : python -m pip install C:\Users%USER%\Downloads\Twisted-17.9.0-cp36-cp36m-win32.whl
How do I fix this on Mac?
pip install pyaudio
Collecting pyaudio
Downloading PyAudio-0.2.11.tar.gz (37 kB)
Using legacy 'setup.py install' for pyaudio, since package 'wheel' is not installed.
Installing collected packages: pyaudio
Running setup.py install for pyaudio ... error
ERROR: Command errored out with exit status 1:
command: /Users/cosborn/.pyenv/versions/3.9.7/bin/python3.9 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/m0/m681np354bd2swyyjwk_hjqc0000gn/T/pip-install-zn2ff94j/pyaudio_5d1ed113096b45bebffba24edffa38b4/setup.py'"'"'; __file__='"'"'/private/var/folders/m0/m681np354bd2swyyjwk_hjqc0000gn/T/pip-install-zn2ff94j/pyaudio_5d1ed113096b45bebffba24edffa38b4/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/m0/m681np354bd2swyyjwk_hjqc0000gn/T/pip-record-drroe6wg/install-record.txt --single-version-externally-managed --compile --install-headers /Users/cosborn/.pyenv/versions/3.9.7/include/python3.9/pyaudio
cwd: /private/var/folders/m0/m681np354bd2swyyjwk_hjqc0000gn/T/pip-install-zn2ff94j/pyaudio_5d1ed113096b45bebffba24edffa38b4/
Complete output (16 lines):
running install
running build
running build_py
creating build
creating build/lib.macosx-11.4-arm64-3.9
copying src/pyaudio.py -> build/lib.macosx-11.4-arm64-3.9
running build_ext
building '_portaudio' extension
creating build/temp.macosx-11.4-arm64-3.9
creating build/temp.macosx-11.4-arm64-3.9/src
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -DMACOSX=1 -I/Users/cosborn/.pyenv/versions/3.9.7/include/python3.9 -c src/_portaudiomodule.c -o build/temp.macosx-11.4-arm64-3.9/src/_portaudiomodule.o
src/_portaudiomodule.c:29:10: fatal error: 'portaudio.h' file not found
#include "portaudio.h"
^~~~~~~~~~~~~
1 error generated.
error: command '/usr/bin/clang' failed with exit code 1
----------------------------------------
ERROR: Command errored out with exit status 1: /Users/cosborn/.pyenv/versions/3.9.7/bin/python3.9 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/m0/m681np354bd2swyyjwk_hjqc0000gn/T/pip-install-zn2ff94j/pyaudio_5d1ed113096b45bebffba24edffa38b4/setup.py'"'"'; __file__='"'"'/private/var/folders/m0/m681np354bd2swyyjwk_hjqc0000gn/T/pip-install-zn2ff94j/pyaudio_5d1ed113096b45bebffba24edffa38b4/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/m0/m681np354bd2swyyjwk_hjqc0000gn/T/pip-record-drroe6wg/install-record.txt --single-version-externally-managed --compile --install-headers /Users/cosborn/.pyenv/versions/3.9.7/include/python3.9/pyaudio Check the logs for full command output.
WARNING: You are using pip version 21.2.3; however, version 21.2.4 is available.
You should consider upgrading via the '/Users/cosborn/.pyenv/versions/3.9.7/bin/python3.9 -m pip install --upgrade pip' command.
➜ speech_recognition git:(master) python -m speech_recognition
Traceback (most recent call last):
File "/Users/cosborn/vendor/speech_recognition/speech_recognition/__init__.py", line 107, 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 "/Users/cosborn/.pyenv/versions/3.9.7/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/Users/cosborn/.pyenv/versions/3.9.7/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/Users/cosborn/vendor/speech_recognition/speech_recognition/__main__.py", line 4, in <module>
m = sr.Microphone()
File "/Users/cosborn/vendor/speech_recognition/speech_recognition/__init__.py", line 79, in __init__
self.pyaudio_module = self.get_pyaudio()
File "/Users/cosborn/vendor/speech_recognition/speech_recognition/__init__.py", line 109, in get_pyaudio
raise AttributeError("Could not find PyAudio; check installation")
AttributeError: Could not find PyAudio; check installation
You need to install "portaudio.h" binary. Search online to see if you can find the apt package for portaudio development version. That should fix the issue
I got this running on MacOS by doing this:
-
Install PortAudio using Homebrew:
brew install portaudio -
Then, install PyAudio using pip:
pip3 install pyaudio
Check this docs.