Synthesize speech from text
Converts text into spoken audio using text-to-speech synthesis.
Features
- Multiple voices and languages
- Configurable sample rate (44100, 22050, 16000 Hz)
- Automatic resampling
- Streaming audio output (chunked transfer encoding)
Sample Rate
The TTS engine outputs audio at 44100 Hz by default. If you specify a different
sample_rate, the audio will be automatically resampled to match your request.
Example Request
{
"text": "Hello, how are you today?",
"model": "melo-tts-en",
"language": "en",
"voice": "default",
"sample_rate": 44100
}
Response
The response is binary PCM audio data (raw audio, not WAV format) streamed using HTTP chunked
transfer encoding. To play the audio, you’ll need to convert it to WAV format using the
provided pcm_to_wav.py script:
python pcm_to_wav.py speech.pcm speech.wav --rate 44100 --channels 1 --bits 16
Supported Parameters
Check model capabilities via /tts/models to see which parameters are supported:
gender: Voice gender (if supported)style: Speaking style (if supported)sample_rate: Output sample rate (if supported)parameters: Additional fine-tuning options
Body
Text-to-speech synthesis request
Text to synthesize into speech
"Hello, how are you today?"
TTS model ID
"melo-tts-en"
ISO 639-1 language code
"en"
Voice identifier (if model supports multiple voices)
"default"
Voice gender preference (if supported by model)
male, female, neutral "neutral"
Speaking style (if supported by model)
"neutral"
Output sample rate in Hz (if supported by model). Audio will be resampled if different from native rate.
44100
Additional synthesis parameters (e.g., speaking_rate, pitch, gain)
Output audio data results to speaker
false
Response
Speech synthesized successfully
Raw PCM audio data (16-bit little-endian). Not WAV — convert before playback.

