Overview
Stream cloned voice audio as it’s generated using Server-Sent Events. Pass the speaker_embedding from Voice Clone Embeddings to use your cloned voice. Reduces latency compared to Voice Cloned TTS REST. For the lowest latency, see Voice Cloned TTS Realtime.
Endpoint
POST https://api.vachana.ai/api/v1/tts/sse
Authentication
| Header | Required | Description | Example |
|---|
X-API-Key-ID | Yes | Your API key for authentication | your-api-key-id |
Content-Type | Yes | Must be application/json | application/json |
Request Body
The text to synthesize into speech
Voice cloning model to use. Currently supported: vachana-vc-v1
Audio output configuration
Sample rate in Hz (8000-44100)
Number of audio channels (1-8)
Sample width in bytes (1-4)
Audio encoding format: linear_pcm or oggopus
Audio container format: raw, mp3, wav, mulaw, or ogg
MP3 bitrate (only when container=mp3): 96k, 128k, or 192k
Voice clone embedding obtained from the Voice Clone Embeddings endpoint
The voice clone embedding string
Shape of the embedding tensor, e.g., [1, 768]
Data type of the embedding, e.g., torch.bfloat16
Response
The server streams audio data via Server-Sent Events (SSE). Each event contains a chunk of audio data encoded in base64.
Event Types
Contains base64-encoded audio dataevent: audio_chunk
data: UklGRiQAAABXQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgAZGF0YQAAAAA=
Signals the end of the audio streamevent: completed
data: {"status": "success"}
Example Request
curl -X POST https://api.vachana.ai/api/v1/tts/sse \
-H "X-API-Key-ID: your-api-key-id" \
-H "Content-Type: application/json" \
-H "Accept: text/event-stream" \
-N \
-d '{
"text": "नमस्ते, आप कैसे हैं?",
"model": "vachana-vc-v1",
"audio_config": {
"sample_rate": 44100,
"encoding": "linear_pcm",
"container": "wav"
},
"speaker_embedding": {
"embedding": "your-embedding-string",
"shape": [1, 768],
"dtype": "torch.bfloat16"
}
}'
Error Responses
Invalid text or audio configuration{
"success": false,
"error": {
"type": "INVALID_REQUEST_ERROR",
"message": "Invalid text or audio configuration."
}
}
Rate limit exceeded{
"success": false,
"error": {
"type": "RATE_LIMIT_ERROR",
"message": "Rate limit exceeded. Please try again later."
}
}
Unexpected error occurred{
"success": false,
"error": {
"type": "API_ERROR",
"message": "An unexpected error occurred while processing."
}
}