Python 使用运行Ubuntu服务器但来自Windows平台的Docker映像录制语音时出错

Python 使用运行Ubuntu服务器但来自Windows平台的Docker映像录制语音时出错,python,docker,microphone,Python,Docker,Microphone,我的操作系统是windows,我有一个docker映像,如下所示: FROM python:3.6 # Set the working directory to /app WORKDIR /app # Copy the current directory contents into the container at /app COPY . /app # Install any needed packages specified in requirements.txt RUN apt

我的操作系统是windows,我有一个docker映像,如下所示:

FROM python:3.6

# Set the working directory to /app

WORKDIR /app

# Copy the current directory contents into the container at /app

COPY . /app



# Install any needed packages specified in requirements.txt
RUN apt-get update && apt-get install -y python-pip libasound-dev libasound2-dev portaudio19-dev libportaudio2 libportaudiocpp0 ffmpeg pulseaudio
#libav-tools

RUN pip install --upgrade pip && pip install --trusted-host pypi.python.org -r requirements.txt

# Define environment variable

ENV NAME nlpText
此外,我的要求文件是:

deepspeech==0.4.1
pyspellchecker
scipy
pynput
pyaudio
pyalsaaudio
ffmpeg-python
当我想运行python代码时,只需通过以下方式记录我的语音:

