Metadata-Version: 2.5
Name: livekit-plugins-vaakini
Version: 0.1.0
Summary: LiveKit Agents plugin for Vaakini (https://vaakini.com): text to speech in 12 Indian languages
Project-URL: Homepage, https://vaakini.com
Project-URL: Documentation, https://docs.vaakini.com/livekit
Author: Oggnai Technologies Private Limited
License-Expression: Apache-2.0
License-File: LICENSE
Keywords: ai,audio,hindi,indian-languages,livekit,realtime,text-to-speech,tts,vaakini,voice
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Topic :: Multimedia :: Sound/Audio
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10.0
Requires-Dist: livekit-agents>=1.8.5
Description-Content-Type: text/markdown

# livekit-plugins-vaakini

[LiveKit Agents](https://github.com/livekit/agents) plugin for [Vaakini](https://vaakini.com):
text to speech in 12 Indian languages with one model, `vaakini-tts-1`.

Full documentation: [docs.vaakini.com/livekit](https://docs.vaakini.com/livekit).

## Install

```bash
pip install livekit-plugins-vaakini
```

## Usage

```python
from livekit.agents import AgentSession
from livekit.plugins import vaakini

session = AgentSession(
    tts=vaakini.TTS(voice="Monika", language="hi"),
    # ... stt, llm, vad
)
```

Set `VAAKINI_API_KEY` to your API key, from the dashboard at [vaakini.com](https://vaakini.com)
(or pass `api_key=`).

### `TTS(...)`

| Argument | Default | |
|---|---|---|
| `voice` | required | a Vaakini voice's name, in any case (`"Monika"`), or the id of one of your org's custom voices (`"cv_…"`); `GET /v1/voices` lists them |
| `language` | `None` | the language the text is in: `"as"`, `"bn"`, `"en"`, `"gu"`, `"hi"`, `"kn"`, `"ml"`, `"mr"`, `"or"`, `"pa"`, `"ta"` or `"te"`. Left out, the model picks it from each sentence's script |
| `model` | `"vaakini-tts-1"` | the model; this is the only one |
| `normalize` | `None` (on) | numbers, currency, dates, times, phone numbers, URLs and emails spoken as words; `False` turns it off |
| `temperature` | `None` | sampling temperature, 0.1 to 1.5: lower is steadier |
| `top_k` | `None` | sample from the k likeliest codes, 1 to 2048 |
| `top_p` | `None` | nucleus sampling, above 0 and at most 1 |
| `repetition_penalty` | `None` | penalty on recently repeated codes, 0 to 5 |
| `api_key` | `$VAAKINI_API_KEY` | your Vaakini API key |
| `base_url` | `wss://api.vaakini.com` | Vaakini's URL |
| `http_session` | the job's | an aiohttp session to connect with |

`normalize`, `temperature`, `top_k`, `top_p` and `repetition_penalty` are sent only when
given: left as `None`, the model's own default applies. The audio is 24000 Hz, 16-bit, mono.

Vaakini checks the settings: when the session starts, the plugin connects and a wrong setting is
logged as an error, and a reply with a wrong one fails with `APIStatusError` (`bad_request`, not
retryable).

### How a reply is spoken

The plugin streams a reply's text to Vaakini as the LLM writes it. Vaakini splits it into
sentences and speaks each as soon as it is complete, so the first audio follows the reply's first
sentence. Transcripts follow the audio a sentence at a time. `tts.synthesize(text)` speaks a text
you have in full, the same way.

### Changing settings mid-session

```python
tts.update_options(voice="Bunty", temperature=0.6)
tts.update_options(temperature=None)  # back to the model's default
```

Replies that start afterwards use the new settings. A setting left out keeps its value; `None`
puts one back to the model's default.

### Connections

When an `AgentSession` starts, it calls `tts.prewarm()`: the plugin connects to Vaakini, which
readies the model for the current settings at once, so the first reply doesn't wait for either.
Idle connections stay open between replies, for up to about 30 minutes, and are replaced at once
when a server restarts.

### Interruptions

When the agent is interrupted, the plugin cancels the reply at Vaakini, which stops speaking it,
and keeps the connection open, so the next reply starts on a warm connection.

### Metrics

`TTSMetrics.characters_count` is the characters Vaakini spoke for the reply, which are the ones
it charges for: the reply's sentences, without the spaces between them. An interrupted reply
reports its metrics too (`TTSMetrics.cancelled` set), counting the sentences sent in full before
the interruption.

## License

Apache-2.0.
