#!/usr/bin/env bash # Fetch the configured voice if the shared volume doesn't have it yet, then # serve it. The download is the only step that needs the internet, and it runs # once per voice for the life of the volume — Petal itself stays offline-first. set -euo pipefail voice="${PIPER_VOICE:?PIPER_VOICE must be set}" data_dir="${PIPER_DATA_DIR:-/voices}" port="${PIPER_PORT:-5000}" if [ ! -f "${data_dir}/${voice}.onnx" ]; then echo ">> downloading voice ${voice} into ${data_dir}" python -m piper.download_voices "${voice}" --data-dir "${data_dir}" fi echo ">> serving ${voice} on :${port}" # 0.0.0.0 is safe here: the container sits on Petal's internal compose network # with no published ports, so only Petal can reach it. exec python -m piper.http_server \ -m "${voice}" \ --data-dir "${data_dir}" \ --host 0.0.0.0 --port "${port}"