Skip to navigation

LiveKit

Bakbak TTS for Indian languages in LiveKit Agents, with the official livekit-plugins-bakbak plugin.

View as Markdown

livekit-plugins-bakbak is the official LiveKit Agents plugin for Bakbak TTS. It streams each sentence of your agent’s reply over one WebSocket as soon as the LLM finishes writing it, so speech starts while the rest of the reply is still being generated.

Install

pip install --pre livekit-plugins-bakbak # 1.0 is in release candidates
export BAKBAK_API_KEY="raya_..."

Requires livekit-agents 1.8.7 or newer (below 2.0) and Python 3.10+.

Use it in an agent

from livekit.agents import AgentSession
from livekit.plugins import bakbak
session = AgentSession(
tts=bakbak.TTS(
voice_id="009ae8b5-4a03-492d-af1c-3055989ac734", # Anika M1
language="hi",
model="m1",
),
# stt=..., llm=..., vad=...
)

LiveKit calls prewarm() when the session starts, which opens the WebSocket before the first turn.

Options

OptionDefault
api_keyBAKBAK_API_KEYYour API key.
voice_idAnika M1 (Hindi)A voice belongs to one model; see list_voices().
language"hi"Codes, BCP-47 tags and names all work (hi, hi-IN, "hindi").
model"m1""m1" or "standard"; must match the voice’s model.
speednot sent (1.0)0.5 to 1.5. Changes standard voices only; m1 ignores it.
sample_rate240008000, 16000, 22050 or 24000 Hz, 16-bit mono PCM.
transport"websocket""websocket", or "http" for one SSE request per sentence.
tokenizerbakbak.SentenceTokenizer()How text is split into requests.
text_pacingFalseBatch sentences by how much audio is still queued.

Change voice settings at any time; they apply from the next utterance:

tts.update_options(voice_id="...", language="mr", model="standard", speed=1.1) # a standard Marathi voice

Voices

for voice in await tts.list_voices(model="m1", language="hi"):
print(voice.id, voice.name)

Sentences

The default SentenceTokenizer is built for Indian text. It splits on the danda (।, ॥) and Latin punctuation, never inside decimals, domains, titles such as Dr. and डॉ., or list markers, and never inside an Indic conjunct. The first sentence of a reply is sent as soon as it ends. It splits text exactly as the Python and JavaScript SDKs do.

tts = bakbak.TTS(tokenizer=bakbak.SentenceTokenizer(min_chars=20, eager_first_clause=True))

eager_first_clause=True also sends the first clause of a long first sentence on its own, for an earlier start.

Interruptions and errors

When the user interrupts, the plugin cancels the rest of the reply on the server and keeps the connection open for the next turn. Errors carry the API’s error_code and request_id (see Errors). LiveKit retries failures before any audio; a failure after audio has started is never retried, so nothing is spoken twice.

Migrating from livekit-plugins-raya

livekit-plugins-bakbak replaces livekit-plugins-raya.

-pip install livekit-plugins-raya
+pip install livekit-plugins-bakbak
-from livekit.plugins import raya
-tts = raya.TTS(language="hi")
+from livekit.plugins import bakbak
+tts = bakbak.TTS(language="hi")
  • BAKBAK_API_KEY replaces RAYA_API_KEY (the old name still works, with a warning).
  • One WebSocket replaces one HTTP request per sentence, and audio arrives as 16-bit PCM, so numpy is no longer needed. The encoding and codec options are gone.
  • The default voice is now Anika M1; pass voice_id to keep yours.
  • IndicSentenceTokenizer is now SentenceTokenizer (the old name still works).

The README covers transports, latency measurements and the plugin’s few deliberate differences from the SDKs.