Python 3.x OSError:没有可用的默认输入设备(语音识别)(python)(docker)(ubuntu容器)
我正在使用ubuntu docker容器,它运行在我的ubuntu虚拟机上,运行在我的windows主机上。我已经在我的ubuntu docker容器中安装了所有必要的软件包(apt更新、apt升级、python3、pip3、pyttsx3、语音识别、pyaudio、alsa utils)。当我尝试运行以下代码时:Python 3.x OSError:没有可用的默认输入设备(语音识别)(python)(docker)(ubuntu容器),python-3.x,linux,docker,ubuntu,speech-recognition,Python 3.x,Linux,Docker,Ubuntu,Speech Recognition,我正在使用ubuntu docker容器,它运行在我的ubuntu虚拟机上,运行在我的windows主机上。我已经在我的ubuntu docker容器中安装了所有必要的软件包(apt更新、apt升级、python3、pip3、pyttsx3、语音识别、pyaudio、alsa utils)。当我尝试运行以下代码时: import speech_recognition as sr r = sr.Recognizer() with sr.Microphone() as src: print(
import speech_recognition as sr
r = sr.Recognizer()
with sr.Microphone() as src:
print("tell me")
audio = r.listen(src)
said = ""
try:
said = r.recognize_google(audio)
except Exception as e:
print("Exception: ", e)
finally:
print (said.lower())
我的ubuntu docker容器中出现以下错误
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5220:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM sysdefault
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5220:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM sysdefault
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround40
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround41
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround50
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround51
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround71
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5220:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM default
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5220:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM default
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5220:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM dmix
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.8/dist-packages/speech_recognition/__init__.py", line 86, in __init__
device_info = audio.get_device_info_by_index(device_index) if device_index is not None else audio.get_default_input_device_info()
File "/usr/local/lib/python3.8/dist-packages/pyaudio.py", line 949, in get_default_input_device_info
device_index = pa.get_default_input_device()
OSError: No Default Input Device Available
ALSA lib confmisc.c:767:(解析卡)找不到卡“0”
ALSA lib conf.c:4732:(_snd_config_evaluate)函数snd_func_card_驱动程序返回错误:没有这样的文件或目录
ALSA lib confmisc.c:392:(snd_func_concat)计算字符串时出错
ALSA lib conf.c:4732:(_snd_config_evaluate)函数snd_func_concat返回错误:没有这样的文件或目录
ALSA lib confmisc.c:1246:(snd_func_REFERE)计算名称时出错
ALSA lib conf.c:4732:(_snd_config_evaluate)函数snd_func_refere返回错误:没有这样的文件或目录
ALSA lib conf.c:5220:(snd_config_expand)评估错误:没有这样的文件或目录
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate)未知pcm系统默认值
ALSA lib confmisc.c:767:(解析卡)找不到卡“0”
ALSA lib conf.c:4732:(_snd_config_evaluate)函数snd_func_card_驱动程序返回错误:没有这样的文件或目录
ALSA lib confmisc.c:392:(snd_func_concat)计算字符串时出错
ALSA lib conf.c:4732:(_snd_config_evaluate)函数snd_func_concat返回错误:没有这样的文件或目录
ALSA lib confmisc.c:1246:(snd_func_REFERE)计算名称时出错
ALSA lib conf.c:4732:(_snd_config_evaluate)函数snd_func_refere返回错误:没有这样的文件或目录
ALSA lib conf.c:5220:(snd_config_expand)评估错误:没有这样的文件或目录
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate)未知pcm系统默认值
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate)未知pcm卡.pcm.front
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate)未知pcm卡。pcm.rear
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate)未知pcm卡.pcm.center_lfe
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate)未知pcm卡.pcm.side
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate)未知pcm卡。pcm.surround21
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate)未知pcm卡。pcm.surround21
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate)未知pcm卡。pcm.SURROUND 40
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate)未知pcm卡。pcm.SURROUND 41
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate)未知pcm卡。pcm.surround50
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate)未知pcm卡。pcm.surround51
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate)未知pcm卡。pcm.SURROUND 71
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate)未知pcm卡.pcm.iec958
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate)未知pcm卡.pcm.iec958
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate)未知pcm卡.pcm.iec958
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate)未知pcm卡.pcm.hdmi
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate)未知pcm卡.pcm.hdmi
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate)未知pcm卡.pcm.modem
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate)未知pcm卡.pcm.modem
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate)未知pcm卡.pcm.phoneline
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate)未知pcm卡.pcm.phoneline
ALSA lib confmisc.c:767:(解析卡)找不到卡“0”
ALSA lib conf.c:4732:(_snd_config_evaluate)函数snd_func_card_驱动程序返回错误:没有这样的文件或目录
ALSA lib confmisc.c:392:(snd_func_concat)计算字符串时出错
ALSA lib conf.c:4732:(_snd_config_evaluate)函数snd_func_concat返回错误:没有这样的文件或目录
ALSA lib confmisc.c:1246:(snd_func_REFERE)计算名称时出错
ALSA lib conf.c:4732:(_snd_config_evaluate)函数snd_func_refere返回错误:没有这样的文件或目录
ALSA lib conf.c:5220:(snd_config_expand)评估错误:没有这样的文件或目录
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate)未知pcm默认值
ALSA lib confmisc.c:767:(解析卡)找不到卡“0”
ALSA lib conf.c:4732:(_snd_config_evaluate)函数snd_func_card_驱动程序返回错误:没有这样的文件或目录
ALSA lib confmisc.c:392:(snd_func_concat)计算字符串时出错
ALSA lib conf.c:4732:(_snd_config_evaluate)函数snd_func_concat返回错误:没有这样的文件或目录
ALSA lib confmisc.c:1246:(snd_func_REFERE)计算名称时出错
ALSA lib conf.c:4732:(_snd_config_evaluate)函数snd_func_refere返回错误:没有这样的文件或目录
ALSA lib conf.c:5220:(snd_config_expand)评估错误:没有这样的文件或目录
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate)未知pcm默认值
ALSA lib confmisc.c:767:(解析卡)找不到卡“0”
ALSA lib conf.c:4732:(_snd_config_evaluate)函数snd_func_card_驱动程序返回错误:没有这样的文件或目录
ALSA lib confmisc.c:392:(snd_func_concat)计算字符串时出错
ALSA lib conf.c:4732:(_snd_config_evaluate)函数snd_func_concat返回错误:没有这样的文件或目录
ALSA lib confmisc.c:1246:(snd_func_REFERE)计算名称时出错
ALSA lib conf.c:4732:(_snd_config_evaluate)函数snd_func_refere返回错误:没有这样的文件或目录
ALSA lib conf.c:5220:(snd_config_expand)评估错误:没有这样的文件或目录
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate)未知pcm dmix
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
文件“/usr/local/lib/python3.8/dist packages/speech_recognition/__init__.py”,第86行,in__init__
设备\信息=音频。如果设备\索引不是其他音频,则通过\索引(设备\索引)获取\设备\信息。获取\默认\输入\设备\信息()
文件“/usr/local/lib/python3.8/dist packages/pyaudio.py”,第949行,在获取默认输入设备信息中
设备索引=pa。获取默认输入设备()
操作错误:没有可用的默认输入设备
由于麦克风设备未设置,我收到此错误。但是我不知道如何从docker容器thr解决这个错误