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

README: added Docker build and run instructions #109

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rudolfolah
Copy link

  • build the image with a tag name
  • run the image, downloading voice files into container and copying output to host

* build the image with a tag name
* run the image, downloading voice files into container and copying output to host
@rudolfolah rudolfolah mentioned this pull request Jun 14, 2023
@sebastiancarlos
Copy link

sebastiancarlos commented Jul 8, 2023

Thanks! This worked for me on a non-M1 mac.

The only issue for me is that the --output_file welcome.wav part doesn't seem to work. If I remove it, a file with a default name is generated in the current directory.

@rudolfolah
Copy link
Author

Thanks! This worked for me on a non-M1 mac.

Awesome 😎

The only issue for me is that the --output_file welcome.wav part doesn't seem to work. If I remove it a file with a default name is generated in the current directory.

I wonder if using an absolute path would work or using --output_dir

@ishan0102
Copy link

ishan0102 commented Jul 9, 2023

Worked for me on an M1 mac! And similarly, --output_file didn't save it and --output_dir claimed to have saved it but I wasn't seeing it. No args worked fine, it saved to the working directory. Screenshots attached.

--output_file: doesn't say it is saved anywhere

image

--output_dir: says it is saved to welcome.wav dir but doesn't show up when running ls

image

no args: shows up as 1688860855967686335.wav

image

@ishan0102
Copy link

Also quick question, does this mean piper can only be called by spinning up a docker image and running these commands? Is there a way to get piper into my path so that I can call it from anywhere? I'm trying to get this repo working on my M1 mac: https://github.com/yacineMTB/talk

Comment on lines +91 to +95
echo 'Welcome to the world of speech synthesis!' | \
./piper --model en-us-lessac-medium.onnx --output_file welcome.wav

# while the container is running, and in a different terminal, copy the output file to the host
docker cp $(docker ps -lq):/dist/piper/welcome.wav .
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

based on the comments suggesting that the --output_file and --output_dir command line arguments are not working as expected (could be working and putting it in the wrong path?), here's a possible workaround for the current directory:

Suggested change
echo 'Welcome to the world of speech synthesis!' | \
./piper --model en-us-lessac-medium.onnx --output_file welcome.wav
# while the container is running, and in a different terminal, copy the output file to the host
docker cp $(docker ps -lq):/dist/piper/welcome.wav .
echo 'Welcome to the world of speech synthesis!' | \
./piper --model en-us-lessac-medium.onnx
# while the container is running, and in a different terminal, copy the output files to the host
docker exec $(docker ps -lq)bash -c "ls /dist/piper/*.wav" | while read line; do docker cp $(docker ps -lq):/$line .; done

based on this StackOverflow answer, I have not tested this yet

Copy link

@ishan0102 ishan0102 Jul 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kept running into errors with this along the lines of:
image

However I was able to get a quick bash script that accomplishes copying all of the files over:

#!/bin/bash

# Get the ID of the most recently created Docker container
container_id=$(docker ps -lq)

# Execute a command in the Docker container to get the list of .wav files
files=$(docker exec -it $container_id bash -c "cd /dist/piper && ls *.wav")

# Remove any carriage return characters (in case this script is run on Windows)
files=${files//$'\r'/}

# Loop over each file
for file in $files; do
  # Copy the file from the Docker container to the current directory
  docker cp "$container_id:/dist/piper/$file" .
done

*script generated by GPT-4, works on my machine but someone should probably verify this

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that script works; on Windows I had to run bash first

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sweet

@rudolfolah
Copy link
Author

here's an alternative way of running piper in Docker where the output directory is mounted:

mkdir output

# Linux, MacOS
docker run -it --name piper --entrypoint /bin/bash -w /dist/piper --volume $PWD:/dist/piper/output -d piper:latest
# Windows
docker run -it --name` piper --entrypoint /bin/bash -w /dist/piper --volume ${PWD}/output:/dist/piper/output -d piper:latest

docker exec piper bash -c 'curl -L --output voice-en-us-lessac-medium.tar.gz https://github.com/rhasspy/piper/releases/download/v0.0.2/voice-en-us-lessac-medium.tar.gz && tar -xvf voice-en-us-lessac-medium.tar.gz'

docker exec piper bash -c "echo 'Welcome to the world of speech synthesis!' | ./piper --model en-us-lessac-medium.onnx --output_dir ./output"

Output dir and the mounted volume worked for me on Windows:

piper-output

piper-docker

@sebastiancarlos
Copy link

here's an alternative way of running piper in Docker where the output directory is mounted:

Works great for me, thanks!. I just had to add the missing /output in the Linux/MacOS version after $PWD. And I removed the exclamation mark from the sample text, which hilariously crashes on Bash.

@KarlLivesey
Copy link

I'm cloning the repo and am getting this when running the docker build what am I missing

docker buildx build --target build -t piper:latest .
[+] Building 0.3s (12/15) docker:desktop-linux
=> [internal] load .dockerignore 0.0s
=> => transferring context: 170B 0.0s
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 2.53kB 0.0s
=> [internal] load metadata for quay.io/pypa/manylinux_2_28_aarch64:latest 0.1s
=> [build-arm64 1/1] FROM quay.io/pypa/manylinux_2_28_aarch64@sha256:9484084f91da3883b7c79aeab5cee5a466abd5a34fe9cfb243a26d5e8534a6bb 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 996.82kB 0.0s
=> CACHED [build 1/10] WORKDIR /build 0.0s
=> CACHED [build 2/10] RUN curl -L "https://github.com/gabime/spdlog/archive/refs/tags/v1.11.0.tar.gz" | tar -xzvf - && mkdir -p "spdlog-1.11.0/build" && cd "spdlog-1.11.0/build" && cmake .. && make -j8 && cmake --install . --prefix /usr 0.0s
=> CACHED [build 3/10] RUN mkdir -p "lib/Linux-$(uname -m)" 0.0s
=> CACHED [build 4/10] RUN mkdir -p "lib/Linux-$(uname -m)/piper_phonemize" && curl -L "https://github.com/rhasspy/piper-phonemize/releases/download/v1.1.0/libpiper_phonemize-arm64.tar.gz" | tar -C "lib/Linux-$(uname -m)/piper_phonemize" -xzvf - 0.0s
=> CACHED [build 5/10] COPY VERSION Makefile ./ 0.0s
=> CACHED [build 6/10] COPY src/cpp/ ./src/cpp/ 0.0s
=> ERROR [build 7/10] RUN make 0.1s

[build 7/10] RUN make:
0.087 cmake -Bbuild -DCMAKE_INSTALL_PREFIX=install
0.101 CMake Error: The source directory "/build" does not appear to contain CMakeLists.txt.
0.101 Specify --help for usage, or press the help button on the CMake GUI.
0.104 make: *** [Makefile:4: all] Error 1


Dockerfile:44

42 | COPY VERSION Makefile ./
43 | COPY src/cpp/ ./src/cpp/
44 | >>> RUN make
45 |
46 | # Do a test run

ERROR: failed to solve: process "/bin/sh -c make" did not complete successfully: exit code: 2

running on m2 max

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.

None yet

4 participants