我试图将文本到语音应用程序停靠,以便与其他开发人员共享代码,但我现在遇到的问题是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容器。
答案 0 :(得分:18)
绝对有可能,您需要挂载/ 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