v2: drawn word delivery, duration and prosody flows, tuned sighs and breaths; samples at temperature 0.55
Browse files- README.md +73 -52
- config.json +240 -1
- inference.pt +2 -2
- pitput/config.py +62 -1
- pitput/infer.py +19 -12
- pitput/model.py +497 -16
- recipe.json +15 -7
- samples/01-default.wav +2 -2
- samples/02-default.wav +2 -2
- samples/03-default.wav +2 -2
- samples/04-excited.wav +2 -2
- samples/05-sad.wav +2 -2
- samples/06-angry.wav +2 -2
- samples/07-fearful.wav +2 -2
- samples/08-surprised.wav +2 -2
- samples/09-calm.wav +2 -2
- samples/10-whisper.wav +2 -2
README.md
CHANGED
|
@@ -17,34 +17,42 @@ tags:
|
|
| 17 |
# pitput
|
| 18 |
|
| 19 |
**pitput** (פִּטְפּוּט) is a Hebrew take on [tiny-voca](https://github.com/n4ze3m/tiny-voca): a tiny TTS model
|
| 20 |
-
built to run on a CPU. The whole model, vocoder included, is **only
|
| 21 |
mono and runs faster than real time on a laptop CPU. It reads plain Hebrew without niqqud, in one voice with
|
| 22 |
**8 delivery styles** and **8 expression tags** (`<laugh>`, `<sigh>`, `<short pause>` …).
|
| 23 |
|
| 24 |
-
It is a personal learning project, trained from scratch on synthetic speech.
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
## Samples
|
| 28 |
|
| 29 |
-
The 10 listening texts
|
| 30 |
|
| 31 |
| Style | Text | Audio |
|
| 32 |
|---|---|---|
|
| 33 |
-
| default | לפי נתוני הלשכה המרכזית לסטטיסטיקה, אוכלוסיית ישראל גדלה בשנה האחרונה בכמאה ושמונים אלף איש. | <audio controls src="https://huggingface.co/useless-ai/pitput/resolve/
|
| 34 |
-
| default, addressee f | מה שלומך? שמעתי שלא הרגשת טוב בשבוע שעבר. | <audio controls src="https://huggingface.co/useless-ai/pitput/resolve/
|
| 35 |
-
| default | הרכבת לחיפה יוצאת בשבע ועשרים ומגיעה בשמונה וחצי, `<chuckle>` אם היא בכלל תגיע. | <audio controls src="https://huggingface.co/useless-ai/pitput/resolve/
|
| 36 |
-
| excited | `<laugh>` אני לא מאמינה, קיבלנו את הדירה! | <audio controls src="https://huggingface.co/useless-ai/pitput/resolve/
|
| 37 |
-
| sad | `<sigh>` חיכיתי לו כל הערב, והוא פשוט לא הגיע. | <audio controls src="https://huggingface.co/useless-ai/pitput/resolve/
|
| 38 |
-
| angry, addressee m | כמה פעמים אמרתי לך לס
|
| 39 |
-
| fearful | שמעת את זה? `<gasp>` יש מישהו בחוץ. | <audio controls src="https://huggingface.co/useless-ai/pitput/resolve/
|
| 40 |
-
| surprised | רגע, `<short pause>` הוא באמת התפטר? אחרי עשרים שנה? | <audio controls src="https://huggingface.co/useless-ai/pitput/resolve/
|
| 41 |
-
| calm | `<breath>` קחו נשימה עמוקה, `<long pause>` ותנו לגוף להירגע לאט לאט. | <audio controls src="https://huggingface.co/useless-ai/pitput/resolve/
|
| 42 |
-
| whisper | בוא נדבר בשקט, כולם כבר ישנים. | <audio controls src="https://huggingface.co/useless-ai/pitput/resolve/
|
| 43 |
|
| 44 |
## Usage
|
| 45 |
|
| 46 |
```bash
|
| 47 |
-
huggingface-cli login # the repository is private
|
| 48 |
git clone https://huggingface.co/useless-ai/pitput
|
| 49 |
cd pitput
|
| 50 |
pip install -r requirements.txt # PyTorch, Phonikud, onnxruntime, soundfile, huggingface_hub
|
|
@@ -59,10 +67,12 @@ On first use the Phonikud model (~300 MB) is downloaded to the Hugging Face cach
|
|
| 59 |
|---|---|
|
| 60 |
| `--style` | `default`, `excited`, `sad`, `angry`, `fearful`, `surprised`, `calm`, `whisper` |
|
| 61 |
| `--addressee m` / `f` | Gender of the person spoken to (לך, אותך, אמרת …). Without it Phonikud reads the masculine form |
|
|
|
|
|
|
|
| 62 |
| `--text-file` | Read the text from a UTF-8 file instead of `--text` |
|
| 63 |
| `--speed` | 1.0 = as trained; 0.9 is 10% slower |
|
| 64 |
| `--pitch-shift` | Added to log F0 (0.058 ≈ one semitone) |
|
| 65 |
-
| `--pitch-range` | Scales the melody around each sentence's mean pitch (
|
| 66 |
| `--device` | `cpu` (default) or `cuda` |
|
| 67 |
|
| 68 |
From Python:
|
|
@@ -72,10 +82,12 @@ import soundfile as sf
|
|
| 72 |
from pitput.infer import CHECKPOINT, load_model, speak_text
|
| 73 |
|
| 74 |
model = load_model(CHECKPOINT) # inference.pt next to the package
|
| 75 |
-
wave, utterances = speak_text(model, "שלום, <sigh> מה שלומך?", "calm", addressee="f")
|
| 76 |
sf.write("out.wav", wave.numpy(), model.config.sample_rate)
|
| 77 |
```
|
| 78 |
|
|
|
|
|
|
|
| 79 |
### What the input must look like
|
| 80 |
|
| 81 |
- **Plain Hebrew in spoken form.** There is no text normalizer: write numbers, dates, times, acronyms and
|
|
@@ -95,54 +107,64 @@ differentiable source-filter vocoder, so there is no separate neural vocoder.
|
|
| 95 |
- **Input:** 47 tokens: 29 Phonikud phonemes, 5 punctuation marks, word boundary, utterance edges and the 8
|
| 96 |
expression tags. Stress is a parallel feature, not a token.
|
| 97 |
- **Text encoder:** 4 transformer layers, 192 channels, with the style embedding added to every token.
|
| 98 |
-
- **
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
- **
|
| 102 |
-
|
| 103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
|
| 105 |
## Training data
|
| 106 |
|
| 107 |
-
The dataset is **synthetic only**, with no recorded human speech:
|
| 108 |
-
of which
|
| 109 |
-
for validation and 160 for test.
|
| 110 |
|
| 111 |
-
- **Text:**
|
| 112 |
-
ivrit.ai transcripts and LLM-written scenes
|
|
|
|
| 113 |
- **Spoken form:** an LLM rewrote numbers, dates, money, acronyms and Latin script as Hebrew words, and every answer
|
| 114 |
was checked by code.
|
| 115 |
- **Addressee gender:** an LLM decided the gender of ambiguous second-person words (לך, אותך, אמרת) in context.
|
| 116 |
The audio and the training phonemes follow the same decision.
|
| 117 |
- **Styles:** an LLM picked a style for each dialogue sentence and inserted the tags; calm and whisper were assigned
|
| 118 |
-
to plain statements
|
| 119 |
-
delivery.
|
| 120 |
-
|
| 121 |
-
| Style | Clips synthesized |
|
| 122 |
-
|---|---|
|
| 123 |
-
| default | 52,
|
| 124 |
-
| calm |
|
| 125 |
-
| whisper | 4,
|
| 126 |
-
| fearful |
|
| 127 |
-
| angry |
|
| 128 |
-
| sad |
|
| 129 |
-
| excited |
|
| 130 |
-
| surprised |
|
| 131 |
-
|
| 132 |
-
|
|
|
|
| 133 |
- **Labels:** Phonikud phonemes with the addressee decisions applied, phonemized word by word with the tags at
|
| 134 |
their positions. Durations come from forced alignment with
|
| 135 |
[facebook/wav2vec2-lv-60-espeak-cv-ft](https://huggingface.co/facebook/wav2vec2-lv-60-espeak-cv-ft), which is used
|
| 136 |
-
only for labeling and is not part of the model. A tag owns the sound
|
| 137 |
|
| 138 |
## Limitations
|
| 139 |
|
| 140 |
-
- **Laughs and
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
|
|
|
| 146 |
- **Pronunciation follows Phonikud,** including its mistakes (e.g. וואו read as "vaʔu").
|
| 147 |
- **Second person defaults to masculine** unless `--addressee f` is given; there is no per-word decision at
|
| 148 |
inference.
|
|
@@ -153,7 +175,6 @@ for validation and 160 for test.
|
|
| 153 |
- **Code** (`pitput/`): Apache License 2.0. It is a fork of fiato by cfahlgren1 and tiny-voca by Muhammed Nazeem,
|
| 154 |
both Apache-2.0; see `NOTICE`, `LICENSE` and `LICENSE.tiny-voca`.
|
| 155 |
- **Weights and audio samples: private research use only, not licensed for redistribution or any commercial use.**
|
| 156 |
-
Keep this repository private.
|
| 157 |
- **Phonikud** ([thewh1teagle/phonikud-onnx](https://huggingface.co/thewh1teagle/phonikud-onnx), MIT) is downloaded
|
| 158 |
at first use and is not included here.
|
| 159 |
|
|
@@ -164,7 +185,7 @@ for validation and 160 for test.
|
|
| 164 |
| `inference.pt` | Weights, model configuration and front-end fingerprint (loaded with `weights_only=True`) |
|
| 165 |
| `pitput/` | Inference code: `infer.py` (command line and `speak_text`), `model.py`, `text.py` (phoneme tokens), `g2p.py` (Phonikud and addressee gender), `labels.py`, `config.py` |
|
| 166 |
| `samples/` | The audio above |
|
| 167 |
-
| `config.json`, `recipe.json` | Model and training settings of this
|
| 168 |
| `requirements.txt` | Python dependencies |
|
| 169 |
| `NOTICE`, `LICENSE`, `LICENSE.tiny-voca` | Attribution and license of the code |
|
| 170 |
|
|
|
|
| 17 |
# pitput
|
| 18 |
|
| 19 |
**pitput** (פִּטְפּוּט) is a Hebrew take on [tiny-voca](https://github.com/n4ze3m/tiny-voca): a tiny TTS model
|
| 20 |
+
built to run on a CPU. The whole model, vocoder included, is **only 20 MB** (5.0M parameters). It outputs 24 kHz
|
| 21 |
mono and runs faster than real time on a laptop CPU. It reads plain Hebrew without niqqud, in one voice with
|
| 22 |
**8 delivery styles** and **8 expression tags** (`<laugh>`, `<sigh>`, `<short pause>` …).
|
| 23 |
|
| 24 |
+
It is a personal learning project, trained from scratch on synthetic speech. **Private research use only; see
|
| 25 |
+
[License](#license).**
|
| 26 |
+
|
| 27 |
+
## Versions
|
| 28 |
+
|
| 29 |
+
| Version | What changed |
|
| 30 |
+
|---|---|
|
| 31 |
+
| **v2** (this, November 21, 2026) | The delivery of each word is drawn instead of averaged: livelier melody and tempo, audible laughs and chuckles, pauses where a speaker would take them. More expressive training data. Cleaner whisper and breaths. Sighs and breaths tuned to the loudness and length of the data |
|
| 32 |
+
| v1 (November 18, 2026) | First model. Steady, somewhat robotic delivery; laughs came out as a soft breath |
|
| 33 |
+
|
| 34 |
+
v1 stays available as the `v1` tag: `git checkout v1`, or `revision="v1"` in `huggingface_hub`.
|
| 35 |
|
| 36 |
## Samples
|
| 37 |
|
| 38 |
+
The 10 listening texts, synthesized with the default settings (temperature 0.55, seed 0).
|
| 39 |
|
| 40 |
| Style | Text | Audio |
|
| 41 |
|---|---|---|
|
| 42 |
+
| default | לפי נתוני הלשכה המרכזית לסטטיסטיקה, אוכלוסיית ישראל גדלה בשנה האחרונה בכמאה ושמונים אלף איש. | <audio controls src="https://huggingface.co/useless-ai/pitput/resolve/v2/samples/01-default.wav"></audio> |
|
| 43 |
+
| default, addressee f | מה שלומך? שמעתי שלא הרגשת טוב בשבוע שעבר. | <audio controls src="https://huggingface.co/useless-ai/pitput/resolve/v2/samples/02-default.wav"></audio> |
|
| 44 |
+
| default | הרכבת לחיפה יוצאת בשבע ועשרים ומגיעה בשמונה וחצי, `<chuckle>` אם היא בכלל תגיע. | <audio controls src="https://huggingface.co/useless-ai/pitput/resolve/v2/samples/03-default.wav"></audio> |
|
| 45 |
+
| excited | `<laugh>` אני לא מאמינה, קיבלנו את הדירה! | <audio controls src="https://huggingface.co/useless-ai/pitput/resolve/v2/samples/04-excited.wav"></audio> |
|
| 46 |
+
| sad | `<sigh>` חיכיתי לו כל הערב, והוא פשוט לא הגיע. | <audio controls src="https://huggingface.co/useless-ai/pitput/resolve/v2/samples/05-sad.wav"></audio> |
|
| 47 |
+
| angry, addressee m | כמה פעמים אמרתי לך לס��ור את הדלת?! | <audio controls src="https://huggingface.co/useless-ai/pitput/resolve/v2/samples/06-angry.wav"></audio> |
|
| 48 |
+
| fearful | שמעת את זה? `<gasp>` יש מישהו בחוץ. | <audio controls src="https://huggingface.co/useless-ai/pitput/resolve/v2/samples/07-fearful.wav"></audio> |
|
| 49 |
+
| surprised | רגע, `<short pause>` הוא באמת התפטר? אחרי עשרים שנה? | <audio controls src="https://huggingface.co/useless-ai/pitput/resolve/v2/samples/08-surprised.wav"></audio> |
|
| 50 |
+
| calm | `<breath>` קחו נשימה עמוקה, `<long pause>` ותנו לגוף להירגע לאט לאט. | <audio controls src="https://huggingface.co/useless-ai/pitput/resolve/v2/samples/09-calm.wav"></audio> |
|
| 51 |
+
| whisper | בוא נדבר בשקט, כולם כבר ישנים. | <audio controls src="https://huggingface.co/useless-ai/pitput/resolve/v2/samples/10-whisper.wav"></audio> |
|
| 52 |
|
| 53 |
## Usage
|
| 54 |
|
| 55 |
```bash
|
|
|
|
| 56 |
git clone https://huggingface.co/useless-ai/pitput
|
| 57 |
cd pitput
|
| 58 |
pip install -r requirements.txt # PyTorch, Phonikud, onnxruntime, soundfile, huggingface_hub
|
|
|
|
| 67 |
|---|---|
|
| 68 |
| `--style` | `default`, `excited`, `sad`, `angry`, `fearful`, `surprised`, `calm`, `whisper` |
|
| 69 |
| `--addressee m` / `f` | Gender of the person spoken to (לך, אותך, אמרת …). Without it Phonikud reads the masculine form |
|
| 70 |
+
| `--temperature` | How freely the delivery is drawn (default 0.55). Lower is steadier, higher is livelier and less predictable; above ~1 it starts to break up |
|
| 71 |
+
| `--seed` | Another seed gives another delivery of the same text (default 0). If a laugh or chuckle comes out weak, try another seed |
|
| 72 |
| `--text-file` | Read the text from a UTF-8 file instead of `--text` |
|
| 73 |
| `--speed` | 1.0 = as trained; 0.9 is 10% slower |
|
| 74 |
| `--pitch-shift` | Added to log F0 (0.058 ≈ one semitone) |
|
| 75 |
+
| `--pitch-range` | Scales the melody around each sentence's mean pitch (default: the model's own, 1.2) |
|
| 76 |
| `--device` | `cpu` (default) or `cuda` |
|
| 77 |
|
| 78 |
From Python:
|
|
|
|
| 82 |
from pitput.infer import CHECKPOINT, load_model, speak_text
|
| 83 |
|
| 84 |
model = load_model(CHECKPOINT) # inference.pt next to the package
|
| 85 |
+
wave, utterances = speak_text(model, "שלום, <sigh> מה שלומך?", "calm", addressee="f", seed=0, temperature=0.55)
|
| 86 |
sf.write("out.wav", wave.numpy(), model.config.sample_rate)
|
| 87 |
```
|
| 88 |
|
| 89 |
+
`temperature=None` plays the model's own settings instead (word choices at 0.5, melody at 0.3).
|
| 90 |
+
|
| 91 |
### What the input must look like
|
| 92 |
|
| 93 |
- **Plain Hebrew in spoken form.** There is no text normalizer: write numbers, dates, times, acronyms and
|
|
|
|
| 107 |
- **Input:** 47 tokens: 29 Phonikud phonemes, 5 punctuation marks, word boundary, utterance edges and the 8
|
| 108 |
expression tags. Stress is a parallel feature, not a token.
|
| 109 |
- **Text encoder:** 4 transformer layers, 192 channels, with the style embedding added to every token.
|
| 110 |
+
- **Word delivery codes:** each word or tag gets one of 32 learned delivery codes, chosen by a small recurrent
|
| 111 |
+
planner from the text, the style and the previous codes. A sound tag's code comes from a table of the codes
|
| 112 |
+
that gave full, audible renderings of that tag.
|
| 113 |
+
- **Timing:** a token-level flow (flow matching, 2 layers) draws every token's length and whether a pause follows
|
| 114 |
+
it, for the whole sentence at once.
|
| 115 |
+
- **Frame level:** the style embedding is added again; a frame-level flow (2 layers) draws the pitch, voicing and
|
| 116 |
+
energy contour, and 5 transformer layers predict the acoustic features.
|
| 117 |
+
- **Vocoder:** a harmonic pulse train, on voiced frames only, plus noise, each shaped by a complex cepstrum per frame.
|
| 118 |
+
- **Sounds tuned after training:** the sigh and breath directions inside the two flows were adjusted so sighs come
|
| 119 |
+
out as loud and as long as in the data and breaths not too long.
|
| 120 |
+
- **Size:** 4,991,888 parameters at inference (20 MB checkpoint); the weights are a moving average over training.
|
| 121 |
+
Training also uses parameters that are not in the checkpoint (discriminators, a reference encoder for the
|
| 122 |
+
delivery codes, an auxiliary mel head).
|
| 123 |
|
| 124 |
## Training data
|
| 125 |
|
| 126 |
+
The dataset is **synthetic only**, with no recorded human speech: about 73,500 clips (152 h) of one synthetic
|
| 127 |
+
voice, of which 70,864 training clips (148 h) passed forced alignment. 160 held-out sentences (20 per style) were
|
| 128 |
+
kept for validation and 160 for test.
|
| 129 |
|
| 130 |
+
- **Text:** Hebrew sentences from news (archive, HeSum, RSS), HeDC4 web text and stories, Hebrew
|
| 131 |
+
Wikipedia, ivrit.ai transcripts and LLM-written scenes, among them emotional, dialogue-heavy scenes written for
|
| 132 |
+
the expressive styles and sounds.
|
| 133 |
- **Spoken form:** an LLM rewrote numbers, dates, money, acronyms and Latin script as Hebrew words, and every answer
|
| 134 |
was checked by code.
|
| 135 |
- **Addressee gender:** an LLM decided the gender of ambiguous second-person words (לך, אותך, אמרת) in context.
|
| 136 |
The audio and the training phonemes follow the same decision.
|
| 137 |
- **Styles:** an LLM picked a style for each dialogue sentence and inserted the tags; calm and whisper were assigned
|
| 138 |
+
to plain statements, and some expressive sentences were recorded in a second style. Each style was rendered with
|
| 139 |
+
one fixed delivery instruction; default is a bright, friendly delivery.
|
| 140 |
+
|
| 141 |
+
| Style | Clips synthesized |
|
| 142 |
+
|---|---|
|
| 143 |
+
| default | 52,576 |
|
| 144 |
+
| calm | 5,087 |
|
| 145 |
+
| whisper | 4,912 |
|
| 146 |
+
| fearful | 2,614 |
|
| 147 |
+
| angry | 2,314 |
|
| 148 |
+
| sad | 2,145 |
|
| 149 |
+
| excited | 1,936 |
|
| 150 |
+
| surprised | 1,888 |
|
| 151 |
+
|
| 152 |
+
Tags in the aligned training clips (at most 2 per clip): short pause 2,270, breath 1,627, chuckle 1,085,
|
| 153 |
+
sigh 936, long pause 924, gasp 798, laugh 796, throat-clearing 389.
|
| 154 |
- **Labels:** Phonikud phonemes with the addressee decisions applied, phonemized word by word with the tags at
|
| 155 |
their positions. Durations come from forced alignment with
|
| 156 |
[facebook/wav2vec2-lv-60-espeak-cv-ft](https://huggingface.co/facebook/wav2vec2-lv-60-espeak-cv-ft), which is used
|
| 157 |
+
only for labeling and is not part of the model. A tag owns the sound up to the neighbouring phonemes.
|
| 158 |
|
| 159 |
## Limitations
|
| 160 |
|
| 161 |
+
- **Laughs and chuckles are not reliable.** They are a few dB quieter than in the data, and some draws leave them
|
| 162 |
+
faint; another `--seed` usually helps. `<breath>` is quiet.
|
| 163 |
+
- **Melody and emphasis:** the melody is less varied than a human reading, and the emphasis of a sentence sometimes
|
| 164 |
+
lands on the wrong word. Tempo changes less within a sentence than in the data.
|
| 165 |
+
- **Temperature trades life for stability:** at 0.3 and below the delivery gets flat; above ~1 words can be
|
| 166 |
+
mispronounced and the sound can break.
|
| 167 |
+
- **Fearful is the weakest style:** many of its training clips failed alignment.
|
| 168 |
- **Pronunciation follows Phonikud,** including its mistakes (e.g. וואו read as "vaʔu").
|
| 169 |
- **Second person defaults to masculine** unless `--addressee f` is given; there is no per-word decision at
|
| 170 |
inference.
|
|
|
|
| 175 |
- **Code** (`pitput/`): Apache License 2.0. It is a fork of fiato by cfahlgren1 and tiny-voca by Muhammed Nazeem,
|
| 176 |
both Apache-2.0; see `NOTICE`, `LICENSE` and `LICENSE.tiny-voca`.
|
| 177 |
- **Weights and audio samples: private research use only, not licensed for redistribution or any commercial use.**
|
|
|
|
| 178 |
- **Phonikud** ([thewh1teagle/phonikud-onnx](https://huggingface.co/thewh1teagle/phonikud-onnx), MIT) is downloaded
|
| 179 |
at first use and is not included here.
|
| 180 |
|
|
|
|
| 185 |
| `inference.pt` | Weights, model configuration and front-end fingerprint (loaded with `weights_only=True`) |
|
| 186 |
| `pitput/` | Inference code: `infer.py` (command line and `speak_text`), `model.py`, `text.py` (phoneme tokens), `g2p.py` (Phonikud and addressee gender), `labels.py`, `config.py` |
|
| 187 |
| `samples/` | The audio above |
|
| 188 |
+
| `config.json`, `recipe.json` | Model and training settings of this version |
|
| 189 |
| `requirements.txt` | Python dependencies |
|
| 190 |
| `NOTICE`, `LICENSE`, `LICENSE.tiny-voca` | Attribution and license of the code |
|
| 191 |
|
config.json
CHANGED
|
@@ -28,13 +28,252 @@
|
|
| 28 |
"acoustic_layers": 5,
|
| 29 |
"dropout": 0.1,
|
| 30 |
"predictor_channels": 128,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
"synth_fft": 512,
|
| 32 |
"synth_hop": 128,
|
| 33 |
"noise_fft": 256,
|
| 34 |
"noise_hop": 64,
|
| 35 |
"cep_causal": 80,
|
| 36 |
"cep_anti": 16,
|
| 37 |
-
"noise_cep":
|
|
|
|
| 38 |
"harmonic_limit": 0.47,
|
| 39 |
"max_tokens": 512,
|
| 40 |
"max_frames": 3000,
|
|
|
|
| 28 |
"acoustic_layers": 5,
|
| 29 |
"dropout": 0.1,
|
| 30 |
"predictor_channels": 128,
|
| 31 |
+
"prosody_codes": 32,
|
| 32 |
+
"code_width": 16,
|
| 33 |
+
"planner_width": 128,
|
| 34 |
+
"flow_layers": 2,
|
| 35 |
+
"flow_channels": 96,
|
| 36 |
+
"flow_heads": 2,
|
| 37 |
+
"flow_steps": 32,
|
| 38 |
+
"duration_flow_layers": 2,
|
| 39 |
+
"duration_flow_channels": 64,
|
| 40 |
+
"word_flow_layers": 0,
|
| 41 |
+
"word_flow_channels": 64,
|
| 42 |
+
"code_temperature": 0.5,
|
| 43 |
+
"contour_temperature": 0.3,
|
| 44 |
+
"pitch_range": 1.2,
|
| 45 |
+
"sound_codes": [
|
| 46 |
+
[
|
| 47 |
+
"<laugh>",
|
| 48 |
+
[
|
| 49 |
+
0.0,
|
| 50 |
+
0.0,
|
| 51 |
+
0.0,
|
| 52 |
+
0.0,
|
| 53 |
+
0.0,
|
| 54 |
+
0.0,
|
| 55 |
+
0.0,
|
| 56 |
+
0.0,
|
| 57 |
+
0.2127,
|
| 58 |
+
0.0,
|
| 59 |
+
0.1338,
|
| 60 |
+
0.0,
|
| 61 |
+
0.0,
|
| 62 |
+
0.0,
|
| 63 |
+
0.2522,
|
| 64 |
+
0.0,
|
| 65 |
+
0.0,
|
| 66 |
+
0.0088,
|
| 67 |
+
0.0154,
|
| 68 |
+
0.0,
|
| 69 |
+
0.0,
|
| 70 |
+
0.0,
|
| 71 |
+
0.0,
|
| 72 |
+
0.0,
|
| 73 |
+
0.0,
|
| 74 |
+
0.0,
|
| 75 |
+
0.0482,
|
| 76 |
+
0.1645,
|
| 77 |
+
0.1118,
|
| 78 |
+
0.0241,
|
| 79 |
+
0.0285,
|
| 80 |
+
0.0
|
| 81 |
+
]
|
| 82 |
+
],
|
| 83 |
+
[
|
| 84 |
+
"<chuckle>",
|
| 85 |
+
[
|
| 86 |
+
0.0,
|
| 87 |
+
0.0,
|
| 88 |
+
0.0,
|
| 89 |
+
0.0632,
|
| 90 |
+
0.0,
|
| 91 |
+
0.0105,
|
| 92 |
+
0.009,
|
| 93 |
+
0.0,
|
| 94 |
+
0.1053,
|
| 95 |
+
0.0,
|
| 96 |
+
0.1684,
|
| 97 |
+
0.0,
|
| 98 |
+
0.0,
|
| 99 |
+
0.0,
|
| 100 |
+
0.1504,
|
| 101 |
+
0.1248,
|
| 102 |
+
0.0,
|
| 103 |
+
0.0,
|
| 104 |
+
0.0,
|
| 105 |
+
0.0,
|
| 106 |
+
0.0,
|
| 107 |
+
0.0,
|
| 108 |
+
0.0135,
|
| 109 |
+
0.0331,
|
| 110 |
+
0.0,
|
| 111 |
+
0.0,
|
| 112 |
+
0.0135,
|
| 113 |
+
0.1579,
|
| 114 |
+
0.1504,
|
| 115 |
+
0.0,
|
| 116 |
+
0.0,
|
| 117 |
+
0.0
|
| 118 |
+
]
|
| 119 |
+
],
|
| 120 |
+
[
|
| 121 |
+
"<sigh>",
|
| 122 |
+
[
|
| 123 |
+
0.0,
|
| 124 |
+
0.0,
|
| 125 |
+
0.0187,
|
| 126 |
+
0.1042,
|
| 127 |
+
0.0,
|
| 128 |
+
0.0,
|
| 129 |
+
0.0729,
|
| 130 |
+
0.0,
|
| 131 |
+
0.2,
|
| 132 |
+
0.0,
|
| 133 |
+
0.1062,
|
| 134 |
+
0.0,
|
| 135 |
+
0.0,
|
| 136 |
+
0.0,
|
| 137 |
+
0.0625,
|
| 138 |
+
0.0,
|
| 139 |
+
0.0,
|
| 140 |
+
0.0,
|
| 141 |
+
0.0208,
|
| 142 |
+
0.0,
|
| 143 |
+
0.0146,
|
| 144 |
+
0.0,
|
| 145 |
+
0.0,
|
| 146 |
+
0.0,
|
| 147 |
+
0.0,
|
| 148 |
+
0.0,
|
| 149 |
+
0.0,
|
| 150 |
+
0.1458,
|
| 151 |
+
0.1958,
|
| 152 |
+
0.0583,
|
| 153 |
+
0.0,
|
| 154 |
+
0.0
|
| 155 |
+
]
|
| 156 |
+
],
|
| 157 |
+
[
|
| 158 |
+
"<breath>",
|
| 159 |
+
[
|
| 160 |
+
0.0,
|
| 161 |
+
0.0,
|
| 162 |
+
0.0,
|
| 163 |
+
0.1053,
|
| 164 |
+
0.0,
|
| 165 |
+
0.0,
|
| 166 |
+
0.0,
|
| 167 |
+
0.0,
|
| 168 |
+
0.1779,
|
| 169 |
+
0.0,
|
| 170 |
+
0.1011,
|
| 171 |
+
0.0,
|
| 172 |
+
0.0,
|
| 173 |
+
0.0,
|
| 174 |
+
0.0568,
|
| 175 |
+
0.1758,
|
| 176 |
+
0.0,
|
| 177 |
+
0.0,
|
| 178 |
+
0.0,
|
| 179 |
+
0.0,
|
| 180 |
+
0.0,
|
| 181 |
+
0.0,
|
| 182 |
+
0.0,
|
| 183 |
+
0.0,
|
| 184 |
+
0.0126,
|
| 185 |
+
0.0,
|
| 186 |
+
0.0126,
|
| 187 |
+
0.1716,
|
| 188 |
+
0.1863,
|
| 189 |
+
0.0,
|
| 190 |
+
0.0,
|
| 191 |
+
0.0
|
| 192 |
+
]
|
| 193 |
+
],
|
| 194 |
+
[
|
| 195 |
+
"<gasp>",
|
| 196 |
+
[
|
| 197 |
+
0.0,
|
| 198 |
+
0.0,
|
| 199 |
+
0.0,
|
| 200 |
+
0.0,
|
| 201 |
+
0.0,
|
| 202 |
+
0.0,
|
| 203 |
+
0.0,
|
| 204 |
+
0.0,
|
| 205 |
+
0.3765,
|
| 206 |
+
0.0647,
|
| 207 |
+
0.1199,
|
| 208 |
+
0.0,
|
| 209 |
+
0.0,
|
| 210 |
+
0.0,
|
| 211 |
+
0.1295,
|
| 212 |
+
0.0,
|
| 213 |
+
0.0,
|
| 214 |
+
0.0,
|
| 215 |
+
0.0192,
|
| 216 |
+
0.0,
|
| 217 |
+
0.0,
|
| 218 |
+
0.0,
|
| 219 |
+
0.0192,
|
| 220 |
+
0.0,
|
| 221 |
+
0.0192,
|
| 222 |
+
0.0,
|
| 223 |
+
0.0,
|
| 224 |
+
0.0935,
|
| 225 |
+
0.1247,
|
| 226 |
+
0.0336,
|
| 227 |
+
0.0,
|
| 228 |
+
0.0
|
| 229 |
+
]
|
| 230 |
+
],
|
| 231 |
+
[
|
| 232 |
+
"<throat-clearing>",
|
| 233 |
+
[
|
| 234 |
+
0.0,
|
| 235 |
+
0.0,
|
| 236 |
+
0.015,
|
| 237 |
+
0.0,
|
| 238 |
+
0.015,
|
| 239 |
+
0.0,
|
| 240 |
+
0.4361,
|
| 241 |
+
0.0,
|
| 242 |
+
0.0,
|
| 243 |
+
0.0,
|
| 244 |
+
0.3008,
|
| 245 |
+
0.0,
|
| 246 |
+
0.0,
|
| 247 |
+
0.0,
|
| 248 |
+
0.0526,
|
| 249 |
+
0.1805,
|
| 250 |
+
0.0,
|
| 251 |
+
0.0,
|
| 252 |
+
0.0,
|
| 253 |
+
0.0,
|
| 254 |
+
0.0,
|
| 255 |
+
0.0,
|
| 256 |
+
0.0,
|
| 257 |
+
0.0,
|
| 258 |
+
0.0,
|
| 259 |
+
0.0,
|
| 260 |
+
0.0,
|
| 261 |
+
0.0,
|
| 262 |
+
0.0,
|
| 263 |
+
0.0,
|
| 264 |
+
0.0,
|
| 265 |
+
0.0
|
| 266 |
+
]
|
| 267 |
+
]
|
| 268 |
+
],
|
| 269 |
"synth_fft": 512,
|
| 270 |
"synth_hop": 128,
|
| 271 |
"noise_fft": 256,
|
| 272 |
"noise_hop": 64,
|
| 273 |
"cep_causal": 80,
|
| 274 |
"cep_anti": 16,
|
| 275 |
+
"noise_cep": 64,
|
| 276 |
+
"voiced_pulses": true,
|
| 277 |
"harmonic_limit": 0.47,
|
| 278 |
"max_tokens": 512,
|
| 279 |
"max_frames": 3000,
|
inference.pt
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c0fa04292d3b399958a65fbb74c70bcbe14e26b6257045d2768624454e06bbe3
|
| 3 |
+
size 20066151
|
pitput/config.py
CHANGED
|
@@ -4,6 +4,8 @@ import json
|
|
| 4 |
|
| 5 |
CHECKPOINT_FORMAT = 4 # 2-3: byte tokens + learned aligner (rejected explicitly).
|
| 6 |
ANNOTATION_VERSION = 3
|
|
|
|
|
|
|
| 7 |
|
| 8 |
|
| 9 |
def _digest(value):
|
|
@@ -35,6 +37,39 @@ class Config:
|
|
| 35 |
acoustic_layers: int = 5
|
| 36 |
dropout: float = 0.1
|
| 37 |
predictor_channels: int = 128
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
# Source-filter waveform head: harmonic branch and noise branch STFT sizes,
|
| 39 |
# causal/anticausal complex-cepstrum orders.
|
| 40 |
synth_fft: int = 512
|
|
@@ -44,6 +79,9 @@ class Config:
|
|
| 44 |
cep_causal: int = 80
|
| 45 |
cep_anti: int = 16
|
| 46 |
noise_cep: int = 32
|
|
|
|
|
|
|
|
|
|
| 47 |
harmonic_limit: float = 0.47
|
| 48 |
max_tokens: int = 512
|
| 49 |
max_frames: int = 3000
|
|
@@ -72,14 +110,37 @@ class Config:
|
|
| 72 |
raise ValueError("layer counts must be positive and the kernel odd")
|
| 73 |
if min(self.mel_scale, self.energy_scale) <= 0 or not 0 < self.harmonic_limit < 0.5:
|
| 74 |
raise ValueError("invalid normalization scale or harmonic limit")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
|
| 76 |
def to_dict(self):
|
| 77 |
return asdict(self)
|
| 78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
@classmethod
|
| 80 |
def from_dict(cls, value):
|
| 81 |
return cls(**{**value, "speakers": tuple(value["speakers"]),
|
| 82 |
-
"unvoiced_speakers": tuple(value.get("unvoiced_speakers", ()))
|
|
|
|
| 83 |
|
| 84 |
@property
|
| 85 |
def fingerprint(self):
|
|
|
|
| 4 |
|
| 5 |
CHECKPOINT_FORMAT = 4 # 2-3: byte tokens + learned aligner (rejected explicitly).
|
| 6 |
ANNOTATION_VERSION = 3
|
| 7 |
+
# Config fields that only change synthesis, not the weights: a resumed run may change them.
|
| 8 |
+
PLAYBACK_FIELDS = ("flow_steps", "code_temperature", "contour_temperature", "pitch_range", "sound_codes")
|
| 9 |
|
| 10 |
|
| 11 |
def _digest(value):
|
|
|
|
| 37 |
acoustic_layers: int = 5
|
| 38 |
dropout: float = 0.1
|
| 39 |
predictor_channels: int = 128
|
| 40 |
+
# Word-level prosody codes (model.ProsodyCodes); 0 turns them off (the try-1 architecture).
|
| 41 |
+
prosody_codes: int = 0
|
| 42 |
+
code_width: int = 16
|
| 43 |
+
planner_width: int = 128
|
| 44 |
+
# Pitch, voicing and energy drawn by flow matching (model.ProsodyFlow) instead of
|
| 45 |
+
# the regression head; 0 layers turns it off (tries 1 and 2). Euler steps at inference
|
| 46 |
+
# only (PLAYBACK_FIELDS): fewer steps pull laughs toward a flat average (8: 2-4 dB quieter).
|
| 47 |
+
flow_layers: int = 0
|
| 48 |
+
flow_channels: int = 96
|
| 49 |
+
flow_heads: int = 2
|
| 50 |
+
flow_steps: int = 32
|
| 51 |
+
# Token lengths and pauses drawn by flow matching (model.DurationFlow) instead of the
|
| 52 |
+
# duration predictor's regression and independent pause draws; 0 layers turns it off
|
| 53 |
+
# (tries 1-3). It shares flow_heads and flow_steps.
|
| 54 |
+
duration_flow_layers: int = 0
|
| 55 |
+
duration_flow_channels: int = 64
|
| 56 |
+
# The word codes of a whole sentence drawn by flow matching (model.WordFlow) instead of the
|
| 57 |
+
# planner's guesses one word after the other; 0 layers keeps the planner (tries 2-4). Needs
|
| 58 |
+
# prosody_codes; shares flow_heads and flow_steps.
|
| 59 |
+
word_flow_layers: int = 0
|
| 60 |
+
word_flow_channels: int = 64
|
| 61 |
+
# Playback defaults when synthesis is called without a temperature (PLAYBACK_FIELDS; -1 =
|
| 62 |
+
# the general temperature). Word codes drawn at 0 (the most likely; sound tags still at the
|
| 63 |
+
# sound temperature) and the contour at 0.3, widened 1.4x, follow the recordings' word melody best
|
| 64 |
+
# (try 5: word correlation 0.45 vs 0.27 at 0.7, with the same pitch range).
|
| 65 |
+
code_temperature: float = -1.0
|
| 66 |
+
contour_temperature: float = -1.0
|
| 67 |
+
pitch_range: float = 1.0
|
| 68 |
+
# Playback: the word code of a sound-tag unit is drawn from these weights per tag instead of
|
| 69 |
+
# the planner, ((tag, (weight per code, ...)), ...); empty = the planner. The weights are the
|
| 70 |
+
# codes of the recordings' fuller renderings of the tag (collected during training): the planner
|
| 71 |
+
# spread its guesses over all codes and left a chuckle quiet in about 40% of draws (try 7).
|
| 72 |
+
sound_codes: tuple = ()
|
| 73 |
# Source-filter waveform head: harmonic branch and noise branch STFT sizes,
|
| 74 |
# causal/anticausal complex-cepstrum orders.
|
| 75 |
synth_fft: int = 512
|
|
|
|
| 79 |
cep_causal: int = 80
|
| 80 |
cep_anti: int = 16
|
| 81 |
noise_cep: int = 32
|
| 82 |
+
# The pulse train sounds only on voiced frames (model.SourceFilter), so breath noise must come
|
| 83 |
+
# from the noise branch; off in tries 1-6. Try 7 also gives the noise envelope 64 coefficients.
|
| 84 |
+
voiced_pulses: bool = False
|
| 85 |
harmonic_limit: float = 0.47
|
| 86 |
max_tokens: int = 512
|
| 87 |
max_frames: int = 3000
|
|
|
|
| 110 |
raise ValueError("layer counts must be positive and the kernel odd")
|
| 111 |
if min(self.mel_scale, self.energy_scale) <= 0 or not 0 < self.harmonic_limit < 0.5:
|
| 112 |
raise ValueError("invalid normalization scale or harmonic limit")
|
| 113 |
+
if self.prosody_codes < 0 or self.prosody_codes == 1 or min(self.code_width, self.planner_width) < 1:
|
| 114 |
+
raise ValueError("prosody_codes must be 0 (off) or at least 2, with positive code and planner widths")
|
| 115 |
+
if self.flow_layers < 0 or self.flow_steps < 1 or self.flow_heads < 1 or self.flow_channels % self.flow_heads \
|
| 116 |
+
or (self.flow_channels // self.flow_heads) % 2:
|
| 117 |
+
raise ValueError("flow_layers must be 0 (off) or more, with at least one step and an even flow head width")
|
| 118 |
+
if self.duration_flow_layers < 0 or self.duration_flow_channels % self.flow_heads \
|
| 119 |
+
or (self.duration_flow_channels // self.flow_heads) % 2:
|
| 120 |
+
raise ValueError("duration_flow_layers must be 0 (off) or more, with an even flow head width")
|
| 121 |
+
if self.word_flow_layers < 0 or (self.word_flow_layers and not self.prosody_codes) \
|
| 122 |
+
or self.word_flow_channels % self.flow_heads or (self.word_flow_channels // self.flow_heads) % 2:
|
| 123 |
+
raise ValueError("word_flow_layers must be 0 (off) or more, needs prosody codes and an even flow head width")
|
| 124 |
+
if not all(t == -1 or 0 <= t <= 3 for t in (self.code_temperature, self.contour_temperature)) or not 0 < self.pitch_range <= 3:
|
| 125 |
+
raise ValueError("playback temperatures must be -1 (the general one) or in [0, 3], pitch_range in (0, 3]")
|
| 126 |
+
from .text import EXPRESSIONS
|
| 127 |
+
for entry in self.sound_codes:
|
| 128 |
+
if len(entry) != 2 or entry[0] not in EXPRESSIONS or entry[0].endswith("_pause>") or len(entry[1]) != self.prosody_codes \
|
| 129 |
+
or min(entry[1]) < 0 or sum(entry[1]) <= 0:
|
| 130 |
+
raise ValueError("sound_codes entries must be (sound tag, one non-negative weight per prosody code)")
|
| 131 |
|
| 132 |
def to_dict(self):
|
| 133 |
return asdict(self)
|
| 134 |
|
| 135 |
+
def architecture(self):
|
| 136 |
+
"""``to_dict`` without the playback settings: equal for weights that fit each other."""
|
| 137 |
+
return {key: value for key, value in self.to_dict().items() if key not in PLAYBACK_FIELDS}
|
| 138 |
+
|
| 139 |
@classmethod
|
| 140 |
def from_dict(cls, value):
|
| 141 |
return cls(**{**value, "speakers": tuple(value["speakers"]),
|
| 142 |
+
"unvoiced_speakers": tuple(value.get("unvoiced_speakers", ())),
|
| 143 |
+
"sound_codes": tuple((tag, tuple(weights)) for tag, weights in value.get("sound_codes", ()))})
|
| 144 |
|
| 145 |
@property
|
| 146 |
def fingerprint(self):
|
pitput/infer.py
CHANGED
|
@@ -15,6 +15,8 @@ from .model import Fiato, UtteranceTooLong
|
|
| 15 |
from .text import NothingToPronounce, frontend_fingerprint, hebrew_label, phonemize
|
| 16 |
|
| 17 |
CHECKPOINT = Path(__file__).resolve().parent.parent / "inference.pt"
|
|
|
|
|
|
|
| 18 |
# The loudest sample of the audio that ``speak_text`` and the command return.
|
| 19 |
PEAK = 0.99
|
| 20 |
NOTHING = "nothing in the text could be read (Hebrew words only)"
|
|
@@ -83,37 +85,39 @@ def limit_peak(wave, peak=PEAK):
|
|
| 83 |
return wave * (peak / loudest) if loudest > peak else wave
|
| 84 |
|
| 85 |
|
| 86 |
-
def _voice(model, phones, style, speed, pitch_shift, seed, pitch_range):
|
| 87 |
"""Phonemes -> (float waveform tensor, details): one call of the model."""
|
| 88 |
device = next(model.parameters()).device
|
| 89 |
tokens = torch.tensor([phones.ids], device=device)
|
| 90 |
stress = torch.tensor([phones.stress], device=device)
|
| 91 |
speaker = torch.tensor([model.config.speakers.index(style)], device=device)
|
| 92 |
-
audio, lengths, details = model.synthesize(tokens, stress, torch.tensor([len(phones)], device=device), speaker, speed, pitch_shift, seed,
|
|
|
|
| 93 |
if not torch.isfinite(audio).all():
|
| 94 |
raise RuntimeError("model produced non-finite audio")
|
| 95 |
return audio[0, :int(lengths[0])].cpu(), details
|
| 96 |
|
| 97 |
|
| 98 |
-
def speak(model, label, style, speed=1.0, pitch_shift=0.0, seed=0, pitch_range=
|
| 99 |
"""One utterance from a label string (``pitput.labels`` format): -> (float
|
| 100 |
waveform tensor, phonemized text, details). ``speak_text`` reads Hebrew text."""
|
| 101 |
phones = phonemize(label)
|
| 102 |
if len(phones) > model.config.max_tokens:
|
| 103 |
raise ValueError("text is too long for one utterance; speak_text splits it into sentences")
|
| 104 |
-
wave, details = _voice(model, phones, style, speed, pitch_shift, seed, pitch_range)
|
| 105 |
return wave, phones, details
|
| 106 |
|
| 107 |
|
| 108 |
-
def speak_text(model, text, style, speed=1.0, pitch_shift=0.0, seed=0, pitch_range=
|
| 109 |
"""Hebrew text of any length -> (float waveform tensor, phonemized utterances).
|
| 110 |
|
| 111 |
The text is read sentence by sentence and the audio is joined. A text that
|
| 112 |
ends without a mark gets a full stop (``finished``). A sentence too long for
|
| 113 |
one call of the model is cut after commas, then between words. ``addressee``
|
| 114 |
-
("m" or "f") sets the gender of second-person words.
|
| 115 |
-
|
| 116 |
-
|
|
|
|
| 117 |
limit = model.config.max_tokens - 12
|
| 118 |
waves, spoken = [], []
|
| 119 |
|
|
@@ -124,7 +128,7 @@ def speak_text(model, text, style, speed=1.0, pitch_shift=0.0, seed=0, pitch_ran
|
|
| 124 |
return
|
| 125 |
if len(phones) <= limit:
|
| 126 |
try:
|
| 127 |
-
wave, _ = _voice(model, phones, style, speed, pitch_shift, seed + len(waves), pitch_range)
|
| 128 |
except UtteranceTooLong:
|
| 129 |
pass
|
| 130 |
else:
|
|
@@ -156,7 +160,10 @@ def main():
|
|
| 156 |
parser.add_argument("--output", type=Path, required=True)
|
| 157 |
parser.add_argument("--speed", type=float, default=1)
|
| 158 |
parser.add_argument("--pitch-shift", type=float, default=0, help="Added to log F0 (0.058 is about one semitone)")
|
| 159 |
-
parser.add_argument("--pitch-range", type=float,
|
|
|
|
|
|
|
|
|
|
| 160 |
parser.add_argument("--device", default="cpu")
|
| 161 |
args = parser.parse_args()
|
| 162 |
import soundfile as sf
|
|
@@ -165,8 +172,8 @@ def main():
|
|
| 165 |
parser.error(f"--style must be one of {model.config.speakers}")
|
| 166 |
text = args.text if args.text is not None else args.text_file.read_text(encoding="utf-8")
|
| 167 |
try:
|
| 168 |
-
raw, spoken = speak_text(model, text, args.style, args.speed, args.pitch_shift, pitch_range=args.pitch_range,
|
| 169 |
-
addressee=args.addressee)
|
| 170 |
except NothingToPronounce:
|
| 171 |
parser.exit(1, f"{NOTHING}, so no file was written.\n")
|
| 172 |
wave = limit_peak(raw)
|
|
|
|
| 15 |
from .text import NothingToPronounce, frontend_fingerprint, hebrew_label, phonemize
|
| 16 |
|
| 17 |
CHECKPOINT = Path(__file__).resolve().parent.parent / "inference.pt"
|
| 18 |
+
# The temperature of the published samples; None plays the model's own playback settings.
|
| 19 |
+
TEMPERATURE = 0.55
|
| 20 |
# The loudest sample of the audio that ``speak_text`` and the command return.
|
| 21 |
PEAK = 0.99
|
| 22 |
NOTHING = "nothing in the text could be read (Hebrew words only)"
|
|
|
|
| 85 |
return wave * (peak / loudest) if loudest > peak else wave
|
| 86 |
|
| 87 |
|
| 88 |
+
def _voice(model, phones, style, speed, pitch_shift, seed, pitch_range, temperature=None):
|
| 89 |
"""Phonemes -> (float waveform tensor, details): one call of the model."""
|
| 90 |
device = next(model.parameters()).device
|
| 91 |
tokens = torch.tensor([phones.ids], device=device)
|
| 92 |
stress = torch.tensor([phones.stress], device=device)
|
| 93 |
speaker = torch.tensor([model.config.speakers.index(style)], device=device)
|
| 94 |
+
audio, lengths, details = model.synthesize(tokens, stress, torch.tensor([len(phones)], device=device), speaker, speed, pitch_shift, seed,
|
| 95 |
+
pitch_range, temperature=temperature)
|
| 96 |
if not torch.isfinite(audio).all():
|
| 97 |
raise RuntimeError("model produced non-finite audio")
|
| 98 |
return audio[0, :int(lengths[0])].cpu(), details
|
| 99 |
|
| 100 |
|
| 101 |
+
def speak(model, label, style, speed=1.0, pitch_shift=0.0, seed=0, pitch_range=None, temperature=TEMPERATURE):
|
| 102 |
"""One utterance from a label string (``pitput.labels`` format): -> (float
|
| 103 |
waveform tensor, phonemized text, details). ``speak_text`` reads Hebrew text."""
|
| 104 |
phones = phonemize(label)
|
| 105 |
if len(phones) > model.config.max_tokens:
|
| 106 |
raise ValueError("text is too long for one utterance; speak_text splits it into sentences")
|
| 107 |
+
wave, details = _voice(model, phones, style, speed, pitch_shift, seed, pitch_range, temperature)
|
| 108 |
return wave, phones, details
|
| 109 |
|
| 110 |
|
| 111 |
+
def speak_text(model, text, style, speed=1.0, pitch_shift=0.0, seed=0, pitch_range=None, peak=PEAK, addressee=None, temperature=TEMPERATURE):
|
| 112 |
"""Hebrew text of any length -> (float waveform tensor, phonemized utterances).
|
| 113 |
|
| 114 |
The text is read sentence by sentence and the audio is joined. A text that
|
| 115 |
ends without a mark gets a full stop (``finished``). A sentence too long for
|
| 116 |
one call of the model is cut after commas, then between words. ``addressee``
|
| 117 |
+
("m" or "f") sets the gender of second-person words. ``temperature`` and
|
| 118 |
+
``seed`` choose how varied and which delivery a model with prosody codes
|
| 119 |
+
draws (``Fiato.synthesize``). The audio is scaled down as a whole when it
|
| 120 |
+
peaks above ``peak``; ``peak=None`` returns the model's output as it is."""
|
| 121 |
limit = model.config.max_tokens - 12
|
| 122 |
waves, spoken = [], []
|
| 123 |
|
|
|
|
| 128 |
return
|
| 129 |
if len(phones) <= limit:
|
| 130 |
try:
|
| 131 |
+
wave, _ = _voice(model, phones, style, speed, pitch_shift, seed + len(waves), pitch_range, temperature)
|
| 132 |
except UtteranceTooLong:
|
| 133 |
pass
|
| 134 |
else:
|
|
|
|
| 160 |
parser.add_argument("--output", type=Path, required=True)
|
| 161 |
parser.add_argument("--speed", type=float, default=1)
|
| 162 |
parser.add_argument("--pitch-shift", type=float, default=0, help="Added to log F0 (0.058 is about one semitone)")
|
| 163 |
+
parser.add_argument("--pitch-range", type=float, help="Scale pitch movement around the utterance mean (default: the model's pitch_range; 1 = as predicted)")
|
| 164 |
+
parser.add_argument("--temperature", type=float, default=TEMPERATURE, help="How freely the delivery of each word is drawn: 0 = the most likely, "
|
| 165 |
+
"higher = livelier and more varied (default 0.55)")
|
| 166 |
+
parser.add_argument("--seed", type=int, default=0, help="Another seed gives another delivery of the same text")
|
| 167 |
parser.add_argument("--device", default="cpu")
|
| 168 |
args = parser.parse_args()
|
| 169 |
import soundfile as sf
|
|
|
|
| 172 |
parser.error(f"--style must be one of {model.config.speakers}")
|
| 173 |
text = args.text if args.text is not None else args.text_file.read_text(encoding="utf-8")
|
| 174 |
try:
|
| 175 |
+
raw, spoken = speak_text(model, text, args.style, args.speed, args.pitch_shift, args.seed, pitch_range=args.pitch_range,
|
| 176 |
+
peak=None, addressee=args.addressee, temperature=args.temperature)
|
| 177 |
except NothingToPronounce:
|
| 178 |
parser.exit(1, f"{NOTHING}, so no file was written.\n")
|
| 179 |
wave = limit_peak(raw)
|
pitput/model.py
CHANGED
|
@@ -3,9 +3,12 @@
|
|
| 3 |
All weights start random. Tensor conventions: hidden [B,T,C], frame features
|
| 4 |
[B,T], waveform [B,S]. Acoustic frame i is centred on sample ``i * hop``.
|
| 5 |
|
| 6 |
-
phoneme + stress + voice -> transformer encoder
|
|
|
|
|
|
|
| 7 |
-> repeat tokens by duration (supervised durations while training)
|
| 8 |
-> frame transformer A -> pitch / voicing / energy
|
|
|
|
| 9 |
-> frame transformer B -> filter parameters
|
| 10 |
-> harmonic pulse train (from pitch) and noise, each shaped by its
|
| 11 |
time-varying filter in the STFT domain -> 24 kHz waveform
|
|
@@ -16,12 +19,20 @@ only has to predict slowly varying spectral envelopes (complex cepstra), which
|
|
| 16 |
is what keeps the voice from sounding buzzy or unstable at this size.
|
| 17 |
"""
|
| 18 |
|
|
|
|
| 19 |
import math
|
| 20 |
import torch
|
| 21 |
from torch import nn
|
| 22 |
from torch.nn import functional as F
|
| 23 |
from .config import Config
|
| 24 |
-
from .text import PHONE_IDS, SYMBOL_TO_ID, VOWELS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
|
| 27 |
class UtteranceTooLong(ValueError):
|
|
@@ -33,6 +44,22 @@ def length_mask(lengths, size=None):
|
|
| 33 |
return torch.arange(size, device=lengths.device)[None, :] < lengths[:, None]
|
| 34 |
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
def rotary_table(size, width, device):
|
| 37 |
inverse = 1.0 / (10000 ** (torch.arange(0, width, 2, device=device, dtype=torch.float32) / width))
|
| 38 |
angle = torch.arange(size, device=device, dtype=torch.float32)[:, None] * inverse[None]
|
|
@@ -204,7 +231,11 @@ class SourceFilter(nn.Module):
|
|
| 204 |
# then the same whether it stands alone or is padded inside a batch.
|
| 205 |
return filtered(F.pad(source, (0, fft // 2)), response, fft, hop, window)[:, :source.shape[-1]]
|
| 206 |
|
| 207 |
-
def forward(self, hidden, f0, lengths, noise=None, phase=None):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 208 |
c = self.config
|
| 209 |
frames = hidden.shape[1]
|
| 210 |
samples = frames * c.hop
|
|
@@ -231,6 +262,11 @@ class SourceFilter(nn.Module):
|
|
| 231 |
# utterance's final frame must not depend on what the batch was padded with.
|
| 232 |
f0 = f0.float().gather(1, torch.minimum(torch.arange(frames, device=f0.device)[None], last))
|
| 233 |
pulses = pulse_train(f0, c.sample_rate, c.hop, c.harmonic_limit, phase) * audible
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 234 |
if noise is None:
|
| 235 |
noise = torch.randn(hidden.shape[0], samples, device=hidden.device)
|
| 236 |
wave = (self._shape(pulses, harmonic_response, c.synth_fft, c.synth_hop, self.synth_window)
|
|
@@ -238,6 +274,313 @@ class SourceFilter(nn.Module):
|
|
| 238 |
return wave * audible
|
| 239 |
|
| 240 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 241 |
class Fiato(nn.Module):
|
| 242 |
def __init__(self, config=Config()):
|
| 243 |
super().__init__()
|
|
@@ -258,6 +601,18 @@ class Fiato(nn.Module):
|
|
| 258 |
self.prosody_projection = nn.Linear(3, c.channels)
|
| 259 |
self.acoustic_stack = Stack(c, c.acoustic_layers)
|
| 260 |
self.vocoder = SourceFilter(c)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 261 |
phones = torch.zeros(c.vocab_size, dtype=torch.bool)
|
| 262 |
phones[sorted(PHONE_IDS)] = True
|
| 263 |
self.register_buffer("phone_tokens", phones, persistent=False)
|
|
@@ -276,6 +631,69 @@ class Fiato(nn.Module):
|
|
| 276 |
x = (self.tokens(tokens) + self.stress(stress) + self.voices(speakers)[:, None]) * mask[..., None]
|
| 277 |
return self.encoder(x, mask), mask
|
| 278 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 279 |
def expand(self, hidden, durations, token_mask, speakers):
|
| 280 |
"""Repeat token states by integer durations (zero is allowed for pause
|
| 281 |
tokens) and add each frame's position inside its token."""
|
|
@@ -309,6 +727,10 @@ class Fiato(nn.Module):
|
|
| 309 |
return torch.stack((prediction[..., 0].clamp(-2.0, 1.5), (prediction[..., 1] > 0).to(prediction.dtype),
|
| 310 |
prediction[..., 2].clamp(-4.5, 3.0)), dim=-1)
|
| 311 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 312 |
def decode(self, prosody_hidden, condition, frame_mask):
|
| 313 |
return self.acoustic_stack((prosody_hidden + self.prosody_projection(condition)) * frame_mask[..., None], frame_mask)
|
| 314 |
|
|
@@ -316,15 +738,31 @@ class Fiato(nn.Module):
|
|
| 316 |
c = self.config
|
| 317 |
return (c.pitch_reference_hz * torch.exp(log_f0.float())).clamp(c.f0_min, c.f0_max)
|
| 318 |
|
| 319 |
-
def predict_durations(self, hidden, mask, tokens, speed=1.0):
|
| 320 |
output = self.duration(hidden, mask).float()
|
| 321 |
frames = torch.round(torch.expm1(output[..., 0].clamp(0, math.log1p(400))) / speed).long().clamp_min(1)
|
| 322 |
# Every phoneme is audible for at least one frame. A pause-capable token
|
| 323 |
# (edge, punctuation, word boundary) lasts its predicted length when the
|
| 324 |
-
# presence logit says there is a pause, and vanishes otherwise
|
| 325 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 326 |
return torch.where(present, frames, torch.zeros_like(frames)) * mask
|
| 327 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 328 |
@staticmethod
|
| 329 |
def widen_pitch(prosody, frame_mask, pitch_range):
|
| 330 |
"""Scale the predicted pitch movement around each utterance's voiced mean.
|
|
@@ -349,28 +787,69 @@ class Fiato(nn.Module):
|
|
| 349 |
return ((2 * slow + fast) / 5 ** 0.5 * semitones * math.log(2) / 12).to(device)
|
| 350 |
|
| 351 |
@torch.inference_mode()
|
| 352 |
-
def synthesize(self, tokens, stress, lengths, speakers, speed=1.0, pitch_shift=0.0, seed=0, pitch_range=
|
| 353 |
-
voiced_vowels=True):
|
| 354 |
-
"""Free-running synthesis: predicted durations, pitch, voicing and energy.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 355 |
if not math.isfinite(speed) or not 0.25 <= speed <= 4 or not math.isfinite(pitch_shift) or not 0 <= pitch_range <= 3:
|
| 356 |
raise ValueError("speed must be between 0.25 and 4, pitch_shift finite and pitch_range between 0 and 3")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 357 |
hidden, mask = self.encode(tokens, stress, lengths, speakers)
|
| 358 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 359 |
frames, frame_mask, frame_lengths = self.expand(hidden, durations, mask, speakers)
|
| 360 |
prosody_hidden, prosody = self.predict_prosody(frames, frame_mask)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 361 |
if voiced_vowels:
|
| 362 |
# The pitch tracker missed creaky vowels in the recordings, and the
|
| 363 |
# voicing predictor learned to drop whole vowels (heard as a whispered
|
| 364 |
# word). A vowel is voiced by definition, so its frames are kept voiced,
|
| 365 |
# except in a whispering style.
|
| 366 |
-
ends = durations.cumsum(1)
|
| 367 |
-
frame = torch.arange(frames.shape[1], device=tokens.device)[None].expand(len(lengths), -1).contiguous()
|
| 368 |
-
owner = torch.searchsorted(ends, frame, right=True).clamp(max=tokens.shape[1] - 1)
|
| 369 |
vowel = self.vowel_tokens[tokens].gather(1, owner) & frame_mask & ~self.unvoiced_speakers[speakers][:, None]
|
| 370 |
prosody = torch.cat((prosody[..., :1], torch.where(vowel, prosody[..., 1].clamp_min(2.0), prosody[..., 1])[..., None],
|
| 371 |
prosody[..., 2:]), dim=-1)
|
| 372 |
prosody = self.widen_pitch(prosody, frame_mask, pitch_range)
|
| 373 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 374 |
# One noise stream per row, drawn at the row's own length, so batching or
|
| 375 |
# padding never changes a row's audio.
|
| 376 |
noise = nn.utils.rnn.pad_sequence([torch.randn(int(n) * self.config.hop, generator=torch.Generator().manual_seed(seed + row))
|
|
@@ -378,5 +857,7 @@ class Fiato(nn.Module):
|
|
| 378 |
pitch = prosody[..., 0] + pitch_shift
|
| 379 |
if pitch_jitter > 0:
|
| 380 |
pitch = pitch + self.pitch_wobble(pitch.shape, pitch_jitter, seed, pitch.device)
|
| 381 |
-
wave = self.vocoder(acoustic, self.frequency(pitch), frame_lengths, noise=noise.to(hidden.device)
|
| 382 |
-
|
|
|
|
|
|
|
|
|
| 3 |
All weights start random. Tensor conventions: hidden [B,T,C], frame features
|
| 4 |
[B,T], waveform [B,S]. Acoustic frame i is centred on sample ``i * hop``.
|
| 5 |
|
| 6 |
+
phoneme + stress + voice -> transformer encoder
|
| 7 |
+
-> + word-level prosody code (optional; sampled by the planner at inference)
|
| 8 |
+
-> duration predictor (or token lengths and pauses drawn by a small flow)
|
| 9 |
-> repeat tokens by duration (supervised durations while training)
|
| 10 |
-> frame transformer A -> pitch / voicing / energy
|
| 11 |
+
(regression, or drawn from noise by a small flow-matching transformer)
|
| 12 |
-> frame transformer B -> filter parameters
|
| 13 |
-> harmonic pulse train (from pitch) and noise, each shaped by its
|
| 14 |
time-varying filter in the STFT domain -> 24 kHz waveform
|
|
|
|
| 19 |
is what keeps the voice from sounding buzzy or unstable at this size.
|
| 20 |
"""
|
| 21 |
|
| 22 |
+
import dataclasses
|
| 23 |
import math
|
| 24 |
import torch
|
| 25 |
from torch import nn
|
| 26 |
from torch.nn import functional as F
|
| 27 |
from .config import Config
|
| 28 |
+
from .text import EXPRESSIONS, PHONE_IDS, SYMBOL_TO_ID, VOWELS
|
| 29 |
+
|
| 30 |
+
# Planner temperature when a model with prosody codes synthesizes and none is given.
|
| 31 |
+
DEFAULT_TEMPERATURE = 0.7
|
| 32 |
+
# The prosody flow's temperature inside sound tags (laugh, sigh ...): a lower one pulls a
|
| 33 |
+
# laugh's bursts toward a flat, quiet average (measured on try 3: -2.5 dB peak at 0.7, +6.4 at 1.0).
|
| 34 |
+
SOUND_TEMPERATURE = 1.0
|
| 35 |
+
SOUNDS = tuple(tag for tag in EXPRESSIONS if not tag.endswith("_pause>"))
|
| 36 |
|
| 37 |
|
| 38 |
class UtteranceTooLong(ValueError):
|
|
|
|
| 44 |
return torch.arange(size, device=lengths.device)[None, :] < lengths[:, None]
|
| 45 |
|
| 46 |
|
| 47 |
+
def frame_owner(durations, frames):
|
| 48 |
+
"""Token index of every frame [B, frames]; frames past an utterance's end belong to its last token."""
|
| 49 |
+
ends = durations.cumsum(1)
|
| 50 |
+
frame = torch.arange(frames, device=durations.device)[None].expand(len(durations), -1).contiguous()
|
| 51 |
+
return torch.searchsorted(ends, frame, right=True).clamp(max=durations.shape[1] - 1)
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
def pool(values, index, size, mask):
|
| 55 |
+
"""Mean of ``values`` [B,N,C] per group ``index`` [B,N] (``size`` groups) over ``mask`` [B,N] -> [B,size,C]."""
|
| 56 |
+
weight = mask.to(values.dtype)[..., None]
|
| 57 |
+
total = values.new_zeros(values.shape[0], size, values.shape[-1])
|
| 58 |
+
total = total.scatter_add(1, index[..., None].expand(-1, -1, values.shape[-1]), values * weight)
|
| 59 |
+
count = values.new_zeros(values.shape[0], size, 1).scatter_add(1, index[..., None], weight)
|
| 60 |
+
return total / count.clamp_min(1)
|
| 61 |
+
|
| 62 |
+
|
| 63 |
def rotary_table(size, width, device):
|
| 64 |
inverse = 1.0 / (10000 ** (torch.arange(0, width, 2, device=device, dtype=torch.float32) / width))
|
| 65 |
angle = torch.arange(size, device=device, dtype=torch.float32)[:, None] * inverse[None]
|
|
|
|
| 231 |
# then the same whether it stands alone or is padded inside a batch.
|
| 232 |
return filtered(F.pad(source, (0, fft // 2)), response, fft, hop, window)[:, :source.shape[-1]]
|
| 233 |
|
| 234 |
+
def forward(self, hidden, f0, lengths, noise=None, phase=None, voiced=None):
|
| 235 |
+
"""``voiced`` [B, frames] (0/1) gates the pulse train, ramped between frame centres:
|
| 236 |
+
unvoiced frames (whisper, breath, sighs, voiceless consonants) then come from the noise
|
| 237 |
+
branch only. Without the gate the training drifted toward making breath noise from the
|
| 238 |
+
pulse train (try 6: 50% of whisper energy at 10K steps, 89% at 57K), a metallic comb at the pitch."""
|
| 239 |
c = self.config
|
| 240 |
frames = hidden.shape[1]
|
| 241 |
samples = frames * c.hop
|
|
|
|
| 262 |
# utterance's final frame must not depend on what the batch was padded with.
|
| 263 |
f0 = f0.float().gather(1, torch.minimum(torch.arange(frames, device=f0.device)[None], last))
|
| 264 |
pulses = pulse_train(f0, c.sample_rate, c.hop, c.harmonic_limit, phase) * audible
|
| 265 |
+
if voiced is not None:
|
| 266 |
+
gate = voiced.float().gather(1, torch.minimum(torch.arange(frames, device=voiced.device)[None], last))
|
| 267 |
+
gate = F.interpolate(F.pad(gate[:, None], (1, 1), mode="replicate"), scale_factor=c.hop, mode="linear",
|
| 268 |
+
align_corners=False)[:, 0, c.hop:c.hop + samples]
|
| 269 |
+
pulses = pulses * gate
|
| 270 |
if noise is None:
|
| 271 |
noise = torch.randn(hidden.shape[0], samples, device=hidden.device)
|
| 272 |
wave = (self._shape(pulses, harmonic_response, c.synth_fft, c.synth_hop, self.synth_window)
|
|
|
|
| 274 |
return wave * audible
|
| 275 |
|
| 276 |
|
| 277 |
+
class Quantizer(nn.Module):
|
| 278 |
+
"""Vector quantizer with a moving-average codebook. A code used far below its
|
| 279 |
+
fair share is moved onto a random current vector; on the first step every code
|
| 280 |
+
is unused, which initializes the codebook from data. No host syncs."""
|
| 281 |
+
|
| 282 |
+
def __init__(self, codes, width, decay=0.99, dead=0.03):
|
| 283 |
+
super().__init__()
|
| 284 |
+
self.decay, self.dead = decay, dead
|
| 285 |
+
self.register_buffer("codebook", torch.zeros(codes, width))
|
| 286 |
+
self.register_buffer("count", torch.zeros(codes))
|
| 287 |
+
self.register_buffer("total", torch.zeros(codes, width))
|
| 288 |
+
|
| 289 |
+
def forward(self, vectors, mask):
|
| 290 |
+
"""vectors [B,U,D], mask [B,U] -> (straight-through quantized [B,U,D], index [B,U], commitment, perplexity)."""
|
| 291 |
+
with torch.autocast(device_type=vectors.device.type, enabled=False):
|
| 292 |
+
shape = vectors.shape
|
| 293 |
+
flat = vectors.float().reshape(-1, shape[-1])
|
| 294 |
+
weight = mask.reshape(-1).float()
|
| 295 |
+
codebook = self.codebook
|
| 296 |
+
distance = flat.detach().square().sum(1, keepdim=True) - 2 * flat.detach() @ codebook.t() + codebook.square().sum(1)
|
| 297 |
+
index = distance.argmin(1)
|
| 298 |
+
quantized = codebook[index]
|
| 299 |
+
hits = F.one_hot(index, len(codebook)).float() * weight[:, None]
|
| 300 |
+
if self.training:
|
| 301 |
+
with torch.no_grad():
|
| 302 |
+
self.count.mul_(self.decay).add_(hits.sum(0), alpha=1 - self.decay)
|
| 303 |
+
self.total.mul_(self.decay).add_(hits.t() @ flat, alpha=1 - self.decay)
|
| 304 |
+
fair = self.count.mean().clamp_min(1.0)
|
| 305 |
+
dead = self.count <= self.dead * self.count.mean()
|
| 306 |
+
fresh = flat[torch.multinomial(weight + 1e-6, len(codebook), replacement=True)]
|
| 307 |
+
self.total.copy_(torch.where(dead[:, None], fresh * fair, self.total))
|
| 308 |
+
self.count.copy_(torch.where(dead, fair, self.count))
|
| 309 |
+
self.codebook.copy_(self.total / self.count.clamp_min(1e-6)[:, None])
|
| 310 |
+
used = weight.sum().clamp_min(1)
|
| 311 |
+
commitment = ((flat - quantized).square().sum(1) * weight).sum() / used
|
| 312 |
+
share = hits.sum(0) / used
|
| 313 |
+
perplexity = torch.exp(-(share * share.clamp_min(1e-10).log()).sum())
|
| 314 |
+
straight = flat + (quantized - flat).detach()
|
| 315 |
+
return straight.view(shape), index.view(shape[:-1]), commitment, perplexity
|
| 316 |
+
|
| 317 |
+
|
| 318 |
+
class Planner(nn.Module):
|
| 319 |
+
"""Autoregressive prior over the units' codes, from each unit's text state (the
|
| 320 |
+
encoder sees the whole sentence), the style and the previous unit's code."""
|
| 321 |
+
|
| 322 |
+
def __init__(self, c):
|
| 323 |
+
super().__init__()
|
| 324 |
+
width = c.planner_width
|
| 325 |
+
self.start = c.prosody_codes
|
| 326 |
+
self.text = nn.Linear(c.channels, width)
|
| 327 |
+
self.code = nn.Embedding(c.prosody_codes + 1, width)
|
| 328 |
+
self.voice = nn.Embedding(len(c.speakers), width)
|
| 329 |
+
self.rnn = nn.GRU(width, width, batch_first=True)
|
| 330 |
+
self.out = nn.Linear(width, c.prosody_codes)
|
| 331 |
+
|
| 332 |
+
def forward(self, text, codes, speakers):
|
| 333 |
+
"""Logits [B,U,codes] for every unit given the true codes before it."""
|
| 334 |
+
previous = F.pad(codes[:, :-1], (1, 0), value=self.start)
|
| 335 |
+
hidden, _ = self.rnn(self.text(text) + self.code(previous) + self.voice(speakers)[:, None])
|
| 336 |
+
return self.out(hidden)
|
| 337 |
+
|
| 338 |
+
def sample(self, text, speakers, temperature=0.0, generator=None):
|
| 339 |
+
"""Codes [B,U], one unit after the other: drawn at ``temperature`` (0 = most likely)."""
|
| 340 |
+
codes = torch.full(text.shape[:2], self.start, dtype=torch.long, device=text.device)
|
| 341 |
+
previous, state = codes[:, 0], None
|
| 342 |
+
for unit in range(text.shape[1]):
|
| 343 |
+
step = self.text(text[:, unit]) + self.code(previous) + self.voice(speakers)
|
| 344 |
+
hidden, state = self.rnn(step[:, None], state)
|
| 345 |
+
logits = self.out(hidden[:, 0]).float()
|
| 346 |
+
if temperature > 0:
|
| 347 |
+
probability = torch.softmax(logits / temperature, -1).cpu()
|
| 348 |
+
previous = torch.multinomial(probability, 1, generator=generator)[:, 0].to(text.device)
|
| 349 |
+
else:
|
| 350 |
+
previous = logits.argmax(-1)
|
| 351 |
+
codes[:, unit] = previous
|
| 352 |
+
return codes
|
| 353 |
+
|
| 354 |
+
|
| 355 |
+
class WordFlow(nn.Module):
|
| 356 |
+
"""The codes of all units of a sentence drawn from noise at once (rectified flow),
|
| 357 |
+
in place of the planner.
|
| 358 |
+
|
| 359 |
+
The planner guesses one unit after the other from the units before it. It learned
|
| 360 |
+
little (about a fifth of the recorded codes; on try 4 the word melody it drew
|
| 361 |
+
correlated 0.31 with the recording's, against 0.85 with the recorded codes). Here
|
| 362 |
+
all units move together, each seeing the whole sentence, so a phrase's melody is
|
| 363 |
+
planned as a whole. A drawn vector snaps to the nearest codebook entry: the rest of
|
| 364 |
+
the model only knows those."""
|
| 365 |
+
|
| 366 |
+
def __init__(self, c):
|
| 367 |
+
super().__init__()
|
| 368 |
+
width = c.word_flow_channels
|
| 369 |
+
self.context = nn.Linear(c.channels, width)
|
| 370 |
+
self.voice = nn.Embedding(len(c.speakers), width)
|
| 371 |
+
self.value = nn.Linear(c.code_width, width)
|
| 372 |
+
self.time = nn.Sequential(nn.Linear(width, width), nn.GELU(), nn.Linear(width, width))
|
| 373 |
+
self.stack = Stack(dataclasses.replace(c, channels=width, heads=c.flow_heads, feedforward=2 * width), c.word_flow_layers)
|
| 374 |
+
self.out = nn.Linear(width, c.code_width)
|
| 375 |
+
# The codebook's centre and spread: flow space has codes at about unit scale.
|
| 376 |
+
self.register_buffer("center", torch.zeros(c.code_width))
|
| 377 |
+
self.register_buffer("scale", torch.ones(()))
|
| 378 |
+
self.register_buffer("frequencies", torch.exp(-math.log(10000.0) * torch.arange(width // 2) / (width // 2)), persistent=False)
|
| 379 |
+
|
| 380 |
+
@torch.no_grad()
|
| 381 |
+
def fit_codebook(self, codebook):
|
| 382 |
+
self.center.copy_(codebook.float().mean(0))
|
| 383 |
+
self.scale.copy_((codebook.float() - self.center).std().clamp_min(1e-6))
|
| 384 |
+
|
| 385 |
+
def forward(self, x, t, text, speakers, mask):
|
| 386 |
+
"""Velocity [B,U,D] at the points ``x`` (flow space) and times ``t`` [B] in [0, 1]."""
|
| 387 |
+
angle = 1000 * t.float()[:, None] * self.frequencies[None]
|
| 388 |
+
time = self.time(torch.cat((angle.sin(), angle.cos()), -1).to(text.dtype))
|
| 389 |
+
h = self.context(text) + self.voice(speakers)[:, None] + self.value(x.to(text.dtype)) + time[:, None]
|
| 390 |
+
return self.out(self.stack(h * mask[..., None], mask)) * mask[..., None]
|
| 391 |
+
|
| 392 |
+
def errors(self, text, speakers, target, mask):
|
| 393 |
+
"""Squared velocity error per unit [B,U] at a random time per sentence; ``target`` are code vectors [B,U,D]."""
|
| 394 |
+
x1 = (target.float() - self.center) / self.scale
|
| 395 |
+
x0 = torch.randn_like(x1)
|
| 396 |
+
t = torch.rand(len(x1), device=x1.device)
|
| 397 |
+
return (self(x0 + t[:, None, None] * (x1 - x0), t, text, speakers, mask).float() - (x1 - x0)).square().mean(-1)
|
| 398 |
+
|
| 399 |
+
def sample(self, text, speakers, mask, codebook, steps, noise):
|
| 400 |
+
"""Code indices [B,U], integrated in ``steps`` Euler steps from ``noise`` [B,U,D] (standard normal times a temperature)."""
|
| 401 |
+
x = noise.float()
|
| 402 |
+
for step in range(steps):
|
| 403 |
+
t = torch.full((len(x),), step / steps, device=x.device)
|
| 404 |
+
x = x + self(x, t, text, speakers, mask).float() / steps
|
| 405 |
+
drawn = x * self.scale + self.center
|
| 406 |
+
distance = drawn.square().sum(-1, keepdim=True) - 2 * drawn @ codebook.float().t() + codebook.float().square().sum(1)
|
| 407 |
+
return distance.argmin(-1) * mask
|
| 408 |
+
|
| 409 |
+
|
| 410 |
+
class ProsodyCodes(nn.Module):
|
| 411 |
+
"""How each unit (a word with the pause tokens after it, or an expression tag)
|
| 412 |
+
is delivered, as one of ``prosody_codes`` learned codes.
|
| 413 |
+
|
| 414 |
+
In training the codes come from the recording (``ProsodyReference``, training
|
| 415 |
+
only), so the duration, pause, pitch and energy predictors learn to follow a
|
| 416 |
+
committed delivery instead of averaging every delivery of similar text; the
|
| 417 |
+
planner learns to predict them from the text. At inference the planner samples
|
| 418 |
+
them. A code reaches the model as a vector added to its unit's token states."""
|
| 419 |
+
|
| 420 |
+
def __init__(self, c):
|
| 421 |
+
super().__init__()
|
| 422 |
+
self.quantizer = Quantizer(c.prosody_codes, c.code_width)
|
| 423 |
+
self.planner = WordFlow(c) if c.word_flow_layers else Planner(c)
|
| 424 |
+
self.projection = nn.Linear(c.code_width, c.channels)
|
| 425 |
+
|
| 426 |
+
def attach(self, hidden, vectors, unit, token_mask):
|
| 427 |
+
spread = vectors.gather(1, unit[..., None].expand(-1, -1, vectors.shape[-1]))
|
| 428 |
+
return hidden + self.projection(spread.to(hidden.dtype)) * token_mask[..., None]
|
| 429 |
+
|
| 430 |
+
|
| 431 |
+
class ProsodyReference(nn.Module):
|
| 432 |
+
"""Training only: the recorded delivery of every unit as a vector, from its
|
| 433 |
+
durations, pitch, voicing and energy, next to its text state (so a code can
|
| 434 |
+
say how this word differs from the usual reading of such a word)."""
|
| 435 |
+
|
| 436 |
+
def __init__(self, c, width=64):
|
| 437 |
+
super().__init__()
|
| 438 |
+
self.tokens = nn.Linear(3, width)
|
| 439 |
+
self.frames = nn.Linear(4, width)
|
| 440 |
+
self.conv = nn.Conv1d(width, width, 5, padding=2)
|
| 441 |
+
self.text = nn.Linear(c.channels, width)
|
| 442 |
+
self.out = nn.Sequential(nn.Linear(3 * width, 128), nn.GELU(), nn.Linear(128, c.code_width))
|
| 443 |
+
|
| 444 |
+
def forward(self, text, unit, token_mask, phone, durations, prosody, trusted):
|
| 445 |
+
count = text.shape[1]
|
| 446 |
+
logged = torch.log1p(durations.float())
|
| 447 |
+
tokens = torch.stack((logged * phone, logged * (token_mask & ~phone), phone.float()), -1)
|
| 448 |
+
token_part = pool(F.gelu(self.tokens(tokens)), unit, count, token_mask)
|
| 449 |
+
frames = prosody.shape[1]
|
| 450 |
+
frame_mask = length_mask(durations.sum(1), frames)
|
| 451 |
+
frame_unit = unit.gather(1, frame_owner(durations, frames))
|
| 452 |
+
x = torch.cat((prosody.float(), trusted.float()[..., None]), -1) * frame_mask[..., None]
|
| 453 |
+
x = F.gelu(self.frames(x)) * frame_mask[..., None]
|
| 454 |
+
x = F.gelu(self.conv(x.transpose(1, 2)).transpose(1, 2))
|
| 455 |
+
frame_part = pool(x, frame_unit, count, frame_mask)
|
| 456 |
+
return self.out(torch.cat((F.gelu(self.text(text)), token_part.to(text.dtype), frame_part.to(text.dtype)), -1))
|
| 457 |
+
|
| 458 |
+
|
| 459 |
+
class ProsodyFlow(nn.Module):
|
| 460 |
+
"""Pitch, voicing and energy of every frame, drawn from noise (rectified flow).
|
| 461 |
+
|
| 462 |
+
The regression head gives a frame the average of every recorded delivery of
|
| 463 |
+
such a frame. Where deliveries differ in shape the average is none of them:
|
| 464 |
+
the bursts of a laugh fall somewhere else in every recording and average to a
|
| 465 |
+
flat hiss, and pitch movement flattens. This transformer learns the velocity
|
| 466 |
+
that carries Gaussian noise along a straight line to the recorded contour;
|
| 467 |
+
integrating it from fresh noise draws one contour. All frames move together,
|
| 468 |
+
so the contour is coherent over time."""
|
| 469 |
+
|
| 470 |
+
# Brings log pitch to a spread of about one, like voicing (as -1/+1) and normalized energy.
|
| 471 |
+
PITCH_SCALE = 0.3
|
| 472 |
+
|
| 473 |
+
def __init__(self, c):
|
| 474 |
+
super().__init__()
|
| 475 |
+
width = c.flow_channels
|
| 476 |
+
self.context = nn.Linear(c.channels, width)
|
| 477 |
+
self.value = nn.Linear(3, width)
|
| 478 |
+
self.time = nn.Sequential(nn.Linear(width, width), nn.GELU(), nn.Linear(width, width))
|
| 479 |
+
self.stack = Stack(dataclasses.replace(c, channels=width, heads=c.flow_heads, feedforward=3 * width), c.flow_layers)
|
| 480 |
+
self.out = nn.Linear(width, 3)
|
| 481 |
+
self.register_buffer("frequencies", torch.exp(-math.log(10000.0) * torch.arange(width // 2) / (width // 2)), persistent=False)
|
| 482 |
+
|
| 483 |
+
@classmethod
|
| 484 |
+
def normalize(cls, prosody):
|
| 485 |
+
"""Recorded prosody (continuous log pitch, voiced 0/1, normalized energy) -> flow space."""
|
| 486 |
+
return torch.stack((prosody[..., 0] / cls.PITCH_SCALE, 2 * prosody[..., 1] - 1, prosody[..., 2]), -1)
|
| 487 |
+
|
| 488 |
+
@classmethod
|
| 489 |
+
def denormalize(cls, x):
|
| 490 |
+
"""Flow space -> the regression head's format: log pitch, a voicing logit (> 0 is voiced), energy."""
|
| 491 |
+
return torch.stack((x[..., 0] * cls.PITCH_SCALE, 4 * x[..., 1], x[..., 2]), -1)
|
| 492 |
+
|
| 493 |
+
def forward(self, x, t, context, mask):
|
| 494 |
+
"""Velocity [B,T,3] at the points ``x`` [B,T,3] (flow space) and times ``t`` [B] in [0, 1]."""
|
| 495 |
+
angle = 1000 * t.float()[:, None] * self.frequencies[None]
|
| 496 |
+
time = self.time(torch.cat((angle.sin(), angle.cos()), -1).to(context.dtype))
|
| 497 |
+
h = self.context(context) + self.value(x.to(context.dtype)) + time[:, None]
|
| 498 |
+
return self.out(self.stack(h * mask[..., None], mask)) * mask[..., None]
|
| 499 |
+
|
| 500 |
+
def errors(self, context, target, mask, trusted, untrusted=0.1):
|
| 501 |
+
"""Squared velocity error per frame [B,T] at a random time per utterance.
|
| 502 |
+
Pitch counts fully where it was measured, and ``untrusted`` times on the
|
| 503 |
+
interpolated stretches. The decoder learns from the recorded contour, whose
|
| 504 |
+
pitch is the interpolation there (a constant for a whispered clip); a flow that
|
| 505 |
+
draws loose pitch on those frames feeds the decoder something it never saw."""
|
| 506 |
+
x1 = self.normalize(target.float())
|
| 507 |
+
x0 = torch.randn_like(x1)
|
| 508 |
+
t = torch.rand(len(x1), device=x1.device)
|
| 509 |
+
error = (self(x0 + t[:, None, None] * (x1 - x0), t, context, mask).float() - (x1 - x0)).square()
|
| 510 |
+
return (error[..., 0] * (trusted + untrusted * (1 - trusted)) + error[..., 1] + error[..., 2]) / 3
|
| 511 |
+
|
| 512 |
+
def sample(self, context, mask, steps, noise):
|
| 513 |
+
"""One contour per row in the regression head's format, integrated in
|
| 514 |
+
``steps`` Euler steps from ``noise`` [B,T,3] (standard normal times a
|
| 515 |
+
temperature; zero noise gives the same contour every time)."""
|
| 516 |
+
x = noise.float()
|
| 517 |
+
for step in range(steps):
|
| 518 |
+
t = torch.full((len(x),), step / steps, device=x.device)
|
| 519 |
+
x = x + self(x, t, context, mask).float() / steps
|
| 520 |
+
return self.denormalize(x) * mask[..., None]
|
| 521 |
+
|
| 522 |
+
|
| 523 |
+
class DurationFlow(nn.Module):
|
| 524 |
+
"""Every token's length, and whether each pause-capable token (word boundary,
|
| 525 |
+
punctuation, edge, tag) has frames at all, drawn from noise for the whole
|
| 526 |
+
sentence at once (rectified flow).
|
| 527 |
+
|
| 528 |
+
The duration predictor gives a token the average length of every recorded
|
| 529 |
+
delivery of such a token, and draws each pause on its own. A speaker plans a
|
| 530 |
+
phrase's rhythm as a whole; here all of a sentence's tokens move together, so
|
| 531 |
+
lengths and pauses fit each other."""
|
| 532 |
+
|
| 533 |
+
# log(1 + frames) of tokens with frames: about this mean and spread in the training clips.
|
| 534 |
+
LOG_MEAN, LOG_SCALE = 2.0, 0.55
|
| 535 |
+
|
| 536 |
+
def __init__(self, c):
|
| 537 |
+
super().__init__()
|
| 538 |
+
width = c.duration_flow_channels
|
| 539 |
+
self.context = nn.Linear(c.channels, width)
|
| 540 |
+
self.value = nn.Linear(2, width)
|
| 541 |
+
self.time = nn.Sequential(nn.Linear(width, width), nn.GELU(), nn.Linear(width, width))
|
| 542 |
+
self.stack = Stack(dataclasses.replace(c, channels=width, heads=c.flow_heads, feedforward=2 * width), c.duration_flow_layers)
|
| 543 |
+
self.out = nn.Linear(width, 2)
|
| 544 |
+
self.register_buffer("frequencies", torch.exp(-math.log(10000.0) * torch.arange(width // 2) / (width // 2)), persistent=False)
|
| 545 |
+
|
| 546 |
+
@classmethod
|
| 547 |
+
def normalize(cls, durations):
|
| 548 |
+
"""Frames per token -> flow space: (normalized log(1 + frames), presence as -1/+1)."""
|
| 549 |
+
present = durations > 0
|
| 550 |
+
logged = (torch.log1p(durations.float()) - cls.LOG_MEAN) / cls.LOG_SCALE
|
| 551 |
+
return torch.stack((torch.where(present, logged, torch.zeros_like(logged)), 2 * present.float() - 1), -1)
|
| 552 |
+
|
| 553 |
+
@classmethod
|
| 554 |
+
def frames(cls, x, phone, speed=1.0):
|
| 555 |
+
"""Flow space -> frames per token: a phone always lasts at least one frame, any other token only if present."""
|
| 556 |
+
logged = (x[..., 0].float() * cls.LOG_SCALE + cls.LOG_MEAN).clamp(0, math.log1p(400))
|
| 557 |
+
frames = torch.round(torch.expm1(logged) / speed).long().clamp_min(1)
|
| 558 |
+
return torch.where(phone | (x[..., 1] > 0), frames, torch.zeros_like(frames))
|
| 559 |
+
|
| 560 |
+
def forward(self, x, t, context, mask):
|
| 561 |
+
"""Velocity [B,N,2] at the points ``x`` (flow space) and times ``t`` [B] in [0, 1]."""
|
| 562 |
+
angle = 1000 * t.float()[:, None] * self.frequencies[None]
|
| 563 |
+
time = self.time(torch.cat((angle.sin(), angle.cos()), -1).to(context.dtype))
|
| 564 |
+
h = self.context(context) + self.value(x.to(context.dtype)) + time[:, None]
|
| 565 |
+
return self.out(self.stack(h * mask[..., None], mask)) * mask[..., None]
|
| 566 |
+
|
| 567 |
+
def errors(self, context, durations, mask, phone):
|
| 568 |
+
"""Squared velocity error per token at a random time per utterance; a phone's presence is given."""
|
| 569 |
+
x1 = self.normalize(durations)
|
| 570 |
+
x0 = torch.randn_like(x1)
|
| 571 |
+
t = torch.rand(len(x1), device=x1.device)
|
| 572 |
+
error = (self(x0 + t[:, None, None] * (x1 - x0), t, context, mask).float() - (x1 - x0)).square()
|
| 573 |
+
return error[..., 0] + error[..., 1] * (~phone).float()
|
| 574 |
+
|
| 575 |
+
def sample(self, context, mask, steps, noise):
|
| 576 |
+
"""Flow-space values [B,N,2] integrated in ``steps`` Euler steps from ``noise`` (standard normal times a temperature)."""
|
| 577 |
+
x = noise.float()
|
| 578 |
+
for step in range(steps):
|
| 579 |
+
t = torch.full((len(x),), step / steps, device=x.device)
|
| 580 |
+
x = x + self(x, t, context, mask).float() / steps
|
| 581 |
+
return x * mask[..., None]
|
| 582 |
+
|
| 583 |
+
|
| 584 |
class Fiato(nn.Module):
|
| 585 |
def __init__(self, config=Config()):
|
| 586 |
super().__init__()
|
|
|
|
| 601 |
self.prosody_projection = nn.Linear(3, c.channels)
|
| 602 |
self.acoustic_stack = Stack(c, c.acoustic_layers)
|
| 603 |
self.vocoder = SourceFilter(c)
|
| 604 |
+
if c.prosody_codes:
|
| 605 |
+
self.codes = ProsodyCodes(c)
|
| 606 |
+
if c.flow_layers:
|
| 607 |
+
self.flow = ProsodyFlow(c)
|
| 608 |
+
if c.duration_flow_layers:
|
| 609 |
+
self.duration_flow = DurationFlow(c)
|
| 610 |
+
expressions = torch.zeros(c.vocab_size, dtype=torch.bool)
|
| 611 |
+
expressions[[SYMBOL_TO_ID[e] for e in EXPRESSIONS]] = True
|
| 612 |
+
self.register_buffer("expression_tokens", expressions, persistent=False)
|
| 613 |
+
sounds = torch.zeros(c.vocab_size, dtype=torch.bool)
|
| 614 |
+
sounds[[SYMBOL_TO_ID[s] for s in SOUNDS]] = True
|
| 615 |
+
self.register_buffer("sound_tokens", sounds, persistent=False)
|
| 616 |
phones = torch.zeros(c.vocab_size, dtype=torch.bool)
|
| 617 |
phones[sorted(PHONE_IDS)] = True
|
| 618 |
self.register_buffer("phone_tokens", phones, persistent=False)
|
|
|
|
| 631 |
x = (self.tokens(tokens) + self.stress(stress) + self.voices(speakers)[:, None]) * mask[..., None]
|
| 632 |
return self.encoder(x, mask), mask
|
| 633 |
|
| 634 |
+
def units(self, tokens, mask):
|
| 635 |
+
"""Unit of every token [B,N] and the unit mask [B,U]. A unit is a word with the
|
| 636 |
+
pause tokens after it, or an expression tag with those after it; unit 0 holds
|
| 637 |
+
what comes before the first of them (BOS)."""
|
| 638 |
+
phone = self.phone_tokens[tokens] & mask
|
| 639 |
+
before = torch.cat((torch.zeros_like(phone[:, :1]), phone[:, :-1]), 1)
|
| 640 |
+
start = (phone & ~before) | (self.expression_tokens[tokens] & mask)
|
| 641 |
+
start[:, 0] = True
|
| 642 |
+
unit = (start.long().cumsum(1) - 1) * mask
|
| 643 |
+
return unit, length_mask(unit.amax(1) + 1)
|
| 644 |
+
|
| 645 |
+
def text_units(self, hidden, tokens, mask):
|
| 646 |
+
"""Units and each unit's mean text state (detached: the planner and the
|
| 647 |
+
reference encoder read the encoder, they do not train it)."""
|
| 648 |
+
unit, unit_mask = self.units(tokens, mask)
|
| 649 |
+
return unit, unit_mask, pool(hidden.detach(), unit, unit_mask.shape[1], mask)
|
| 650 |
+
|
| 651 |
+
def planned_codes(self, hidden, tokens, mask, speakers, temperature=0.0, generator=None, sound_temperature=None, sound_codes=False):
|
| 652 |
+
"""Token states with the planner's codes added, and the codes [B,U]. With the word
|
| 653 |
+
flow, sound-tag units are drawn at ``sound_temperature`` (default: ``temperature``).
|
| 654 |
+
With ``sound_codes`` and a ``Config.sound_codes`` table, sound-tag units take a code
|
| 655 |
+
drawn from their tag's weights instead."""
|
| 656 |
+
unit, unit_mask, text = self.text_units(hidden, tokens, mask)
|
| 657 |
+
scale = temperature
|
| 658 |
+
if sound_temperature is not None and self.config.word_flow_layers:
|
| 659 |
+
sound = torch.zeros(unit_mask.shape, device=tokens.device)
|
| 660 |
+
sound = sound.scatter_reduce(1, unit, (self.sound_tokens[tokens] & mask).float(), "amax") > 0
|
| 661 |
+
scale = torch.where(sound, sound_temperature, temperature)
|
| 662 |
+
index = self.plan(text, unit_mask, speakers, scale, generator)
|
| 663 |
+
if sound_codes and self.config.sound_codes:
|
| 664 |
+
index = self.sound_unit_codes(index, tokens, mask, unit, generator)
|
| 665 |
+
return self.codes.attach(hidden, self.codes.quantizer.codebook[index], unit, mask), index
|
| 666 |
+
|
| 667 |
+
def unit_tags(self, tokens, mask, unit, units):
|
| 668 |
+
"""The sound tag of every unit [B,U] (its token id; 0 for other units)."""
|
| 669 |
+
sound = (self.sound_tokens[tokens] & mask).long()
|
| 670 |
+
return torch.zeros(len(tokens), units, dtype=torch.long, device=tokens.device).scatter_reduce(1, unit, tokens * sound, "amax")
|
| 671 |
+
|
| 672 |
+
def sound_unit_codes(self, index, tokens, mask, unit, generator=None):
|
| 673 |
+
"""``index`` [B,U] with each sound-tag unit's code drawn from ``Config.sound_codes``."""
|
| 674 |
+
table = torch.zeros(self.config.vocab_size, self.config.prosody_codes)
|
| 675 |
+
for tag, weights in self.config.sound_codes:
|
| 676 |
+
table[SYMBOL_TO_ID[tag]] = torch.tensor(weights, dtype=torch.float)
|
| 677 |
+
rows = table[self.unit_tags(tokens, mask, unit, index.shape[1]).cpu()]
|
| 678 |
+
chosen = rows.sum(-1) > 0
|
| 679 |
+
if not bool(chosen.any()):
|
| 680 |
+
return index
|
| 681 |
+
index = index.clone()
|
| 682 |
+
index[chosen.to(index.device)] = torch.multinomial(rows[chosen], 1, generator=generator)[:, 0].to(index.device)
|
| 683 |
+
return index
|
| 684 |
+
|
| 685 |
+
def plan(self, text, unit_mask, speakers, temperature=0.0, generator=None):
|
| 686 |
+
"""Codes [B,U] for the units' text states, by the word flow (noise times ``temperature``,
|
| 687 |
+
a number or one per unit [B,U]) or the planner."""
|
| 688 |
+
if not self.config.word_flow_layers:
|
| 689 |
+
return self.codes.planner.sample(text, speakers, temperature, generator)
|
| 690 |
+
noise = torch.randn(*text.shape[:2], self.config.code_width, generator=generator).to(text.device)
|
| 691 |
+
if torch.is_tensor(temperature):
|
| 692 |
+
noise = noise * temperature[..., None].to(noise.dtype)
|
| 693 |
+
else:
|
| 694 |
+
noise = noise * temperature
|
| 695 |
+
return self.codes.planner.sample(text, speakers, unit_mask, self.codes.quantizer.codebook, self.config.flow_steps, noise)
|
| 696 |
+
|
| 697 |
def expand(self, hidden, durations, token_mask, speakers):
|
| 698 |
"""Repeat token states by integer durations (zero is allowed for pause
|
| 699 |
tokens) and add each frame's position inside its token."""
|
|
|
|
| 727 |
return torch.stack((prediction[..., 0].clamp(-2.0, 1.5), (prediction[..., 1] > 0).to(prediction.dtype),
|
| 728 |
prediction[..., 2].clamp(-4.5, 3.0)), dim=-1)
|
| 729 |
|
| 730 |
+
def pulse_gate(self, voicing):
|
| 731 |
+
"""The vocoder's ``voiced`` argument for a 0/1 voicing channel [B,T] (None: no gate)."""
|
| 732 |
+
return voicing if self.config.voiced_pulses else None
|
| 733 |
+
|
| 734 |
def decode(self, prosody_hidden, condition, frame_mask):
|
| 735 |
return self.acoustic_stack((prosody_hidden + self.prosody_projection(condition)) * frame_mask[..., None], frame_mask)
|
| 736 |
|
|
|
|
| 738 |
c = self.config
|
| 739 |
return (c.pitch_reference_hz * torch.exp(log_f0.float())).clamp(c.f0_min, c.f0_max)
|
| 740 |
|
| 741 |
+
def predict_durations(self, hidden, mask, tokens, speed=1.0, temperature=0.0, generator=None):
|
| 742 |
output = self.duration(hidden, mask).float()
|
| 743 |
frames = torch.round(torch.expm1(output[..., 0].clamp(0, math.log1p(400))) / speed).long().clamp_min(1)
|
| 744 |
# Every phoneme is audible for at least one frame. A pause-capable token
|
| 745 |
# (edge, punctuation, word boundary) lasts its predicted length when the
|
| 746 |
+
# presence logit says there is a pause, and vanishes otherwise; with a
|
| 747 |
+
# temperature the pause is drawn with probability sigmoid(logit / temperature).
|
| 748 |
+
if temperature > 0:
|
| 749 |
+
draw = torch.rand(output.shape[:2], generator=generator).to(output.device)
|
| 750 |
+
pause = draw < torch.sigmoid(output[..., 1] / temperature)
|
| 751 |
+
else:
|
| 752 |
+
pause = output[..., 1] > 0
|
| 753 |
+
present = self.phone_tokens[tokens] | pause
|
| 754 |
return torch.where(present, frames, torch.zeros_like(frames)) * mask
|
| 755 |
|
| 756 |
+
def drawn_durations(self, hidden, mask, tokens, speed=1.0, temperature=0.0, sound_temperature=0.0, seed=0):
|
| 757 |
+
"""Frames per token drawn by the duration flow (sound tags at ``sound_temperature``),
|
| 758 |
+
from noise drawn per row at the row's own length."""
|
| 759 |
+
noise = torch.zeros(*tokens.shape, 2)
|
| 760 |
+
for row, n in enumerate(mask.sum(1).tolist()):
|
| 761 |
+
noise[row, :n] = torch.randn(n, 2, generator=torch.Generator().manual_seed(seed + 4099 + row))
|
| 762 |
+
scale = torch.where(self.sound_tokens[tokens], sound_temperature, temperature)
|
| 763 |
+
x = self.duration_flow.sample(hidden, mask, self.config.flow_steps, noise.to(hidden.device) * scale[..., None].to(hidden.device))
|
| 764 |
+
return DurationFlow.frames(x, self.phone_tokens[tokens], speed) * mask
|
| 765 |
+
|
| 766 |
@staticmethod
|
| 767 |
def widen_pitch(prosody, frame_mask, pitch_range):
|
| 768 |
"""Scale the predicted pitch movement around each utterance's voiced mean.
|
|
|
|
| 787 |
return ((2 * slow + fast) / 5 ** 0.5 * semitones * math.log(2) / 12).to(device)
|
| 788 |
|
| 789 |
@torch.inference_mode()
|
| 790 |
+
def synthesize(self, tokens, stress, lengths, speakers, speed=1.0, pitch_shift=0.0, seed=0, pitch_range=None, pitch_jitter=0.0,
|
| 791 |
+
voiced_vowels=True, temperature=None, sound_temperature=None):
|
| 792 |
+
"""Free-running synthesis: predicted durations, pitch, voicing and energy.
|
| 793 |
+
|
| 794 |
+
``temperature`` (default: DEFAULT_TEMPERATURE with prosody codes or a
|
| 795 |
+
flow, else 0) controls how freely the planner draws each word's delivery,
|
| 796 |
+
whether a pause is drawn rather than taken when likely (or the duration
|
| 797 |
+
flow's lengths and pauses), and how far the prosody flow's contour may stray
|
| 798 |
+
from its most typical one; 0 picks the most likely ones. Without a
|
| 799 |
+
``temperature`` the configuration's code_temperature and contour_temperature
|
| 800 |
+
replace it for the word codes and the contour (when not -1). Inside sound tags
|
| 801 |
+
the flows (and the word flow) draw at ``sound_temperature`` (default:
|
| 802 |
+
SOUND_TEMPERATURE or ``temperature`` if higher; 0 when ``temperature`` is 0).
|
| 803 |
+
``pitch_range`` defaults to the configuration's. ``seed`` fixes the draws as
|
| 804 |
+
well as the noise."""
|
| 805 |
+
c = self.config
|
| 806 |
+
pitch_range = c.pitch_range if pitch_range is None else pitch_range
|
| 807 |
if not math.isfinite(speed) or not 0.25 <= speed <= 4 or not math.isfinite(pitch_shift) or not 0 <= pitch_range <= 3:
|
| 808 |
raise ValueError("speed must be between 0.25 and 4, pitch_shift finite and pitch_range between 0 and 3")
|
| 809 |
+
code_temperature = contour_temperature = temperature
|
| 810 |
+
if temperature is None:
|
| 811 |
+
temperature = DEFAULT_TEMPERATURE if c.prosody_codes or c.flow_layers or c.duration_flow_layers else 0.0
|
| 812 |
+
code_temperature = temperature if c.code_temperature < 0 else c.code_temperature
|
| 813 |
+
contour_temperature = temperature if c.contour_temperature < 0 else c.contour_temperature
|
| 814 |
+
if sound_temperature is None:
|
| 815 |
+
sound_temperature = max(temperature, SOUND_TEMPERATURE) if temperature > 0 else 0.0
|
| 816 |
+
if not all(math.isfinite(t) and 0 <= t <= 3 for t in (temperature, sound_temperature)):
|
| 817 |
+
raise ValueError("temperatures must be between 0 and 3")
|
| 818 |
+
generator = torch.Generator().manual_seed(seed + 104729)
|
| 819 |
hidden, mask = self.encode(tokens, stress, lengths, speakers)
|
| 820 |
+
codes = None
|
| 821 |
+
if self.config.prosody_codes:
|
| 822 |
+
hidden, codes = self.planned_codes(hidden, tokens, mask, speakers, code_temperature, generator, sound_temperature, sound_codes=True)
|
| 823 |
+
if c.duration_flow_layers:
|
| 824 |
+
durations = self.drawn_durations(hidden, mask, tokens, speed, temperature, sound_temperature, seed)
|
| 825 |
+
else:
|
| 826 |
+
durations = self.predict_durations(hidden, mask, tokens, speed, temperature, generator)
|
| 827 |
frames, frame_mask, frame_lengths = self.expand(hidden, durations, mask, speakers)
|
| 828 |
prosody_hidden, prosody = self.predict_prosody(frames, frame_mask)
|
| 829 |
+
owner = frame_owner(durations, frames.shape[1])
|
| 830 |
+
if self.config.flow_layers:
|
| 831 |
+
# Drawn per row at the row's own length, like the oscillator noise below.
|
| 832 |
+
noise = nn.utils.rnn.pad_sequence([torch.randn(int(n), 3, generator=torch.Generator().manual_seed(seed + 31337 + row))
|
| 833 |
+
for row, n in enumerate(frame_lengths)], batch_first=True).to(prosody_hidden.device)
|
| 834 |
+
scale = torch.where(self.sound_tokens[tokens].gather(1, owner), sound_temperature, contour_temperature)
|
| 835 |
+
prosody = self.flow.sample(prosody_hidden, frame_mask, self.config.flow_steps,
|
| 836 |
+
noise * scale[..., None].to(noise.dtype)).to(prosody.dtype)
|
| 837 |
if voiced_vowels:
|
| 838 |
# The pitch tracker missed creaky vowels in the recordings, and the
|
| 839 |
# voicing predictor learned to drop whole vowels (heard as a whispered
|
| 840 |
# word). A vowel is voiced by definition, so its frames are kept voiced,
|
| 841 |
# except in a whispering style.
|
|
|
|
|
|
|
|
|
|
| 842 |
vowel = self.vowel_tokens[tokens].gather(1, owner) & frame_mask & ~self.unvoiced_speakers[speakers][:, None]
|
| 843 |
prosody = torch.cat((prosody[..., :1], torch.where(vowel, prosody[..., 1].clamp_min(2.0), prosody[..., 1])[..., None],
|
| 844 |
prosody[..., 2:]), dim=-1)
|
| 845 |
prosody = self.widen_pitch(prosody, frame_mask, pitch_range)
|
| 846 |
+
# A whispered recording has (almost) no voiced frame, so the decoder and the
|
| 847 |
+
# oscillator learned it with the reference pitch throughout; any drawn pitch
|
| 848 |
+
# there is something they never saw and comes out as an underwater flutter.
|
| 849 |
+
whispered = self.unvoiced_speakers[speakers][:, None] & (prosody[..., 1] <= 0)
|
| 850 |
+
prosody = torch.cat((torch.where(whispered, torch.zeros_like(prosody[..., 0]), prosody[..., 0])[..., None], prosody[..., 1:]), -1)
|
| 851 |
+
hard = self.hard_prosody(prosody)
|
| 852 |
+
acoustic = self.decode(prosody_hidden, hard, frame_mask)
|
| 853 |
# One noise stream per row, drawn at the row's own length, so batching or
|
| 854 |
# padding never changes a row's audio.
|
| 855 |
noise = nn.utils.rnn.pad_sequence([torch.randn(int(n) * self.config.hop, generator=torch.Generator().manual_seed(seed + row))
|
|
|
|
| 857 |
pitch = prosody[..., 0] + pitch_shift
|
| 858 |
if pitch_jitter > 0:
|
| 859 |
pitch = pitch + self.pitch_wobble(pitch.shape, pitch_jitter, seed, pitch.device)
|
| 860 |
+
wave = self.vocoder(acoustic, self.frequency(pitch), frame_lengths, noise=noise.to(hidden.device),
|
| 861 |
+
voiced=self.pulse_gate(hard[..., 1]))
|
| 862 |
+
return wave, frame_lengths * self.config.hop, {"durations": durations, "prosody": prosody, "frame_mask": frame_mask,
|
| 863 |
+
"codes": codes}
|
recipe.json
CHANGED
|
@@ -14,11 +14,14 @@
|
|
| 14 |
"crops": 2,
|
| 15 |
"teacher_hold": 3000,
|
| 16 |
"teacher_ramp": 7000,
|
| 17 |
-
"teacher_final":
|
| 18 |
"subset": null,
|
| 19 |
"validation_size": 32,
|
| 20 |
"seed": 20261113,
|
| 21 |
"voiced_vowel_targets": true,
|
|
|
|
|
|
|
|
|
|
| 22 |
"weights": {
|
| 23 |
"duration": 1.0,
|
| 24 |
"pause": 1.0,
|
|
@@ -28,14 +31,19 @@
|
|
| 28 |
"energy": 1.0,
|
| 29 |
"mel_head": 2.0,
|
| 30 |
"stft": 2.0,
|
| 31 |
-
"mel": 10.0
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
},
|
| 33 |
"branched_from": null,
|
| 34 |
-
"annotation": "
|
| 35 |
"frontend": "d78567bd1892b2dec5a33d791fa537c1e0b0223742141cd5420335f73142fc13",
|
| 36 |
-
"train_utterances":
|
| 37 |
"datasets": [
|
| 38 |
-
"
|
| 39 |
-
"
|
| 40 |
-
]
|
|
|
|
| 41 |
}
|
|
|
|
| 14 |
"crops": 2,
|
| 15 |
"teacher_hold": 3000,
|
| 16 |
"teacher_ramp": 7000,
|
| 17 |
+
"teacher_final": 1.0,
|
| 18 |
"subset": null,
|
| 19 |
"validation_size": 32,
|
| 20 |
"seed": 20261113,
|
| 21 |
"voiced_vowel_targets": true,
|
| 22 |
+
"expression_weight": 5.0,
|
| 23 |
+
"ema_decay": 0.999,
|
| 24 |
+
"flow_untrusted_weight": 1.0,
|
| 25 |
"weights": {
|
| 26 |
"duration": 1.0,
|
| 27 |
"pause": 1.0,
|
|
|
|
| 31 |
"energy": 1.0,
|
| 32 |
"mel_head": 2.0,
|
| 33 |
"stft": 2.0,
|
| 34 |
+
"mel": 10.0,
|
| 35 |
+
"commitment": 0.25,
|
| 36 |
+
"planner": 1.0,
|
| 37 |
+
"flow": 1.0,
|
| 38 |
+
"duration_flow": 1.0
|
| 39 |
},
|
| 40 |
"branched_from": null,
|
| 41 |
+
"annotation": "dbe8c7f516e860c6f6c92f68d00c3c0f2862dc12574ebc74b474a3ba620aa6c0",
|
| 42 |
"frontend": "d78567bd1892b2dec5a33d791fa537c1e0b0223742141cd5420335f73142fc13",
|
| 43 |
+
"train_utterances": 70864,
|
| 44 |
"datasets": [
|
| 45 |
+
"38de51b54e96081b3e775be22d31e1185aebaa8eadf9e5642e3997e80a06c956",
|
| 46 |
+
"1ced508eeb0ed0c4a7c5a09590f3f17f339fc9dc8604b965ac0c3bbb30926cdd"
|
| 47 |
+
],
|
| 48 |
+
"step": 46000
|
| 49 |
}
|
samples/01-default.wav
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6370797bd60fe8cce3b7bd5e9687e8664e1370f0e1d05e80f47211c42ed74992
|
| 3 |
+
size 360492
|
samples/02-default.wav
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d7631e69ddaeb6176a2d39a5e5b144c42086c169a9dc20e8ff643a29fde6b5e5
|
| 3 |
+
size 223276
|
samples/03-default.wav
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0a3ffea70f20e4c0a270c9f39b77b449fd69dff459a86b055c2cdd0eb24e582c
|
| 3 |
+
size 297516
|
samples/04-excited.wav
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:68d7c9a7f6be4d9b6aa18beadcd81df749df19822a674b1f4c9b46993f0ae9ec
|
| 3 |
+
size 179244
|
samples/05-sad.wav
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5022376d684a7d60c7dab75e69e5b5d5ec6b25462d9dc1582daa5c61131cd9df
|
| 3 |
+
size 221740
|
samples/06-angry.wav
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2e17679ecb2e917b6136ce27ee1513087996e4edddbe0e903b6f1c55c9bbce3f
|
| 3 |
+
size 177708
|
samples/07-fearful.wav
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fbfdbbf494e5a15c4df00a9fa529a04b2395350bac3c55495c824e8236a66cd6
|
| 3 |
+
size 175148
|
samples/08-surprised.wav
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9983284bdd310adfa33c28834acafa9f0770ecbc41e814061d927119e09ec201
|
| 3 |
+
size 270892
|
samples/09-calm.wav
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fd9ad6d312af40c999296fb0f5058128e40295b75efe2794d6a4c5cb32c282fa
|
| 3 |
+
size 289324
|
samples/10-whisper.wav
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:446062faf651bcd2c5e797c1b481841fa223184bde0948bf22612bdf9a1974de
|
| 3 |
+
size 165420
|