A local text-to-speech server powered by Piper TTS and FastAPI. Sends synthesized audio to a PulseAudio device.
- Python 3.14+
- PulseAudio (for
paplay) - espeak-ng (required by Piper)
- Clone the repo and create a virtual environment:
git clone https://github.com/JamesBlackman-SLG/jbpiper.git
cd jbpiper
python -m venv venv
source venv/bin/activate- Install dependencies:
pip install fastapi uvicorn piper-tts- Download a Piper voice model. The default config expects
en_US-lessac-medium:
curl -LO https://huggingface.co/rhasspy/piper-voices/resolve/main/en/en_US/lessac/medium/en_US-lessac-medium.onnx
curl -LO https://huggingface.co/rhasspy/piper-voices/resolve/main/en/en_US/lessac/medium/en_US-lessac-medium.onnx.json- Update the
DEVICEvariable inserver.pyto match your PulseAudio sink. List available sinks with:
pactl list short sinksStart the FastAPI server:
source venv/bin/activate
uvicorn server:app --host 0.0.0.0 --port 8000Then send a POST request:
curl -X POST http://localhost:8000/speak \
-H "Content-Type: application/json" \
-d '{"text": "Hello, how are you doing?"}'For quick testing without the server:
source venv/bin/activate
python speak.pyEdit the TEXT variable in speak.py to change what is spoken.