Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Dockerfile #38

Merged
merged 1 commit into from
Dec 23, 2020
Merged

Create Dockerfile #38

merged 1 commit into from
Dec 23, 2020

Conversation

dosentmatter
Copy link
Contributor

@dosentmatter dosentmatter commented Dec 22, 2020

Hey @hgneng, this is the Dockerfile mentioned in #37. I'm not sure if you want to have instructions in a README somewhere, but I put instructions inside the Dockerfile.

To build the docker image, you do docker build --pull -t dosentmatter/ekho ..

Currently, I pushed it to my own dockerhub repo, but that can change. If you push it to your own repo, you could set up automatic builds from this github repo.

I also have it hardcoded to curl and built from ekho version 8.5, because I only know how to build from the release and not the github repo.

This docker image might be useful for users that don't want to bother with building ekho manually. They can just pull the docker image and run it.

@hgneng hgneng merged commit 2a315d5 into hgneng:master Dec 23, 2020
@hgneng
Copy link
Owner

hgneng commented Dec 23, 2020

Thank you for the Dockerfile. I successfully generate wave file with following command:
docker run -it -v /Users/hgneng/code/docker/:/mnt/docker dosentmatter/ekho 123 -o /mnt/docker/demo.wav

Can we play it directly from docker? When I try to play it directly, it seems pulseaudio not working.

$ docker run -it dosentmatter/ekho 123
pa_simple_new() failed: Connection refused
pa_sample_spec(format=3,rate=16000,channels=ch=1)
Fail to init audio stream.
Fail to init sound.

@dosentmatter
Copy link
Contributor Author

dosentmatter commented Dec 23, 2020

You're welcome. Yeah, you can play it directly from docker. What operating system are you using? I wrote instructions for Linux, macOS, Windows (Powershell or WSL) in the Dockerfile.

You have to route the audio to the host to be able to hear any sound since docker doesn't support audio by itself.

For Linux, in order to route the audio, you have to add the host's sound device to the running container.

For macOS and Windows, you have to have a pulseaudio server running on the host OS. Then set the pulseaudio client in the container to point to the pulseaudio server.

Copy-pasted (with some modifications) from the Dockerfile:

# Linux:
docker run --rm -it \
    --device /dev/snd \
    dosentmatter/ekho -s -30 -v Toisanese 排骨

# macOS:
brew install pulseaudio
# Using BSD `sed` to enable network pulseaudio through tcp
sed -i '' \
    -e '/#load-module module-native-protocol-tcp/ s/^#//' \
    /usr/local/Cellar/pulseaudio/*/etc/pulse/default.pa
brew services start pulseaudio
# mount .config/pulse/cookie for authentication to the server.
docker run --rm -it \
    -e PULSE_SERVER=host.docker.internal \
    --mount type=bind,source=$HOME/.config/pulse,target=/home/pulseaudio/.config/pulse \
    dosentmatter/ekho -s -30 -v Toisanese 排骨

@hgneng
Copy link
Owner

hgneng commented Dec 23, 2020

I am using MacOS. I see. I need to route audio to the host.

Thank you very much! You teach me a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants