Text-to-Speech
Generate audio from text with multiple voice options and formats.
Create Speech
Generate audio from input text.
Request Body
| Parameter | Type | Required | Default | Description |
|---|
model | string | Yes | — | TTS model: tts-1, tts-1-hd, kokoro-82m |
input | string | Yes | — | Text to convert (max 4096 chars) |
voice | string | Yes | — | Voice to use (see below) |
response_format | string | No | mp3 | Audio format |
speed | number | No | 1.0 | Speed multiplier (0.25-4.0) |
Available Voices
| Voice | Description |
|---|
alloy | Neutral, balanced |
echo | Warm, conversational |
fable | Expressive, storytelling |
onyx | Deep, authoritative |
nova | Friendly, upbeat |
shimmer | Soft, gentle |
Kokoro voices (for kokoro-82m model):
af_bella, af_sarah — Female American
am_adam, am_michael — Male American
bf_emma, bf_isabella — Female British
bm_george, bm_lewis — Male British
| Format | Description |
|---|
mp3 | Compressed, widely compatible |
opus | Efficient, good for streaming |
aac | Apple-friendly |
flac | Lossless |
wav | Uncompressed |
pcm | Raw audio |
Example Request
curl -X POST https://api.ymq-01.edge.polargrid.ai:55111/v1/audio/speech \
-H "Authorization: Bearer pg_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"model": "tts-1",
"input": "Hello from PolarGrid!",
"voice": "alloy",
"response_format": "mp3"
}' \
--output speech.mp3
Response
Returns raw audio bytes in the requested format.
Streaming TTS
For real-time audio playback, use streaming:
for await (const chunk of client.textToSpeechStream({
model: 'tts-1',
input: 'Long text to convert to speech...',
voice: 'nova',
})) {
// Process audio chunks as they arrive
audioStream.write(chunk);
}
Streaming TTS is available in mock mode. Production streaming coming soon.