我正在尝试将文本语音转换应用程序与其他开发人员共享,但是我现在遇到的问题是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_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容器无法到达主机上的声卡。
到目前为止,我有
--group-add audio
docker run --group-add audio -t -i self/debian /bin/bash
我不确定docker是否可以做到这一点(我不确定如何将声卡之类的硬件资源与容器共享)。我在Mac OS Yosemite主机上使用了Debian容器。
绝对有可能,您需要挂载/ dev / snd,看看Jess Frazelle如何启动Spotify容器,从
https://blog.jessfraz.com/post/docker-containers-on-the- desktop/
你会注意到
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
或对于Chrome,最后
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