Install the necessary dependencies:
python3 -m pip install piper-tts[http]Download a voice, for example:
python3 -m piper.download_voices en_US-lessac-mediumRun the web server:
python3 -m piper.http_server -m en_US-lessac-mediumThis will start an HTTP server on port 5000 (use --host and --port to override).
If you have voices in a different directory, use --data-dir <DIR>
Now you can get WAV files via HTTP:
curl -X POST -H 'Content-Type: application/json' -d '{ "text": "This is a test." }' -o test.wav localhost:5000The JSON data fields area:
text(required) - text to synthesizevoice(optional) - name of voice to use; defaults to-m <VOICE>speaker(optional) - name of speaker for multi-speaker voicesspeaker_id(optional) - id of speaker for multi-speaker voices; overridesspeakerlength_scale(optional) - speaking speed; defaults to 1noise_scale(optional) - speaking variabilitynoise_w_scale(optional) - phoneme width variabilityrealtime(optional) - stream with a provisional WAV header and zero‑padding for low‑latency playback
Get the available voices with:
curl localhost:5000/voices