heystreamer/tools/tts/setup.sh
Bashy b5a81bdb15 Add TTS voice builder (/tts): Piper + espeak, layers, effects
- src/tts.js: synth(config, text) -> cached mp3 in public/tts; up to 3 layers
  (engine, voice, speaker, speed, pitch, volume, delay) mixed with ffmpeg,
  8 effects (stadium, echo, 8-bit, radio, robot, choir, warp, shaky), loudnorm;
  config is clamped and voice/speaker names are restricted to plain names
- tools/tts/worker.py: long-running Python worker (JSON lines), Piper models
  kept loaded (LRU of 4), espeak-ng via libespeak-ng + ctypes
- tools/tts/setup.sh: venv + piper-tts + default voice set
- /tts page: presets, layers, effects, test playback, save/load/delete named
  voices (tts_voices table); TTS link in the nav
- public/tts, tools/tts/venv and tools/tts/voices are gitignored

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 13:06:32 +02:00

26 lines
1.4 KiB
Bash
Executable file

#!/usr/bin/env bash
# One-time TTS setup for HeyStreamer. Run on the server (or dev PC) from anywhere:
# tools/tts/setup.sh -> installs Piper into tools/tts/venv and downloads the default voices
# tools/tts/setup.sh en_US-amy-medium ... -> downloads extra voices (names: https://huggingface.co/rhasspy/piper-voices)
# Needs: python3-venv, ffmpeg, espeak-ng (sudo apt install python3-venv ffmpeg espeak-ng). Restart HeyStreamer afterwards.
set -euo pipefail
cd "$(dirname "$0")"
missing=()
command -v ffmpeg >/dev/null || missing+=(ffmpeg)
ldconfig -p 2>/dev/null | grep -q libespeak-ng || missing+=(espeak-ng)
python3 -c 'import venv, ensurepip' 2>/dev/null || missing+=(python3-venv)
if ((${#missing[@]})); then echo "First install: sudo apt install ${missing[*]}"; exit 1; fi
[ -x venv/bin/python ] || python3 -m venv venv
venv/bin/pip install -q --upgrade pip piper-tts
# default set (~65 MB each): male-heavy English picks + a few female voices
DEFAULT=(
en_GB-alan-medium en_GB-northern_english_male-medium en_GB-semaine-medium en_GB-vctk-medium
en_US-ryan-high en_US-joe-medium en_US-john-medium en_US-norman-medium en_US-bryce-medium
en_US-kusal-medium en_US-mike-medium en_US-hfc_male-medium en_US-arctic-medium
en_US-lessac-medium en_US-kristin-medium en_GB-cori-medium
)
venv/bin/python -m piper.download_voices --download-dir voices "${@:-${DEFAULT[@]}}"
echo "Voices in $(pwd)/voices:"; ls voices/*.onnx | sed 's|.*/||; s|\.onnx$||'