API Reference

Build with Sonu AI

Integrate hyper-realistic Hindi text-to-speech into your product with a single API call. Choose v1 (stable, streaming) or v2 (better quality, non-streaming).

REST API SSE Streaming Bearer Auth WAV Output Hindi / Devanagari

Authentication

Every request must include your secret API key as a Bearer token in the Authorization header. You can generate a key from your dashboard.

HTTP Header
Authorization: Bearer sk_your_api_key_here
Keep your API key secret. Never expose it in client-side JavaScript, browser extensions, or public repositories.

Voice Models

Two hyper-realistic Hindi voice models are available. Both are trained on native Devanagari speech for natural intonation and prosody.

🎙️

Sonu (Yash)

Male · Hindi · Neutral

yash
🎤

Sonu (Charu)

Female · Hindi · Warm

charu

Generate Audio

Convert Hindi text (Devanagari script) to hyper-realistic speech. Returns the full WAV audio file once synthesis is complete.

Free v1 keys include 10,000 characters.
POST https://sonuai.technoparticles.cloud/api/v1/tts
Parameter Type Description
text string  required The Hindi text (Devanagari script) to synthesize into audio.
speaker string  optional Voice model ID. Options: yash  charu. Defaults to yash.
Response 200 OK — audio/wav
Returns raw WAV audio bytes. Save the response body directly as .wav. Content-Type: audio/wav.

Generate Audio (Streaming)

Same as the standard endpoint, but returns audio chunks as Server-Sent Events (SSE) in real-time — enabling immediate playback without waiting for full synthesis.

POST https://sonuai.technoparticles.cloud/api/v1/tts-stream
Parameter Type Description
text string  required The Hindi text (Devanagari) to synthesize.
speaker string  optional Voice model: yash or charu.
Add the header Accept: text/event-stream and set stream=True in your client. Chunks arrive progressively for lower latency playback.

List Available Models

Returns all voice models available for use with the TTS endpoints.

GET https://sonuai.technoparticles.cloud/api/v1/models
Example Response 200 OK
JSON
{
  "models": [
    {
      "id":          "yash",
      "name":        "Sonu (Yash)",
      "gender":      "male",
      "description": "Default male Hindi voice"
    },
    {
      "id":          "charu",
      "name":        "Sonu (Charu)",
      "gender":      "female",
      "description": "Default female Hindi voice"
    }
  ]
}

Code Examples

Ready-to-use examples in multiple languages. Replace sk_your_api_key_here with your actual key.

cURL
Python
JavaScript
PHP
# Standard request (saves WAV file)
curl -X POST https://sonuai.technoparticles.cloud/api/v1/tts \
  -H "Authorization: Bearer sk_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "एक छोटा लड़का जंगल में गया, रास्ता भटक गया, पर हिम्मत से घर लौट आया।",
    "speaker": "yash"
  }' \
  --output output.wav

# Streaming request
curl -X POST https://sonuai.technoparticles.cloud/api/v1/tts-stream \
  -H "Authorization: Bearer sk_your_api_key_here" \
  -H "Content-Type: application/json" \
  -H "Accept: text/event-stream" \
  -d '{"text": "नमस्ते, कैसे हो आप?", "speaker": "yash"}'
import requests

# ── Standard Request ────────────────────────────
response = requests.post(
    "https://sonuai.technoparticles.cloud/api/v1/tts",
    headers={"Authorization": "Bearer sk_your_api_key_here"},
    json={
        "text": "नमस्ते, कैसे हो आप?",
        "speaker": "yash"
    }
)

if response.status_code == 200:
    with open("output.wav", "wb") as f:
        f.write(response.content)
    print("✅ Audio saved to output.wav")
else:
    print("❌ Error:", response.text)


# ── Streaming Request ───────────────────────────
response = requests.post(
    "https://sonuai.technoparticles.cloud/api/v1/tts-stream",
    headers={
        "Authorization": "Bearer sk_your_api_key_here",
        "Accept": "text/event-stream"
    },
    json={"text": "नमस्ते, कैसे हो आप?", "speaker": "yash"},
    stream=True
)

for chunk in response.iter_content(chunk_size=4096):
    if chunk:
        print(f"Received {len(chunk)} bytes")
// ── Standard Request (Node.js / Browser) ────────
const response = await fetch(
  "https://sonuai.technoparticles.cloud/api/v1/tts",
  {
    method: "POST",
    headers: {
      "Authorization": "Bearer sk_your_api_key_here",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      text: "नमस्ते, कैसे हो आप?",
      speaker: "yash",
    }),
  }
);

const blob = await response.blob();
const url  = URL.createObjectURL(blob);
const audio = new Audio(url);
audio.play(); // 🎵 Plays the generated speech


// ── Streaming (EventSource / SSE) ───────────────
const res = await fetch(
  "https://sonuai.technoparticles.cloud/api/v1/tts-stream",
  {
    method: "POST",
    headers: {
      "Authorization": "Bearer sk_your_api_key_here",
      "Content-Type": "application/json",
      "Accept": "text/event-stream",
    },
    body: JSON.stringify({ text: "नमस्ते", speaker: "yash" }),
  }
);
const reader = res.body.getReader();
while (true) {
  const { done, value } = await reader.read();
  if (done) break;
  console.log("Chunk:", value.byteLength, "bytes");
 }
<?php
// ── Standard Request ────────────────────────────
$ch = curl_init("https://sonuai.technoparticles.cloud/api/v1/tts");
curl_setopt_array($ch, [
    CURLOPT_POST           => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER     => [
        "Authorization: Bearer sk_your_api_key_here",
        "Content-Type: application/json",
    ],
    CURLOPT_POSTFIELDS => json_encode([
        "text"    => "नमस्ते, कैसे हो आप?",
        "speaker" => "yash",
    ]),
]);

$audio  = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($status === 200) {
    file_put_contents("output.wav", $audio);
    echo "✅ Saved to output.wav\n";
} else {
    echo "❌ Error: " . $audio;
}
?>

Ready to build?

Generate your free API key and start integrating Sonu AI into your project in minutes.