Skip to main content
POST
/
api
/
v1
/
tts
/
sse
TTS Stream
curl --request POST \
  --url https://api.vachana.ai/api/v1/tts/sse \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key-ID: <x-api-key-id>' \
  --data '
{
  "audio_config": {
    "bitrate": "192k",
    "container": "mp3",
    "encoding": "linear_pcm",
    "num_channels": 1,
    "sample_rate": 44100,
    "sample_width": 2
  },
  "model": "vachana-voice-v3",
  "text": "नमस्ते, आप कैसे हैं?"
}
'
import requests

url = "https://api.vachana.ai/api/v1/tts/sse"

payload = {
"audio_config": {
"bitrate": "192k",
"container": "mp3",
"encoding": "linear_pcm",
"num_channels": 1,
"sample_rate": 44100,
"sample_width": 2
},
"model": "vachana-voice-v3",
"text": "नमस्ते, आप कैसे हैं?"
}
headers = {
"X-API-Key-ID": "<x-api-key-id>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {'X-API-Key-ID': '<x-api-key-id>', 'Content-Type': 'application/json'},
body: JSON.stringify({
audio_config: {
bitrate: '192k',
container: 'mp3',
encoding: 'linear_pcm',
num_channels: 1,
sample_rate: 44100,
sample_width: 2
},
model: 'vachana-voice-v3',
text: 'नमस्ते, आप कैसे हैं?'
})
};

fetch('https://api.vachana.ai/api/v1/tts/sse', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
"event: audio_chunk\ndata: UklGRiQAAABXQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgAZGF0YQAAAAA=\n\nevent: completed\ndata: {\"status\": \"success\"}\n"
{
"success": false,
"error": {
"type": "INVALID_REQUEST_ERROR",
"message": "Invalid text or audio configuration."
}
}
{
"success": false,
"error": {
"type": "RATE_LIMIT_ERROR",
"message": "Rate limit exceeded. Please try again later."
}
}
{
"success": false,
"error": {
"type": "API_ERROR",
"message": "An unexpected error occurred while processing."
}
}
{
"success": false,
"error": {
"type": "SERVICE_UNAVAILABLE",
"message": "Text-to-speech service is temporarily unavailable."
}
}
Currently in beta. You’re on the priority waitlist and among the first to get access.

Overview

Receive audio in chunks as it’s generated, allowing playback to start immediately. Reduces latency compared to TTS REST.
Passing numbers, IDs, dates, or currency as raw strings causes mispronunciations. See the Input Formatting Guide for correct formatting of phone numbers, account numbers, PINs, Aadhaar, vehicle registration numbers, GSTIN, currency, and more.

Available Voices

VoiceGenderDescription
PranavMaleBold, Trustworthy
KaveriFemaleConfident, Bright
ShubhraFemaleGentle, Expressive
DeepakMaleGrounded, Conversational

Python SDK

The SDK’s streaming client handles SSE parsing and chunk reassembly for you — you just iterate and write.

Installation

pip install gnani-vachana
Requires Python 3.9+.

Authentication

from gnani.tts import GnaniTTSStreamClient

client = GnaniTTSStreamClient(api_key="your-api-key")
export GNANI_API_KEY="your-api-key"
from gnani.tts import GnaniTTSStreamClient

client = GnaniTTSStreamClient()

Stream Audio to a File

synthesize_stream yields audio chunks as they arrive. Playback or writing can begin before the full response is complete.
from gnani.tts import GnaniTTSStreamClient

client = GnaniTTSStreamClient(api_key="your-api-key")

with open("output.wav", "wb") as f:
    for chunk in client.synthesize_stream(
        "Streaming TTS response in Hindi",
        voice="sia",
    ):
        f.write(chunk)

With Custom Audio Config

from gnani.tts import GnaniTTSStreamClient, AudioConfig

client = GnaniTTSStreamClient(api_key="your-api-key")

with open("output.wav", "wb") as f:
    for chunk in client.synthesize_stream(
        "नमस्ते, आप कैसे हैं?",
        voice="raju",
        audio_config=AudioConfig(
            sample_rate=44100,
            encoding="linear_pcm",
            container="wav",
        ),
    ):
        f.write(chunk)

Supported Languages

The Gnani Timbre v2.0 API supports 2 languages.
LanguageNative ScriptExample
EnglishLatin”I am going to the market”
HindiDevanagari (हिन्दी)“मैं बाज़ार जा रहा हूँ”

Headers

X-API-Key-ID
string
required

Body

application/json

Request body for TTS inference.

text
string
required
model
enum<string>
required

Supported TTS models.

Available options:
vachana-voice-v3
audio_config
AudioConfig · object
required

Audio output configuration.

voice
enum<string>

ID of a pre-defined voice. Ignored if speaker_embedding is provided.

Available options:
Karan,
Simran,
Nara,
Riya,
Viraj,
Raju

Response

Successful Server-Sent Events stream

The response is of type string.