Uberi / speech_recognition

Speech recognition module for Python, supporting several engines and APIs, online and offline.
https://pypi.python.org/pypi/SpeechRecognition/
BSD 3-Clause "New" or "Revised" License
8.41k stars 2.4k forks source link

AttributeError: Could not find PyAudio; check installation Raspberry Pi 3 #326

Open aaroncheung123 opened 6 years ago

aaroncheung123 commented 6 years ago

I am currently trying to get speech recognition to work on my raspberry pi 3 however this is the error that I am getting.

Traceback (most recent call last): File "listen.py", line 8, in <module> with sr.Microphone() as source: File "/home/pi/Documents/Test/env/local/lib/python2.7/site-packages/speech_recognition/__init__.py", line 79, in __init__ self.pyaudio_module = self.get_pyaudio() File "/home/pi/Documents/Test/env/local/lib/python2.7/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

My issue is almost exactly the same as sanster9292 who opened a ticket on June 2, 2017. I tried everything that you asked him to; however, I am still getting the error above. Please, let me know if you need more information. Do you have any idea how to get this to work on my raspberry pi 3?

jhoelzl commented 6 years ago

Try in terminal in your project / virtual environment:


python -i
import pyaudio

Do you also get an error?

aaroncheung123 commented 6 years ago

Yes I do. Below is the error I got.

>>> import pyaudio Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named pyaudio

jhoelzl commented 6 years ago

Okay, then please install pyaudio using:

pip install pyaudio

aaroncheung123 commented 6 years ago

That's my problem. I have done pip install pyaudio but it is still giving me that error. I'm using a virtual environment, I'm using python 2.7, and I am on a raspberry pi 3.

jhoelzl commented 6 years ago

Do you get an error when installing pyaudio?

aaroncheung123 commented 6 years ago

No, there are no errors. I just and pyaudio does import when I pull up python. I think the restart helped.

aaroncheung123 commented 6 years ago

When I run this code

import speech_recognition as sr

r = sr.Recognizer()
with sr.Microphone() as source:
    print("Waiting to be called on")
    audio = r.listen(source)
try:
    #print(r.recognize_google(audio))

    if "hey buddy" in r.recognize_google(audio):
        print('Yay')

except sr.UnknownValueError:
    print("Could not understand audio")
except sr.RequestError as e:
    print("Could not request results; {0}".format(e))

This is the error I receive.

ALSA lib pcm_dsnoop.c:618:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'defaults.bluealsa.device'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4996:(snd_config_expand) Args evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM bluealsa
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'defaults.bluealsa.device'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4996:(snd_config_expand) Args evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM bluealsa
ALSA lib pcm_dsnoop.c:618:(snd_pcm_dsnoop_open) unable to open slave
connect(2) call to /tmp/jack-1000/default/jack_0 failed (err=No such file or directory)
attempt to connect to server failed
Waiting to be called on

When I speak into the microphone it just doesn't work. I know the microphone is working too.

WhiteDevil02 commented 5 years ago

dear sir my error is same import pyaudio

please help me

ScrappyCocoJamba commented 4 years ago

hello guys, I have some problem too

anyone solved this problem?

ubuntu 19.10

sourabh-st commented 4 years ago

i got this problem while installing pyaudio.

Screenshot 2020-05-07 at 11 05 50 AM

sandesh2526 commented 4 years ago

i got this problem while installing pyaudio.

Screenshot 2020-05-07 at 11 05 50 AM

I got same problem while installing it on pydroid...if it appears on windows you can fix it using pip install pipwin pipwin install pyaudio

ritujashinde97 commented 4 years ago

pip install pipwin pipwin install pyaudio

It worked for me (windows)

Jayant-tembhurkar commented 4 years ago

Not working in window

maansiii commented 4 years ago

yes its not working for me either (Windows) although i updated python

sandesh2526 commented 4 years ago

What error it shows?

maansiii commented 4 years ago

This

On Wed, May 27, 2020 at 4:03 PM sandesh2526 notifications@github.com wrote:

What error it shows?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Uberi/speech_recognition/issues/326#issuecomment-634574171, or unsubscribe https://github.com/notifications/unsubscribe-auth/AORWHDSLCRWETLBKCZ452FDRTTT7PANCNFSM4EQZIKGA .

sandesh2526 commented 4 years ago

pip install pipwin pipwin install pyaudio

After executing this commands what it shows?

maansiii commented 4 years ago

It shows that pipwin is external and is non recognised I tried

On Wed, 27 May 2020 at 7:12 PM, sandesh2526 notifications@github.com wrote:

pip install pipwin pipwin install pyaudio

After executing this commands what it shows?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Uberi/speech_recognition/issues/326#issuecomment-634669178, or unsubscribe https://github.com/notifications/unsubscribe-auth/AORWHDURJ6CW6LIEN6HP663RTUKDLANCNFSM4EQZIKGA .

maansiii commented 4 years ago

-

On Wed, May 27, 2020 at 7:17 PM riyaaa singh singhriyaaa544@gmail.com wrote:

It shows that pipwin is external and is non recognised I tried

On Wed, 27 May 2020 at 7:12 PM, sandesh2526 notifications@github.com wrote:

pip install pipwin pipwin install pyaudio

After executing this commands what it shows?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Uberi/speech_recognition/issues/326#issuecomment-634669178, or unsubscribe https://github.com/notifications/unsubscribe-auth/AORWHDURJ6CW6LIEN6HP663RTUKDLANCNFSM4EQZIKGA .

sandesh2526 commented 4 years ago

Can you share a screenshot of error...?

maansiii commented 4 years ago

pipwin error

On Thu, May 28, 2020 at 11:36 AM sandesh2526 notifications@github.com wrote:

Can you share a screenshot of error...?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Uberi/speech_recognition/issues/326#issuecomment-635125655, or unsubscribe https://github.com/notifications/unsubscribe-auth/AORWHDWSG6JQHPQJ6CKAOLDRTX5PPANCNFSM4EQZIKGA .

sandesh2526 commented 4 years ago

What are you using IDE or command prompt?

maansiii commented 4 years ago

cmd also im using windows

On Fri, May 29, 2020 at 4:31 PM sandesh2526 notifications@github.com wrote:

What are you using IDE or command prompt?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Uberi/speech_recognition/issues/326#issuecomment-635911742, or unsubscribe https://github.com/notifications/unsubscribe-auth/AORWHDVW23UBUWBZP23TTBLRT6IXLANCNFSM4EQZIKGA .

sandesh2526 commented 4 years ago

This might work- install PyAudio‑0.2.11‑cp37‑cp37m‑win_amd64.whl

maansiii commented 4 years ago

not working

On Sat, May 30, 2020 at 5:05 PM sandesh2526 notifications@github.com wrote:

This might work- install PyAudio‑0.2.11‑cp37‑cp37m‑win_amd64.whl

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Uberi/speech_recognition/issues/326#issuecomment-636318430, or unsubscribe https://github.com/notifications/unsubscribe-auth/AORWHDQ7XD4CVR5OGW5GURDRUDVO7ANCNFSM4EQZIKGA .

Jayant-tembhurkar commented 4 years ago

Use python version 3.6 not above than that

On Wednesday, May 27, 2020, maannsaayyy notifications@github.com wrote:

yes its not working for me either (Windows) although i updated python

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Uberi/speech_recognition/issues/326#issuecomment-634565416, or unsubscribe https://github.com/notifications/unsubscribe-auth/APTUWUSZ4QLZW2JMPRLGJULRTTRY3ANCNFSM4EQZIKGA .

maansiii commented 4 years ago

But why is this issue happening in latest version of python?

On Wed, Jun 3, 2020 at 9:32 PM Jayant-tembhurkar notifications@github.com wrote:

Use python version 3.6 not above than that

On Wednesday, May 27, 2020, maannsaayyy notifications@github.com wrote:

yes its not working for me either (Windows) although i updated python

— You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/Uberi/speech_recognition/issues/326#issuecomment-634565416 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/APTUWUSZ4QLZW2JMPRLGJULRTTRY3ANCNFSM4EQZIKGA

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Uberi/speech_recognition/issues/326#issuecomment-638292747, or unsubscribe https://github.com/notifications/unsubscribe-auth/AORWHDV7KH4VMXKURZCJGJLRUZX3HANCNFSM4EQZIKGA .

Sudarshan-17 commented 4 years ago

i got this problem while installing pyaudio. Screenshot 2020-05-07 at 11 05 50 AM

I got same problem while installing it on pydroid...if it appears on windows you can fix it using pip install pipwin pipwin install pyaudio

Not working .....

jit01 commented 4 years ago

When It comes to listing part it was saying


ALSA lib pcm_dmix.c:1052:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_dmix.c:1052:(snd_pcm_dmix_open) unable to open slave```

and code was 
 with sr.Microphone() as source:
        print("Listening")
        audio = re.listen(source)

I solved this problem by simply changing the listen() parameter, and installed some pkg 

sudo apt-get install portaudio19-dev 
sudo apt-get install portaudio19-dev python-all-dev python3-all-dev && sudo pip install pyaudio
pip install pyaudio

with sr.Microphone() as source:
        print("Listening")
        audio = re.listen(source, timeout=3, phrase_time_limit=3)
parthgandhi487 commented 4 years ago

I installed pip install pipwin and then when i tried installing pipwin install pyaudio, it is showing syntax error as below :

File "", line 1 pip install pipwin ^ SyntaxError: invalid syntax

parthgandhi487 commented 4 years ago

Please help me on this

gursevakgill23 commented 4 years ago

pip install pipwin pipwin install PyAudio Try this ommand in cmd not in any IDE

TuHechiceroFavorito commented 4 years ago

I'm using Linux and for me this command on terminal worked:

sudo apt install python3-pyaudio

Im-Fran commented 3 years ago

If someone still having this issue after installing python3-pyaudio this is how I solved it:

  1. Execute this: sudo apt-get install portaudio19-dev python3-pyaudio
  2. Now install pyaudio through pip: pip install pyaudio
  3. Now you should be able to use pyaudio!

This is for linux, tested in popOS (should work in ubuntu and other linux distrubtions too)