mmmhusto commited on
Commit
f712b8a
·
verified ·
1 Parent(s): 0c8ca44

v2.3: the two-voice model (former English Duo) as the base model; new fast decoder and Vocos; measured cloning and voice fine-tuning

Browse files
.gitattributes CHANGED
@@ -33,3 +33,9 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ samples/fast_vocos_story_92.wav filter=lfs diff=lfs merge=lfs -text
37
+ samples/numbers_92.wav filter=lfs diff=lfs merge=lfs -text
38
+ samples/story_92.wav filter=lfs diff=lfs merge=lfs -text
39
+ samples/story_dt0.wav filter=lfs diff=lfs merge=lfs -text
40
+ samples/talk_92_conversational.wav filter=lfs diff=lfs merge=lfs -text
41
+ samples/talk_dt0.wav filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,58 +1,183 @@
1
  ---
 
2
  language:
3
  - en
4
- - sk
5
- license: cc-by-sa-4.0
6
  pipeline_tag: text-to-speech
 
7
  tags:
8
  - text-to-speech
9
- - onnx
10
- - bilingual
 
 
 
 
 
 
11
  ---
12
 
13
- # TTS English, Slovak by husto
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
- ## Versions
 
 
 
 
16
 
17
- One repository, one model line. `main` is always the newest version; every release has a tag.
18
 
19
- | Version | What changed | Download |
20
  |---|---|---|
21
- | v1.0 | English base model: 590 voices, two speaking styles, fast mode, voice cloning (internal name v2.3) | `hf download mmmhusto/TTS-husto --revision v1.0` |
22
- | v2.0 | Fine-tune of v1.0 on two voices: Studio 92 (Cori Samuel) and DailyTalk man | `hf download mmmhusto/TTS-husto --revision v2.0` |
23
- | v3.0 | Fine-tune of v2.0 that adds Slovak: 5 voices (2 English, 3 Slovak), browser ONNX. Slovak is experimental. | `hf download mmmhusto/TTS-husto --revision v3.0` |
 
24
 
25
- **This page describes v3.0.**
26
 
 
27
 
28
- Bilingual SkttsV2 text-to-speech by husto. The **same acoustic weights** generate English and Slovak speech with a shared BigVGAN vocoder at 24 kHz. The five available voice profiles are:
 
 
 
 
 
 
 
 
 
29
 
30
- | Language | Voice IDs |
31
- |---|---|
32
- | English | `en_hifi_92_clean`, `en_dt_0` |
33
- | Slovak | `sk_muz`, `sk_cori`, `sk_dailytalk` |
34
 
35
- The release packages the full bilingual checkpoint from the 42M English Duo training. Slovak learning used the project's Slovak phoneme frontend, examples from Lili, SlovakSpeech and TrePal, plus English replay. The published checkpoint is the one evaluated after 2,200 additional steps with original Slovak speech. The Slovak male profile uses the speaker row fitted on SlovakSpeech Male. Slovak is experimental. In the previous evaluation of this checkpoint on 12 challenging Slovak prompts, the Cori and DailyTalk profiles had 26 and 31 transcription errors respectively out of 84 words each. Those measurements refer to the two adapted voice profiles.
 
 
 
 
36
 
37
- - `model.safetensors` and `config.json` contain the standalone five-voice acoustic model.
38
- - `vocoder/` contains the shared BigVGAN weights and config.
39
- - `web/` contains the ONNX export and English pronunciation assets for the demo.
40
- - `slovak-frontend.zip` contains the original project frontend used for Slovak phonemes.
41
 
42
- The published model uses Husto's acoustic model and voice checkpoints. [Original English Duo and source credits](https://huggingface.co/mmmhusto/TTS-husto/tree/v2.0) · [Bilingual demo](https://huggingface.co/spaces/mmmhusto/TTS-English-demo)
 
43
 
44
- ## Local synthesis
45
 
46
- With the project Python dependencies and NVIDIA BigVGAN source installed, download the repository and run:
 
 
47
 
48
- ```sh
49
- python povedz.py --jazyk sk --hlas sk_muz 'Vonku už prestalo pršať.' vystup.wav
50
- python povedz.py --jazyk en --hlas en_dt_0 'Good morning.' speech.wav
51
- ```
 
 
52
 
53
- ## Data and attribution
 
 
 
 
 
54
 
