Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux PyAudio打印ALSA警告,但不工作_Linux_Python 3.x_Speech To Text_Alsa - Fatal编程技术网

Linux PyAudio打印ALSA警告,但不工作

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

我正在尝试运行一个基本的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")
代码在到达打印阶段之前工作正常,然后抛出此错误。我做错什么了吗

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行)。