我正在尝试将文本语音转换应用程序与其他开发人员共享,但是我现在遇到的问题是Docker容器在主机上找不到声卡。
当我尝试在docker容器中播放wav文件时
root @ 3e9ef1e869ea:/#播放Alesis-Fusion-Acoustic-Bass-C2.wav ALSA lib confmisc.c:768:(parse_card)找不到卡'0' ALSA lib conf.c: 4259:(_ snd_config_evaluate)函数snd_func_card_driver返回错误:没有这样的文件或目录 ALSA lib confmisc.c:392:(snd_func_concat)错误评估字符串 ALSA lib conf.c:4259:(_ snd_config_evaluate)函数snd_func_concat返回错误:没有这样的文件或目录 ALSA lib confmisc.c:1251:(snd_func_refer)错误评估名称 ALSA lib conf.c:4259:(_ snd_config_evaluate)函数snd_func_refer返回错误:没有这样的文件或目录目录 ALSA lib conf.c:4738:(snd_config_expand)评估错误:没有这样的文件或目录 ALSA lib pcm.c:2239:(snd_pcm_open_noupdate)未知的PCM默认播放:主要: 722:音频打开错误:没有这样的文件或目录我想主要是提示docker容器无法到达主机上的声卡。
到目前为止,我已经
我不确定docker是否可以做到这一点(我不确定如何将声卡之类的硬件资源与容器共享)。我在Mac OS Yosemite主机上使用的是Debian容器。
解决方案绝对有可能,您需要挂载/ dev / snd,看看Jess Frazelle如何从以下位置启动Spotify容器: / p>
https: //blog.jessfraz/post/docker-containers-on-the-desktop/
您会注意到
docker run -it \ -v /tmp/.X11-unix:/tmp/.X11-unix \#安装X11套接字 -e DISPLAY = unix $ DISPLAY \#通过显示 --device / dev / snd \#声音 --name spotify \ jess / spotify或Chrome浏览器,最后
docker run -it \ --net host \#也可以YOLO --cpuset-cpus 0 \#控制cpu --memory 512mb \#可以使用的最大内存 -v /tmp/.X11-unix:/tmp/.X11-unix \#安装X11插槽 -e DISPLAY = unix $显示\#通过显示 -v $ HOME / Downloads:/ root / Downloads \#可选,但是不错 -v $ HOME / .config / google-chrome /:/ data \#如果要保存状态 --device / dev / snd \#这样我们就可以听到的声音了--name chrome \ jess / chrome
I'm trying to dockerize a text to speech application for sharing the code with other developers, however the issue I am having right now is the docker container cannot find the sound card on my host machine.
When I try to play a wav file in my docker container
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 directoryI guess that the main problem is docker container is unable reach the sound card on my host.
So far I have
I am not sure if this is even possible with docker(I'm not exactly sure of how hardware resources such as sound cards are shared with containers). I'm using a debian container on a Mac OS Yosemite host.
解决方案It is definitely possible, you need to mount /dev/snd, see how Jess Frazelle launches a Spotify container, from
blog.jessfraz/post/docker-containers-on-the-desktop/
you will notice
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/spotifyor for Chrome, at the end
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
更多推荐
如何在Docker容器中播放声音
发布评论