From 1982b799bf7c1cfb6582360ae6e38d39e3b73946 Mon Sep 17 00:00:00 2001 From: aweise <30200282+atultw@users.noreply.github.com> Date: Wed, 10 Sep 2025 20:12:00 -0400 Subject: [PATCH] wrap piper servers in docker image --- tts/Dockerfile | 34 ++++++++++++++++++++++++++++++++++ tts/start.sh | 15 +++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 tts/Dockerfile create mode 100644 tts/start.sh diff --git a/tts/Dockerfile b/tts/Dockerfile new file mode 100644 index 00000000..b7ae96ae --- /dev/null +++ b/tts/Dockerfile @@ -0,0 +1,34 @@ +# Use a slim Python image as the base +FROM python:3.9-slim-bullseye + +# Set the working directory +WORKDIR /app + +# Install necessary dependencies (like wget) and piper-tts +RUN apt-get update && \ + apt-get install -y wget ca-certificates && \ + rm -rf /var/lib/apt/lists/* && \ + pip install piper-tts[http]==1.3.0 + +# --- Download Voice 1: en_US-amy-medium --- +RUN mkdir -p /app/voices/en_US-amy-medium +RUN wget 'https://huggingface.co/rhasspy/piper-voices/resolve/main/en/en_US/amy/medium/en_US-amy-medium.onnx' -O /app/voices/en_US-amy-medium/model.onnx && \ + wget 'https://huggingface.co/rhasspy/piper-voices/resolve/main/en/en_US/amy/medium/en_US-amy-medium.onnx.json' -O /app/voices/en_US-amy-medium/model.onnx.json + +# --- Download Voice 2: ne_NP-google-medium --- +RUN mkdir -p /app/voices/ne_NP-google-medium +RUN wget 'https://huggingface.co/rhasspy/piper-voices/resolve/v1.0.0/ne/ne_NP/google/medium/ne_NP-google-medium.onnx' -O /app/voices/ne_NP-google-medium/model.onnx && \ + wget 'https://huggingface.co/rhasspy/piper-voices/resolve/v1.0.0/ne/ne_NP/google/medium/ne_NP-google-medium.onnx.json' -O /app/voices/ne_NP-google-medium/model.onnx.json + +# Copy the startup script into the container +COPY start.sh . + +# Make the startup script executable +RUN chmod +x start.sh + +# Expose both ports +EXPOSE 5001 +EXPOSE 5002 + +# Set the command to run the startup script +CMD ["./start.sh"] diff --git a/tts/start.sh b/tts/start.sh new file mode 100644 index 00000000..31c3e21d --- /dev/null +++ b/tts/start.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# Start the Piper server for the English (Amy) voice on port 5001 +# The '&' runs the process in the background +python3 -m piper.http_server --model /app/voices/en_US-amy-medium/model.onnx --port 5001 & +echo "Started Piper server for en_US-amy-medium on port 5001." + +# Start the Piper server for the Nepali (Google) voice on port 5002 +# The '&' runs the process in the background +python3 -m piper.http_server --model /app/voices/ne_NP-google-medium/model.onnx --port 5002 & +echo "Started Piper server for ne_NP-google-medium on port 5002." + +# The 'wait' command is crucial. It waits for all background jobs +# to finish, which prevents the container from exiting immediately. +wait