Metadata-Version: 2.4
Name: vaani-kokoro-worker
Version: 0.1.1
Summary: The Kokoro speech process Vaani runs as a separate program (GPL-3.0-or-later)
Author: Kirtika
License-Expression: GPL-3.0-or-later
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
Requires-Python: <3.14,>=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: kokoro-onnx<0.7,>=0.6.1
Requires-Dist: numpy>=1.26
Dynamic: license-file

# vaani-kokoro-worker

The Kokoro speech process for [Vaani](https://pypi.org/project/vaani-voice/), run as
its own program.

Vaani speaks with the Kokoro-82M model (Apache-2.0) through `kokoro-onnx` (MIT). Turning
text into phonemes goes through `phonemizer` and the espeak-ng library, which are both
GPL-3.0-or-later. That code runs in this separate program, which is itself licensed
**GPL-3.0-or-later** (see `LICENSE`). Vaani starts it as a child process and talks to it
only over stdin and stdout.

You don't run this yourself. `pip install 'vaani-voice[kokoro]'` installs it, and
Vaani starts it when `tts.engine` is `kokoro`.

## Protocol

Every message is one line of UTF-8 JSON. The spoken text is never logged.

| Direction | Message |
|---|---|
| worker → Vaani, once at start | `{"event": "ready", "protocol": 1, "version": "...", "sample_rate": 24000}`, or `{"event": "error", "error": "..."}` and exit 1 |
| Vaani → worker | `{"op": "synthesize", "id": 1, "text": "...", "voice": "af_heart", "voice_file": null, "language": "en-us", "speed": 1.0}` |
| worker → Vaani | `{"id": 1, "ok": true, "sample_rate": 24000, "samples": N}`, then `4 * N` bytes of little-endian float32 audio |
| worker → Vaani, on failure | `{"id": 1, "ok": false, "error": "..."}`, with no audio after it |
| Vaani → worker | `{"op": "quit"}`, or close stdin, to make the worker exit 0 |

`voice_file` names a `.npy` voice array (never a pickle). When it is set, `voice` is
ignored.

Since 0.1.1 a request may also carry `"segments": [{"text": "...", "language": "hi"}, ...]`
for a sentence that mixes scripts (Devanagari and Latin). Each segment is phonemized
in its own language and the joined phonemes are spoken in one pass. An older worker
ignores the field and speaks `text` in `language`.

## Usage

```
vaani-kokoro-worker --model kokoro-v1.0.int8.onnx --voices voices-v1.0.bin
```

Copyright (c) 2026 Kirtika.
