sudo apt-get install portaudio19-dev python-all-dev python3-all-dev && sudo pip install pyaudio
Use pip3 instead of pip for python3. Windows users can install pyaudio by executing the following command in a terminal
pip install pyaudio
You can test the speech recognition module, with the command:python -m speech_recognition