Metadata-Version: 2.5
Name: pipecat-vaakini
Version: 0.1.0
Summary: Pipecat TTS service 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/pipecat
Author: Oggnai Technologies Private Limited
License-Expression: Apache-2.0
License-File: LICENSE
Keywords: ai,audio,hindi,indian-languages,pipecat,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.11
Classifier: Topic :: Multimedia :: Sound/Audio
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.11
Requires-Dist: pipecat-ai>=1.12.0
Description-Content-Type: text/markdown

# pipecat-vaakini

[Pipecat](https://github.com/pipecat-ai/pipecat) TTS service for [Vaakini](https://vaakini.com):
text to speech in 12 Indian languages with one model, `vaakini-tts-1`.

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

Tested with Pipecat v1.12.0 and v1.16.0. Maintained by Oggnai Technologies, the company that runs
Vaakini.

## Install

```bash
pip install pipecat-vaakini
```

## Usage

```python
import os

from pipecat_vaakini import VaakiniTTSService

tts = VaakiniTTSService(
    api_key=os.environ["VAAKINI_API_KEY"],
    settings=VaakiniTTSService.Settings(voice="Monika", language="hi"),
)

pipeline = Pipeline(
    [transport.input(), stt, user_aggregator, llm, tts, transport.output(), assistant_aggregator]
)
```

Your API key is in the dashboard at [vaakini.com](https://vaakini.com).

### `VaakiniTTSService(...)`

| Argument | Default | |
|---|---|---|
| `api_key` | required | your Vaakini API key |
| `settings` | required | `VaakiniTTSService.Settings(...)`, below |
| `base_url` | `wss://api.vaakini.com` | Vaakini's URL |

Other keyword arguments go to Pipecat's `WebsocketTTSService`, except `text_aggregation_mode`
(Vaakini splits the text into sentences itself, so the service streams the LLM's text to it as it
arrives) and `sample_rate`: the audio is 24000 Hz, and the pipeline's output transport resamples it
to its own rate.

### `VaakiniTTSService.Settings(...)`

| Setting | 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"`, or its Pipecat `Language` (`Language.HI`; a region, as in `Language.HI_IN`, is dropped). 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 |

`normalize`, `temperature`, `top_k`, `top_p` and `repetition_penalty` are sent only when
set: left out or `None`, the model's own default applies.

Vaakini checks the settings: a wrong one is reported as an `ErrorFrame`.

### How a reply is spoken

The service streams the LLM's text to Vaakini as it arrives. Vaakini splits it into sentences and
speaks each as soon as it is complete, so the first audio follows the reply's first sentence.

### Changing settings mid-session

```python
from pipecat.frames.frames import TTSUpdateSettingsFrame

await worker.queue_frame(
    TTSUpdateSettingsFrame(delta=VaakiniTTSService.Settings(voice="Bunty", temperature=0.6))
)
```

Replies that start afterwards use the new settings. A setting left out of the update keeps its
value; `None` puts one back to the model's default (`Settings(temperature=None)`).

### Interruptions

When the user interrupts, the service tells Vaakini to stop the reply. The next reply starts on
the same connection.

### Transcripts

The service's `TTSTextFrame`s follow the audio: each sentence's words as its audio starts.

### Metrics

With usage metrics on, each reply's `TTSUsageMetricsData` is the characters Vaakini spoke, which
are the ones it charges for: the reply's sentences, without the spaces between them. An
interrupted reply counts the sentences sent in full before the interruption.

## License

Apache-2.0.
