PyAudio 打印 ALSA 警告并且不起作用

Cha*_*yan 2 linux alsa speech-to-text python-3.x

我正在尝试运行一个基本的 python 语音到文本代码。这是代码。

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")
Run Code Online (Sandbox Code Playgroud)

代码运行良好,直到到达打印阶段,然后抛出此错误。有什么我做错了吗?

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
Run Code Online (Sandbox Code Playgroud)

小智 9

如果有人还在寻找摆脱

ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map
Run Code Online (Sandbox Code Playgroud)

我刚刚注释掉了“PCM 接口”部分中的所有 pcm.surround* 行

/usr/share/alsa/alsa.conf
Run Code Online (Sandbox Code Playgroud)

文件,它对我来说很好用。