TTS Inference
curl --request POST \
--url https://api.vachana.ai/api/v1/tts/inference \
--header 'Content-Type: application/json' \
--header 'X-API-Key-ID: <api-key>' \
--data '
{
"text": "नमस्ते, आप कैसे हैं?",
"model": "timbre-v2.5",
"audio_config": {
"encoding": "linear_pcm",
"container": "wav",
"num_channels": 1,
"sample_rate": 48000,
"sample_width": 2
}
}
'import requests
url = "https://api.vachana.ai/api/v1/tts/inference"
payload = {
"text": "नमस्ते, आप कैसे हैं?",
"model": "timbre-v2.5",
"audio_config": {
"encoding": "linear_pcm",
"container": "wav",
"num_channels": 1,
"sample_rate": 48000,
"sample_width": 2
}
}
headers = {
"X-API-Key-ID": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key-ID': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
text: 'नमस्ते, आप कैसे हैं?',
model: 'timbre-v2.5',
audio_config: {
encoding: 'linear_pcm',
container: 'wav',
num_channels: 1,
sample_rate: 48000,
sample_width: 2
}
})
};
fetch('https://api.vachana.ai/api/v1/tts/inference', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));"<string>"{
"success": false,
"error": {
"type": "INVALID_REQUEST_ERROR",
"message": "Invalid text or audio configuration."
}
}{
"success": false,
"error": {
"type": "FORBIDDEN",
"message": "You do not have permission to access this resource. Check your API key, organization status, or available credits."
}
}{
"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."
}
}Text-to-Speech
Text-to-Speech (REST)
Synchronous text-to-speech with full audio returned in one response.
POST
/
api
/
v1
/
tts
/
inference
TTS Inference
curl --request POST \
--url https://api.vachana.ai/api/v1/tts/inference \
--header 'Content-Type: application/json' \
--header 'X-API-Key-ID: <api-key>' \
--data '
{
"text": "नमस्ते, आप कैसे हैं?",
"model": "timbre-v2.5",
"audio_config": {
"encoding": "linear_pcm",
"container": "wav",
"num_channels": 1,
"sample_rate": 48000,
"sample_width": 2
}
}
'import requests
url = "https://api.vachana.ai/api/v1/tts/inference"
payload = {
"text": "नमस्ते, आप कैसे हैं?",
"model": "timbre-v2.5",
"audio_config": {
"encoding": "linear_pcm",
"container": "wav",
"num_channels": 1,
"sample_rate": 48000,
"sample_width": 2
}
}
headers = {
"X-API-Key-ID": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key-ID': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
text: 'नमस्ते, आप कैसे हैं?',
model: 'timbre-v2.5',
audio_config: {
encoding: 'linear_pcm',
container: 'wav',
num_channels: 1,
sample_rate: 48000,
sample_width: 2
}
})
};
fetch('https://api.vachana.ai/api/v1/tts/inference', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));"<string>"{
"success": false,
"error": {
"type": "INVALID_REQUEST_ERROR",
"message": "Invalid text or audio configuration."
}
}{
"success": false,
"error": {
"type": "FORBIDDEN",
"message": "You do not have permission to access this resource. Check your API key, organization status, or available credits."
}
}{
"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."
}
}Overview
Get the complete synthesized audio in one response. Best for downloads or batch processing. For streaming playback, see TTS Streaming or TTS Realtime.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.
Models
| Model | model value | Languages | Extra parameters |
|---|---|---|---|
| Timbre v2.5 | timbre-v2.5 | 10 Indian languages | language, speed |
Timbre v2.5 is now the recommended TTS model. Migrate from Timbre v2.0 to continue receiving the latest improvements. Timbre v2.0 will be deprecated soon.
Endpoint
POST https://api.vachana.ai/api/v1/tts/inference
Authentication
| Header | Required | Description |
|---|---|---|
X-API-Key-ID | Yes | Your Gnani API key |
Request Parameters
{
"text": "नमस्ते, आप कैसे हैं?",
"voice": "Nalini",
"model": "timbre-v2.5",
"language": "hi-IN",
"speed": 1.0,
"audio_config": {
"sample_rate": 48000,
"num_channels": 1,
"sample_width": 2,
"encoding": "linear_pcm",
"container": "wav"
}
}
string
required
The text to synthesize into speech. Pass numbers, dates, and currency as spoken words to avoid mispronunciations — see Input Formatting Guide.
string
required
Set to
timbre-v2.5.string
required
Voice name from the Timbre v2.5 catalog. See the Voice Catalog for preferred voices by language. Example:
Nalini, Kaveri, Deepak.string
required
Language of the input text. Controls text normalization and routing.
| Value | Language |
|---|---|
auto | Auto-detect from script (recommended for mixed content) |
hi-IN | Hindi |
en-IN | English |
ta-IN | Tamil |
te-IN | Telugu |
kn-IN | Kannada |
ml-IN | Malayalam |
mr-IN | Marathi |
pa-IN | Punjabi |
bn-IN | Bengali |
gu-IN | Gujarati |
hi-en | Hinglish (code-mixed Hindi–English) |
number | string
default:"1.0"
Playback speed multiplier. Numeric range:
0.85 (slowest) to 1.15 (fastest). String shortcuts: "slow" = 0.85, "medium" = 1.0, "fast" = 1.15.object
Controls the format of the returned audio.
Show audio_config fields
Show audio_config fields
integer
default:"48000"
Sample rate in Hz. Supported:
8000, 16000, 22050, 24000, 44100, 48000.integer
default:"1"
Number of audio channels.
1 for mono.integer
default:"2"
Sample width in bytes.
2 for 16-bit audio.string
default:"linear_pcm"
Audio encoding format. Options:
linear_pcm, pcm_s16le, pcm_mulaw, pcm_alaw, oggopus. For telephony, prefer container=mulaw or container=alaw over this field — both produce the same output. Use oggopus (or container=ogg) for a playable OGG Opus file. Not required when container is mp3.string
default:"wav"
Output container format. Options:
wav, raw, mp3, ogg, mulaw, alaw. Use ogg for OGG Opus. Use mulaw or alaw for G.711 telephony (forces 8000 Hz).string
default:"128k"
MP3 bitrate. Only used when
container is mp3. Supported: 32k, 64k, 96k, 128k, 192k.Audio Format Reference
container | encoding | Output | sample_rate | bitrate | Content-Type |
|---|---|---|---|---|---|
wav | linear_pcm | WAV file (with header) | 8000–48000 Hz | — | audio/wav |
raw | linear_pcm | Raw 16-bit PCM | 8000–48000 Hz | — | application/octet-stream |
mp3 | — | MP3 file | 8000–48000 Hz | 32k–192k | audio/mpeg |
ogg | — | OGG Opus file | 8000–48000 Hz | — | audio/ogg |
mulaw | — | Raw G.711 µ-law | forced 8000 Hz | — | audio/basic |
alaw | — | Raw G.711 A-law | forced 8000 Hz | — | audio/alaw |
container rows above:
container | encoding | Equivalent to |
|---|---|---|
raw | pcm_mulaw | container=mulaw |
raw | pcm_alaw | container=alaw |
raw or ogg | oggopus | container=ogg |
bitrate only applies when container=mp3. container=mulaw/alaw override sample_rate to 8000 Hz.
Response
A successful request returns200 OK with raw binary audio in the format specified by audio_config.container.
| Status | Meaning |
|---|---|
200 | Audio returned as binary in the requested format |
400 | Bad request — invalid parameters or unsupported voice |
429 | Rate limit exceeded |
500 | Internal server error — retry with backoff |
503 | Service temporarily unavailable |
Code Example
curl -X POST https://api.vachana.ai/api/v1/tts/inference \
-H "Content-Type: application/json" \
-H "X-API-Key-ID: <your-api-key>" \
-d '{
"text": "नमस्ते, आप कैसे हैं?",
"voice": "Nalini",
"model": "timbre-v2.5",
"language": "hi-IN",
"speed": 1.0,
"audio_config": {
"sample_rate": 48000,
"num_channels": 1,
"sample_width": 2,
"encoding": "linear_pcm",
"container": "wav"
}
}' \
--output response.wav
const response = await fetch("https://api.vachana.ai/api/v1/tts/inference", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-Key-ID": "<your-api-key>",
},
body: JSON.stringify({
text: "नमस्ते, आप कैसे हैं?",
voice: "Nalini",
model: "timbre-v2.5",
language: "hi-IN",
speed: 1.0,
audio_config: {
sample_rate: 48000,
num_channels: 1,
sample_width: 2,
encoding: "linear_pcm",
container: "wav",
},
}),
});
const audio = await response.arrayBuffer();
console.log("Received audio:", audio.byteLength, "bytes");
import requests
response = requests.post(
"https://api.vachana.ai/api/v1/tts/inference",
headers={
"Content-Type": "application/json",
"X-API-Key-ID": "<your-api-key>",
},
json={
"text": "नमस्ते, आप कैसे हैं?",
"voice": "Nalini",
"model": "timbre-v2.5",
"language": "hi-IN",
"speed": 1.0,
"audio_config": {
"sample_rate": 48000,
"num_channels": 1,
"sample_width": 2,
"encoding": "linear_pcm",
"container": "wav",
},
},
)
with open("response.wav", "wb") as f:
f.write(response.content)
Available Voices
42 voices across 10 Indian languages, English, and Hinglish. See the full Voice Catalog for preferred voices by language, gender, persona, and description. Popular examples:Nalini (Hindi), Kaveri (English), Deepak (Hindi), Poorvi (Hinglish).
Python SDK
The official Python SDK handles authentication headers and binary audio responses automatically.Installation
pip install gnani-vachana
Authentication
from gnani.tts import GnaniTTSClient
client = GnaniTTSClient(api_key="your-api-key")
export GNANI_API_KEY="your-api-key"
from gnani.tts import GnaniTTSClient
client = GnaniTTSClient()
Synthesize Speech
from gnani.tts import GnaniTTSClient
client = GnaniTTSClient(api_key="your-api-key")
audio = client.synthesize(
"नमस्ते, आप कैसे हैं?",
voice="Nalini",
model="timbre-v2.5",
language="hi-IN",
)
with open("output.wav", "wb") as f:
f.write(audio)
Custom Audio Config
from gnani.tts import GnaniTTSClient, AudioConfig
client = GnaniTTSClient(api_key="your-api-key")
audio = client.synthesize(
"यह एक टेस्ट है",
voice="Nalini",
model="timbre-v2.5",
language="hi-IN",
audio_config=AudioConfig(
sample_rate=48000,
encoding="linear_pcm",
container="wav",
),
)
with open("output.wav", "wb") as f:
f.write(audio)
Authorizations
Headers
Body
application/json
Request body for TTS inference.
TTS model. Use timbre-v2.5. Timbre v2.0 is deprecated and will be removed soon.
Available options:
timbre-v2.5 Audio output configuration.
Show child attributes
Show child attributes
Voice name from the Timbre catalog.
Language code. Use auto, hi-IN, en-IN, hi-en, ta-IN, te-IN, kn-IN, ml-IN, mr-IN, pa-IN, bn-IN, or gu-IN.
Playback speed multiplier. Range: 0.85–1.15.
Response
Successful audio synthesis
The response is of type file.
Was this page helpful?