Metadata-Version: 2.4
Name: kleintts
Version: 0.1.0
Summary: Klein-TTS: small multilingual text-to-speech models (Pro, Flash, Flash Lite)
Author: Klein ML
License-Expression: Apache-2.0
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: torch>=2.1
Requires-Dist: numpy
Requires-Dist: safetensors
Requires-Dist: huggingface_hub
Requires-Dist: misaki>=0.7
Requires-Dist: regex
Requires-Dist: num2words
Requires-Dist: addict
Requires-Dist: spacy>=3.8
Requires-Dist: espeakng-loader
Requires-Dist: phonemizer-fork
Provides-Extra: transformers
Requires-Dist: transformers>=4.40; extra == "transformers"
Dynamic: license-file

# kleintts

Klein-TTS text-to-speech models in plain PyTorch: **Pro** (13M; English, Spanish, French, Italian), **Flash** (1.7M) and **Flash Lite** (0.4M) (English, French, Italian). One small package: the model, the
text front-end (the full misaki + spaCy one used for training, installed for you), the voices (17 in Pro) and the synthesis loop.

```bash
pip install kleintts
```

```python
from kleintts import KleinTTS

tts = KleinTTS.from_pretrained("pro")      # "pro", "flash", "flash-lite", a Hugging Face repo id or a local folder
out = tts.tts("Hello from Klein TTS.", voice="Sarah", speed=1.0, seed=0)
tts.save_wav("hello.wav", out.waveform, out.sample_rate)
```

```bash
kleintts "Ciao, questa è una prova." --voice Giulia -o ciao.wav
kleintts "Hello there." --model flash -o hello.wav
kleintts --list-voices
```

`tts(text, voice, voice2, mix, speed, seed, pause, phonemes, use_m)`: `voice2`/`mix` blend two voices of one language,
`phonemes` skips the text front-end, `use_m` switches on the optional evaluation stream (off by default).

## No library? Use Transformers

The model repo also carries Transformers remote code, so this works without installing `kleintts`. It uses a compact copy of
the English front-end (bundled dictionaries, no spaCy), which agrees with the full one on about 97% of English sentences:

```python
from transformers import AutoModel
model = AutoModel.from_pretrained("klein-ml/Klein-TTS-X1.5-Pro", trust_remote_code=True)
out = model.tts("Hello from Klein TTS.", voice="Sarah")
model.save_wav("hello.wav", out.waveform, out.sample_rate)
```

## Layout

* `src/kleintts/core.py`: everything (generator, phonemizer, voices, synthesis). It is the first half of `modeling_klein_tts.py`
  in the model repo, with one block swapped: the package front-end uses misaki + spaCy, the remote code uses `vendor/frontend_vendored.py`.
* `hf/`: the Transformers wrapper and config class, and an example script.
* `build_release.py`: turns a training checkpoint into the upload folder (safetensors, config.json, remote code).
* `vendor/`: `make_g2p.py` builds the compact English front-end and lexicons from misaki; `test_g2p.py` compares it with the real one.
* `test_package.py`: the package against the original training code, and every language.
* `test_remote_code.py`: the Transformers path with misaki, spaCy and num2words blocked.

## License

Apache-2.0 (see `LICENSE`).
