Providers
Vaakini
Vaakini through the cache: in a LiveKit agent with our plugin or Vaakini's LiveKit plugin, in Pipecat, or with Vaakini's own HTTP and WebSocket APIs and the Vaakini SDK, changing only the base URL and key.
With our LiveKit plugin#
Vaakini’s vaakini-tts-1: one model for 12 Indian languages, in Vaakini’s voices or your Vaakini org’s custom voices. Language codes are bare (hi, not hi-IN); leave language out and Vaakini picks it from the script of the text.
pip install livekit-plugins-tts-cache-routerfrom livekit.plugins import tts_cache_router as tcr# The API key comes from TTS_CACHE_ROUTER_API_KEY.tts = tcr.TTS( model="vaakini/vaakini-tts-1", voice="Monika", language="hi",)Pass tts to AgentSession(tts=tts). Set TTS_CACHE_ROUTER_API_KEY in the agent’s environment, and store your Vaakini key under Provider keys. TTS’s own arguments are on the plugin’s page.
Options#
tcr.TTS(...)’s settings for Vaakini, in the router’s names: model, voice, language and speed as arguments, and the rest in the options dict (options={"name": value}). The router checks them; the languages per model are in Models and options.
modelstringRequiredOne of vaakini/vaakini-tts-1
Which model synthesizes the replies, with its provider.voicestringRequired- A voice of the chosen model, passed to Vaakini as given. See models and voices.
languagestring | nullOptional- A Vaakini language code from languages, passed through as given. Leave it out and Vaakini detects the language.
sample_rateintDefault24000One of 24000
Of the audio you receive, in Hz.options.normalizeboolean | nullDefaultnull- Speak numbers, currency, dates, times, OTPs, phone numbers, URLs and emails as words in the request's language. Null: Vaakini's default (on).
options.temperaturenumber | nullDefaultnullRange 0.1 – 1.5
Sampling temperature: lower is steadier, higher is more varied. Null: Vaakini's default.options.top_kinteger | nullDefaultnullRange 1 – 2048
Sample from the k likeliest codes. Null: Vaakini's default.options.top_pnumber | nullDefaultnullRange 0.0 – 1.0
Nucleus sampling, above 0 and at most 1. Null: Vaakini's default.options.repetition_penaltynumber | nullDefaultnullRange 0.0 – 5.0
Penalty on recently repeated codes. Null: Vaakini's default.
Changing settings#
Replies that start afterwards use the new settings:
tts.update_options(voice="Bunty", options={"temperature": 0.6})# Another language, in the same voice or another.tts.update_options(language="ta")With Vaakini's LiveKit plugin#
Keep livekit-plugins-vaakini and point it at the router: your router API key in place of your Vaakini key, and the router’s address.
pip install livekit-plugins-vaakiniimport osfrom livekit.plugins import vaakinitts = vaakini.TTS( voice="Monika", language="hi", api_key=os.environ["TTS_CACHE_ROUTER_API_KEY"], base_url="wss://api.media.ttscacherouter.dev/vaakini",)The plugin derives its WebSocket address from base_url: wss://api.media.ttscacherouter.dev/vaakini/v1/stream. It streams 16-bit PCM at 24000 Hz, and takes Vaakini’s options as arguments of their own (normalize, temperature, top_k, top_p, repetition_penalty).
The plugin streams a reply’s text as the LLM writes it; the router splits it into sentences and caches each one. Its requests are the ones our plugin makes, so the two share cached sentences. Its TTSMetrics.characters_count comes from the reply’s done message, which through the router counts the router’s pieces, cached or not (below).
Requests, responses and errors keep Vaakini’s own shape; the endpoints are below.
Which plugin to choose#
Both use your org's cache and your stored provider key, and sound the same.
- Our plugin reports only the characters Vaakini billed in
TTSMetrics(cache hits count zero), and switches provider withupdate_options. - Vaakini’s plugin is the smallest change to an agent that already uses it. Its metrics count every character, cached or not; Usage has the real split.
Voices and languages#
voice is one of Vaakini’s voices by name, in any case (Monika), or the id of a custom voice of your Vaakini org (cv_…). Vaakini checks it.
- GET /v1/voices with
?provider=vaakinilists them live from Vaakini with your stored key, never cached: Vaakini’s built-in voices, then the custom voices of the Vaakini org your key belongs to. Vaakini’s voice catalog describes them. - The model is
vaakini-tts-1, the only one:vaakini/vaakini-tts-1for our plugins and/v1/audio/speech. languageis optional. Left out, Vaakini picks it from the script of each sentence.- Vaakini takes no
speed: it speaks at one pace.
| language | Language |
|---|---|
| as | Assamese |
| bn | Bengali |
| en | English |
| gu | Gujarati |
| hi | Hindi |
| kn | Kannada |
| ml | Malayalam |
| mr | Marathi |
| or | Odia |
| pa | Punjabi |
| ta | Tamil |
| te | Telugu |
The options are normalize (numbers, currency, dates, times, phone numbers, URLs and emails spoken as words; on by default), temperature (0.1 to 1.5), top_k (1 to 2048), top_p (above 0, at most 1) and repetition_penalty (0 to 5). One left out, or null, takes Vaakini’s default. They are listed with the formats in Models and options.
| Format | /v1/stream and our plugins | /v1/audio/speech |
|---|---|---|
| pcm | Yes: 16-bit little-endian mono | Yes |
| mp3 | Yes | Yes |
| wav | No | Yes: PCM with a WAV header |
Every format is 24000 Hz, mono, and made by Vaakini itself. There is no mulaw, alaw, aac, opus or flac.
With Pipecat#
Our Pipecat service takes the same settings as our LiveKit plugin. Vaakini's own Pipecat service works too, pointed at the router.
pip install pipecat-tts-cache-routerimport osfrom pipecat_tts_cache_router import TTSCacheRouterTTSServicetts = TTSCacheRouterTTSService( api_key=os.environ["TTS_CACHE_ROUTER_API_KEY"], settings=TTSCacheRouterTTSService.Settings( model="vaakini/vaakini-tts-1", voice="Monika", language="hi", ),)Put tts in your pipeline where a TTS service goes, after the LLM. The rest is on the service’s page.
To keep pipecat-vaakini, change its base_url and use your router API key in place of your Vaakini key:
pip install pipecat-vaakiniimport osfrom pipecat_vaakini import VaakiniTTSServicetts = VaakiniTTSService( api_key=os.environ["TTS_CACHE_ROUTER_API_KEY"], base_url="wss://api.media.ttscacherouter.dev/vaakini", settings=VaakiniTTSService.Settings(voice="Monika", language="hi"),)Vaakini's Python SDK#
The vaakini package, with base_url set to https://api.media.ttscacherouter.dev/vaakini and your router API key as api_key. AsyncVaakini takes the same two arguments.
pip install vaakiniimport osfrom vaakini import Vaakiniclient = Vaakini( api_key=os.environ["TTS_CACHE_ROUTER_API_KEY"], base_url="https://api.media.ttscacherouter.dev/vaakini",)audio = client.speech.create( input="नमस्ते, मैं सिटी हॉस्पिटल से प्रिया बोल रही हूँ। आपकी अपॉइंटमेंट गुरुवार को है।", voice="Monika", language="hi",)with open("speech.mp3", "wb") as f: f.write(audio)for voice in client.voices.list(): print(voice.id, voice.category, voice.languages)import osimport wavefrom vaakini import Vaakiniclient = Vaakini( api_key=os.environ["TTS_CACHE_ROUTER_API_KEY"], base_url="https://api.media.ttscacherouter.dev/vaakini",)pcm = bytearray()with client.stream(voice="Monika", language="hi") as stream: # Send text as it arrives, an LLM's tokens for instance; flush ends the reply. stream.send_text("नमस्ते, आपका ऑर्डर भेज दिया गया है। ") stream.send_text("यह शुक्रवार को पहुँचेगा।") stream.flush() for event in stream: if event.type == "audio": pcm += event.data # 16-bit mono PCM, 24000 Hz elif event.type == "sentence": print(event.index, event.text) elif event.type == "done": print(event.sentences, "sentences,", event.characters, "characters")with wave.open("speech.wav", "wb") as w: w.setnchannels(1) w.setsampwidth(2) w.setframerate(24000) w.writeframes(pcm)client.speech, client.stream(), client.voices, client.models and client.custom_voices all work through the router; the endpoints they call are below.
WebSocket#
Vaakini’s /v1/stream WebSocket, mirrored at wss://api.media.ttscacherouter.dev/vaakini/v1/stream: Vaakini’s messages, in and out. Send your router API key as Authorization: Bearer, where Vaakini takes its key; the router sends your text to Vaakini with the Vaakini key stored under Provider keys.
{"type": "start", "segment_id": "c0ffee", "model": "vaakini-tts-1", "voice": "Monika", "language": "hi", "sample_rate": 24000, "format": "pcm", "options": {"temperature": 0.6}}{"type": "text", "segment_id": "c0ffee", "text": "नमस्ते, आपका ऑर्डर भेज दिया गया है। यह शुक्रवार को पहुँचेगा।"}{"type": "flush", "segment_id": "c0ffee"}- In:
start(segment_id,model,voice,language,sample_rate,format,options),text,flush,cancelandwarm. Out:sentence, then that sentence’s audio in binary frames, anddone,cancelledorerrorto end the segment. Vaakini’s reference has every field. - A connection carries segments one after another, one reply each, as at Vaakini. The router splits each segment’s text into sentences as it arrives, plays each one your org has synthesized before from the cache, and sends the rest to Vaakini.
formatispcmormp3, at 24000 Hz.cancelstops the segment at Vaakini, for a barge-in; nothing of the stopped sentence is cached.- Vaakini’s own clients use this endpoint through the router: its SDK’s
stream()(above), its LiveKit plugin (above) and its Pipecat service (above).
Sentences and counts#
The one difference from calling Vaakini directly. The router cuts a reply at the first comma of its first sentence, as it does for every provider, so the first audio starts sooner. The sentence messages, and done’s sentences and characters, describe the router’s pieces: a reply whose first sentence has a comma followed by a space is one more sentence than at Vaakini, and characters leaves out the space at the cut. Vaakini directly:
{"type": "sentence", "index": 0, "text": "नमस्ते, आपका ऑर्डर भेज दिया गया है।"}{"type": "sentence", "index": 1, "text": "यह शुक्रवार को पहुँचेगा।"}{"type": "done", "segment_id": "c0ffee", "sentences": 2, "characters": 59}Through the router:
{"type": "sentence", "index": 0, "text": "नमस्ते,"}{"type": "sentence", "index": 1, "text": "आपका ऑर्डर भेज दिया गया है।"}{"type": "sentence", "index": 2, "text": "यह शुक्रवार को पहुँचेगा।"}{"type": "done", "segment_id": "c0ffee", "sentences": 3, "characters": 58}characters counts what was spoken, from the cache or by Vaakini. What Vaakini charged and what the cache served are on the dashboard’s Usage page.
HTTP, voices and custom voices#
Vaakini’s HTTP API, mirrored under https://api.media.ttscacherouter.dev/vaakini: Vaakini’s requests, responses and errors, with your router API key as Authorization: Bearer.
POST /vaakini/v1/audio/speech: the text you have in full, asmp3(Vaakini’s default),pcmorwav. The router splitsinputinto sentences, caches each one, and streams the audio back in order as one file; audio starts as soon as the first sentence is ready.GET /vaakini/v1/voicesandGET /vaakini/v1/models: Vaakini’s lists, relayed live with your stored key, never cached. GET /v1/voices lists the same voices in the router’s own shape./vaakini/v1/custom-voices: your Vaakini org’s custom voices, relayed to Vaakini with your stored key.GETlists them,POSTcreates one,GET,PATCHandDELETE /vaakini/v1/custom-voices/{voice_id}read, rename and delete one, andPUT /vaakini/v1/custom-voices/{voice_id}/recordingreplaces its recording. So a team whose Vaakini key lives only with the router can still manage its voices.
Any other path under /vaakini answers Vaakini’s 404.
curl https://api.media.ttscacherouter.dev/vaakini/v1/audio/speech \ -H "Authorization: Bearer $TTS_CACHE_ROUTER_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "vaakini-tts-1", "voice": "Monika", "language": "hi", "input": "नमस्ते, मैं प्रिया बोल रही हूँ।", "response_format": "wav"}' \ --output speech.wavcurl https://api.media.ttscacherouter.dev/vaakini/v1/voices -H "Authorization: Bearer $TTS_CACHE_ROUTER_API_KEY"The router’s own /v1/audio/speech takes vaakini/vaakini-tts-1 as the model, with the options as top-level fields, and serves every provider.
Splitting#
Vaakini is split into sentences, as every provider is.
- The router splits the text at sentence ends (including
।) and at the opening sentence’s first comma, with the splitter it uses for Sarvam and Raya, on every way in: our plugins,/v1/stream,/v1/audio/speechand the drop-in.
What is cached#
- Each sentence, sent to Vaakini on its own with your settings. A sentence your org has synthesized before with the same voice, language, options and format comes from the cache, whatever text surrounds it.
- Every way in shares cached sentences when the request is the same: our plugins and /v1/stream (Vaakini’s WebSocket), /v1/audio/speech (Vaakini’s HTTP endpoint) and the drop-in’s two. PCM and WAV share entries; MP3 has its own.
- An option counts when you send it: a request that leaves
temperatureout and one that sends a value for it are cached apart. - A voice’s name matches in any case:
monikaandMonikashare entries. When a voice’s recording is replaced at Vaakini, its sentences are synthesized afresh: the cache never serves the old recording’s audio for the new one. - Only a complete take is cached: a sentence Vaakini ended with
done, or an HTTP body that ended cleanly. Errors, cancelled sentences and cut-off bodies are never cached. - Audio is kept for your org’s retention, counted from its last use. At retention
0, nothing is cached and every sentence goes to Vaakini.
Billing#
- Vaakini bills the Vaakini org your stored key belongs to for the characters it synthesizes, at Vaakini’s price, as when you call it directly.
- The router charges $0.002 per 1,000 characters served from the cache, as for every provider, and nothing for what Vaakini synthesizes. See Pricing and billing.
- Get a Vaakini key (
vk_…) from Vaakini’s dashboard and store it under Provider keys.
Errors#
On our plugins, /v1/stream and /v1/audio/speech, Vaakini’s refusals become the router’s error codes:
| Code | When |
|---|---|
| provider_key_missing | Your org has no Vaakini key stored. |
| provider_rejected | Vaakini refused the request, with its message passed through: an unknown voice, a wrong stored key, a Vaakini org out of credit. |
| provider_rate_limited | Vaakini is at capacity. Retry after a moment. |
| provider_unavailable | Vaakini can't be reached or failed. |
| provider_timeout | Vaakini sent no audio in time. |
| bad_request | An unknown language, an option out of range or a speed, refused before anything reaches Vaakini. |
On the drop-in, errors keep Vaakini’s shape and statuses, so its SDK raises the errors it raises directly. Over HTTP that is a JSON body; on the WebSocket, an error message with the same fields, after which the connection closes.
{"error": {"code": "unauthorized", "message": "…", "retryable": false}}- A wrong or missing router API key is refused as Vaakini refuses a key: HTTP 401
unauthorized, at the WebSocket handshake too. An org with no Vaakini key stored gets the same answer. - An org out of router credit gets HTTP 402
insufficient_credits, at the WebSocket handshake too. - Over HTTP, the status is sent with the first audio, so a sentence that fails after audio has started can only cut the body short. Treat a body that ends early as a failed request.