docker run -it --rm --name NLPTEST -v D:\nariman\NLP\NLP_docker_voice_recorder:/app --privileged --device /dev/snd nlp_base bash
python recorder.py
我得到以下错误:

ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4528:(_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:4528:(_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:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM sysdefault
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4528:(_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:4528:(_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:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM sysdefault
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround40
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround41
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround50
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround51
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround71
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4528:(_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:4528:(_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:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM default
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4528:(_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:4528:(_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:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM default
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4528:(_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:4528:(_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:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM dmix
Traceback (most recent call last):
  File "recorder.py", line 30, in <module>
    frames_per_buffer=CHUNK)
  File "/usr/local/lib/python3.6/site-packages/pyaudio.py", line 750, in open
    stream = Stream(self, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pyaudio.py", line 441, in __init__
    self._stream = pa.open(**arguments)
OSError: [Errno -9996] Invalid input device (no default output device)
ALSA lib confmisc.c:767:(解析卡)找不到卡“0”
ALSA lib conf.c:4528:(_snd_config_evaluate)函数snd_func_card_驱动程序返回错误:没有这样的文件或目录
ALSA lib confmisc.c:392:(snd_func_concat)计算字符串时出错
ALSA lib conf.c:4528:(_snd_config_evaluate)函数snd_func_concat返回错误:没有这样的文件或目录
ALSA lib confmisc.c:1246:(snd_func_REFERE)计算名称时出错
ALSA lib conf.c:4528:(_snd_config_evaluate)函数snd_func_refere返回错误:没有这样的文件或目录
ALSA lib conf.c:5007:(snd_config_expand)评估错误:没有这样的文件或目录
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate)未知pcm系统默认值
ALSA lib confmisc.c:767:(解析卡)找不到卡“0”
ALSA lib conf.c:4528:(_snd_config_evaluate)函数snd_func_card_驱动程序返回错误:没有这样的文件或目录
ALSA lib confmisc.c:392:(snd_func_concat)计算字符串时出错
ALSA lib conf.c:4528:(_snd_config_evaluate)函数snd_func_concat返回错误:没有这样的文件或目录
ALSA lib confmisc.c:1246:(snd_func_REFERE)计算名称时出错
ALSA lib conf.c:4528:(_snd_config_evaluate)函数snd_func_refere返回错误:没有这样的文件或目录
ALSA lib conf.c:5007:(snd_config_expand)评估错误:没有这样的文件或目录
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate)未知pcm系统默认值
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate)未知pcm卡.pcm.front
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate)未知pcm卡。pcm.rear
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate)未知pcm卡.pcm.center_lfe
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate)未知pcm卡.pcm.side
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate)未知pcm卡。pcm.SURROUND 21
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate)未知pcm卡。pcm.SURROUND 21
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate)未知pcm卡。pcm.SURROUND 40
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate)未知pcm卡。pcm.SURROUND 41
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate)未知pcm卡。pcm.SURROUND 50
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate)未知pcm卡。pcm.surround51
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate)未知pcm卡。pcm.SURROUND 71
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate)未知pcm卡.pcm.iec958
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate)未知pcm卡.pcm.iec958
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate)未知pcm卡.pcm.iec958
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate)未知pcm卡.pcm.hdmi
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate)未知pcm卡.pcm.hdmi
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate)未知pcm卡.pcm.modem
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate)未知pcm卡.pcm.modem
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate)未知pcm卡。pcm。电话线
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate)未知pcm卡。pcm。电话线
ALSA lib confmisc.c:767:(解析卡)找不到卡“0”
ALSA lib conf.c:4528:(_snd_config_evaluate)函数snd_func_card_驱动程序返回错误:没有这样的文件或目录
ALSA lib confmisc.c:392:(snd_func_concat)计算字符串时出错
ALSA lib conf.c:4528:(_snd_config_evaluate)函数snd_func_concat返回错误:没有这样的文件或目录
ALSA lib confmisc.c:1246:(snd_func_REFERE)计算名称时出错
ALSA lib conf.c:4528:(_snd_config_evaluate)函数snd_func_refere返回错误:没有这样的文件或目录
ALSA lib conf.c:5007:(snd_config_expand)评估错误:没有这样的文件或目录
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate)未知pcm默认值
ALSA lib confmisc.c:767:(解析卡)找不到卡“0”
ALSA lib conf.c:4528:(_snd_config_evaluate)函数snd_func_card_驱动程序返回错误:没有这样的文件或目录
ALSA lib confmisc.c:392:(snd_func_concat)计算字符串时出错
ALSA lib conf.c:4528:(_snd_config_evaluate)函数snd_func_concat返回错误:没有这样的文件或目录
ALSA lib confmisc.c:1246:(snd_func_REFERE)计算名称时出错
ALSA lib conf.c:4528:(_snd_config_evaluate)函数snd_func_refere返回错误:没有这样的文件或目录
ALSA lib conf.c:5007:(snd_config_expand)评估错误:没有这样的文件或目录
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate)未知pcm默认值
ALSA lib confmisc.c:767:(解析卡)找不到卡“0”
ALSA lib conf.c:4528:(_snd_config_evaluate)函数snd_func_card_驱动程序返回错误:没有这样的文件或目录
ALSA lib confmisc.c:392:(snd_func_concat)计算字符串时出错
ALSA lib conf.c:4528:(_snd_config_evaluate)函数snd_func_concat返回错误:没有这样的文件或目录
ALSA lib confmisc.c:1246:(snd_func_REFERE)计算名称时出错
ALSA lib conf.c:4528:(_snd_config_evaluate)函数snd_func_refere返回错误:没有这样的文件或目录
ALSA lib conf.c:5007:(snd_config_expand)评估错误:没有这样的文件或目录
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate)未知pcm dmix
回溯(最近一次呼叫最后一次):
文件“recorder.py”,第30行,在
帧(每帧缓冲区=块)
文件“/usr/local/lib/python3.6/site packages/pyaudio.py”,第750行,打开
流=流(自,*args,**kwargs)
文件“/usr/local/lib/python3.6/site packages/pyaudio.py”,第441行,在__
self.\u stream=pa.open(**参数)
OSError:[Errno-9996]无效的输入设备(没有默认的输出设备)
我尝试过——特权——设备/dev/snd:/dev/snd,但仍然没有成功。我假设因为我使用的是来自windows的docker,/dev/snd的第一部分应该是其他内容,但我不知道

因此,理想情况下,图像应该运行并通过笔记本电脑麦克风录制我的声音,但上面给出了错误!请帮忙