-1

I am a beginner in python language. I have written a test function in python for converting speech-to-text :

def getAudioFromMicrophone():
    r = sr.Recognizer()
    with sr.Microphone() as source:
        lets_talk.in_female_voice('I am ready for your next command')
        r.pause_threshold=1
        r.adjust_for_ambient_noise(source,duration=1)

    return r.listen(source)

When I run it, it says :

File "D:/PycharmProjects/python-modules/jarvis/jarvis.py", line 5, in import pyaudio ModuleNotFoundError: No module named 'pyaudio'

So, I am trying to install pyaudio in my windows 10 which is again showing an error.

Collecting pyaudio   Using cached https://files.pythonhosted.org/packages/ab/42/b4f04721c5c5bfc196ce156b3c768998ef8c0ae3654ed29ea5020c749a6b/PyAudio-0.2.11.tar.gz Installing collected packages: pyaudio   Running setup.py install for pyaudio: started
    Running setup.py install for pyaudio: finished with status 'error'
    Complete output from command D:\softwares\python-compiler\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\username\\AppData\\Local\\Temp\\pycharm-packaging\\pyaudio\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install
--record C:\Users\username\AppData\Local\Temp\pip-record-9qmland0\install-record.txt
--single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.7
    copying src\pyaudio.py -> build\lib.win-amd64-3.7
    warning: build_py: byte-compiling is disabled, skipping.

    running build_ext
    building '_portaudio' extension
    creating build\temp.win-amd64-3.7
    creating build\temp.win-amd64-3.7\Release
    creating build\temp.win-amd64-3.7\Release\src
    C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DMS_WIN64=1
-ID:\softwares\python-compiler\include -ID:\softwares\python-compiler\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt" /Tcsrc/_portaudiomodule.c /Fobuild\temp.win-amd64-3.7\Release\src/_portaudiomodule.obj
    _portaudiomodule.c
    d:\softwares\python-compiler\include\pyconfig.h(117): warning C4005: 'MS_WIN64': macro redefinition
    src/_portaudiomodule.c: note: see previous definition of 'MS_WIN64'
    src/_portaudiomodule.c(29): fatal error C1083: Cannot open include file: 'portaudio.h': No such file or directory
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2

    ----------------------------------------

Command "D:\softwares\python-compiler\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\username\\AppData\\Local\\Temp\\pycharm-packaging\\pyaudio\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install
--record C:\Users\username\AppData\Local\Temp\pip-record-9qmland0\install-record.txt
--single-version-externally-managed --compile" failed with error code 1 in C:\Users\username\AppData\Local\Temp\pycharm-packaging\pyaudio\ You are using pip version 18.1, however version 19.0.2 is available. You should consider upgrading via the 'python -m pip install --upgrade pip' command.

Any sort of help will be appreciated!

Shamim Ahmad
  • 808
  • 3
  • 22
  • 40
  • Have you checked out https://pypi.org/project/PyAudio/? Did you use `pip install PyAudio` to install the module? – Matthew Smith Feb 14 '19 at 10:13
  • @MatthewSmith I have tried to install pyaudio using "pip install PyAudio" it says "Requirement already satisfied: pyaudio in d:\softwares\python-3.5.3\lib\site-packages (0.2.11)" – Shamim Ahmad Feb 14 '19 at 10:26
  • That means that you've already installed the module. However, it appears as if you've installed the package on an external device such as a USB. Is that the case? I'm only saying that because the message says that the module is installed the D: drive... – Matthew Smith Feb 14 '19 at 10:39

3 Answers3

1

This is a problem with Python 3.7 because there isn't a PyAudio wheel for this version of Python for pip to find. To solve this, download a wheel that fits your computer's specs from here. Now, navigate to the folder the wheel was downloaded to in the command prompt and run: pip install (name of the .whl file here). This should work fine if you are on Windows and using Python 3.7.

I got this information from this post.

SomeMosa
  • 413
  • 5
  • 28
  • If you are on Linux, you should be able to get away with a simple `sudo apt-get install portaudio` and on Mac, you should be able to run a `brew install portaudio` and the normal pip install should work. – SomeMosa Feb 19 '19 at 02:41
  • I tried this command unfortunately it did not work, `Requirement already satisfied: PyAudio==0.2.11 from file:///C:/Users/username/Desktop/PyAudio-0.2.11-cp35-cp35m-win_amd64.whl in d:\softwares\python-3.5.3\lib\site-packages (0.2.11)` – Shamim Ahmad Feb 19 '19 at 14:18
  • Also, my python --version says `Python 3.5.3` – Shamim Ahmad Feb 19 '19 at 14:22
  • Well, it appears PyAudio is installed so I have no idea why you are getting that error. Do you have 32-bit Python or 32-bit Windows? – SomeMosa Feb 20 '19 at 23:48
  • No, 64bit Python & Windows both – Shamim Ahmad Feb 25 '19 at 06:13
  • Taking a closer look, you are attempting to install PyAudio on the `D:` drive. PyAudio seems to be installed on the `C:` drive. Why are you trying to install it on the `D:` drive? – SomeMosa Apr 09 '19 at 00:21
0

Try below commands to install the pyaudio on "Windows 10".

 pip install pipwin
 pipwin install pyaudio
Marina Aguilar
  • 1,151
  • 9
  • 26
Tushar Patil
  • 51
  • 1
  • 4
0

Follow the steps

Step1. Download the PyAudio-0.2.11-cp310-cp310-win_amd64.whl from this link https://pypi.bartbroe.re/pyaudio

Step2. Use the following comand in cmd pip install (path to the file)/PyAudio-0.2.11-cp310-cp310-win_amd64.whl

Now it will install in my case hope this will help you too.