Skip to content

A research project focused on developing a lightweight neural voice cloning and speech synthesis system, optimized for deployment on edge devices.

Python

Prepare the release: README and docs (#2)

Bartekba46de8d0473
diff --git a/README.md b/README.md
index 95caf46..2b0e4c1 100644
--- a/README.md
+++ b/README.md
@@ -1,17 +1,36 @@
-# Reverb
+<picture>
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/software-mansion-labs/Reverb-TTS/main/docs/assets/header_dark.png">
+ <img src="https://raw.githubusercontent.com/software-mansion-labs/Reverb-TTS/main/docs/assets/header.png" alt="Reverb-TTS: zero-shot voice cloning with open weights in 7 languages. 297M parameters; 232.3x faster than real time on an H200 and 164.9x on an RTX 5090 at batch 32, 21.6x on an M4 Pro and 20.6x on an iPhone 17; 0.96% word error rate on MiniMax. Software Mansion AI Labs.">
+</picture>
-**Reverb** is a voice-cloning text-to-speech model: give it a few seconds of someone speaking, and it speaks any text
-in that voice. It speaks English, German, French, Spanish, Italian, Polish and Portuguese, and is small and fast enough
-to run locally on desktop and mobile devices.
+# Reverb-TTS
+
+<p align="center">
+ <a href="https://huggingface.co/software-mansion/Reverb-TTS"><img src="https://img.shields.io/badge/%F0%9F%A4%97-weights-3a3cd6?style=for-the-badge" alt="Weights on Hugging Face"></a>
+ <a href="https://github.com/software-mansion-labs/Reverb-TTS/blob/main/LICENSE"><img src="https://img.shields.io/badge/code-Apache%202.0-3a3cd6?style=for-the-badge" alt="Code license: Apache 2.0"></a>
+ <a href="https://creativecommons.org/licenses/by-nc/4.0/"><img src="https://img.shields.io/badge/weights-CC%20BY--NC%204.0-3a3cd6?style=for-the-badge" alt="Weights license: CC BY-NC 4.0"></a>
+ <a href="https://discord.swmansion.com"><img src="https://img.shields.io/badge/Discord-join%20us-3a3cd6?style=for-the-badge&logo=discord&logoColor=white" alt="Join the Software Mansion Discord"></a>
+</p>
+
+**Reverb** is a **text-to-speech** model designed for high-quality **voice cloning**: give it a few seconds of
+someone speaking and the transcript, and it speaks any text in that voice. This repository holds the Python package
+that runs it.
+
+- **Zero-shot cloning** from 3 to 10 seconds of speech and its transcript, with no fine-tuning.
+- **7 languages:** English, German, French, Spanish, Italian, Polish, and Portuguese. A voice can speak any of them.
+- **0.96% word error rate** on the Open TTS Leaderboard's MiniMax test set, lower than every model on the leaderboard.
+- **297M parameters**, plus a 22M-parameter codec decoder.
+- **232.3× real time** on an NVIDIA H200 and **164.9×** on an RTX 5090 at batch 32, **over 20×** on an Apple M4 Pro and an iPhone 17 at batch 1.
+- **Weights:** fp32, fp16, int8, and int4 safetensors, and ExecuTorch programs for MLX, Vulkan, and QNN.
## Install
```bash
-pip install .
+pip install reverb-tts
```
-Python 3.10 or later. The weights download from Hugging Face on first use; while the weights repository is private, log
-in first (`hf auth login`) or set `HF_TOKEN`.
+Python 3.10 or later. The weights download from [Hugging Face](https://huggingface.co/software-mansion/Reverb-TTS) on
+first use.
## Quick start
@@ -25,15 +44,52 @@ audio = tts.generate("Hello! This is my cloned voice.", voice, language="en")
sf.write("output.wav", audio, tts.sample_rate)
```
+No recording at hand? Use a preset voice:
+
+```python
+voice = tts.preset_voice("pl_male_standard") # tts.preset_voices() lists them all
+audio = tts.generate("Dzień dobry! Mówię po polsku.", voice, language="pl")
+```
+
+`TTS.from_pretrained` picks CUDA, Apple's MPS, or the CPU, in that order. Numbers, dates, money, and abbreviations are
+read out as words, and long texts are split at sentence ends, so you can pass text as you'd write it.
+
+### In the browser
+
+[ruNNtime](https://docs.swmansion.com/runntime/zoo/getting-started/) runs Reverb on the GPU in the browser through
+WebGPU. Install it with `npm install runntime` and follow its getting-started guide.
+
## Documentation
-- [Overview](docs/overview.md): what the model is, how it was made, and how it scores.
-- [Usage](docs/usage.md): every use case, from the quick start to sampler settings.
-- [Reference](docs/reference.md): model variants and the repositories' layout.
+- [Overview](https://github.com/software-mansion-labs/Reverb-TTS/blob/main/docs/overview.md): what the model is, how it was made, and how it scores.
+- [Usage](https://github.com/software-mansion-labs/Reverb-TTS/blob/main/docs/usage.md): every use case, from the quick start to sampler settings.
+- [Reference](https://github.com/software-mansion-labs/Reverb-TTS/blob/main/docs/reference.md): the safetensors variants, the ExecuTorch programs, and the repositories' layout.
+
+## Benchmarks
+
+On the [Open TTS Leaderboard](https://huggingface.co/spaces/hf-audio/open_tts_leaderboard)'s MiniMax test set, across
+seven languages, all with voice cloning: WER, speaker similarity (SIM-o), and speed on an NVIDIA H200 at batch 32.
+
+| Model | Parameters | WER ↓ | SIM-o ↑ | H200, × real time ↑ |
+|:---|---:|---:|---:|---:|
+| **Reverb** | **319M** | **1.03%** | 0.817 | **125.2×** |
+| [OmniVoice](https://huggingface.co/k2-fsa/OmniVoice) | 634M | 1.13% | **0.833** | 27.1× |
+| [VoxCPM2](https://huggingface.co/openbmb/VoxCPM2) | 2,336M | 1.20% | 0.812 | 2.0× |
+| [Fish S2 Pro](https://huggingface.co/fishaudio/s2-pro) | 4.95B | 1.35% | 0.761 | 0.40× |
+| [MOSS-TTS](https://huggingface.co/OpenMOSS-Team/MOSS-TTS) | 8.49B | 1.84% | 0.774 | 19.4× |
+| [Chatterbox](https://huggingface.co/ResembleAI/chatterbox) | 0.80B | 2.76% | 0.715 | 2.0× |
+| [Higgs TTS 3](https://huggingface.co/bosonai/higgs-tts-3-4b) | 4.65B | 6.59% | 0.754 | 72.9× |
+
+The full tables, the Apple M4 Pro and iPhone 17 speeds, and the method are in the [overview](https://github.com/software-mansion-labs/Reverb-TTS/blob/main/docs/overview.md#results).
+
+## Use it responsibly
+
+Clone only voices you have the right to use. Get the speaker's consent, don't impersonate real people, and don't use
+generated speech to deceive, defraud, or harass. Tell your listeners when they hear a synthetic voice.
## License and acknowledgments
-- **Code:** Apache 2.0; see [LICENSE](LICENSE).
+- **Code:** Apache 2.0; see [LICENSE](https://github.com/software-mansion-labs/Reverb-TTS/blob/main/LICENSE).
- **Model weights:** [CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/), for non-commercial use with
attribution.
@@ -41,3 +97,21 @@ Reverb's weights were initialized from [OmniVoice](https://github.com/k2-fsa/Omn
target-length rule and prompt format come from OmniVoice's code. We thank its authors for releasing the model and code
openly. Reverb uses the [Higgs Audio v2 tokenizer](https://huggingface.co/eustlb/higgs-audio-v2-tokenizer) as its audio
codec, and [Verbalis](https://github.com/software-mansion-labs/Verbalis) prepares its text.
+
+## Community Discord
+
+[Join the Software Mansion Community Discord](https://discord.swmansion.com) to chat about Reverb or other Software
+Mansion libraries.
+
+## Reverb is created by Software Mansion AI Labs
+
+<a href="https://ai.swmansion.com/?utm_source=reverb&utm_medium=readme">
+ <picture>
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/software-mansion-labs/Reverb-TTS/main/docs/assets/swm_ai_labs_dark.svg">
+ <img src="https://raw.githubusercontent.com/software-mansion-labs/Reverb-TTS/main/docs/assets/swm_ai_labs.svg" alt="Software Mansion AI Labs" width="122" height="80" align="left">
+ </picture>
+</a>
+
+We're an end-to-end AI development lab focused on local and hybrid AI. We build and fine-tune models, deploy them
+anywhere and turn them into agents that solve real business problems.
+[Hire us](https://ai.swmansion.com/?utm_source=reverb&utm_medium=readme#contact).
diff --git a/docs/assets/frontier_size_speed.png b/docs/assets/frontier_size_speed.png
new file mode 100644
index 0000000..37d5eba
Binary files /dev/null and b/docs/assets/frontier_size_speed.png differ
diff --git a/docs/assets/frontier_size_speed_dark.png b/docs/assets/frontier_size_speed_dark.png
new file mode 100644
index 0000000..fc92816
Binary files /dev/null and b/docs/assets/frontier_size_speed_dark.png differ
diff --git a/docs/assets/header.png b/docs/assets/header.png
new file mode 100644
index 0000000..43064f3
Binary files /dev/null and b/docs/assets/header.png differ
diff --git a/docs/assets/header_dark.png b/docs/assets/header_dark.png
new file mode 100644
index 0000000..0e0278f
Binary files /dev/null and b/docs/assets/header_dark.png differ
diff --git a/docs/assets/swm_ai_labs.svg b/docs/assets/swm_ai_labs.svg
new file mode 100644
index 0000000..c858a2a
--- /dev/null
+++ b/docs/assets/swm_ai_labs.svg
@@ -0,0 +1,24 @@
+<svg width="61" height="40" viewBox="0 0 61 40" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M0 22C0 16.4771 4.47715 12 10 12H15V34C15 37.3137 12.3137 40 9 40H0V22Z" fill="url(#paint0_linear_1056_496)"/>
+<path d="M17 6C17 2.68629 19.6863 0 23 0H32V4C32 7.31371 29.3137 10 26 10H17V6Z" fill="url(#paint1_linear_1056_496)"/>
+<path d="M17 12H22C27.5228 12 32 16.4771 32 22V40H23C19.6863 40 17 37.3137 17 34V12Z" fill="url(#paint2_linear_1056_496)"/>
+<path d="M34 0H39C44.5228 0 49 4.47715 49 10V40H40C36.6863 40 34 37.3137 34 34V0Z" fill="url(#paint3_linear_1056_496)"/>
+<defs>
+<linearGradient id="paint0_linear_1056_496" x1="-2.5" y1="23.2" x2="12.7409" y2="31.5417" gradientUnits="userSpaceOnUse">
+<stop stop-color="#1F1919"/>
+<stop offset="1" stop-color="#2E2B3B"/>
+</linearGradient>
+<linearGradient id="paint1_linear_1056_496" x1="14.5" y1="4" x2="20.4149" y2="13.0646" gradientUnits="userSpaceOnUse">
+<stop stop-color="#1F1919"/>
+<stop offset="1" stop-color="#2E2B3B"/>
+</linearGradient>
+<linearGradient id="paint2_linear_1056_496" x1="14.5" y1="23.2" x2="29.7409" y2="31.5417" gradientUnits="userSpaceOnUse">
+<stop stop-color="#1F1919"/>
+<stop offset="1" stop-color="#2E2B3B"/>
+</linearGradient>
+<linearGradient id="paint3_linear_1056_496" x1="31.5" y1="16" x2="48.7713" y2="22.6171" gradientUnits="userSpaceOnUse">
+<stop stop-color="#1F1919"/>
+<stop offset="1" stop-color="#2E2B3B"/>
+</linearGradient>
+</defs>
+</svg>
diff --git a/docs/assets/swm_ai_labs_dark.svg b/docs/assets/swm_ai_labs_dark.svg
new file mode 100644
index 0000000..4510d16
--- /dev/null
+++ b/docs/assets/swm_ai_labs_dark.svg
@@ -0,0 +1,24 @@
+<svg width="61" height="40" viewBox="0 0 61 40" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M0 22C0 16.4771 4.47715 12 10 12H15V34C15 37.3137 12.3137 40 9 40H0V22Z" fill="url(#paint0_linear_1056_496)"/>
+<path d="M17 6C17 2.68629 19.6863 0 23 0H32V4C32 7.31371 29.3137 10 26 10H17V6Z" fill="url(#paint1_linear_1056_496)"/>
+<path d="M17 12H22C27.5228 12 32 16.4771 32 22V40H23C19.6863 40 17 37.3137 17 34V12Z" fill="url(#paint2_linear_1056_496)"/>
+<path d="M34 0H39C44.5228 0 49 4.47715 49 10V40H40C36.6863 40 34 37.3137 34 34V0Z" fill="url(#paint3_linear_1056_496)"/>
+<defs>
+<linearGradient id="paint0_linear_1056_496" x1="-2.5" y1="23.2" x2="12.7409" y2="31.5417" gradientUnits="userSpaceOnUse">
+<stop stop-color="#F0F6FC"/>
+<stop offset="1" stop-color="#C9C6D6"/>
+</linearGradient>
+<linearGradient id="paint1_linear_1056_496" x1="14.5" y1="4" x2="20.4149" y2="13.0646" gradientUnits="userSpaceOnUse">
+<stop stop-color="#F0F6FC"/>
+<stop offset="1" stop-color="#C9C6D6"/>
+</linearGradient>
+<linearGradient id="paint2_linear_1056_496" x1="14.5" y1="23.2" x2="29.7409" y2="31.5417" gradientUnits="userSpaceOnUse">
+<stop stop-color="#F0F6FC"/>
+<stop offset="1" stop-color="#C9C6D6"/>
+</linearGradient>
+<linearGradient id="paint3_linear_1056_496" x1="31.5" y1="16" x2="48.7713" y2="22.6171" gradientUnits="userSpaceOnUse">
+<stop stop-color="#F0F6FC"/>
+<stop offset="1" stop-color="#C9C6D6"/>
+</linearGradient>
+</defs>
+</svg>
diff --git a/docs/assets/training_scheme.png b/docs/assets/training_scheme.png
new file mode 100644
index 0000000..395581e
Binary files /dev/null and b/docs/assets/training_scheme.png differ
diff --git a/docs/assets/training_scheme_dark.png b/docs/assets/training_scheme_dark.png
new file mode 100644
index 0000000..d2a3edf
Binary files /dev/null and b/docs/assets/training_scheme_dark.png differ
diff --git a/docs/overview.md b/docs/overview.md
index a907d09..0f11a92 100644
--- a/docs/overview.md
+++ b/docs/overview.md
@@ -6,31 +6,63 @@ second) over a few passes, conditioned on the text and on a reference recording
## How it was made
-1. **Initialized from [OmniVoice](https://github.com/k2-fsa/OmniVoice)**, a 613M-parameter masked-diffusion TTS model.
-2. **Pruned with distillation:** 4 of the 28 transformer layers removed, the FFN cut from 3072 to 2048, the text
- vocabulary from 151,676 to 62,035 tokens; the pruned model was trained to match OmniVoice's predictions.
+1. **Initialized from [OmniVoice](https://github.com/k2-fsa/OmniVoice)**, a 612M-parameter masked-diffusion TTS model.
+2. **Pruned with distillation:** 4 of the 28 transformer layers removed, the FFN cut from 3072 to 2048, the KV groups
+ from 8 to 6, the text vocabulary from 151,676 to 62,035 tokens; the pruned model was trained to match OmniVoice's
+ predictions.
3. **Retrained** on cleaned, selected subsets of open speech datasets in the seven languages.
4. **Preference post-training (RLHF-like):** the model generated several takes per prompt, a critic fitted on human
preference rankings and a CTC intelligibility check picked the better and worse ones, and DPO trained on those pairs.
+<picture>
+ <source media="(prefers-color-scheme: dark)" srcset="assets/training_scheme_dark.png">
+ <img src="assets/training_scheme.png" alt="How Reverb is made: OmniVoice is pruned and distilled, retrained on seven languages, then refined with iterative DPO against a critic fitted on human preference rankings.">
+</picture>
+
## Results
-Quality on the [MiniMax Multilingual Test Set](https://huggingface.co/datasets/k2-fsa/TTS_eval_datasets) (the seven
-languages, 700 sentences), scored with OmniVoice's evaluation scripts; WER and SIM-o are averaged over languages. Speed
-is RTFx, seconds of speech generated per second: batch 32 on one RTX 5090, from the text and an already-encoded reference
-to the waveform, each model in its default runtime.
+We compare Reverb with well-known open-weight models on the
+[Open TTS Leaderboard](https://huggingface.co/spaces/hf-audio/open_tts_leaderboard)'s MiniMax test set, in seven
+languages: 100 sentences per language, one take each, every model cloning a reference recording. WER (Qwen3-ASR) and
+speaker similarity (SIM-o, WavLM) are averaged over the languages.
+
+| Model | Parameters | WER ↓ | SIM-o ↑ |
+|:---|---:|---:|---:|
+| **Reverb** | **319M** | **1.03%** | 0.817 |
+| [OmniVoice](https://huggingface.co/k2-fsa/OmniVoice) | 634M | 1.13% | **0.833** |
+| [VoxCPM2](https://huggingface.co/openbmb/VoxCPM2) | 2,336M | 1.20% | 0.812 |
+| [Fish S2 Pro](https://huggingface.co/fishaudio/s2-pro) | 4.95B | 1.35% | 0.761 |
+| [Audio8-TTS-Realistic](https://huggingface.co/Edge0/Audio8-TTS-Realistic-0.6b) | 732M | 1.46% | 0.764 |
+| [MOSS-TTS](https://huggingface.co/OpenMOSS-Team/MOSS-TTS) | 8.49B | 1.84% | 0.774 |
+| [Chatterbox](https://huggingface.co/ResembleAI/chatterbox) | 0.80B | 2.76% | 0.715 |
+| [Higgs TTS 3](https://huggingface.co/bosonai/higgs-tts-3-4b) | 4.65B | 6.59% | 0.754 |
+
+Generation speed, in × real time (seconds of audio per second of compute; higher is better), with each model's default
+settings. The H200 row is the Open TTS Leaderboard's run over all seven MiniMax languages; the other rows are ours, on
+MiniMax English sentences, timed from the text and an already-encoded reference voice.
+
+| Hardware | Reverb | OmniVoice | Audio8 | Qwen3-TTS 0.6B | Qwen3-TTS 1.7B | VoxCPM2 | Fish S2 Pro |
+|:---|---:|---:|---:|---:|---:|---:|---:|
+| NVIDIA H200, batch 32 | **232.3×** | 45.5× | 11.2× | – | – | 1.9× | 0.40ײ |
+| NVIDIA RTX 5090, batch 32 | **164.9×** | 13.2× | 4.2× | 3.3× | 4.0× | 3.0ײ | 0.18ײ |
+| Apple M4 Pro, batch 1 | **12.3׳** | 0.84× | 0.76× | 0.51× | 0.52× | 0.69× | – |
+| iPhone 17, batch 1 | **20.6×** | 0.91× | 1.03× | 1.14× | 0.74× | – | – |
+
+RTX 5090 and M4 Pro: PyTorch in bf16 on the GPU, to the waveform with codec decoding. iPhone 17: ExecuTorch MLX
+programs in fp16 on the GPU, to the codec codes, without the decoder. H200: the Open TTS Leaderboard's default voice,
+MiniMax test set, 7 languages.<br>
+² No batched generation: sentences run one at a time.<br>
+³ Reverb's ExecuTorch MLX program (fp16) with the Core ML codec decoder, as it ships: 21.6×.
-| Model | Parameters | Weights (16-bit) | WER ↓ | SIM-o ↑ | RTFx ↑ |
-|---|---|---|---|---|---|
-| **Reverb** | **297M** | **0.59 GB** | **1.35%** | 0.816 | **164.9×** |
-| [OmniVoice](https://huggingface.co/k2-fsa/OmniVoice) | 613M | 1.23 GB | 1.64% | **0.835** | 13.2× |
-| [Qwen3-TTS 0.6B Base](https://huggingface.co/Qwen/Qwen3-TTS-12Hz-0.6B-Base) | 915M | 1.83 GB | 11.96%¹ | 0.780¹ | 3.3× |
-| [Audio8-TTS-Realistic-Air](https://huggingface.co/Edge0/Audio8-TTS-Realistic-Air) | 601M | 1.20 GB | 1.97% | 0.750 | 4.2× |
+<picture>
+ <source media="(prefers-color-scheme: dark)" srcset="assets/frontier_size_speed_dark.png">
+ <img src="assets/frontier_size_speed.png" alt="Speed against size on an RTX 5090, batch 32: every other model is bigger and slower than Reverb-TTS">
+</picture>
-¹ Over the six languages Qwen3-TTS supports (Polish excluded); the other models over all seven.
+### Time to codes on an Apple M4 Pro
-On an Apple M4 Pro (ExecuTorch MLX, median time from text to audio codes; speed relative to real time in brackets),
-against OmniVoice at 16 guided passes:
+ExecuTorch MLX, median time from the text to audio codes, without codec decoding (speed relative to real time in
+brackets), against OmniVoice at 16 guided passes:
| Reference + target speech | OmniVoice | Reverb int8 | Speed-up |
|---|---|---|---|
diff --git a/docs/reference.md b/docs/reference.md
index 2c3cd61..650b1a2 100644
--- a/docs/reference.md
+++ b/docs/reference.md
@@ -2,26 +2,37 @@
## Model variants
-Weights for the Python package (`TTS.from_pretrained(variant=...)`):
+### safetensors
+
+PyTorch weights for the `reverb-tts` package, in four variants (`TTS.from_pretrained(variant=...)`):
| Variant | Weights | Activations | Download |
|---|---|---|---|
| `fp32` | fp32 | full precision | 1.19 GB |
+| `fp16` | fp16 | full precision | 594 MB |
| `int8` (default) | int8, one scale per output channel | full precision | 307 MB |
-| `int8a8` | int8, one scale per output channel | int8, one scale per token | 307 MB |
| `int4` | int4, one scale per group of 32 inputs | full precision | 191 MB |
-In the quantized variants the decoder's linear layers hold the quantized weights, with fp16 scales. In automatic scoring
-of generated speech, `int8` and `int8a8` showed no measurable loss against `fp32`, and `int4` a small one.
+In the quantized variants the decoder's linear layers hold the quantized weights, with fp16 scales. On an internal test
+set, `int8` showed no quality loss against `fp32`, and `int4` none that we could measure. The benchmarks use full
+precision.
+
+### ExecuTorch
+
+[ExecuTorch](https://pytorch.org/executorch) programs for on-device inference, with the codec kept out of the program:
+
+| Program | Hardware | Size |
+|---|---|---|
+| MLX fp16 | Apple GPUs | 612 MB |
+| MLX int8 | Apple GPUs | 352 MB |
+| MLX int4 | Apple GPUs | 232 MB |
+| Vulkan int4 | Android GPUs | 233 MB |
+| QNN int4 | Qualcomm NPUs, one program per chip: Snapdragon 8 Gen 1 (SM8450, v69), 8 Gen 2 (SM8550, v73), 8 Gen 3 (SM8650, v75), 8 Elite (SM8750, v79), 8 Elite Gen 5 (SM8850, v81) | 232–237 MB each |
-[ExecuTorch](https://pytorch.org/executorch) programs for on-device inference (Apple GPUs through MLX), with the codec
-kept out of the program:
+### In the browser
-| Program | Size |
-|---|---|
-| MLX fp16 | 612 MB |
-| MLX int8 | 352 MB |
-| MLX int4 | 232 MB |
+[ruNNtime](https://docs.swmansion.com/runntime/zoo/getting-started/) runs Reverb on the GPU in the browser through
+WebGPU, from its own copy of the weights.
## Repository layout
@@ -43,8 +54,12 @@ The weights on Hugging Face, [software-mansion/Reverb-TTS](https://huggingface.c
```
model/
tokenizer.json, tokenizer_config.json, chat_template.jinja
- safetensors/<variant>/ config.json, model.safetensors: fp32, int8, int8a8, int4
+ safetensors/<variant>/ config.json, model.safetensors: fp32, fp16, int8, int4
executorch/mlx/<precision>/ reverb_mlx_<precision>.pte: fp16, int8, int4
+ executorch/vulkan/int4/ reverb_vulkan_int4.pte
+ executorch/qnn/int4/ reverb_qnn_int4_<hexagon>.pte: v69, v73, v75, v79, v81
+ runntime/<precision>/ model.safetensors for ruNNtime: int8, int4
voices/ preset voices: <name>.json
+assets/ images for the model card
```
diff --git a/docs/usage.md b/docs/usage.md
index b687f03..dd9a857 100644
--- a/docs/usage.md
+++ b/docs/usage.md
@@ -103,12 +103,12 @@ for text that is already written out, in `generate` or in `voice`.
```python
import torch
-tts = TTS.from_pretrained(variant="int4") # fp32, int8 (default), int8a8 or int4
+tts = TTS.from_pretrained(variant="int4") # fp32, fp16, int8 (default) or int4
tts = TTS.from_pretrained(device="cpu", dtype=torch.float32)
tts = TTS.from_pretrained("path/to/weights") # a local folder
```
-- **variant:** quantized weights download smaller and are expanded to `dtype` on load, so every variant runs at the same
+- **variant:** every variant is converted to `dtype` on load, so the smaller ones download faster but run at the same
speed. See [Reference](reference.md#model-variants).
- **device:** the first available of CUDA, MPS and CPU by default.
- **dtype:** bfloat16 on CUDA (float16 without bf16 support), float16 on MPS, float32 on CPU by default.
@@ -133,7 +133,7 @@ tts = TTS.from_pretrained(sampler=SamplerConfig(steps=12))
| `codebook_penalty` | 5.0 | makes codebook 0 tend to be decided before codebook 1 |
| `position_temperature` | 5.0 | scales confidence against random noise; higher is more random |
| `polish_bias` | 1.0 | attention bias towards the reference in the polish passes |
-| `polish_guidance` | 1.0 | weight of the second polish pass's change over the first (codebooks 4-7) |
+| `polish_guidance` | 0.5 | weight of the second polish pass's change over the first (codebooks 4-7) |
-The defaults are the tuned setup. On the MiniMax test set they scored 1.35% WER and 0.816 SIM-o, against 1.50% and
-0.817 with `remasking=False`.
+The defaults are the tuned setup. On the MiniMax test set they scored 1.35% WER and 0.818 SIM-o, against 1.50% and
+0.817 with `remasking=False`. A `polish_guidance` of 1.0 scored 1.34% and 0.816.
diff --git a/reverb_tts/model.py b/reverb_tts/model.py
index 7858921..64cb2fa 100644
--- a/reverb_tts/model.py
+++ b/reverb_tts/model.py
@@ -5,7 +5,7 @@ config.json and model.safetensors - full precision, or a quantized variant whose
import json
from pathlib import Path
-from typing import Dict, Optional, Tuple
+from typing import Dict, Optional
import torch
from safetensors.torch import load_file
@@ -63,12 +63,6 @@ class Network(torch.nn.Module):
heads = weights["audio_heads.weight"].view(CODEBOOKS, CODES, -1)
weights["audio_heads.weight"] = (heads - heads.mean(1, keepdim=True)).flatten(0, 1)
network.load_state_dict(weights)
-
- # An int8a8 checkpoint was made to run with each token's projection inputs rounded to int8.
- if quantization and quantization.get("activations"):
- for module in network.llm.layers.modules():
- if isinstance(module, torch.nn.Linear):
- module.register_forward_pre_hook(round_per_token)
return network.eval()
@@ -80,6 +74,8 @@ def dequantize(weights: Dict[str, torch.Tensor], quantization: Dict) -> Dict[str
if quantization.get("rotation"):
raise NotImplementedError("checkpoints with rotated projections are not supported")
+ if quantization.get("activations"):
+ raise NotImplementedError("checkpoints with quantized activations, such as int8a8, are not supported")
bits, group = quantization["bits"], quantization.get("group_size")
for key in [key for key in weights if key.endswith(SCALE)]:
name, scale = key[: -len(SCALE)], weights.pop(key).float()
@@ -95,12 +91,3 @@ def dequantize(weights: Dict[str, torch.Tensor], quantization: Dict) -> Dict[str
weights[name] = codes * scale
return weights
-
-def round_per_token(module: torch.nn.Module, args: Tuple[torch.Tensor, ...]) -> Tuple[torch.Tensor, ...]:
- """
- Rounds each token's input to symmetric int8, with a scale of its own.
- """
-
- x = args[0]
- scale = x.abs().amax(-1, keepdim=True).clamp(min=1e-12) / 127
- return ((x / scale).round().clamp(-127, 127) * scale,) + args[1:]
diff --git a/reverb_tts/sampler.py b/reverb_tts/sampler.py
index 29df561..36ec239 100644
--- a/reverb_tts/sampler.py
+++ b/reverb_tts/sampler.py
@@ -26,7 +26,7 @@ class SamplerConfig:
codebook_penalty: float = 5.0 # per codebook index, so codebook 0 tends to be committed before codebook 1
position_temperature: float = 5.0 # scales confidence and penalty against the Gumbel noise
polish_bias: float = 1.0 # attention bias towards the reference frames, in the polish passes only
- polish_guidance: float = 1.0 # codebooks 4-7: weight of (second polish pass - first polish pass)
+ polish_guidance: float = 0.5 # codebooks 4-7: weight of (second polish pass - first polish pass)
def __post_init__(self) -> None:
if self.steps < 1:
diff --git a/reverb_tts/tts.py b/reverb_tts/tts.py
index bf4197d..ac9adce 100644
--- a/reverb_tts/tts.py
+++ b/reverb_tts/tts.py
@@ -28,7 +28,7 @@ logger = logging.getLogger(__name__)
REPOSITORY, REVISION = "software-mansion/Reverb-TTS", "v1.0.0" # the released weights
PRESETS = REPOSITORY # preset voices, as voices/<name>.json
CODEC, CODEC_REVISION = "eustlb/higgs-audio-v2-tokenizer", "0e3a9177c2991016b8e5e17d23aa474ee665bef2"
-VARIANTS = ("fp32", "int8", "int8a8", "int4")
+VARIANTS = ("fp32", "fp16", "int8", "int4")
FRAME_RATE = 25 # codec frames per second
LONGEST, PIECE = 30.0, 15.0 # seconds: a text estimated longer than LONGEST is spoken in pieces of about PIECE
END_CUT = 0.2 # seconds cut from every take's end, where the codec can leave a short burst of noise
@@ -134,8 +134,8 @@ class TTS:
model/safetensors/<variant>/) or one checkpoint (config.json and model.safetensors, with the tokenizer beside or
above it).
- - variant: fp32, int8 (the default), int8a8 or int4. Quantized weights are expanded to `dtype` on load, so they
- download smaller but run at the same speed.
+ - variant: fp32, fp16, int8 (the default) or int4. Every variant is converted to `dtype` on load, so the
+ smaller ones download faster but run at the same speed.
- device: cuda, mps or cpu; by default the first one available.
- dtype: by default bfloat16 on CUDA (float16 without bf16 support), float16 on MPS and float32 on the CPU.
"""
diff --git a/tests/test_model.py b/tests/test_model.py
index 51ed7e2..22e06a1 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -18,6 +18,14 @@ def test_full_precision_checkpoint_loads_with_centred_heads(network: Network, tm
assert torch.allclose(original, centred, atol=1e-4)
+def test_half_precision_checkpoint_loads_as_its_rounded_weights(network: Network, tmp_path: Path) -> None:
+ half = {key: value.half() for key, value in network.state_dict().items()}
+ loaded = Network.load(write_checkpoint(tmp_path, network.half()))
+ name = "llm.layers.0.self_attn.q_proj.weight"
+ assert loaded.state_dict()[name].dtype == torch.float32
+ assert torch.equal(loaded.state_dict()[name], half[name].float())
+
+
@pytest.mark.parametrize("bits, group", [(8, None), (4, 8)])
def test_quantized_checkpoints_are_expanded_on_load(network: Network, tmp_path: Path, bits: int, group: int) -> None:
quantization = {"bits": bits, "group_size": group, "activations": None, "rotation": None}
@@ -30,11 +38,10 @@ def test_quantized_checkpoints_are_expanded_on_load(network: Network, tmp_path:
assert (table - loaded.state_dict()["llm.embed_tokens.table.weight"]).abs().max() <= table.abs().amax() / 254 + 1e-3
-def test_int8a8_checkpoint_rounds_projection_inputs(network: Network, tmp_path: Path) -> None:
+def test_checkpoints_with_quantized_activations_are_rejected(network: Network, tmp_path: Path) -> None:
quantization = {"bits": 8, "group_size": None, "activations": "per_token", "rotation": None}
- loaded = Network.load(write_checkpoint(tmp_path, network, quantization))
- hooked = [m for m in loaded.llm.layers.modules() if isinstance(m, torch.nn.Linear) and m._forward_pre_hooks]
- assert len(hooked) == 7 * 2 # q, k, v, o, gate, up, down in each of 2 layers
+ with pytest.raises(NotImplementedError, match="int8a8"):
+ Network.load(write_checkpoint(tmp_path, network, quantization))
def test_rotated_checkpoints_are_rejected(network: Network, tmp_path: Path) -> None:
diff --git a/tests/test_tts.py b/tests/test_tts.py
index 3216745..15ca9a7 100644
--- a/tests/test_tts.py
+++ b/tests/test_tts.py
@@ -131,7 +131,7 @@ def test_sampler_overrides_reach_the_sampler(tts: TTS, voice: Voice, monkeypatch
monkeypatch.setattr(tts_module, "sample", spy)
tts.generate("Hello there.", voice, "en", seed=0, steps=3, remasking=False)
- assert seen[-1].steps == 3 and not seen[-1].remasking and seen[-1].polish_guidance == 1.0
+ assert seen[-1].steps == 3 and not seen[-1].remasking and seen[-1].polish_guidance == SamplerConfig().polish_guidance
with pytest.raises(TypeError):
tts.generate("Hello there.", voice, "en", seed=0, not_a_setting=1)
@@ -163,3 +163,11 @@ def test_resolve_finds_a_release_layout(tmp_path: Path) -> None:
_resolve(tmp_path, "int4", None, None)
with pytest.raises(ValueError, match="variant"):
_resolve(tmp_path, "int2", None, None)
+
+
+def test_resolve_finds_the_safetensors_layout(tmp_path: Path) -> None:
+ weights = tmp_path / "model" / "safetensors" / "int4"
+ weights.mkdir(parents=True)
+ (weights / "config.json").write_text(json.dumps({}))
+ (tmp_path / "model" / "tokenizer.json").write_text("{}")
+ assert _resolve(tmp_path, "int4", None, None) == (weights, tmp_path / "model")