Voice Cloned 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": "नमस्ते, आप कैसे हैं?",
"speaker_embedding": {
"embedding": "<base64-encoded embedding>",
"shape": [
1,
768
],
"dtype": "torch.bfloat16"
},
"audio_config": {
"sample_rate": 44100,
"num_channels": 1,
"sample_width": 2,
"encoding": "linear_pcm",
"container": "wav"
}
}
'import requests
url = "https://api.vachana.ai/api/v1/tts/inference"
payload = {
"text": "नमस्ते, आप कैसे हैं?",
"speaker_embedding": {
"embedding": "<base64-encoded embedding>",
"shape": [1, 768],
"dtype": "torch.bfloat16"
},
"audio_config": {
"sample_rate": 44100,
"num_channels": 1,
"sample_width": 2,
"encoding": "linear_pcm",
"container": "wav"
}
}
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: 'नमस्ते, आप कैसे हैं?',
speaker_embedding: {
embedding: '<base64-encoded embedding>',
shape: [1, 768],
dtype: 'torch.bfloat16'
},
audio_config: {
sample_rate: 44100,
num_channels: 1,
sample_width: 2,
encoding: 'linear_pcm',
container: 'wav'
}
})
};
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": "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."
}
}Voice Cloning
Voice Cloned TTS (REST)
Generate cloned voice audio in a single synchronous response.
POST
/
api
/
v1
/
tts
/
inference
Voice Cloned 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": "नमस्ते, आप कैसे हैं?",
"speaker_embedding": {
"embedding": "<base64-encoded embedding>",
"shape": [
1,
768
],
"dtype": "torch.bfloat16"
},
"audio_config": {
"sample_rate": 44100,
"num_channels": 1,
"sample_width": 2,
"encoding": "linear_pcm",
"container": "wav"
}
}
'import requests
url = "https://api.vachana.ai/api/v1/tts/inference"
payload = {
"text": "नमस्ते, आप कैसे हैं?",
"speaker_embedding": {
"embedding": "<base64-encoded embedding>",
"shape": [1, 768],
"dtype": "torch.bfloat16"
},
"audio_config": {
"sample_rate": 44100,
"num_channels": 1,
"sample_width": 2,
"encoding": "linear_pcm",
"container": "wav"
}
}
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: 'नमस्ते, आप कैसे हैं?',
speaker_embedding: {
embedding: '<base64-encoded embedding>',
shape: [1, 768],
dtype: 'torch.bfloat16'
},
audio_config: {
sample_rate: 44100,
num_channels: 1,
sample_width: 2,
encoding: 'linear_pcm',
container: 'wav'
}
})
};
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": "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
1
Step 1 — Generate a voice embedding
Upload a reference audio clip to get a
speaker_embedding. See Voice Clone Embeddings.2
Step 2 — Synthesize with your cloned voice — this page
Pass the
speaker_embedding from Step 1 to this endpoint to synthesize audio in your cloned voice.speaker_embedding obtained from Voice Clone Embeddings along with your text. The full audio is returned in one response. For streaming playback, see Voice Cloning Streaming or Voice Cloning Realtime.
Endpoint
POST https://api.vachana.ai/api/v1/tts/inference
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
string
required
The text to synthesize into speech
string
Voice cloning model. Use
vachana-vc-v1. Automatically set when speaker_embedding is provided — you may omit this field.object
required
Audio output configuration
Show properties
Show properties
object
required
Response
Returns binary audio data in the format specified byaudio_config.container:
audio/wavfor WAV filesaudio/mpegfor MP3 filesaudio/oggfor OGG files
Example Request
curl -X POST https://api.vachana.ai/api/v1/tts/inference \
-H "X-API-Key-ID: your-api-key-id" \
-H "Content-Type: application/json" \
-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"
}
}' \
--output audio.wav
import requests
url = "https://api.vachana.ai/api/v1/tts/inference"
headers = {
"X-API-Key-ID": "your-api-key-id",
"Content-Type": "application/json"
}
payload = {
"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"
}
}
response = requests.post(url, headers=headers, json=payload)
if response.status_code == 200:
with open("audio.wav", "wb") as f:
f.write(response.content)
print("Audio saved successfully")
else:
print(f"Error: {response.status_code}")
print(response.json())
const url = "https://api.vachana.ai/api/v1/tts/inference";
const headers = {
"X-API-Key-ID": "your-api-key-id",
"Content-Type": "application/json"
};
const payload = {
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"
}
};
fetch(url, {
method: "POST",
headers: headers,
body: JSON.stringify(payload)
})
.then(response => response.blob())
.then(blob => {
const url = window.URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = "audio.wav";
a.click();
})
.catch(error => console.error("Error:", error));
Error Responses
Bad Request
Invalid text or audio configuration
{
"success": false,
"error": {
"type": "INVALID_REQUEST_ERROR",
"message": "Invalid text or audio configuration."
}
}
Too Many Requests
Rate limit exceeded
{
"success": false,
"error": {
"type": "RATE_LIMIT_ERROR",
"message": "Rate limit exceeded. Please try again later."
}
}
Internal Server Error
Unexpected error occurred
{
"success": false,
"error": {
"type": "API_ERROR",
"message": "An unexpected error occurred while processing."
}
}
Authorizations
Headers
Body
application/json
Request body for voice cloned TTS inference.
The text to synthesize into speech.
Voice clone embedding from the Voice Clone Embeddings endpoint.
Show child attributes
Show child attributes
Audio output configuration.
Show child attributes
Show child attributes
Voice cloning model. Automatically set to vachana-vc-v1 when speaker_embedding is provided.
Available options:
vachana-vc-v1 Response
Successful audio synthesis
The response is of type file.
Was this page helpful?