PyAudio prints ALSA warnings and does not work

匿名 (未验证) 提交于 2019-12-03 02:29:01

问题:

hey guys i'm trying to run a basic python speech to text code. This is the code.

import speech_recognition as sr r = sr.Recognizer() with sr.Microphone() as source:                 audio = r.listen(source)                     try:    print("You said " + r.recognize(audio))      except LookupError:                                print("Could not understand audio") 

The code works fine till it reaches the print stage and then throws this error. Is there anything that i have done wrong?

ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map 

Any help is appreciated and Thanks in advance

回答1:

It seems that you have multiple audio input sources, and the first one is not supported by the speech-recognition library. There is another possibility that you have no audio inputs at all.

Try different indexes (e.g. 0, 1, 2, etc) with sr.Microphone(...) as per example below:

with sr.Microphone(device_index=0) as source: 

But first, it's a good idea to run cat /proc/asound/card to see what audio devices you've got.



回答2:

if someone is still looking for getting rid of

ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map 

I just commented out all pcm.surround* lines in "PCM interface" section in

/usr/share/alsa/alsa.conf 

file and it works fine for me.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!