Metadata-Version: 2.4
Name: caesura-tts
Version: 0.1.0
Summary: Text-to-speech that sounds like a person talking: fillers, pauses and liveliness on a dial.
License-Expression: Apache-2.0
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE
Requires-Dist: torch>=2.4
Requires-Dist: transformers>=4.45
Requires-Dist: numpy>=1.26
Requires-Dist: nltk>=3.8
Requires-Dist: g2p-en>=2.1
Requires-Dist: inflect>=7
Dynamic: license-file

<div align="center">

# Caesura

**Text-to-speech that sounds like a person talking, not reading.**

Caesura places fillers, pauses and hesitations on its own, and lets you turn the liveliness up or down with one dial.

[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
![Python](https://img.shields.io/badge/python-3.11%2B-blue.svg)
![Model](https://img.shields.io/badge/model-~620M-green.svg)
[![PyPI](https://img.shields.io/pypi/v/caesura-tts.svg)](https://pypi.org/project/caesura-tts/)

</div>

---

Most TTS systems speak every text like a newsreader. People don't: they say *um*, pause before a hard word, rush through
the easy part. Caesura is a speech language model trained on real, unscripted speech, so these come from the model
itself — nothing is inserted by rules or by an LLM rewriting your text.

You choose how lively the speech is:

| Level | Sounds like | Inserted fillers / 100 words | WER |
|---|---|---|---|
| `0` calm | a clear, composed speaker | 0.1 | 0.053 |
| `1` lively | everyday conversation | 2.4 | 0.043 |
| `2` very lively | thinking out loud | 3.3 | 0.066 |

<sub>30 held-out texts, one voice, level guidance 3, temperature 0.8; fillers counted in a verbatim Whisper large-v3
transcript beyond those written in the text; WER by Whisper large-v3. For reference, two commercial TTS systems
insert 0 fillers on the same texts.</sub>

## Architecture

<p align="center"><img src="docs/architecture.svg" alt="Caesura architecture" width="900"></p>

Caesura generates [Mimi](https://huggingface.co/kyutai/mimi) codes (8 codebooks, 12.5 frames per second) one frame at a
time, conditioned on a single sequence:

```
[SEP] voice prompt  [SEP] text  [SEP + level]  speech …  [END]
```

- **Temporal transformer.** A looped transformer over frames: 2 prelude layers, a 4-layer core run 4 times with
  shared weights (the prelude output is injected at every loop), then 2 coda layers. Width 2048, 16 heads with
  4 key/value heads, rotary positions. It predicts codebook 0 of the next frame.
- **Depth transformer.** 6 layers of width 1024 predict codebooks 1–7 of the frame from the temporal state and the
  codebooks before them. Codebooks 1–7 run one frame behind codebook 0 (acoustic delay 1).
- **Text with pronunciation.** Each GPT-2 BPE token also carries the ARPAbet phonemes of its word (CMUdict, with a
  neural G2P for unknown words), encoded by a small transformer and added to the token embedding. Rare words and
  names are read from how they sound, not guessed from BPE pieces.
- **Manner level.** The level is a learned vector on the separator before the speech. It is dropped 20% of the time
  in training, so at inference the model can be pushed toward a level with classifier-free guidance:
  `logits = cond + (g − 1) · (cond − no level)`.
- **Pause limit.** Codebook-0 codes that decode to silence are masked after 7 silent frames in a row (0.56 s), which
  removes the long dead air that sampling otherwise produces, at the same WER.
- **Long texts** are spoken in pieces of up to 25 words at sentence boundaries. Each piece continues the previous
  one's audio, so intonation and tempo run on across the boundary instead of restarting.

## Training

1. **Audio-only pretraining** on conversational speech: the temporal and depth transformers learn to continue Mimi
   codes, with no text.
2. **Text-to-speech fine-tuning** on spontaneous speech (podcast and YouTube conversations), never read speech. The
   targets keep every *um*, repeat and restart, so the model learns where people actually hesitate.
3. **Manner levels.** Every training clip is labelled by how disfluent it is (fillers and repeats per 100 words in a
   verbatim transcript): level 0, 1 or 2.

## Quick start

```bash
pip install caesura-tts
```

```python
from caesura import Caesura

tts = Caesura.from_checkpoint("caesura.pt", voice="voice.wav")  # voice: 3-10 s, 24 kHz mono WAV

audio = tts.say("Honestly, I didn't expect that at all. But you know what, it kind of makes sense.", level=1)
tts.save(audio, "out.wav")
```

From the command line:

```bash
caesura-say "So here's the thing about deadlines." --ckpt caesura.pt --voice voice.wav --level 2 -o out.wav
```

| Argument | Default | Meaning |
|---|---|---|
| `level` | `1` | `0` calm, `1` lively, `2` very lively, `None` unconditioned |
| `strength` | `3.0` | guidance on the level; `1` turns it off, `2`–`3` steer harder at twice the compute |
| `temperature` | `0.8` | sampling temperature |
| `seed` | `None` | fix it to get the same take again |

Text is cleaned before synthesis: quotes and apostrophes are dropped, `!` is read as `.`, and a missing final stop is
added so the speech ends instead of trailing off. With the released checkpoint (trained on normalised text), numbers,
ordinals and currency are spelled out.

A GPU is recommended: on one RTX PRO 6000, 16 s of speech take about 5.5 s to generate with level guidance on.

## Weights

The checkpoint and the reference voice will be published on Hugging Face. This repository contains the inference code.

## Limitations

- English only.
- One voice per checkpoint works best; zero-shot voice cloning is not part of this release.
- Liveliness comes mostly from fillers and pauses; pitch and tempo vary less than in real speech.
- Rare proper names are still the main source of errors.

## License

Code: [Apache License 2.0](LICENSE). Caesura uses the Mimi codec by Kyutai and the GPT-2 tokenizer at run time; see
[NOTICE](NOTICE).

## Citation

```bibtex
@misc{caesura2026,
  title  = {Caesura: Text-to-Speech with Controllable Liveliness},
  author = {Manifestro},
  year   = {2026},
  url    = {https://github.com/Manifestro/caesura}
}
```
