Multilingual front and decoders trained on the original Kokoro-82M's decoder inputs
Browse files- README.md +141 -0
- decoder/original-front-384.pt +3 -0
- decoder/original-front-512.pt +3 -0
- front/lstm-replacements.pt +3 -0
- front/pitch-energy-predictor.pt +3 -0
README.md
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
base_model: hexgrad/Kokoro-82M
|
| 4 |
+
pipeline_tag: text-to-speech
|
| 5 |
+
language:
|
| 6 |
+
- en
|
| 7 |
+
- es
|
| 8 |
+
- fr
|
| 9 |
+
- hi
|
| 10 |
+
- it
|
| 11 |
+
- ja
|
| 12 |
+
- pt
|
| 13 |
+
- zh
|
| 14 |
+
tags:
|
| 15 |
+
- text-to-speech
|
| 16 |
+
- distillation
|
| 17 |
+
- kokoro
|
| 18 |
+
- styletts2
|
| 19 |
+
- vocos
|
| 20 |
+
---
|
| 21 |
+
|
| 22 |
+
# Órë TTS
|
| 23 |
+
|
| 24 |
+
Órë TTS is [Kokoro-82M](https://huggingface.co/hexgrad/Kokoro-82M) with its slow parts replaced by
|
| 25 |
+
smaller ones distilled from it. It reads the same phonemes with the same voices, in the same nine
|
| 26 |
+
language settings, and is meant to sound the same while running several times faster and starting
|
| 27 |
+
without a long compile.
|
| 28 |
+
|
| 29 |
+
*Órë* is Quenya for "heart", after the voice it was tuned by ear on, `af_heart`.
|
| 30 |
+
|
| 31 |
+
**Status: work in progress.** The checkpoints here are intermediate. A decoder fine-tuned behind the
|
| 32 |
+
distilled front is still training and will be added as the recommended one. Nothing here has had a
|
| 33 |
+
formal listening test.
|
| 34 |
+
|
| 35 |
+
## What changed from Kokoro-82M
|
| 36 |
+
|
| 37 |
+
Kokoro-82M is a StyleTTS 2 model with an iSTFTNet decoder. Three things were replaced, each trained
|
| 38 |
+
to imitate the original with the rest of the model frozen:
|
| 39 |
+
|
| 40 |
+
| Part | Kokoro-82M | Órë TTS |
|
| 41 |
+
|---|---|---|
|
| 42 |
+
| Sequence layers | six bidirectional LSTMs (10.8M parameters) | small ConvNeXt blocks (11.4M) |
|
| 43 |
+
| Pitch and energy predictor | normalizes over the whole sentence (instance norm) | normalizes each frame on its own (layer norm), so sentences batch by padding |
|
| 44 |
+
| Decoder | 53M parameters; upsamples 300-fold through convolutions at up to 4,800 frames per second | 19.5M (or 12.3M) parameters of ConvNeXt blocks at 80 frames per second, then one inverse STFT |
|
| 45 |
+
|
| 46 |
+
Everything else is Kokoro-82M's and is **not in this repository**: ALBERT, the text encoder's
|
| 47 |
+
convolutions, the duration predictor's other layers, and the voice packs. Load them from
|
| 48 |
+
`hexgrad/Kokoro-82M`.
|
| 49 |
+
|
| 50 |
+
### The decoder
|
| 51 |
+
|
| 52 |
+
It is a [Vocos](https://arxiv.org/abs/2306.00814)-style decoder with three changes that mattered:
|
| 53 |
+
|
| 54 |
+
- **Three short spectra per frame.** Each 12.5 ms frame's output is three spectra of 16.7 ms windows
|
| 55 |
+
(n_fft 400, hop 100) instead of one of a 50 ms window. Over 50 ms a voice's pitch moves enough to
|
| 56 |
+
make the upper harmonics' phase hard to predict.
|
| 57 |
+
- **A hybrid head.** The output spectrum is the network's own plus two filtered sources: Kokoro's
|
| 58 |
+
harmonic source (the sines at the pitch and eight overtones, plus noise) and a source with every
|
| 59 |
+
harmonic up to 11.5 kHz, in phase with it. The network predicts a gain and a phase shift per
|
| 60 |
+
frequency bin for each.
|
| 61 |
+
- **Phase losses.** The student is given the exact harmonic source and noise the teacher used, so
|
| 62 |
+
the teacher's waveform is one definite target, and the loss can compare phase as well as
|
| 63 |
+
magnitude: mel at seven resolutions, a multi-resolution STFT loss, a phase loss on unit phasors
|
| 64 |
+
(the phase and its steps across frequency and time) and an L1 loss on compressed complex spectra.
|
| 65 |
+
|
| 66 |
+
No adversarial training was used.
|
| 67 |
+
|
| 68 |
+
## Files
|
| 69 |
+
|
| 70 |
+
Torch checkpoints; load with `torch.load(path, weights_only=True)`.
|
| 71 |
+
|
| 72 |
+
| File | What it is |
|
| 73 |
+
|---|---|
|
| 74 |
+
| `front/lstm-replacements.pt` | The six LSTM replacements, trained on multilingual text. |
|
| 75 |
+
| `front/pitch-energy-predictor.pt` | The per-frame pitch and energy predictor, multilingual. The file also holds an unused decoder from an earlier experiment (`decoder.*` keys); ignore it. |
|
| 76 |
+
| `decoder/original-front-512.pt` | The decoder (width 512, 19.5M parameters), trained on the **original** Kokoro-82M's decoder inputs. It replaces only Kokoro's decoder: the rest of the model can be the unmodified original. |
|
| 77 |
+
| `decoder/original-front-384.pt` | The same at width 384 (12.3M parameters). |
|
| 78 |
+
|
| 79 |
+
The code that defines and runs these is in
|
| 80 |
+
[brendanlong/kokoro](https://github.com/brendanlong/kokoro) (branch `brendanlong/vocos-review`,
|
| 81 |
+
`experiments/vocos/model.py`, `experiments/lstm_swap`, `experiments/batch_first`), and a serving
|
| 82 |
+
worker is being built in [brendanlong/optimized-kokoro](https://github.com/brendanlong/optimized-kokoro).
|
| 83 |
+
There is no pip-installable package yet.
|
| 84 |
+
|
| 85 |
+
## Training data
|
| 86 |
+
|
| 87 |
+
All training audio was generated by Kokoro-82M itself; no recordings of people were used.
|
| 88 |
+
|
| 89 |
+
- Text: sentences from public-domain English novels (Project Gutenberg) and paragraphs of Wikipedia
|
| 90 |
+
(dump of 2023-11-01) in English, Spanish, French, Hindi, Italian, Japanese, Portuguese and Chinese,
|
| 91 |
+
turned into phonemes by optimized-kokoro's text pipeline.
|
| 92 |
+
- The decoders here: 50 hours (nominal) of Kokoro-82M's audio with its decoder inputs, in all nine
|
| 93 |
+
language settings (American and British English count separately), each passage read by a random
|
| 94 |
+
voice of its language, 150,000 steps.
|
| 95 |
+
|
| 96 |
+
## Measurements
|
| 97 |
+
|
| 98 |
+
The decoders against Kokoro-82M's own decoder on the same inputs, 180 held-out passages (20 per
|
| 99 |
+
language setting). Lower is better except voiced/unvoiced agreement. Random phase scores about 1.27
|
| 100 |
+
on the phase error.
|
| 101 |
+
|
| 102 |
+
| Measure | Width 512 | Width 384 |
|
| 103 |
+
|---|---|---|
|
| 104 |
+
| Mel error, seven resolutions (log10) | 0.214 | 0.219 |
|
| 105 |
+
| Multi-resolution STFT error | 0.804 | 0.809 |
|
| 106 |
+
| Phase error | 0.546 | 0.561 |
|
| 107 |
+
| Loudness error per frame | 0.92 dB | 0.94 dB |
|
| 108 |
+
| Periodicity error (CREPE) | 0.119 | 0.120 |
|
| 109 |
+
| Voiced/unvoiced agreement (F1) | 0.941 | 0.941 |
|
| 110 |
+
|
| 111 |
+
By language the mel error runs from 0.18 (Japanese) to 0.23 (Italian); periodicity error is worst
|
| 112 |
+
for Chinese (0.195) and Hindi (0.150).
|
| 113 |
+
|
| 114 |
+
The multilingual front against the original Kokoro-82M, 25 passages per language: speech length
|
| 115 |
+
within 1% in every language, duration error 0.10 to 0.25 frames per phoneme, pitch error 8 to 15 Hz
|
| 116 |
+
(11 to 21 Hz with the per-frame predictor). Japanese is the weakest.
|
| 117 |
+
|
| 118 |
+
Speed, decoder only, on 4 CPU threads without compiling: about 11 ms per second of audio at width
|
| 119 |
+
512, against about 234 ms for Kokoro-82M's decoder. In a serving worker on an RTX 3060 Ti, the full
|
| 120 |
+
distilled model ran at about 570 times real time under load uncompiled, against about 220 for
|
| 121 |
+
Kokoro-82M compiled, with a cold start of about a minute instead of about ten.
|
| 122 |
+
|
| 123 |
+
## Limitations
|
| 124 |
+
|
| 125 |
+
- It imitates Kokoro-82M and inherits its limits; it does not try to beat it.
|
| 126 |
+
- The decoder's phase is still measurably different from the teacher's, and its noise is smoother
|
| 127 |
+
than the teacher's. By ear, on one listener, the result was "mostly indistinguishable"; that is
|
| 128 |
+
not a listening test.
|
| 129 |
+
- The decoders in this repository were trained on the original model's decoder inputs. Behind the
|
| 130 |
+
distilled front they are slightly worse (mel error 0.214 to 0.230 at width 512) until fine-tuned
|
| 131 |
+
there, which is in progress.
|
| 132 |
+
- Quality outside English has been measured but only lightly listened to.
|
| 133 |
+
|
| 134 |
+
## License and credit
|
| 135 |
+
|
| 136 |
+
Apache-2.0, as Kokoro-82M is. Órë TTS is a derivative of
|
| 137 |
+
[Kokoro-82M](https://huggingface.co/hexgrad/Kokoro-82M) by hexgrad, which builds on
|
| 138 |
+
[StyleTTS 2](https://arxiv.org/abs/2306.07691) (Li et al.) and iSTFTNet. The decoder follows
|
| 139 |
+
[Vocos](https://arxiv.org/abs/2306.00814) (Siuzdak); the phase losses follow
|
| 140 |
+
[APNet2](https://arxiv.org/abs/2311.11545). [Paradee](https://arxiv.org/abs/2610.06817), an earlier
|
| 141 |
+
distillation of Kokoro-82M, informed the approach.
|
decoder/original-front-384.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:084dff8d48f949511fe4a59b2b9e3f121edd35ec20f65adf6ee9c417abe85901
|
| 3 |
+
size 49225529
|
decoder/original-front-512.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ce7ef21aa7e9ac65871a00da321d2466c38d569921a6cf8aaa5afdd538600305
|
| 3 |
+
size 78201719
|
front/lstm-replacements.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:880b606f1630234e18137266be795f5cb0c41039bfdf4077f1c573c701e5b2cf
|
| 3 |
+
size 45705305
|
front/pitch-energy-predictor.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:055ad305481685d549710fc2eb96cd9d4650bbdb3adb42c7a652aec3a556c3e6
|
| 3 |
+
size 239793182
|