Skip to content

Instantly share code, notes, and snippets.

@mikejgray
Created January 22, 2024 02:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikejgray/13cbaae8920c05a450ae642e3dd54323 to your computer and use it in GitHub Desktop.
Save mikejgray/13cbaae8920c05a450ae642e3dd54323 to your computer and use it in GitHub Desktop.
OVOS TTS Piper Server
#!/bin/bash
IP=$(hostname -I | cut -d' ' -f1)
cd ~ || echo "No home directory for this user, please install with a user that has a home directory." || exit 1
command -v espeak-ng >/dev/null 2>&1 || { echo >&2 "Piper TTS requires espeak-ng but it's not installed. Please install it before running this script."; exit 1; }
echo "********************************************************************************"
echo "Creating virtual environment at ~/tts_venv"
echo "********************************************************************************"
python3 -m venv tts_venv
source ~/tts_venv/bin/activate
echo "********************************************************************************"
echo "Installing TTS requirements"
echo "********************************************************************************"
pip install --upgrade pip wheel
pip install --pre ovos-tts-server ovos-tts-plugin-piper
echo "********************************************************************************"
echo "Configuring TTS with default alan-low voice. You can change this later by editing ~/.config/mycroft/mycroft.conf"
echo "Alternate voice options can be found at https://github.com/rhasspy/piper/releases/tag/v0.0.2"
echo "********************************************************************************"
echo ""
mkdir -p ~/.config/mycroft
echo "********************************************************************************"
echo "Backing up any existing mycroft.conf to ~/.config/mycroft/mycroft.conf.bak"
echo "********************************************************************************"
echo ""
cp ~/.config/mycroft/mycroft.conf ~/.config/mycroft/mycroft.conf.bak
cat <<EOF > ~/.config/mycroft/mycroft.conf
"tts": {
"module": "ovos-tts-plugin-piper",
"ovos-tts-plugin-piper": {
"model": "alan-low"
}
}
EOF
echo "********************************************************************************"
echo "TTS installed, you can now start the server with:"
echo "ovos-tts-server --engine ovos-tts-plugin-piper --host $IP --cache"
echo "********************************************************************************"
echo ""
# Give optional instructions for systemd service
echo "If you want to run this as a service, you can use the following systemd unit file:"
echo ""
cat <<EOF > ~/ovos-tts-server.service
[Unit]
Description=OVOS Piper TTS Server
After=network.target
[Service]
Type=simple
User=$USER
ExecStart=/home/$USER/tts_venv/bin/ovos-tts-server --engine ovos-tts-plugin-piper --host $IP --cache
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
cat ~/ovos-tts-server.service
echo ""
echo "You can set this up as a long-running service with:"
echo "********************************************************************************"
echo "sudo cp ~/ovos-tts-server.service /etc/systemd/system/ovos-tts-server.service"
echo "sudo systemctl daemon-reload"
echo "sudo systemctl enable ovos-tts-server.service"
echo "sudo systemctl start ovos-tts-server.service"
echo "********************************************************************************"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment