Audio 如何在docker容器中播放声音
我正在尝试将一个文本到语音的应用程序dockerize,以便与其他开发人员共享代码,但是我现在遇到的问题是docker容器在我的主机上找不到声卡 当我尝试在docker容器中播放wav文件时Audio 如何在docker容器中播放声音,audio,docker,alsa,Audio,Docker,Alsa,我正在尝试将一个文本到语音的应用程序dockerize,以便与其他开发人员共享代码,但是我现在遇到的问题是docker容器在我的主机上找不到声卡 当我尝试在docker容器中播放wav文件时 root@3e9ef1e869ea:/# aplay Alesis-Fusion-Acoustic-Bass-C2.wav ALSA lib confmisc.c:768:(parse_card) cannot find card '0' ALSA lib conf.c:4259:(_snd_config_
root@3e9ef1e869ea:/# aplay Alesis-Fusion-Acoustic-Bass-C2.wav
ALSA lib confmisc.c:768:(parse_card) cannot find card '0'
ALSA lib conf.c:4259:(_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:4259:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM default
aplay: main:722: audio open error: No such file or directory
我想主要的问题是docker容器无法到达主机上的声卡
到目前为止我有
docker run--group add audio-t-i来创建容器
self/debian/bin/bash
我不确定docker是否能做到这一点(我不确定硬件资源(如声卡)如何与容器共享)。我正在Mac OS Yosemite主机上使用debian容器 这绝对是可能的,您需要挂载/dev/snd,看看Jess Frazelle如何从 你会注意到的
docker run -it \
-v /tmp/.X11-unix:/tmp/.X11-unix \ # mount the X11 socket
-e DISPLAY=unix$DISPLAY \ # pass the display
--device /dev/snd \ # sound
--name spotify \
jess/spotify
或者是铬,在最后
docker run -it \
--net host \ # may as well YOLO
--cpuset-cpus 0 \ # control the cpu
--memory 512mb \ # max memory it can use
-v /tmp/.X11-unix:/tmp/.X11-unix \ # mount the X11 socket
-e DISPLAY=unix$DISPLAY \ # pass the display
-v $HOME/Downloads:/root/Downloads \ # optional, but nice
-v $HOME/.config/google-chrome/:/data \ # if you want to save state
--device /dev/snd \ # so we have sound
--name chrome \
jess/chrome
会有帮助吗?对于Alsa,您只需要:
--device/dev/snd
。但是如果你在容器中使用非root用户,你必须给它访问音频设备的权限,所以把你的Dockerfile:运行usermod-a-G audio USERNAME
。在论坛上:你知道如何让它作为主机在Windows上工作吗?具体来说,Windows上的SND设备是什么?有什么建议如何在Windows上做同样的事情吗?这对JACK有用吗?我是否需要在容器中安装任何音频软件(ALSA、pulseaudio或JACK),或者在主机中安装它们就足够了?Windows上的--device/dev/snd
等效于什么?至于OP,我也在运行MacOS,我的mac上没有/dev/snd
文件。docker的回答是:docker:daemon的错误响应:添加自定义设备时收集设备信息时出错“/dev/snd”:没有这样的文件或目录。