sarvamai/skills

text-to-speech

Write correct Sarvam Bulbul TTS code — REST, HTTP stream, WebSocket, pronunciation dictionaries, and v3 parameter traps (pitch/loudness, speaker…

First seen Feb 8, 2026

Installation

$ npx skills add https://github.com/sarvamai/skills
Feature your product here Skill page unit · reach builders installing agent skills View pricing →

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from sarvamai/skills.

npx skills add https://github.com/sarvamai/skills

Browse all from sarvamai/skills

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Repository health

Stars 71
License LICENSE
Default branch main
Open issues 2
Status Active

History

  1. First seen on skills.sh
  2. First recorded snapshot · 146 installs

SKILL.md

Text-to-Speech — Bulbul

Live in-chat TTS → [sarvam-mcp](../sarvam-mcp) (sarvamtoolstts_*). This skill = SDK code.

[!IMPORTANT]
Auth: api-subscription-key header — NOT Authorization: Bearer. Base URL: https://api.sarvam.ai (NOT /v1 — that prefix is only for the OpenAI-compatible chat endpoint)
SDK floor for the code below: Python sarvamai>=0.1.29, JS sarvamai@>=1.1.8. On older versions the TTS param is targetlanguagecode — see Gotchas.

Model

bulbul:v3 — 11 languages, 37 voices (23 male, 14 female; default: shubh), REST/HTTP stream/WebSocket.

Quick Start (Python)

from sarvamai import SarvamAI
from sarvamai.play import save

client = SarvamAI()

response = client.text_to_speech.convert(
    text="नमस्ते, आप कैसे हैं?",
    language_code="hi-IN",
    model="bulbul:v3",
    speaker="shubh"
)
save(response, "output.wav")

# HTTP Stream (lower latency, binary audio)
chunks = []
for chunk in client.text_to_speech.convert_stream(
    text="Hello from Sarvam AI",
    language_code="en-IN",
    speaker="shubh",
    model="bulbul:v3"
):
    chunks.append(chunk)
audio = b"".join(chunks)

Quick Start (JavaScript/TypeScript)

import { SarvamAIClient } from "sarvamai";
import { writeFile } from "fs/promises";

const client = new SarvamAIClient({ apiSubscriptionKey: "YOUR_SARVAM_API_KEY" });

// REST
const response = await client.textToSpeech.convert({
    text: "नमस्ते, आप कैसे हैं?",
    language_code: "hi-IN",
    model: "bulbul:v3",
    speaker: "shubh"
});

// HTTP Stream (lower latency, returns BinaryResponse)
const streamResponse = await client.textToSpeech.convertStream({
    text: "Hello from Sarvam AI",
    language_code: "en-IN",
    speaker: "shubh",
    model: "bulbul:v3"
});
const bytes = await streamResponse.bytes();
await writeFile("output.wav", bytes);

WebSocket Streaming

import asyncio
from sarvamai import AsyncSarvamAI

async def tts_stream():
    client = AsyncSarvamAI()
    async with client.text_to_speech_streaming.connect(model="bulbul:v3") as ws:
        await ws.configure(target_language_code="hi-IN", speaker="shubh")
        await ws.convert("Your text here")
        await ws.flush()
        async for message in ws:
            pass  # base64 audio chunks

asyncio.run(tts_stream())

Character Limits

Method Max Text
REST (convert) 2,500 chars
HTTP Stream (convert_stream) 3,500 chars
WebSocket 2,500 chars/msg (keep <500 for lowest latency; send many messages per connection)

Gotchas

Gotcha Detail
language_code is version-gated Python >=0.1.29 and JS >=1.1.8 (both 2026-08-03) take languagecode; earlier versions take targetlanguage_code. Hard rename — no alias, no deprecation shim, and the JSON body key changed too, so the wrong name raises TypeError before any request goes out. Check with pip show sarvamai / npm ls sarvamai if you hit that.
WebSocket was not renamed Python ws.configure() still takes targetlanguagecode (mapped to languagecode on the wire); JS configureConnection() takes languagecode. REST and WebSocket disagree inside the Python SDK.
JS method name client.textToSpeech.convert({...}) and .convertStream({...}) — camelCase. Stream returns BinaryResponse with .stream(), .bytes(), .blob().
pitch/loudness rejected SDK accepts these but API returns 400 for v3. Only pace (0.5–2.0) works.
v2 voices incompatible anushka, abhilash, arya, etc. don't work with v3. Use shubh (default).
Sample rate >24kHz 32kHz, 44.1kHz, 48kHz only via REST, not streaming.
REST response Base64-encoded audio in response.audios[0]. Use sarvamai.play.save() or base64.b64decode().
No SSML SSML markup is NOT supported. Use pace for speed control and the pronunciation dictionary for word-level fixes.
Use native script Romanized Indic input ("Aapka order confirm ho gaya hai") degrades quality. Write Indic words in native script.
Pronunciation dictionary dictid param teaches custom word pronunciations (bulbul:v3 only; 10 dicts/user, 100 words/dict). Create via Python client.pronunciationdictionary.create(file=f). JS SDK upload is broken (missing multipart Content-Type) — use raw fetch + FormData with an explicit Blob type.

Full Docs

Fetch voice catalog, streaming protocol, pronunciation dictionary CRUD, and codec options from: