31 lines
1.7 KiB
Bash
Executable file
31 lines
1.7 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)
|
|
# libespeak-ng (comes with espeak-ng). Look for the file: ldconfig is in /sbin, not on a normal user's PATH
|
|
has_espeak() {
|
|
compgen -G '/usr/lib/*/libespeak-ng.so*' >/dev/null || compgen -G '/usr/lib*/libespeak-ng.so*' >/dev/null ||
|
|
/sbin/ldconfig -p 2>/dev/null | grep -q libespeak-ng
|
|
}
|
|
has_espeak || 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$||'
|