-1

I am currently working on a speech recognition project on my raspberry pi4 and I met with a much unexpected error. The pcm card is 3 and I've already made the necessary changes. Could you please help!!

Below is my code:

import speech_recognition as sr

r = sr.Recognizer()
mic = sr.Microphone()

print("Start talking!")

while True:
    with mic as source:
        audio = r.listen(source)
    words = r.recognize_google(audio)
    print(words)

...and below is the error:

ALSA lib pcm_dsnoop.c:638:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm_dmix.c:1075:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.USB-Audio.pcm.hdmi.0:CARD=3,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM hdmi
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.USB-Audio.pcm.hdmi.0:CARD=3,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM hdmi
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline

Thank you in advance!!

1 Answers1

0

This is an issue with ALSA - the sound subsystem used on the RPi. I strongly suggest using alsamixer to select your sound card and input microphone.

If you use the command arecord -l, what output do you get?

Kathy Reid
  • 575
  • 4
  • 6
  • Thank you very much for the response. The output of arecord -l is: **** List of CAPTURE Hardware Devices **** card 3: Camera [USB 2.0 Camera], device 0: USB Audio [USB Audio] Subdevices: 0/1 Subdevice #0: subdevice #0 – Beeharee Arnav Apr 13 '23 at 08:33
  • I've commented the following lines in the /usr/share/alsa/alsa.conf fle: pcm.rear cards.pcm.rear pcm.center_lfe cards.pcm.center_lfe pcm.side cards.pcm.side Is it necessary? – Beeharee Arnav Apr 13 '23 at 09:04
  • Also when I enter the following command, it gives me an error: arecord --device=NAME and the error is: ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM NAME arecord: main:830: audio open error: No such file or directory – Beeharee Arnav Apr 13 '23 at 09:19
  • I've also commented the following the lines in the /usr/share/alsa/alsa.conf fle: pcm.hdmi cards.pcm.hdmi pcm.modem cards.pcm.modem and pcm.phoneline cards.pcm.phoneline. Now when i when the python script, i get the following error: ALSA lib pcm_dsnoop.c:638:(snd_pcm_dsnoop_open) unable to open slave ALSA lib pcm_dmix.c:1075:(snd_pcm_dmix_open) unable to open slave – Beeharee Arnav Apr 13 '23 at 09:47
  • It's that when i commented out all of the above lines mentioned, the error decreases. – Beeharee Arnav Apr 13 '23 at 09:49