Linux PyAudio打印ALSA警告,但不工作
我正在尝试运行一个基本的python语音到文本代码。这是代码Linux PyAudio打印ALSA警告,但不工作,linux,python-3.x,speech-to-text,alsa,Linux,Python 3.x,Speech To Text,Alsa,我正在尝试运行一个基本的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 Look
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")
代码在到达打印阶段之前工作正常,然后抛出此错误。我做错什么了吗
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
似乎您有多个音频输入源,
语音识别库不支持第一个音频输入源。还有一种可能是您根本没有音频输入
使用sr.micromic(…)
尝试不同的索引(例如0、1、2等),如下例所示:
with sr.Microphone(device_index=0) as source:
但首先,最好运行cat/proc/asound/card
查看您拥有哪些音频设备。如果有人仍在寻找摆脱这些设备的方法
ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map
我刚刚注释掉了中“pcm接口”部分中的所有pcm.surround*行
/usr/share/alsa/alsa.conf
文件,它对我来说很好。这些不是错误信息。我无法从中提取任何信息,因此我认为这是一条错误信息,很抱歉,我不知道,因为我对这条信息非常陌生,可能是《感谢男人》的复制品,尽管我无法删除最后4行与“cat/proc/asound/card”相关的内容如果我将设备索引设置为大于0,则返回“OSError:[Errno-9998]通道数无效”,并在将设备索引设置为0时返回与上述相同的语句对不起,这必须是cat/proc/asound/cards
。目前没有Linux。看一看这篇文章:刚刚意识到您想要摆脱错误消息。请看这篇文章了解您的问题,嗯,它适用于pcm.c错误,但我无法删除其他四行(最后4行)。