55
- - English training and BigVGAN attribution follow [English Duo](https://huggingface.co/mmmhusto/TTS-husto/tree/v2.0).
56
- - [SlovakSpeech Male](https://huggingface.co/datasets/neurlang/slovakspeech_male_dataset) and [SlovakSpeech Female](https://huggingface.co/datasets/neurlang/slovakspeech_female_dataset) by neurlang, CC BY-SA 4.0.
57
- - [Lili](https://huggingface.co/datasets/vsisik/voice-dataset-lili) from the Open Home Foundation, CC0.
58
- - [TrePal](https://huggingface.co/datasets/streams-sro/trepal), CC BY 4.0, © Národná rada Slovenskej republiky, segmentation and alignment by Streams s.r.o.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ license: cc-by-sa-4.0
3
  language:
4
  - en
 
 
5
  pipeline_tag: text-to-speech
6
+ library_name: pytorch
7
  tags:
8
  - text-to-speech
9
+ - tts
10
+ - flow-matching
11
+ - diffusion-transformer
12
+ datasets:
13
+ - mythicinfinity/libritts_r
14
+ - MikhailT/hifi-tts
15
+ - eustlb/dailytalk
16
+ - mmmhusto/sktts-en-features
17
  ---
18
 
19
+ # mmmhusto TTS English v2.3
20
+
21
+ **A small English text-to-speech model with two steady voices, a fast CPU mode and a measured recipe for adding your
22
+ own voice.** Written and trained from scratch: 42 M acoustic model + 14 M vocoder, plain PyTorch.
23
+
24
+ - **Two voices:** `en_hifi_92_clean` (Cori Samuel, studio audiobook, female, default) and `en_dt_0` (DailyTalk actor,
25
+ male, conversational).
26
+ - **Fast mode:** a distilled 2-step decoder and the built-in Vocos vocoder, about 9x faster than real time on an
27
+ Apple M1 Pro CPU, with nothing to install but `pip`.
28
+ - **Your own voice:** 5 minutes of clean speech and 7 minutes on one RTX 3080 (see "Add a voice").
29
+ - **Reads what people write:** numbers, money, times, dates, units and abbreviations are written out first.
30
+ - **Any length:** `tts.long(text)` and `tts.stream(text)` read a whole article sentence by sentence.
31
+ - **Two speaking styles:** reading and conversation (`style="conversational"`).
32
 
33
+ **What changed in v2.3.** This is the former *English Duo* model as the one base model: the 592-voice v2.3 fine-tuned
34
+ 600 steps on the two voices above (1 024 recordings each), which made both voices steadier. The 592-voice model stays
35
+ in this repo's history under the tag [`v2.3-old`](https://huggingface.co/mmmhusto/TTS-English/tree/v2.3-old)
36
+ (`snapshot_download("mmmhusto/TTS-English", revision="v2.3-old")`). The fast decoder and the Vocos vocoder were
37
+ trained again for these weights.
38
 
39
+ ## Listen
40
 
41
+ | | `en_hifi_92_clean` (default) | `en_dt_0` |
42
  |---|---|---|
43
+ | Reading a story | <audio controls preload="none" src="https://huggingface.co/mmmhusto/TTS-English/resolve/main/samples/story_92.wav"></audio> | <audio controls preload="none" src="https://huggingface.co/mmmhusto/TTS-English/resolve/main/samples/story_dt0.wav"></audio> |
44
+ | "Are you kidding me? We missed the train again?" | <audio controls preload="none" src="https://huggingface.co/mmmhusto/TTS-English/resolve/main/samples/talk_92_conversational.wav"></audio> (`style="conversational"`) | <audio controls preload="none" src="https://huggingface.co/mmmhusto/TTS-English/resolve/main/samples/talk_dt0.wav"></audio> |
45
+ | Numbers: "Dr. Smith will see you at 9:30 on March 3rd; the visit costs $45.50 ..." | <audio controls preload="none" src="https://huggingface.co/mmmhusto/TTS-English/resolve/main/samples/numbers_92.wav"></audio> | |
46
+ | The story in fast mode with Vocos (CPU) | <audio controls preload="none" src="https://huggingface.co/mmmhusto/TTS-English/resolve/main/samples/fast_vocos_story_92.wav"></audio> | |
47
 
48
+ All clips are exactly what the code below produces (seed 450, BigVGAN unless stated).
49
 
50
+ ## Quick start
51
 
52
+ ```bash
53
+ pip install torch numpy soundfile huggingface_hub safetensors g2p_en
54
+ python -c "from g2p_en import G2p; G2p()" # fetches g2p_en's NLTK data once
55
+ # for the best quality also the BigVGAN vocoder's code (MIT):
56
+ git clone https://github.com/NVIDIA/BigVGAN && pip install librosa matplotlib
57
+ ```
58
+
59
+ ```python
60
+ from huggingface_hub import snapshot_download
61
+ import sys, soundfile as sf
62
 
63
+ path = snapshot_download("mmmhusto/TTS-English")
64
+ sys.path.insert(0, path)
65
+ from tts_english import TTS, SAMPLE_RATE
 
66
 
67
+ tts = TTS.from_pretrained(path, bigvgan_dir="BigVGAN") # best quality
68
+ # tts = TTS.from_pretrained(path, vocoder="vocos", fast=True) # no BigVGAN clone, fast on a CPU
69
+ wav = tts("It was not the answer she expected; still, she thanked him and left the room.", voice="en_dt_0")
70
+ sf.write("out.wav", wav, SAMPLE_RATE)
71
+ ```
72
 
73
+ or `python infer.py "Text to speak." out.wav --voice en_dt_0` (`--fast`, `--vocoder vocos`), or a local web page with
74
+ `python app.py --bigvgan BigVGAN`.
 
 
75
 
76
+ Keyword arguments override the delivery in `config.json` (`guidance`, `length_scale`, `pause_scale`, `temperature`,
77
+ `n_timesteps`, `sentence_gap`); `seed=None` gives a different rendition every call.
78
 
79
+ ## Modes, quality and speed
80
 
81
+ 64 sentences (32 texts x 2 voices). Word errors: Whisper small.en reads the audio back. PESQ: no-reference estimate
82
+ (torchaudio SQUIM). Speed: seconds of computing per second of speech on an Apple M1 Pro CPU, 8 threads (below 1 is
83
+ faster than real time; measured while the machine did other work, so a little pessimistic).
84
 
85
+ | Mode | Word errors | PESQ | CPU time / speech time |
86
+ |---|---|---|---|
87
+ | full decoder + BigVGAN (default) | 1.9 % | **3.87** | 1.73 |
88
+ | fast decoder + BigVGAN | **1.5 %** | 3.79 | 1.54 |
89
+ | **fast decoder + Vocos** | **1.5 %** | 2.88 | **0.11** |
90
+ | full decoder + Vocos | 1.7 % | 2.94 | 0.43 |
91
 
92
+ - **The fast decoder** (`fast=True`) makes 2 passes instead of 20 (10 steps with guidance) and costs nothing
93
+ measurable. It was distilled by reflow on 13 500 sentences of the model's own output (13 000 steps on an RTX 3080).
94
+ - **On a CPU only Vocos runs faster than real time**, because BigVGAN is most of the time there. Vocos has a slight
95
+ metallic sound (PESQ 2.9 against 3.8), also on real recordings, so it comes from the vocoder, not from the model.
96
+ It was fine-tuned 20 000 steps on these weights' mels. That helped a little; the metallic sound stays.
97
+ - **On a GPU use BigVGAN.**
98
 
99
+ ## Voice cloning: a similar voice, not the person
100
+
101
+ `tts.clone_voice(wav, sample_rate, text=transcript)` turns a short recording into a voice vector in seconds. Measured
102
+ on 8 VCTK speakers the model never heard (64 sentences per row; similarity is ECAPA cosine to the speaker's own
103
+ held-out recordings: 0.75 between two real recordings of the same person, 0.10 for one of the built-in voices):
104
+
105
+ | Recording | 3 s | 5 s | 10 s | 20 s | 30 s |
106
+ |---|---|---|---|---|---|
107
+ | without transcript | 0.19 | 0.20 | 0.20 | 0.20 | 0.21 |
108
+ | with transcript (`text=`, 200 fitting steps, ~1 min on a CPU) | 0.23 | **0.26** | 0.25 | 0.24 | 0.25 |
109
+
110
+ 5 s is enough and more does not help. The clone keeps sex, pitch and roughly the colour of the voice, but someone who
111
+ knows the speaker would not recognise them. The 592-voice `v2.3-old` clones the same (0.19 and 0.24 at 10 s): the
112
+ voice encoder saw ~550 people, too few for close cloning. Word errors stay at 0 to 0.1 %.
113
+
114
+ ## Add a voice (the way that works)
115
+
116
+ Fine-tuning the model on the person's recordings makes a voice that sounds like them. Measured on 2 of the VCTK
117
+ speakers above (1 500 steps on one RTX 3080, about 7 minutes; 64 sentences per row):
118
+
119
+ | | Similarity | Word errors |
120
+ |---|---|---|
121
+ | cloning, 10 s with transcript | 0.25 | 0 % |
122
+ | **fine-tuned on 5 minutes of speech** | **0.69** | 1.7 % |
123
+ | **fine-tuned on 15 minutes of speech** | **0.72** | 1.7 % |
124
+ | the built-in voices | | 1.9 % |
125
+ | two real recordings of the same person | 0.75 | |
126
+
127
+ **Recordings:**
128
+
129
+ - **At least 5 minutes of speech**, better 15. Count only the speech, not silence or noise.
130
+ - A quiet room without echo, one microphone at a fixed 15 to 20 cm, WAV, 24 kHz or more, mono, no background noise or
131
+ music.
132
+ - One sentence per file, read naturally, varied (questions, statements, long and short), with an exact transcript of
133
+ what was said.
134
+ - **Trim the noise before the first word.** Our first try kept about 1 s of room noise and breath before each
135
+ sentence; the model then swallowed the first word in 40 % of sentences (6.7 % word errors). Trimming to 0.15 s of
136
+ silence (`librosa.effects.trim(top_db=25)`) fixed it. Check afterwards that Whisper still hears the first word of
137
+ every trimmed clip.
138
+
139
+ **Training:** build features with `python -m sktts.data.english` and fine-tune with `sktts.train.matcha`
140
+ (`--init-from` these weights, `--only-speakers <new voice>`, `--init-speakers <new voice>=en_hifi_92_clean`, lr 5e-5,
141
+ 1 500 steps); the code is in the project's training repository.
142
+
143
+ ## Architecture
144
+
145
+ All of it is in `tts_english/model.py`, plain PyTorch, no vendored code.
146
+
147
+ - **Text encoder:** six transformer layers (256 wide) with rotary positions over ARPAbet phonemes from g2p_en.
148
+ - **Alignment:** monotonic alignment search during training, no external aligner.
149
+ - **Durations:** a small flow-matching head samples the length of every phoneme and pause.
150
+ - **Decoder:** a diffusion transformer, 10 layers, 512 wide, conditional flow matching, with each frame's position
151
+ inside its phoneme; classifier-free guidance 1.5.
152
+ - **Fast decoder:** a reflow-distilled copy for 2 steps without guidance.
153
+ - **Vocoders:** BigVGAN base (14 M) and Vocos (13.5 M), both fine-tuned on this model's mels.
154
+ - **Voice encoder:** 17 MB, maps a recording to a voice vector (cloning).
155
+
156
+ ## Training
157
+
158
+ | Run | Steps | What | Hardware, time |
159
+ |---|---|---|---|
160
+ | v2-en … v2.2 | see `v2.3-old` | from scratch to 592 voices and two speaking styles | AMD MI300X, RTX 3080 |
161
+ | v2.3-old | | BigVGAN and Vocos fine-tunes, fast decoder, voice encoder | RTX 3080 |
162
+ | **v2.3 (this model)** | +600 | two voices, 1 024 recordings each | RTX 3080 |
163
+ | v2.3 Vocos | 20 000 | from the v2.3-old Vocos, on these weights' mels (HiFi-TTS + DailyTalk) | RTX 3080, 2.1 h |
164
+ | v2.3 fast decoder | 13 000 | reflow on 13 500 sentences | RTX 3080, 1.4 h |
165
+
166
+ ## Limitations
167
+
168
+ - English only, two voices, two styles; no emotions yet.
169
+ - g2p_en can mispronounce rare names and words. Number rules are American English.
170
+ - The Vocos fast mode sounds slightly metallic.
171
+ - The voices belong to real readers (HiFi-TTS, DailyTalk). Do not use them, or voices you add, to impersonate anyone or
172
+ to deceive. Add a person's voice only with their consent. Speech is not watermarked.
173
+
174
+ ## Licenses and attribution
175
+
176
+ - **This model** (weights and code): CC BY-SA 4.0, because it learned from DailyTalk (CC BY-SA 4.0).
177
+ - **Training data:** LibriTTS-R (Koizumi et al., 2023, CC BY 4.0), HiFi-TTS (Bakhturina et al., 2021, CC BY 4.0),
178
+ DailyTalk (Lee et al., ICASSP 2023, CC BY-SA 4.0). The voice tests used VCTK (Yamagishi et al., CC BY 4.0), which the
179
+ published model did not learn from.
180
+ - **Vocoders:** NVIDIA BigVGAN (Lee et al., 2023), MIT: `vocoder/bigvgan_finetuned.pt` is
181
+ `nvidia/bigvgan_base_24khz_100band` fine-tuned here. Vocos (Siuzdak, 2023), MIT: `vocoder/vocos.safetensors` is
182
+ `charactr/vocos-mel-24khz` fine-tuned here; `tts_english/vocos.py` re-implements its forward pass.
183
+ - **G2P:** g2p_en (Kyubyong Park), Apache-2.0, with the CMU Pronouncing Dictionary.
app.py ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Local page to try the model: type any English text, pick a voice, tune pace and pauses, listen.
2
+
3
+ python app.py --bigvgan BigVGAN | --vocoder vocos [--fast] [--repo mmmhusto/TTS-English] [--port 8790] [--device auto|mps|cuda|cpu]
4
+
5
+ Open http://localhost:8790. Only the Python standard library is needed on top of the model's own requirements.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ import argparse
11
+ import io
12
+ import json
13
+ import threading
14
+ import time
15
+ from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
16
+
17
+ import soundfile as sf
18
+ import torch
19
+
20
+ from tts_english import SAMPLE_RATE, TTS
21
+
22
+ PAGE = r"""<!doctype html><html lang=en><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1">
23
+ <title>TTS English</title>
24
+ <style>
25
+ :root{--bg:#f6f5f2;--card:#fff;--fg:#1d1d1b;--mute:#6b6a64;--line:#e2e0d8;--acc:#2f5d50;--accfg:#fff}
26
+ @media (prefers-color-scheme:dark){:root{--bg:#161715;--card:#20211f;--fg:#ecebe6;--mute:#9b9a93;--line:#33342f;--acc:#7fb8a4;--accfg:#10201a;color-scheme:dark}}
27
+ *{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--fg);font:15px/1.5 system-ui,-apple-system,sans-serif}
28
+ main{max-width:760px;margin:0 auto;padding:28px max(16px,env(safe-area-inset-left)) 60px}
29
+ h1{font-size:22px;margin:0 0 4px}p.sub{color:var(--mute);margin:0 0 20px}
30
+ .card{background:var(--card);border:1px solid var(--line);border-radius:12px;padding:16px;display:grid;gap:14px}
31
+ textarea{width:100%;min-height:110px;resize:vertical;font:16px/1.5 system-ui,-apple-system,sans-serif;padding:10px;border:1px solid var(--line);border-radius:8px;background:var(--bg);color:var(--fg)}
32
+ .grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:12px 20px}
33
+ label{display:grid;gap:4px;font-size:13px;color:var(--mute)}label b{color:var(--fg);font-weight:600}
34
+ select{font:inherit;padding:6px;border-radius:6px;border:1px solid var(--line);background:var(--bg);color:var(--fg)}
35
+ input[type=range]{width:100%;accent-color:var(--acc)}
36
+ .row{display:flex;gap:10px;align-items:center;flex-wrap:wrap}
37
+ button{font:600 15px system-ui,-apple-system,sans-serif;padding:9px 18px;border-radius:8px;border:0;background:var(--acc);color:var(--accfg);cursor:pointer}
38
+ button.ghost{background:transparent;color:var(--acc);border:1px solid var(--line);font-weight:500}
39
+ button:disabled{opacity:.5;cursor:wait}#status{color:var(--mute);font-size:13px}
40
+ #out{display:grid;gap:10px;margin-top:18px}.item{background:var(--card);border:1px solid var(--line);border-radius:10px;padding:10px 12px;display:grid;gap:6px}
41
+ .item .t{font-size:14px}.item .m{font-size:12px;color:var(--mute)}audio{width:100%}
42
+ </style>
43
+ <main>
44
+ <h1>TTS English</h1><p class=sub>Napíš anglický text, vyber hlas a nastav pauzy. Generuje sa tu na tvojom počítači (__DEVICE__).</p>
45
+ <div class=card>
46
+ <textarea id=text>The morning was quiet. Then the phone rang, and everything changed. She picked it up, listened for a moment, and smiled.</textarea>
47
+ <div class=grid>
48
+ <label>Hlas<select id=voice>__VOICES__</select></label>
49
+ __STYLE__
50
+ <label>Medzera medzi vetami <b><span id=gap_v></span> s</b><input id=gap type=range min=0.1 max=1.5 step=0.05 value=0.35></label>
51
+ <label>Pauza pri čiarke <b>×<span id=comma_v></span></b><input id=comma type=range min=1 max=5 step=0.25 value=2.5></label>
52
+ <label>Tempo (väčšie = pomalšie) <b><span id=pace_v></span></b><input id=pace type=range min=0.8 max=1.3 step=0.02 value=1.04></label>
53
+ <label>Jednotná farba hlasu <b><span id=uni_v></span></b><input id=uni type=range min=0 max=1 step=0.1 value=0.7></label>
54
+ <label>Variant (seed) <b><span id=seed_v></span></b><input id=seed type=range min=0 max=20 step=1 value=0></label>
55
+ </div>
56
+ <div class=row><button id=go>Vygenerovať</button><button class="ghost" id=reset>Predvolené</button><span id=status></span></div>
57
+ </div>
58
+ <div id=out></div>
59
+ </main>
60
+ <script>
61
+ const $=id=>document.getElementById(id);
62
+ const sliders=["gap","comma","pace","uni","seed"].concat($("sscale")?["sscale"]:[]);
63
+ const defaults={};sliders.forEach(s=>{defaults[s]=$(s).value;const f=()=>$(s+"_v").textContent=$(s).value;$(s).oninput=f;f()});
64
+ $("reset").onclick=()=>sliders.forEach(s=>{$(s).value=defaults[s];$(s).oninput()});
65
+ async function go(){
66
+ const text=$("text").value.trim();if(!text)return;
67
+ $("go").disabled=true;$("status").textContent="Generujem…";
68
+ const body={text,voice:$("voice").value,sentence_gap:+$("gap").value,pause_scale:+$("comma").value,
69
+ length_scale:+$("pace").value,uniform:+$("uni").value,seed:+$("seed").value};
70
+ if($("style")){body.style=$("style").value;body.style_scale=+$("sscale").value}
71
+ try{
72
+ const r=await fetch("/tts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(body)});
73
+ if(!r.ok)throw new Error(await r.text());
74
+ const secs=r.headers.get("X-Seconds"),took=r.headers.get("X-Took");
75
+ const url=URL.createObjectURL(await r.blob());
76
+ const d=document.createElement("div");d.className="item";
77
+ d.innerHTML=`<div class=t></div><audio controls autoplay src="${url}"></audio><div class=m></div>`;
78
+ d.querySelector(".t").textContent=text;
79
+ d.querySelector(".m").textContent=`${body.voice}${body.style?" · "+body.style+" ×"+body.style_scale:""} · medzera ${body.sentence_gap} s · čiarka ×${body.pause_scale} · tempo ${body.length_scale} · seed ${body.seed} · ${secs} s zvuku za ${took} s`;
80
+ $("out").prepend(d);$("status").textContent="";
81
+ }catch(e){$("status").textContent="Chyba: "+e.message}
82
+ $("go").disabled=false;
83
+ }
84
+ $("go").onclick=go;$("text").onkeydown=e=>{if(e.key==="Enter"&&(e.metaKey||e.ctrlKey))go()};
85
+ </script>
86
+ """
87
+
88
+ VOICE_NAMES = {"en_hifi_92_clean": "Studio 92 (žena, odporúčaný)", "en_hifi_8051_other": "Studio 8051 (žena)",
89
+ "en_hifi_11697_other": "Studio 11697 (žena)", "en_dt_0": "DailyTalk (muž, rozhovor)",
90
+ "en_hifi_6670_other": "Studio 6670 (muž, čítanie)"}
91
+
92
+
93
+ def pick_device(want: str) -> str:
94
+ if want != "auto":
95
+ return want
96
+ if torch.cuda.is_available():
97
+ return "cuda"
98
+ return "mps" if torch.backends.mps.is_available() else "cpu"
99
+
100
+
101
+ def main() -> int:
102
+ ap = argparse.ArgumentParser(description=__doc__.split("\n\n")[0])
103
+ ap.add_argument("--bigvgan", default="BigVGAN", help="clone of github.com/NVIDIA/BigVGAN")
104
+ ap.add_argument("--fast", action="store_true", help="distilled 2-step decoder, ~10x faster acoustic model")
105
+ ap.add_argument("--vocoder", default="bigvgan", choices=["bigvgan", "vocos"],
106
+ help="vocos: fast on a CPU and needs no BigVGAN clone")
107
+ ap.add_argument("--repo", default="mmmhusto/TTS-English", help="Hub repo or local folder with the weights")
108
+ ap.add_argument("--port", type=int, default=8790)
109
+ ap.add_argument("--device", default="auto", help="auto picks cuda, then mps (Apple GPU), then cpu")
110
+ a = ap.parse_args()
111
+
112
+ device = pick_device(a.device)
113
+ tts = TTS.from_pretrained(a.repo, a.bigvgan, device=device, vocoder=a.vocoder, fast=a.fast)
114
+ try: # MPS lacks a few ops on some torch versions: fall back to the CPU rather than fail on the first request
115
+ tts("Test.")
116
+ except Exception as e: # noqa: BLE001
117
+ if device == "cpu":
118
+ raise
119
+ print(f"[app] {device} failed ({e.__class__.__name__}: {e}); using cpu", flush=True)
120
+ device = "cpu"
121
+ tts = TTS.from_pretrained(a.repo, a.bigvgan, device=device, vocoder=a.vocoder, fast=a.fast)
122
+ lock = threading.Lock() # one synthesis at a time
123
+
124
+ shown = list(VOICE_NAMES) + [v for v in tts.config.get("recommended_voices", []) if v not in VOICE_NAMES]
125
+ options = "".join(f'<option value="{v}">{VOICE_NAMES.get(v, v)}</option>' for v in shown if v in tts.voices)
126
+ names = {"reading": "čítanie", "conversational": "rozhovor"}
127
+ style = "" if not tts.styles else (
128
+ "<label>Štýl<select id=style>" + "".join(f'<option value="{s}">{names.get(s, s)}</option>' for s in tts.styles)
129
+ + "</select></label>\n<label>Sila štýlu <b>×<span id=sscale_v></span></b>"
130
+ f"<input id=sscale type=range min=0 max=2 step=0.1 value={tts.config['delivery'].get('style_scale', 1)}></label>")
131
+ page = PAGE.replace("__STYLE__", style).replace("__VOICES__", options).replace("__DEVICE__", {"mps": "grafika Apple", "cuda": "NVIDIA GPU",
132
+ "cpu": "procesor"}[device]).encode()
133
+
134
+ class Handler(BaseHTTPRequestHandler):
135
+ def send(self, code, body: bytes, ctype: str, headers=()):
136
+ self.send_response(code)
137
+ self.send_header("Content-Type", ctype)
138
+ self.send_header("Content-Length", str(len(body)))
139
+ for k, v in headers:
140
+ self.send_header(k, v)
141
+ self.end_headers()
142
+ self.wfile.write(body)
143
+
144
+ def do_GET(self):
145
+ self.send(200, page, "text/html; charset=utf-8") if self.path in ("/", "/index.html") else \
146
+ self.send(404, b"not found", "text/plain")
147
+
148
+ def do_POST(self):
149
+ if self.path != "/tts":
150
+ return self.send(404, b"not found", "text/plain")
151
+ try:
152
+ req = json.loads(self.rfile.read(int(self.headers.get("Content-Length", 0))))
153
+ text = str(req["text"]).strip()[:2000]
154
+ voice = req.get("voice") if req.get("voice") in tts.voices else None
155
+ settings = {k: float(req[k]) for k in ("pause_scale", "length_scale", "style_scale") if k in req}
156
+ if req.get("style") in tts.styles:
157
+ settings["style"] = req["style"]
158
+ t0 = time.time()
159
+ with lock:
160
+ wav = tts(text, voice, seed=int(req.get("seed", 0)), uniform=float(req.get("uniform", 0.7)),
161
+ sentence_gap=float(req.get("sentence_gap", 0.35)), **settings)
162
+ buf = io.BytesIO()
163
+ sf.write(buf, wav, SAMPLE_RATE, format="WAV")
164
+ self.send(200, buf.getvalue(), "audio/wav", [("X-Seconds", f"{len(wav) / SAMPLE_RATE:.1f}"),
165
+ ("X-Took", f"{time.time() - t0:.1f}")])
166
+ except Exception as e: # noqa: BLE001
167
+ self.send(400, f"{e.__class__.__name__}: {e}".encode(), "text/plain; charset=utf-8")
168
+
169
+ def log_message(self, *args):
170
+ pass
171
+
172
+ print(f"[app] {device} http://localhost:{a.port}", flush=True)
173
+ ThreadingHTTPServer(("127.0.0.1", a.port), Handler).serve_forever()
174
+ return 0
175
+
176
+
177
+ if __name__ == "__main__":
178
+ raise SystemExit(main())
config.json CHANGED
@@ -1,312 +1,263 @@
1
  {
2
- "model": {
3
- "n_feats": 100,
4
- "spk_dim": 256,
5
- "enc_dim": 256,
6
- "enc_layers": 6,
7
- "enc_heads": 4,
8
- "dec_dim": 512,
9
- "dec_layers": 10,
10
- "dec_heads": 8,
11
- "dropout": 0.1,
12
- "dec_dropout": 0.0,
13
- "p_uncond": 0.1,
14
- "phone_pos": true,
15
- "dur_flow": true,
16
- "dur_dim": 192,
17
- "dur_layers": 3,
18
- "t_uniform": 0.2,
19
- "n_styles": 2
20
- },
21
- "symbols": [
22
- "<pad>",
23
- "<bos>",
24
- "<eos>",
25
- "<unk>",
26
- "▁",
27
- ",",
28
- ".",
29
- "!",
30
- "?",
31
- "AA0",
32
- "AA1",
33
- "AA2",
34
- "AE0",
35
- "AE1",
36
- "AE2",
37
- "AH0",
38
- "AH1",
39
- "AH2",
40
- "AO0",
41
- "AO1",
42
- "AO2",
43
- "AW0",
44
- "AW1",
45
- "AW2",
46
- "AY0",
47
- "AY1",
48
- "AY2",
49
- "EH0",
50
- "EH1",
51
- "EH2",
52
- "ER0",
53
- "ER1",
54
- "ER2",
55
- "EY0",
56
- "EY1",
57
- "EY2",
58
- "IH0",
59
- "IH1",
60
- "IH2",
61
- "IY0",
62
- "IY1",
63
- "IY2",
64
- "OW0",
65
- "OW1",
66
- "OW2",
67
- "OY0",
68
- "OY1",
69
- "OY2",
70
- "UH0",
71
- "UH1",
72
- "UH2",
73
- "UW0",
74
- "UW1",
75
- "UW2",
76
- "B",
77
- "CH",
78
- "D",
79
- "DH",
80
- "F",
81
- "G",
82
- "HH",
83
- "JH",
84
- "K",
85
- "L",
86
- "M",
87
- "N",
88
- "NG",
89
- "P",
90
- "R",
91
- "S",
92
- "SH",
93
- "T",
94
- "TH",
95
- "V",
96
- "W",
97
- "Y",
98
- "Z",
99
- "ZH",
100
- "sk_a",
101
- "sk_e",
102
- "sk_i",
103
- "sk_o",
104
- "sk_u",
105
- "sk_aː",
106
- "sk_eː",
107
- "sk_iː",
108
- "sk_oː",
109
- "sk_uː",
110
- "sk_ia",
111
- "sk_ie",
112
- "sk_iu",
113
- "sk_uo",
114
- "sk_r̩",
115
- "sk_r̩ː",
116
- "sk_l̩",
117
- "sk_l̩ː",
118
- "sk_p",
119
- "sk_b",
120
- "sk_t",
121
- "sk_d",
122
- "sk_c",
123
- "sk_ɟ",
124
- "sk_k",
125
- "sk_g",
126
- "sk_ts",
127
- "sk_dz",
128
- "sk_tʃ",
129
- "sk_dʒ",
130
- "sk_f",
131
- "sk_v",
132
- "sk_w",
133
- "sk_s",
134
- "sk_z",
135
- "sk_ʃ",
136
- "sk_ʒ",
137
- "sk_x",
138
- "sk_ɦ",
139
- "sk_m",
140
- "sk_n",
141
- "sk_ɲ",
142
- "sk_ŋ",
143
- "sk_l",
144
- "sk_ʎ",
145
- "sk_r",
146
- "sk_j"
147
- ],
148
- "voices": [
149
- "en_hifi_92_clean",
150
- "en_dt_0",
151
- "sk_cori",
152
- "sk_dailytalk",
153
- "sk_muz"
154
- ],
155
- "mel_mean": -5.9344089481310744,
156
- "mel_std": 2.3695238543771113,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
  "delivery": {
158
- "guidance": 1.5,
159
- "length_scale": 1.04,
160
- "pause_scale": 2.5,
161
- "n_timesteps": 10,
162
- "temperature": 0.667,
163
- "sentence_gap": 0.35,
164
- "style_scale": 1.5
165
- },
166
- "vocoder": "nvidia/bigvgan_base_24khz_100band",
167
- "sample_rate": 24000,
168
- "training_step": 20000,
169
- "parameters": {
170
- "acoustic_model": 41815690,
171
- "vocoder": 14020000
172
- },
173
- "default_voice": "en_hifi_92_clean",
174
- "recommended_voices": [
175
- "en_hifi_92_clean",
176
- "en_dt_0"
177
- ],
178
- "profiles": {
179
- "en_hifi_92_clean": [
180
- -4.5528,
181
- -4.8893,
182
- -5.2367,
183
- -4.5505,
184
- -3.4233,
185
- -2.8618,
186
- -3.097,
187
- -4.2703,
188
- -4.2467,
189
- -4.0435,
190
- -3.4204,
191
- -3.3618,
192
- -3.6058,
193
- -3.8797,
194
- -4.2246,
195
- -3.9774,
196
- -4.0689,
197
- -3.85,
198
- -4.0776,
199
- -3.9829,
200
- -3.9574,
201
- -3.9879,
202
- -3.9235,
203
- -4.1083,
204
- -3.9021,
205
- -4.1646,
206
- -4.0601,
207
- -4.3304,
208
- -4.4415,
209
- -4.5864,
210
- -4.6558,
211
- -4.7651,
212
- -4.7194,
213
- -4.8787,
214
- -4.914,
215
- -5.0016,
216
- -5.1144,
217
- -5.1995,
218
- -5.2957,
219
- -5.383,
220
- -5.3533,
221
- -5.3153,
222
- -5.2753,
223
- -5.3689,
224
- -5.3588,
225
- -5.4987,
226
- -5.4719,
227
- -5.439,
228
- -5.4255,
229
- -5.4821,
230
- -5.6054,
231
- -5.661,
232
- -5.7136,
233
- -5.7257,
234
- -5.7577,
235
- -5.7937,
236
- -5.7881,
237
- -5.7086,
238
- -5.6496,
239
- -5.5307,
240
- -5.432,
241
- -5.3035,
242
- -5.195,
243
- -5.2011,
244
- -5.2987,
245
- -5.4264,
246
- -5.4868,
247
- -5.4925,
248
- -5.4033,
249
- -5.3616,
250
- -5.3443,
251
- -5.3643,
252
- -5.4964,
253
- -5.6871,
254
- -5.7945,
255
- -5.8009,
256
- -5.7339,
257
- -5.6264,
258
- -5.5396,
259
- -5.5173,
260
- -5.5787,
261
- -5.7013,
262
- -5.9112,
263
- -6.1813,
264
- -6.4441,
265
- -6.6154,
266
- -6.6782,
267
- -6.6212,
268
- -6.5478,
269
- -6.4835,
270
- -6.3629,
271
- -6.2702,
272
- -6.2736,
273
- -6.3551,
274
- -6.5393,
275
- -6.5878,
276
- -6.5743,
277
- -6.6207,
278
- -6.6606,
279
- -7.6826
280
- ]
281
- },
282
- "styles": [
283
- "reading",
284
- "conversational"
285
- ],
286
- "voice_styles": {
287
- "en_dt_0": "conversational",
288
- "sk_cori": "reading",
289
- "sk_dailytalk": "conversational",
290
- "sk_muz": "reading"
291
- },
292
- "vocoder_weights": "vocoder/bigvgan_finetuned.pt",
293
- "vocoder_config": "vocoder/bigvgan_config.json",
294
- "english_duo": {
295
- "source": "mmmhusto/TTS-husto v1.0",
296
- "branch": "same",
297
- "additional_steps": 600,
298
- "sha256": "ddb4d3c30f8f1889ac393e82c70c06e5fd6b64ebf6f54bcef0f10a1984c9fadd"
299
- },
300
- "languages": {
301
- "en": [
302
- "en_hifi_92_clean",
303
- "en_dt_0"
304
- ],
305
- "sk": [
306
- "sk_cori",
307
- "sk_dailytalk",
308
- "sk_muz"
309
- ]
310
  },
311
- "architecture": "SkttsV2"
 
 
 
 
 
 
 
312
  }
 
1
  {
2
+ "model": {
3
+ "n_feats": 100,
4
+ "spk_dim": 256,
5
+ "enc_dim": 256,
6
+ "enc_layers": 6,
7
+ "enc_heads": 4,
8
+ "dec_dim": 512,
9
+ "dec_layers": 10,
10
+ "dec_heads": 8,
11
+ "dropout": 0.1,
12
+ "dec_dropout": 0.0,
13
+ "p_uncond": 0.1,
14
+ "phone_pos": true,
15
+ "dur_flow": true,
16
+ "dur_dim": 192,
17
+ "dur_layers": 3,
18
+ "t_uniform": 0.2,
19
+ "n_styles": 2
20
+ },
21
+ "symbols": [
22
+ "<pad>",
23
+ "<bos>",
24
+ "<eos>",
25
+ "<unk>",
26
+ "\u2581",
27
+ ",",
28
+ ".",
29
+ "!",
30
+ "?",
31
+ "AA0",
32
+ "AA1",
33
+ "AA2",
34
+ "AE0",
35
+ "AE1",
36
+ "AE2",
37
+ "AH0",
38
+ "AH1",
39
+ "AH2",
40
+ "AO0",
41
+ "AO1",
42
+ "AO2",
43
+ "AW0",
44
+ "AW1",
45
+ "AW2",
46
+ "AY0",
47
+ "AY1",
48
+ "AY2",
49
+ "EH0",
50
+ "EH1",
51
+ "EH2",
52
+ "ER0",
53
+ "ER1",
54
+ "ER2",
55
+ "EY0",
56
+ "EY1",
57
+ "EY2",
58
+ "IH0",
59
+ "IH1",
60
+ "IH2",
61
+ "IY0",
62
+ "IY1",
63
+ "IY2",
64
+ "OW0",
65
+ "OW1",
66
+ "OW2",
67
+ "OY0",
68
+ "OY1",
69
+ "OY2",
70
+ "UH0",
71
+ "UH1",
72
+ "UH2",
73
+ "UW0",
74
+ "UW1",
75
+ "UW2",
76
+ "B",
77
+ "CH",
78
+ "D",
79
+ "DH",
80
+ "F",
81
+ "G",
82
+ "HH",
83
+ "JH",
84
+ "K",
85
+ "L",
86
+ "M",
87
+ "N",
88
+ "NG",
89
+ "P",
90
+ "R",
91
+ "S",
92
+ "SH",
93
+ "T",
94
+ "TH",
95
+ "V",
96
+ "W",
97
+ "Y",
98
+ "Z",
99
+ "ZH"
100
+ ],
101
+ "voices": [
102
+ "en_hifi_92_clean",
103
+ "en_dt_0"
104
+ ],
105
+ "mel_mean": -5.9344089481310744,
106
+ "mel_std": 2.3695238543771113,
107
+ "delivery": {
108
+ "guidance": 1.5,
109
+ "length_scale": 1.04,
110
+ "pause_scale": 2.5,
111
+ "n_timesteps": 10,
112
+ "temperature": 0.667,
113
+ "sentence_gap": 0.35,
114
+ "style_scale": 1.5
115
+ },
116
+ "vocoder": "nvidia/bigvgan_base_24khz_100band",
117
+ "sample_rate": 24000,
118
+ "training_step": 20600,
119
+ "parameters": {
120
+ "acoustic_model": 41815690,
121
+ "vocoder": 14020000
122
+ },
123
+ "default_voice": "en_hifi_92_clean",
124
+ "recommended_voices": [
125
+ "en_hifi_92_clean",
126
+ "en_dt_0"
127
+ ],
128
+ "profiles": {
129
+ "en_hifi_92_clean": [
130
+ -4.5528,
131
+ -4.8893,
132
+ -5.2367,
133
+ -4.5505,
134
+ -3.4233,
135
+ -2.8618,
136
+ -3.097,
137
+ -4.2703,
138
+ -4.2467,
139
+ -4.0435,
140
+ -3.4204,
141
+ -3.3618,
142
+ -3.6058,
143
+ -3.8797,
144
+ -4.2246,
145
+ -3.9774,
146
+ -4.0689,
147
+ -3.85,
148
+ -4.0776,
149
+ -3.9829,
150
+ -3.9574,
151
+ -3.9879,
152
+ -3.9235,
153
+ -4.1083,
154
+ -3.9021,
155
+ -4.1646,
156
+ -4.0601,
157
+ -4.3304,
158
+ -4.4415,
159
+ -4.5864,
160
+ -4.6558,
161
+ -4.7651,
162
+ -4.7194,
163
+ -4.8787,
164
+ -4.914,
165
+ -5.0016,
166
+ -5.1144,
167
+ -5.1995,
168
+ -5.2957,
169
+ -5.383,
170
+ -5.3533,
171
+ -5.3153,
172
+ -5.2753,
173
+ -5.3689,
174
+ -5.3588,
175
+ -5.4987,
176
+ -5.4719,
177
+ -5.439,
178
+ -5.4255,
179
+ -5.4821,
180
+ -5.6054,
181
+ -5.661,
182
+ -5.7136,
183
+ -5.7257,
184
+ -5.7577,
185
+ -5.7937,
186
+ -5.7881,
187
+ -5.7086,
188
+ -5.6496,
189
+ -5.5307,
190
+ -5.432,
191
+ -5.3035,
192
+ -5.195,
193
+ -5.2011,
194
+ -5.2987,
195
+ -5.4264,
196
+ -5.4868,
197
+ -5.4925,
198
+ -5.4033,
199
+ -5.3616,
200
+ -5.3443,
201
+ -5.3643,
202
+ -5.4964,
203
+ -5.6871,
204
+ -5.7945,
205
+ -5.8009,
206
+ -5.7339,
207
+ -5.6264,
208
+ -5.5396,
209
+ -5.5173,
210
+ -5.5787,
211
+ -5.7013,
212
+ -5.9112,
213
+ -6.1813,
214
+ -6.4441,
215
+ -6.6154,
216
+ -6.6782,
217
+ -6.6212,
218
+ -6.5478,
219
+ -6.4835,
220
+ -6.3629,
221
+ -6.2702,
222
+ -6.2736,
223
+ -6.3551,
224
+ -6.5393,
225
+ -6.5878,
226
+ -6.5743,
227
+ -6.6207,
228
+ -6.6606,
229
+ -7.6826
230
+ ]
231
+ },
232
+ "styles": [
233
+ "reading",
234
+ "conversational"
235
+ ],
236
+ "voice_styles": {
237
+ "en_dt_0": "conversational"
238
+ },
239
+ "vocoder_weights": "vocoder/bigvgan_finetuned.pt",
240
+ "vocoder_config": "vocoder/bigvgan_config.json",
241
+ "voice_encoder": "voice_encoder.safetensors",
242
+ "voice_encoder_cfg": {
243
+ "dim": 256,
244
+ "layers": 6,
245
+ "kernel": 5,
246
+ "out_dim": 256,
247
+ "dropout": 0.1
248
+ },
249
+ "fast": {
250
+ "weights": "fast_decoder.safetensors",
251
  "delivery": {
252
+ "n_timesteps": 2,
253
+ "guidance": 0.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
254
  },
255
+ "note": "reflow-distilled decoder (teacher: 10 steps x guidance 1.5), 13 000 steps on 13 500 sentences"
256
+ },
257
+ "vocos_weights": "vocoder/vocos.safetensors",
258
+ "version": "2.3",
259
+ "lineage": {
260
+ "base": "mmmhusto/TTS-English v2.3-old (592 voices, 20 000 steps)",
261
+ "fine_tune": "+600 steps, 2 voices (RTX 3080)"
262
+ }
263
  }
fast_decoder.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0697dab2531f66ed610e314edf8812129efd0f40592c42a759a9a3f94f8fe09a
3
+ size 139814904
infer.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """python infer.py "Text to speak." out.wav [--voice en_dt_0] [--bigvgan BigVGAN | --vocoder vocos] [--fast]"""
2
+ import argparse
3
+
4
+ import soundfile as sf
5
+
6
+ from tts_english import SAMPLE_RATE, TTS
7
+
8
+ ap = argparse.ArgumentParser()
9
+ ap.add_argument("text")
10
+ ap.add_argument("out")
11
+ ap.add_argument("--voice", default=None, help="default: the studio voice en_hifi_92_clean")
12
+ ap.add_argument("--bigvgan", default="BigVGAN", help="clone of github.com/NVIDIA/BigVGAN")
13
+ ap.add_argument("--fast", action="store_true", help="distilled 2-step decoder, ~10x faster acoustic model")
14
+ ap.add_argument("--vocoder", default="bigvgan", choices=["bigvgan", "vocos"],
15
+ help="vocos: fast on a CPU and needs no BigVGAN clone")
16
+ ap.add_argument("--repo", default="mmmhusto/TTS-English", help="Hub repo or local folder with the weights")
17
+ ap.add_argument("--seed", type=int, default=0)
18
+ a = ap.parse_args()
19
+ tts = TTS.from_pretrained(a.repo, a.bigvgan, vocoder=a.vocoder, fast=a.fast)
20
+ sf.write(a.out, tts(a.text, a.voice, a.seed), SAMPLE_RATE)
21
+ print(f"{a.out}: {a.voice or tts.config['default_voice']}")
model.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:0bf6d2bd54ccc5eefc6a40002c0718c0dff26efbeb9a2a5990d2b18085e9859f
3
- size 167340904
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ddb4d3c30f8f1889ac393e82c70c06e5fd6b64ebf6f54bcef0f10a1984c9fadd
3
+ size 167289704
samples/fast_vocos_story_92.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:05352b1b0d0ca8c5b8d02e28bac91973ac00e78757341fec7c5410fa20e5349d
3
+ size 640364
samples/numbers_92.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2bb86e50b3798ae8f2633964a97a96f0b3ee58db7fbfcbe27010efa507d9cf84
3
+ size 537164
samples/story_92.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8d5942d5d6872b49e6bf92ce469a0281ef695aa8c90cc26b6ab02c976ce7d5ca
3
+ size 639404
samples/story_dt0.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7bc103508f89fdc554fb08425c6631d26ae43625a4e36daefa07bb0a24b8c434
3
+ size 643244
samples/talk_92_conversational.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8a2505ab7a3d82629b5dda180fae6b5bec4e675957e4280d1ff028eb18b8954e
3
+ size 297164
samples/talk_dt0.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:af17e6d4d48e5a2f5a66c1e20fdf3a6cbc050d39648edba5fe0c25ef9a5af32b
3
+ size 268364
tts_english/__init__.py CHANGED
@@ -1,13 +1,13 @@
1
  """mmmhusto TTS English: text -> 24 kHz speech.
2
 
3
  from tts_english import TTS
4
- tts = TTS.from_pretrained("mmmhusto/TTS-husto", bigvgan_dir="BigVGAN") # a clone of github.com/NVIDIA/BigVGAN
5
  wav = tts("Good morning, and welcome.") # float32 numpy array, 24 kHz
6
 
7
- tts = TTS.from_pretrained("mmmhusto/TTS-husto", vocoder="vocos") # fast vocoder, no BigVGAN clone needed
8
- tts = TTS.from_pretrained("mmmhusto/TTS-husto", vocoder="vocos", fast=True) # + 2-step decoder: fastest
9
 
10
- voice = tts.clone_voice(recording, sample_rate) # a voice vector from 5-15 s of someone's speech
11
  wav = tts("Now I speak with that voice.", voice=voice)
12
 
13
  wav = tts.long(article) # any length: sentence by sentence
@@ -88,7 +88,7 @@ class TTS:
88
  self._get, self._refenc = None, None # set by from_pretrained: where the optional files are
89
 
90
  @classmethod
91
- def from_pretrained(cls, repo: str = "mmmhusto/TTS-husto", bigvgan_dir: str | None = None, device: str = "cpu",
92
  vocoder_weights: str | None = None, vocoder: str | None = None,
93
  fast: bool = False) -> "TTS":
94
  """``vocoder``: "bigvgan" (needs ``bigvgan_dir``, a clone of github.com/NVIDIA/BigVGAN) or "vocos" (fast,
@@ -101,22 +101,11 @@ class TTS:
101
  from safetensors.torch import load_file
102
 
103
  def get(name: str) -> str: # a local folder, or a repo on the Hub
104
- return str(Path(repo) / name) if Path(repo).is_dir() else hf_hub_download(repo, name, revision="v3.0" if repo == "mmmhusto/TTS-husto" else None)
105
 
106
  config = json.load(open(get("config.json")))
107
- if not config.get("vocos_weights") and vocoder in (None, "bigvgan") and bigvgan_dir is None:
108
- import os
109
- candidates = [os.environ.get("SKTTS_BIGVGAN_DIR"), Path.home() / "sktts-work" / "bigvgan",
110
- Path(r"C:\sktts\work\bigvgan"), Path("BigVGAN")]
111
- bigvgan_dir = next((str(p) for p in candidates if p and (Path(p) / "bigvgan.py").is_file()), None)
112
- if bigvgan_dir is None:
113
- raise ValueError("Set bigvgan_dir to the local NVIDIA BigVGAN repository.")
114
- if fast and not config.get("fast"):
115
- raise ValueError("This two-voice model uses the full decoder. Use fast=False.")
116
- if vocoder == "vocos" and not (vocoder_weights or config.get("vocos_weights")):
117
- raise ValueError("This two-voice model includes BigVGAN. Use vocoder='bigvgan'.")
118
- assert config["symbols"][:len(SYMBOLS)] == SYMBOLS, "frontend and checkpoint disagree on the symbol table"
119
- model = SkttsV2(len(config["symbols"]), len(config["voices"]), config["mel_mean"], config["mel_std"], cfg=config["model"])
120
  model.load_state_dict(load_file(get("model.safetensors")))
121
  if fast:
122
  model.load_state_dict(load_file(get(config["fast"]["weights"])), strict=False) # decoder.* only
 
1
  """mmmhusto TTS English: text -> 24 kHz speech.
2
 
3
  from tts_english import TTS
4
+ tts = TTS.from_pretrained("mmmhusto/TTS-English", bigvgan_dir="BigVGAN") # a clone of github.com/NVIDIA/BigVGAN
5
  wav = tts("Good morning, and welcome.") # float32 numpy array, 24 kHz
6
 
7
+ tts = TTS.from_pretrained("mmmhusto/TTS-English", vocoder="vocos") # fast vocoder, no BigVGAN clone needed
8
+ tts = TTS.from_pretrained("mmmhusto/TTS-English", vocoder="vocos", fast=True) # + 2-step decoder: fastest
9
 
10
+ voice = tts.clone_voice(recording, sample_rate, text=transcript) # a similar voice from >= 5 s of speech
11
  wav = tts("Now I speak with that voice.", voice=voice)
12
 
13
  wav = tts.long(article) # any length: sentence by sentence
 
88
  self._get, self._refenc = None, None # set by from_pretrained: where the optional files are
89
 
90
  @classmethod
91
+ def from_pretrained(cls, repo: str = "mmmhusto/TTS-English", bigvgan_dir: str | None = None, device: str = "cpu",
92
  vocoder_weights: str | None = None, vocoder: str | None = None,
93
  fast: bool = False) -> "TTS":
94
  """``vocoder``: "bigvgan" (needs ``bigvgan_dir``, a clone of github.com/NVIDIA/BigVGAN) or "vocos" (fast,
 
101
  from safetensors.torch import load_file
102
 
103
  def get(name: str) -> str: # a local folder, or a repo on the Hub
104
+ return str(Path(repo) / name) if Path(repo).is_dir() else hf_hub_download(repo, name)
105
 
106
  config = json.load(open(get("config.json")))
107
+ assert config["symbols"] == SYMBOLS, "frontend and checkpoint disagree on the symbol table"
108
+ model = SkttsV2(len(SYMBOLS), len(config["voices"]), config["mel_mean"], config["mel_std"], cfg=config["model"])
 
 
 
 
 
 
 
 
 
 
 
109
  model.load_state_dict(load_file(get("model.safetensors")))
110
  if fast:
111
  model.load_state_dict(load_file(get(config["fast"]["weights"])), strict=False) # decoder.* only
tts_english/__main__.py CHANGED
@@ -1,4 +1,4 @@
1
- """tts-english "Text to speak." out.wav [--voice en_hifi_8051_other] [--style conversational] [--fast]
2
 
3
  Long texts are read sentence by sentence; ``-`` as the text reads it from standard input."""
4
  import argparse
@@ -15,7 +15,7 @@ def main(argv=None) -> int:
15
  ap.add_argument("--vocoder", default=None, choices=["bigvgan", "vocos"],
16
  help="default: bigvgan with --bigvgan, else vocos")
17
  ap.add_argument("--bigvgan", default=None, help="clone of github.com/NVIDIA/BigVGAN (best quality)")
18
- ap.add_argument("--repo", default="mmmhusto/TTS-husto", help="Hub repo or local folder with the weights")
19
  ap.add_argument("--device", default="cpu")
20
  ap.add_argument("--seed", type=int, default=0)
21
  a = ap.parse_args(argv)
 
1
+ """tts-english "Text to speak." out.wav [--voice en_dt_0] [--style conversational] [--fast]
2
 
3
  Long texts are read sentence by sentence; ``-`` as the text reads it from standard input."""
4
  import argparse
 
15
  ap.add_argument("--vocoder", default=None, choices=["bigvgan", "vocos"],
16
  help="default: bigvgan with --bigvgan, else vocos")
17
  ap.add_argument("--bigvgan", default=None, help="clone of github.com/NVIDIA/BigVGAN (best quality)")
18
+ ap.add_argument("--repo", default="mmmhusto/TTS-English", help="Hub repo or local folder with the weights")
19
  ap.add_argument("--device", default="cpu")
20
  ap.add_argument("--seed", type=int, default=0)
21
  a = ap.parse_args(argv)
vocoder/vocos.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3b51878ad1068ca671b2315eeb78f741cfbbb0ebbc56778f28398d1010e615f3
3
+ size 54134536
voice_encoder.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2b7ccdbfc9ed71a47de53851865ca8d7b157460cec9d8b778f564267ff37b9e4
3
+ size 17205480