简体   繁体   中英

Pyaudio doesn't work when I try to run the code on windows

This is my code but when I start to code I get error. I installed pip and the other function but error occurs

import speech_recognition as sr r = sr.Recognizer() with sr.Microphone() as source:

print("Speak Anything: ")
audio = r.listen(source)
try:
    text=r.recognize_google(audio)
    print("You said:()".format(text))
except:
    print("Sorry could not recognize what you said")

And also this is my error. I tried a lot of solution but nothings work. Traceback (most recent call last): File "C:\Users\Asus\PycharmProjects\pythonProject2\venv\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\Asus\PycharmProjects\pythonProject2\main.py", line 3, in with sr.Microphone() as source: File "C:\Users\Asus\PycharmProjects\pythonProject2\venv\lib\site-packages\speech_recognition_ init _.py", line 79, in init self.pyaudio_module = self.get_pyaudio() File "C:\Users\Asus\PycharmProjects\pythonProject2\venv\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

As you mention your python version is 3.9 you can find associate wheel file from here

Let me give you example from image as you can see my python version is 3.7 so i will download PyAudio‑0.2.11‑cp37‑cp37m‑win_amd64.whl which contains only python 3.7

在此处输入图像描述

  1. cp37m‑win_amd64 which means python 3.7 with 64 bit and verify from image

  2. Now i will download that file and give full path where i have downloaded and use as pip install path-to-wheel-file

  3. so now you have to do for python 3.9 and check it is 32 bit or 64 bit and download wheel file and install pyaudio

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM