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 filesFiles changed (17)
- .gitattributes+6
- README.md+159-34
- app.pyAdded+178
- config.json+259-308
- fast_decoder.safetensorsAdded+3
- infer.pyAdded+21
- model.safetensors+2-2
- samples/fast_vocos_story_92.wavAdded+3
- samples/numbers_92.wavAdded+3
- samples/story_92.wavAdded+3
- samples/story_dt0.wavAdded+3
- samples/talk_92_conversational.wavAdded+3
- samples/talk_dt0.wavAdded+3
- tts_english/__init__.py+8-19
- tts_english/__main__.py+2-2
- vocoder/vocos.safetensorsAdded+3
- voice_encoder.safetensorsAdded+3
32 unmodified lines33343532 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -text32 unmodified lines33343536373839404132 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -textsamples/fast_vocos_story_92.wav filter=lfs diff=lfs merge=lfs -textsamples/numbers_92.wav filter=lfs diff=lfs merge=lfs -textsamples/story_92.wav filter=lfs diff=lfs merge=lfs -textsamples/story_dt0.wav filter=lfs diff=lfs merge=lfs -textsamples/talk_92_conversational.wav filter=lfs diff=lfs merge=lfs -textsamples/talk_dt0.wav filter=lfs diff=lfs merge=lfs -text
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758---language:- en- sklicense: cc-by-sa-4.0pipeline_tag: text-to-speechtags:- text-to-speech- onnx- bilingual---# TTS English, Slovak by husto## VersionsOne repository, one model line. `main` is always the newest version; every release has a tag.| Version | What changed | Download ||---|---|---|| 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` || 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` || 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` |**This page describes v3.0.**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:| Language | Voice IDs ||---|---|| English | `en_hifi_92_clean`, `en_dt_0` || Slovak | `sk_muz`, `sk_cori`, `sk_dailytalk` |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.- `model.safetensors` and `config.json` contain the standalone five-voice acoustic model.- `vocoder/` contains the shared BigVGAN weights and config.- `web/` contains the ONNX export and English pronunciation assets for the demo.- `slovak-frontend.zip` contains the original project frontend used for Slovak phonemes.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)## Local synthesisWith the project Python dependencies and NVIDIA BigVGAN source installed, download the repository and run:```shpython povedz.py --jazyk sk --hlas sk_muz 'Vonku už prestalo pršať.' vystup.wavpython povedz.py --jazyk en --hlas en_dt_0 'Good morning.' speech.wav```## Data and attribution- English training and BigVGAN attribution follow [English Duo](https://huggingface.co/mmmhusto/TTS-husto/tree/v2.0).- [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.- [Lili](https://huggingface.co/datasets/vsisik/voice-dataset-lili) from the Open Home Foundation, CC0.- [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.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183---license: cc-by-sa-4.0language:- enpipeline_tag: text-to-speechlibrary_name: pytorchtags:- text-to-speech- tts- flow-matching- diffusion-transformerdatasets:- mythicinfinity/libritts_r- MikhailT/hifi-tts- eustlb/dailytalk- mmmhusto/sktts-en-features---# mmmhusto TTS English v2.3**A small English text-to-speech model with two steady voices, a fast CPU mode and a measured recipe for adding yourown voice.** Written and trained from scratch: 42 M acoustic model + 14 M vocoder, plain PyTorch.- **Two voices:** `en_hifi_92_clean` (Cori Samuel, studio audiobook, female, default) and `en_dt_0` (DailyTalk actor,male, conversational).- **Fast mode:** a distilled 2-step decoder and the built-in Vocos vocoder, about 9x faster than real time on anApple M1 Pro CPU, with nothing to install but `pip`.- **Your own voice:** 5 minutes of clean speech and 7 minutes on one RTX 3080 (see "Add a voice").- **Reads what people write:** numbers, money, times, dates, units and abbreviations are written out first.- **Any length:** `tts.long(text)` and `tts.stream(text)` read a whole article sentence by sentence.- **Two speaking styles:** reading and conversation (`style="conversational"`).**What changed in v2.3.** This is the former *English Duo* model as the one base model: the 592-voice v2.3 fine-tuned600 steps on the two voices above (1 024 recordings each), which made both voices steadier. The 592-voice model staysin this repo's history under the tag [`v2.3-old`](https://huggingface.co/mmmhusto/TTS-English/tree/v2.3-old)(`snapshot_download("mmmhusto/TTS-English", revision="v2.3-old")`). The fast decoder and the Vocos vocoder weretrained again for these weights.## Listen| | `en_hifi_92_clean` (default) | `en_dt_0` ||---|---|---|| 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> || "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> || 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> | || 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> | |All clips are exactly what the code below produces (seed 450, BigVGAN unless stated).## Quick start```bashpip install torch numpy soundfile huggingface_hub safetensors g2p_enpython -c "from g2p_en import G2p; G2p()" # fetches g2p_en's NLTK data once# for the best quality also the BigVGAN vocoder's code (MIT):git clone https://github.com/NVIDIA/BigVGAN && pip install librosa matplotlib``````pythonfrom huggingface_hub import snapshot_downloadimport sys, soundfile as sfpath = snapshot_download("mmmhusto/TTS-English")sys.path.insert(0, path)from tts_english import TTS, SAMPLE_RATEtts = TTS.from_pretrained(path, bigvgan_dir="BigVGAN") # best quality# tts = TTS.from_pretrained(path, vocoder="vocos", fast=True) # no BigVGAN clone, fast on a CPUwav = tts("It was not the answer she expected; still, she thanked him and left the room.", voice="en_dt_0")sf.write("out.wav", wav, SAMPLE_RATE)```or `python infer.py "Text to speak." out.wav --voice en_dt_0` (`--fast`, `--vocoder vocos`), or a local web page with`python app.py --bigvgan BigVGAN`.Keyword arguments override the delivery in `config.json` (`guidance`, `length_scale`, `pause_scale`, `temperature`,`n_timesteps`, `sentence_gap`); `seed=None` gives a different rendition every call.## Modes, quality and speed64 sentences (32 texts x 2 voices). Word errors: Whisper small.en reads the audio back. PESQ: no-reference estimate(torchaudio SQUIM). Speed: seconds of computing per second of speech on an Apple M1 Pro CPU, 8 threads (below 1 isfaster than real time; measured while the machine did other work, so a little pessimistic).| Mode | Word errors | PESQ | CPU time / speech time ||---|---|---|---|| full decoder + BigVGAN (default) | 1.9 % | **3.87** | 1.73 || fast decoder + BigVGAN | **1.5 %** | 3.79 | 1.54 || **fast decoder + Vocos** | **1.5 %** | 2.88 | **0.11** || full decoder + Vocos | 1.7 % | 2.94 | 0.43 |- **The fast decoder** (`fast=True`) makes 2 passes instead of 20 (10 steps with guidance) and costs nothingmeasurable. It was distilled by reflow on 13 500 sentences of the model's own output (13 000 steps on an RTX 3080).- **On a CPU only Vocos runs faster than real time**, because BigVGAN is most of the time there. Vocos has a slightmetallic sound (PESQ 2.9 against 3.8), also on real recordings, so it comes from the vocoder, not from the model.It was fine-tuned 20 000 steps on these weights' mels. That helped a little; the metallic sound stays.- **On a GPU use BigVGAN.**## Voice cloning: a similar voice, not the person`tts.clone_voice(wav, sample_rate, text=transcript)` turns a short recording into a voice vector in seconds. Measuredon 8 VCTK speakers the model never heard (64 sentences per row; similarity is ECAPA cosine to the speaker's ownheld-out recordings: 0.75 between two real recordings of the same person, 0.10 for one of the built-in voices):| Recording | 3 s | 5 s | 10 s | 20 s | 30 s ||---|---|---|---|---|---|| without transcript | 0.19 | 0.20 | 0.20 | 0.20 | 0.21 || with transcript (`text=`, 200 fitting steps, ~1 min on a CPU) | 0.23 | **0.26** | 0.25 | 0.24 | 0.25 |5 s is enough and more does not help. The clone keeps sex, pitch and roughly the colour of the voice, but someone whoknows the speaker would not recognise them. The 592-voice `v2.3-old` clones the same (0.19 and 0.24 at 10 s): thevoice encoder saw ~550 people, too few for close cloning. Word errors stay at 0 to 0.1 %.## Add a voice (the way that works)Fine-tuning the model on the person's recordings makes a voice that sounds like them. Measured on 2 of the VCTKspeakers above (1 500 steps on one RTX 3080, about 7 minutes; 64 sentences per row):| | Similarity | Word errors ||---|---|---|| cloning, 10 s with transcript | 0.25 | 0 % || **fine-tuned on 5 minutes of speech** | **0.69** | 1.7 % || **fine-tuned on 15 minutes of speech** | **0.72** | 1.7 % || the built-in voices | | 1.9 % || two real recordings of the same person | 0.75 | |**Recordings:**- **At least 5 minutes of speech**, better 15. Count only the speech, not silence or noise.- A quiet room without echo, one microphone at a fixed 15 to 20 cm, WAV, 24 kHz or more, mono, no background noise ormusic.- One sentence per file, read naturally, varied (questions, statements, long and short), with an exact transcript ofwhat was said.- **Trim the noise before the first word.** Our first try kept about 1 s of room noise and breath before eachsentence; the model then swallowed the first word in 40 % of sentences (6.7 % word errors). Trimming to 0.15 s ofsilence (`librosa.effects.trim(top_db=25)`) fixed it. Check afterwards that Whisper still hears the first word ofevery trimmed clip.**Training:** build features with `python -m sktts.data.english` and fine-tune with `sktts.train.matcha`(`--init-from` these weights, `--only-speakers <new voice>`, `--init-speakers <new voice>=en_hifi_92_clean`, lr 5e-5,1 500 steps); the code is in the project's training repository.## ArchitectureAll of it is in `tts_english/model.py`, plain PyTorch, no vendored code.- **Text encoder:** six transformer layers (256 wide) with rotary positions over ARPAbet phonemes from g2p_en.- **Alignment:** monotonic alignment search during training, no external aligner.- **Durations:** a small flow-matching head samples the length of every phoneme and pause.- **Decoder:** a diffusion transformer, 10 layers, 512 wide, conditional flow matching, with each frame's positioninside its phoneme; classifier-free guidance 1.5.- **Fast decoder:** a reflow-distilled copy for 2 steps without guidance.- **Vocoders:** BigVGAN base (14 M) and Vocos (13.5 M), both fine-tuned on this model's mels.- **Voice encoder:** 17 MB, maps a recording to a voice vector (cloning).## Training| Run | Steps | What | Hardware, time ||---|---|---|---|| v2-en … v2.2 | see `v2.3-old` | from scratch to 592 voices and two speaking styles | AMD MI300X, RTX 3080 || v2.3-old | | BigVGAN and Vocos fine-tunes, fast decoder, voice encoder | RTX 3080 || **v2.3 (this model)** | +600 | two voices, 1 024 recordings each | RTX 3080 || v2.3 Vocos | 20 000 | from the v2.3-old Vocos, on these weights' mels (HiFi-TTS + DailyTalk) | RTX 3080, 2.1 h || v2.3 fast decoder | 13 000 | reflow on 13 500 sentences | RTX 3080, 1.4 h |## Limitations- English only, two voices, two styles; no emotions yet.- g2p_en can mispronounce rare names and words. Number rules are American English.- The Vocos fast mode sounds slightly metallic.- The voices belong to real readers (HiFi-TTS, DailyTalk). Do not use them, or voices you add, to impersonate anyone orto deceive. Add a person's voice only with their consent. Speech is not watermarked.## Licenses and attribution- **This model** (weights and code): CC BY-SA 4.0, because it learned from DailyTalk (CC BY-SA 4.0).- **Training data:** LibriTTS-R (Koizumi et al., 2023, CC BY 4.0), HiFi-TTS (Bakhturina et al., 2021, CC BY 4.0),DailyTalk (Lee et al., ICASSP 2023, CC BY-SA 4.0). The voice tests used VCTK (Yamagishi et al., CC BY 4.0), which thepublished model did not learn from.- **Vocoders:** NVIDIA BigVGAN (Lee et al., 2023), MIT: `vocoder/bigvgan_finetuned.pt` is`nvidia/bigvgan_base_24khz_100band` fine-tuned here. Vocos (Siuzdak, 2023), MIT: `vocoder/vocos.safetensors` is`charactr/vocos-mel-24khz` fine-tuned here; `tts_english/vocos.py` re-implements its forward pass.- **G2P:** g2p_en (Kyubyong Park), Apache-2.0, with the CMU Pronouncing Dictionary.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178"""Local page to try the model: type any English text, pick a voice, tune pace and pauses, listen.
python app.py --bigvgan BigVGAN | --vocoder vocos [--fast] [--repo mmmhusto/TTS-English] [--port 8790] [--device auto|mps|cuda|cpu]
Open http://localhost:8790. Only the Python standard library is needed on top of the model's own requirements."""
from __future__ import annotations
import argparseimport ioimport jsonimport threadingimport timefrom http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
import soundfile as sfimport torch
from tts_english import SAMPLE_RATE, TTS
PAGE = r"""<!doctype html><html lang=en><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>TTS English</title><style>:root{--bg:#f6f5f2;--card:#fff;--fg:#1d1d1b;--mute:#6b6a64;--line:#e2e0d8;--acc:#2f5d50;--accfg:#fff}@media (prefers-color-scheme:dark){:root{--bg:#161715;--card:#20211f;--fg:#ecebe6;--mute:#9b9a93;--line:#33342f;--acc:#7fb8a4;--accfg:#10201a;color-scheme:dark}}*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--fg);font:15px/1.5 system-ui,-apple-system,sans-serif}main{max-width:760px;margin:0 auto;padding:28px max(16px,env(safe-area-inset-left)) 60px}h1{font-size:22px;margin:0 0 4px}p.sub{color:var(--mute);margin:0 0 20px}.card{background:var(--card);border:1px solid var(--line);border-radius:12px;padding:16px;display:grid;gap:14px}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)}.grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:12px 20px}label{display:grid;gap:4px;font-size:13px;color:var(--mute)}label b{color:var(--fg);font-weight:600}select{font:inherit;padding:6px;border-radius:6px;border:1px solid var(--line);background:var(--bg);color:var(--fg)}input[type=range]{width:100%;accent-color:var(--acc)}.row{display:flex;gap:10px;align-items:center;flex-wrap:wrap}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}button.ghost{background:transparent;color:var(--acc);border:1px solid var(--line);font-weight:500}button:disabled{opacity:.5;cursor:wait}#status{color:var(--mute);font-size:13px}#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}.item .t{font-size:14px}.item .m{font-size:12px;color:var(--mute)}audio{width:100%}</style><main><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><div class=card><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><div class=grid><label>Hlas<select id=voice>__VOICES__</select></label>__STYLE__<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><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><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><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><label>Variant (seed) <b><span id=seed_v></span></b><input id=seed type=range min=0 max=20 step=1 value=0></label></div><div class=row><button id=go>Vygenerovať</button><button class="ghost" id=reset>Predvolené</button><span id=status></span></div></div><div id=out></div></main><script>const $=id=>document.getElementById(id);const sliders=["gap","comma","pace","uni","seed"].concat($("sscale")?["sscale"]:[]);const defaults={};sliders.forEach(s=>{defaults[s]=$(s).value;const f=()=>$(s+"_v").textContent=$(s).value;$(s).oninput=f;f()});$("reset").onclick=()=>sliders.forEach(s=>{$(s).value=defaults[s];$(s).oninput()});async function go(){ const text=$("text").value.trim();if(!text)return; $("go").disabled=true;$("status").textContent="Generujem…"; const body={text,voice:$("voice").value,sentence_gap:+$("gap").value,pause_scale:+$("comma").value, length_scale:+$("pace").value,uniform:+$("uni").value,seed:+$("seed").value}; if($("style")){body.style=$("style").value;body.style_scale=+$("sscale").value} try{ const r=await fetch("/tts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(body)}); if(!r.ok)throw new Error(await r.text()); const secs=r.headers.get("X-Seconds"),took=r.headers.get("X-Took"); const url=URL.createObjectURL(await r.blob()); const d=document.createElement("div");d.className="item"; d.innerHTML=`<div class=t></div><audio controls autoplay src="${url}"></audio><div class=m></div>`; d.querySelector(".t").textContent=text; 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`; $("out").prepend(d);$("status").textContent=""; }catch(e){$("status").textContent="Chyba: "+e.message} $("go").disabled=false;}$("go").onclick=go;$("text").onkeydown=e=>{if(e.key==="Enter"&&(e.metaKey||e.ctrlKey))go()};</script>"""
VOICE_NAMES = {"en_hifi_92_clean": "Studio 92 (žena, odporúčaný)", "en_hifi_8051_other": "Studio 8051 (žena)", "en_hifi_11697_other": "Studio 11697 (žena)", "en_dt_0": "DailyTalk (muž, rozhovor)", "en_hifi_6670_other": "Studio 6670 (muž, čítanie)"}
def pick_device(want: str) -> str: if want != "auto": return want if torch.cuda.is_available(): return "cuda" return "mps" if torch.backends.mps.is_available() else "cpu"
def main() -> int: ap = argparse.ArgumentParser(description=__doc__.split("\n\n")[0]) ap.add_argument("--bigvgan", default="BigVGAN", help="clone of github.com/NVIDIA/BigVGAN") ap.add_argument("--fast", action="store_true", help="distilled 2-step decoder, ~10x faster acoustic model") ap.add_argument("--vocoder", default="bigvgan", choices=["bigvgan", "vocos"], help="vocos: fast on a CPU and needs no BigVGAN clone") ap.add_argument("--repo", default="mmmhusto/TTS-English", help="Hub repo or local folder with the weights") ap.add_argument("--port", type=int, default=8790) ap.add_argument("--device", default="auto", help="auto picks cuda, then mps (Apple GPU), then cpu") a = ap.parse_args()
device = pick_device(a.device) tts = TTS.from_pretrained(a.repo, a.bigvgan, device=device, vocoder=a.vocoder, fast=a.fast) try: # MPS lacks a few ops on some torch versions: fall back to the CPU rather than fail on the first request tts("Test.") except Exception as e: # noqa: BLE001 if device == "cpu": raise print(f"[app] {device} failed ({e.__class__.__name__}: {e}); using cpu", flush=True) device = "cpu" tts = TTS.from_pretrained(a.repo, a.bigvgan, device=device, vocoder=a.vocoder, fast=a.fast) lock = threading.Lock() # one synthesis at a time
shown = list(VOICE_NAMES) + [v for v in tts.config.get("recommended_voices", []) if v not in VOICE_NAMES] options = "".join(f'<option value="{v}">{VOICE_NAMES.get(v, v)}</option>' for v in shown if v in tts.voices) names = {"reading": "čítanie", "conversational": "rozhovor"} style = "" if not tts.styles else ( "<label>Štýl<select id=style>" + "".join(f'<option value="{s}">{names.get(s, s)}</option>' for s in tts.styles) + "</select></label>\n<label>Sila štýlu <b>×<span id=sscale_v></span></b>" f"<input id=sscale type=range min=0 max=2 step=0.1 value={tts.config['delivery'].get('style_scale', 1)}></label>") page = PAGE.replace("__STYLE__", style).replace("__VOICES__", options).replace("__DEVICE__", {"mps": "grafika Apple", "cuda": "NVIDIA GPU", "cpu": "procesor"}[device]).encode()
class Handler(BaseHTTPRequestHandler): def send(self, code, body: bytes, ctype: str, headers=()): self.send_response(code) self.send_header("Content-Type", ctype) self.send_header("Content-Length", str(len(body))) for k, v in headers: self.send_header(k, v) self.end_headers() self.wfile.write(body)
def do_GET(self): self.send(200, page, "text/html; charset=utf-8") if self.path in ("/", "/index.html") else \ self.send(404, b"not found", "text/plain")
def do_POST(self): if self.path != "/tts": return self.send(404, b"not found", "text/plain") try: req = json.loads(self.rfile.read(int(self.headers.get("Content-Length", 0)))) text = str(req["text"]).strip()[:2000] voice = req.get("voice") if req.get("voice") in tts.voices else None settings = {k: float(req[k]) for k in ("pause_scale", "length_scale", "style_scale") if k in req} if req.get("style") in tts.styles: settings["style"] = req["style"] t0 = time.time() with lock: wav = tts(text, voice, seed=int(req.get("seed", 0)), uniform=float(req.get("uniform", 0.7)), sentence_gap=float(req.get("sentence_gap", 0.35)), **settings) buf = io.BytesIO() sf.write(buf, wav, SAMPLE_RATE, format="WAV") self.send(200, buf.getvalue(), "audio/wav", [("X-Seconds", f"{len(wav) / SAMPLE_RATE:.1f}"), ("X-Took", f"{time.time() - t0:.1f}")]) except Exception as e: # noqa: BLE001 self.send(400, f"{e.__class__.__name__}: {e}".encode(), "text/plain; charset=utf-8")
def log_message(self, *args): pass
print(f"[app] {device} http://localhost:{a.port}", flush=True) ThreadingHTTPServer(("127.0.0.1", a.port), Handler).serve_forever() return 0
if __name__ == "__main__": raise SystemExit(main())123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312{"model": {"n_feats": 100,"spk_dim": 256,"enc_dim": 256,"enc_layers": 6,"enc_heads": 4,"dec_dim": 512,"dec_layers": 10,"dec_heads": 8,"dropout": 0.1,"dec_dropout": 0.0,"p_uncond": 0.1,"phone_pos": true,"dur_flow": true,"dur_dim": 192,"dur_layers": 3,"t_uniform": 0.2,"n_styles": 2},"symbols": ["<pad>","<bos>","<eos>","<unk>","▁",",",".","!","?","AA0","AA1","AA2","AE0","AE1","AE2","AH0","AH1","AH2","AO0","AO1","AO2","AW0","AW1","AW2","AY0","AY1","AY2","EH0","EH1","EH2","ER0","ER1","ER2","EY0","EY1","EY2","IH0","IH1","IH2","IY0","IY1","IY2","OW0","OW1","OW2","OY0","OY1","OY2","UH0","UH1","UH2","UW0","UW1","UW2","B","CH","D","DH","F","G","HH","JH","K","L","M","N","NG","P","R","S","SH","T","TH","V","W","Y","Z","ZH","sk_a","sk_e","sk_i","sk_o","sk_u","sk_aː","sk_eː","sk_iː","sk_oː","sk_uː","sk_ia","sk_ie","sk_iu","sk_uo","sk_r̩","sk_r̩ː","sk_l̩","sk_l̩ː","sk_p","sk_b","sk_t","sk_d","sk_c","sk_ɟ","sk_k","sk_g","sk_ts","sk_dz","sk_tʃ","sk_dʒ","sk_f","sk_v","sk_w","sk_s","sk_z","sk_ʃ","sk_ʒ","sk_x","sk_ɦ","sk_m","sk_n","sk_ɲ","sk_ŋ","sk_l","sk_ʎ","sk_r","sk_j"],"voices": ["en_hifi_92_clean","en_dt_0","sk_cori","sk_dailytalk","sk_muz"],"mel_mean": -5.9344089481310744,"mel_std": 2.3695238543771113,"delivery": {"guidance": 1.5,"length_scale": 1.04,"pause_scale": 2.5,"n_timesteps": 10,"temperature": 0.667,"sentence_gap": 0.35,"style_scale": 1.5},"vocoder": "nvidia/bigvgan_base_24khz_100band","sample_rate": 24000,"training_step": 20000,"parameters": {"acoustic_model": 41815690,"vocoder": 14020000},"default_voice": "en_hifi_92_clean","recommended_voices": ["en_hifi_92_clean","en_dt_0"],"profiles": {"en_hifi_92_clean": [-4.5528,-4.8893,-5.2367,-4.5505,-3.4233,-2.8618,-3.097,-4.2703,-4.2467,-4.0435,-3.4204,-3.3618,-3.6058,-3.8797,-4.2246,-3.9774,-4.0689,-3.85,-4.0776,-3.9829,-3.9574,-3.9879,-3.9235,-4.1083,-3.9021,-4.1646,-4.0601,-4.3304,-4.4415,-4.5864,-4.6558,-4.7651,-4.7194,-4.8787,-4.914,-5.0016,-5.1144,-5.1995,-5.2957,-5.383,-5.3533,-5.3153,-5.2753,-5.3689,-5.3588,-5.4987,-5.4719,-5.439,-5.4255,-5.4821,-5.6054,-5.661,-5.7136,-5.7257,-5.7577,-5.7937,-5.7881,-5.7086,-5.6496,-5.5307,-5.432,-5.3035,-5.195,-5.2011,-5.2987,-5.4264,-5.4868,-5.4925,-5.4033,-5.3616,-5.3443,-5.3643,-5.4964,-5.6871,-5.7945,-5.8009,-5.7339,-5.6264,-5.5396,-5.5173,-5.5787,-5.7013,-5.9112,-6.1813,-6.4441,-6.6154,-6.6782,-6.6212,-6.5478,-6.4835,-6.3629,-6.2702,-6.2736,-6.3551,-6.5393,-6.5878,-6.5743,-6.6207,-6.6606,-7.6826]},"styles": ["reading","conversational"],"voice_styles": {"en_dt_0": "conversational","sk_cori": "reading","sk_dailytalk": "conversational","sk_muz": "reading"},"vocoder_weights": "vocoder/bigvgan_finetuned.pt","vocoder_config": "vocoder/bigvgan_config.json","english_duo": {"source": "mmmhusto/TTS-husto v1.0","branch": "same","additional_steps": 600,"sha256": "ddb4d3c30f8f1889ac393e82c70c06e5fd6b64ebf6f54bcef0f10a1984c9fadd"},"languages": {"en": ["en_hifi_92_clean","en_dt_0"],"sk": ["sk_cori","sk_dailytalk","sk_muz"]},"architecture": "SkttsV2"}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263{"model": {"n_feats": 100,"spk_dim": 256,"enc_dim": 256,"enc_layers": 6,"enc_heads": 4,"dec_dim": 512,"dec_layers": 10,"dec_heads": 8,"dropout": 0.1,"dec_dropout": 0.0,"p_uncond": 0.1,"phone_pos": true,"dur_flow": true,"dur_dim": 192,"dur_layers": 3,"t_uniform": 0.2,"n_styles": 2},"symbols": ["<pad>","<bos>","<eos>","<unk>","\u2581",",",".","!","?","AA0","AA1","AA2","AE0","AE1","AE2","AH0","AH1","AH2","AO0","AO1","AO2","AW0","AW1","AW2","AY0","AY1","AY2","EH0","EH1","EH2","ER0","ER1","ER2","EY0","EY1","EY2","IH0","IH1","IH2","IY0","IY1","IY2","OW0","OW1","OW2","OY0","OY1","OY2","UH0","UH1","UH2","UW0","UW1","UW2","B","CH","D","DH","F","G","HH","JH","K","L","M","N","NG","P","R","S","SH","T","TH","V","W","Y","Z","ZH"],"voices": ["en_hifi_92_clean","en_dt_0"],"mel_mean": -5.9344089481310744,"mel_std": 2.3695238543771113,"delivery": {"guidance": 1.5,"length_scale": 1.04,"pause_scale": 2.5,"n_timesteps": 10,"temperature": 0.667,"sentence_gap": 0.35,"style_scale": 1.5},"vocoder": "nvidia/bigvgan_base_24khz_100band","sample_rate": 24000,"training_step": 20600,"parameters": {"acoustic_model": 41815690,"vocoder": 14020000},"default_voice": "en_hifi_92_clean","recommended_voices": ["en_hifi_92_clean","en_dt_0"],"profiles": {"en_hifi_92_clean": [-4.5528,-4.8893,-5.2367,-4.5505,-3.4233,-2.8618,-3.097,-4.2703,-4.2467,-4.0435,-3.4204,-3.3618,-3.6058,-3.8797,-4.2246,-3.9774,-4.0689,-3.85,-4.0776,-3.9829,-3.9574,-3.9879,-3.9235,-4.1083,-3.9021,-4.1646,-4.0601,-4.3304,-4.4415,-4.5864,-4.6558,-4.7651,-4.7194,-4.8787,-4.914,-5.0016,-5.1144,-5.1995,-5.2957,-5.383,-5.3533,-5.3153,-5.2753,-5.3689,-5.3588,-5.4987,-5.4719,-5.439,-5.4255,-5.4821,-5.6054,-5.661,-5.7136,-5.7257,-5.7577,-5.7937,-5.7881,-5.7086,-5.6496,-5.5307,-5.432,-5.3035,-5.195,-5.2011,-5.2987,-5.4264,-5.4868,-5.4925,-5.4033,-5.3616,-5.3443,-5.3643,-5.4964,-5.6871,-5.7945,-5.8009,-5.7339,-5.6264,-5.5396,-5.5173,-5.5787,-5.7013,-5.9112,-6.1813,-6.4441,-6.6154,-6.6782,-6.6212,-6.5478,-6.4835,-6.3629,-6.2702,-6.2736,-6.3551,-6.5393,-6.5878,-6.5743,-6.6207,-6.6606,-7.6826]},"styles": ["reading","conversational"],"voice_styles": {"en_dt_0": "conversational"},"vocoder_weights": "vocoder/bigvgan_finetuned.pt","vocoder_config": "vocoder/bigvgan_config.json","voice_encoder": "voice_encoder.safetensors","voice_encoder_cfg": {"dim": 256,"layers": 6,"kernel": 5,"out_dim": 256,"dropout": 0.1},"fast": {"weights": "fast_decoder.safetensors","delivery": {"n_timesteps": 2,"guidance": 0.0},"note": "reflow-distilled decoder (teacher: 10 steps x guidance 1.5), 13 000 steps on 13 500 sentences"},"vocos_weights": "vocoder/vocos.safetensors","version": "2.3","lineage": {"base": "mmmhusto/TTS-English v2.3-old (592 voices, 20 000 steps)","fine_tune": "+600 steps, 2 voices (RTX 3080)"}}
123version https://git-lfs.github.com/spec/v1oid sha256:0697dab2531f66ed610e314edf8812129efd0f40592c42a759a9a3f94f8fe09asize 139814904123456789101112131415161718192021"""python infer.py "Text to speak." out.wav [--voice en_dt_0] [--bigvgan BigVGAN | --vocoder vocos] [--fast]"""import argparse
import soundfile as sf
from tts_english import SAMPLE_RATE, TTS
ap = argparse.ArgumentParser()ap.add_argument("text")ap.add_argument("out")ap.add_argument("--voice", default=None, help="default: the studio voice en_hifi_92_clean")ap.add_argument("--bigvgan", default="BigVGAN", help="clone of github.com/NVIDIA/BigVGAN")ap.add_argument("--fast", action="store_true", help="distilled 2-step decoder, ~10x faster acoustic model")ap.add_argument("--vocoder", default="bigvgan", choices=["bigvgan", "vocos"], help="vocos: fast on a CPU and needs no BigVGAN clone")ap.add_argument("--repo", default="mmmhusto/TTS-English", help="Hub repo or local folder with the weights")ap.add_argument("--seed", type=int, default=0)a = ap.parse_args()tts = TTS.from_pretrained(a.repo, a.bigvgan, vocoder=a.vocoder, fast=a.fast)sf.write(a.out, tts(a.text, a.voice, a.seed), SAMPLE_RATE)print(f"{a.out}: {a.voice or tts.config['default_voice']}")123version https://git-lfs.github.com/spec/v1oid sha256:0bf6d2bd54ccc5eefc6a40002c0718c0dff26efbeb9a2a5990d2b18085e9859fsize 167340904123version https://git-lfs.github.com/spec/v1oid sha256:ddb4d3c30f8f1889ac393e82c70c06e5fd6b64ebf6f54bcef0f10a1984c9faddsize 167289704
123version https://git-lfs.github.com/spec/v1oid sha256:05352b1b0d0ca8c5b8d02e28bac91973ac00e78757341fec7c5410fa20e5349dsize 640364123version https://git-lfs.github.com/spec/v1oid sha256:2bb86e50b3798ae8f2633964a97a96f0b3ee58db7fbfcbe27010efa507d9cf84size 537164123version https://git-lfs.github.com/spec/v1oid sha256:8d5942d5d6872b49e6bf92ce469a0281ef695aa8c90cc26b6ab02c976ce7d5casize 639404123version https://git-lfs.github.com/spec/v1oid sha256:7bc103508f89fdc554fb08425c6631d26ae43625a4e36daefa07bb0a24b8c434size 643244123version https://git-lfs.github.com/spec/v1oid sha256:8a2505ab7a3d82629b5dda180fae6b5bec4e675957e4280d1ff028eb18b8954esize 297164123version https://git-lfs.github.com/spec/v1oid sha256:af17e6d4d48e5a2f5a66c1e20fdf3a6cbc050d39648edba5fe0c25ef9a5af32bsize 2683641234567891011121374 unmodified lines888990919293946 unmodified lines101102103104105106107108109110111112113114115116117118119120121122"""mmmhusto TTS English: text -> 24 kHz speech.from tts_english import TTStts = TTS.from_pretrained("mmmhusto/TTS-husto", bigvgan_dir="BigVGAN") # a clone of github.com/NVIDIA/BigVGANwav = tts("Good morning, and welcome.") # float32 numpy array, 24 kHztts = TTS.from_pretrained("mmmhusto/TTS-husto", vocoder="vocos") # fast vocoder, no BigVGAN clone neededtts = TTS.from_pretrained("mmmhusto/TTS-husto", vocoder="vocos", fast=True) # + 2-step decoder: fastestvoice = tts.clone_voice(recording, sample_rate) # a voice vector from 5-15 s of someone's speechwav = tts("Now I speak with that voice.", voice=voice)wav = tts.long(article) # any length: sentence by sentence74 unmodified linesself._get, self._refenc = None, None # set by from_pretrained: where the optional files are@classmethoddef from_pretrained(cls, repo: str = "mmmhusto/TTS-husto", bigvgan_dir: str | None = None, device: str = "cpu",vocoder_weights: str | None = None, vocoder: str | None = None,fast: bool = False) -> "TTS":"""``vocoder``: "bigvgan" (needs ``bigvgan_dir``, a clone of github.com/NVIDIA/BigVGAN) or "vocos" (fast,6 unmodified linesfrom safetensors.torch import load_filedef get(name: str) -> str: # a local folder, or a repo on the Hubreturn 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)config = json.load(open(get("config.json")))if not config.get("vocos_weights") and vocoder in (None, "bigvgan") and bigvgan_dir is None:import oscandidates = [os.environ.get("SKTTS_BIGVGAN_DIR"), Path.home() / "sktts-work" / "bigvgan",Path(r"C:\sktts\work\bigvgan"), Path("BigVGAN")]bigvgan_dir = next((str(p) for p in candidates if p and (Path(p) / "bigvgan.py").is_file()), None)if bigvgan_dir is None:raise ValueError("Set bigvgan_dir to the local NVIDIA BigVGAN repository.")if fast and not config.get("fast"):raise ValueError("This two-voice model uses the full decoder. Use fast=False.")if vocoder == "vocos" and not (vocoder_weights or config.get("vocos_weights")):raise ValueError("This two-voice model includes BigVGAN. Use vocoder='bigvgan'.")assert config["symbols"][:len(SYMBOLS)] == SYMBOLS, "frontend and checkpoint disagree on the symbol table"model = SkttsV2(len(config["symbols"]), len(config["voices"]), config["mel_mean"], config["mel_std"], cfg=config["model"])model.load_state_dict(load_file(get("model.safetensors")))if fast:model.load_state_dict(load_file(get(config["fast"]["weights"])), strict=False) # decoder.* only1234567891011121374 unmodified lines888990919293946 unmodified lines101102103104105106107108109110111"""mmmhusto TTS English: text -> 24 kHz speech.from tts_english import TTStts = TTS.from_pretrained("mmmhusto/TTS-English", bigvgan_dir="BigVGAN") # a clone of github.com/NVIDIA/BigVGANwav = tts("Good morning, and welcome.") # float32 numpy array, 24 kHztts = TTS.from_pretrained("mmmhusto/TTS-English", vocoder="vocos") # fast vocoder, no BigVGAN clone neededtts = TTS.from_pretrained("mmmhusto/TTS-English", vocoder="vocos", fast=True) # + 2-step decoder: fastestvoice = tts.clone_voice(recording, sample_rate, text=transcript) # a similar voice from >= 5 s of speechwav = tts("Now I speak with that voice.", voice=voice)wav = tts.long(article) # any length: sentence by sentence74 unmodified linesself._get, self._refenc = None, None # set by from_pretrained: where the optional files are@classmethoddef from_pretrained(cls, repo: str = "mmmhusto/TTS-English", bigvgan_dir: str | None = None, device: str = "cpu",vocoder_weights: str | None = None, vocoder: str | None = None,fast: bool = False) -> "TTS":"""``vocoder``: "bigvgan" (needs ``bigvgan_dir``, a clone of github.com/NVIDIA/BigVGAN) or "vocos" (fast,6 unmodified linesfrom safetensors.torch import load_filedef get(name: str) -> str: # a local folder, or a repo on the Hubreturn str(Path(repo) / name) if Path(repo).is_dir() else hf_hub_download(repo, name)config = json.load(open(get("config.json")))assert config["symbols"] == SYMBOLS, "frontend and checkpoint disagree on the symbol table"model = SkttsV2(len(SYMBOLS), len(config["voices"]), config["mel_mean"], config["mel_std"], cfg=config["model"])model.load_state_dict(load_file(get("model.safetensors")))if fast:model.load_state_dict(load_file(get(config["fast"]["weights"])), strict=False) # decoder.* only
123410 unmodified lines15161718192021"""tts-english "Text to speak." out.wav [--voice en_hifi_8051_other] [--style conversational] [--fast]Long texts are read sentence by sentence; ``-`` as the text reads it from standard input."""import argparse10 unmodified linesap.add_argument("--vocoder", default=None, choices=["bigvgan", "vocos"],help="default: bigvgan with --bigvgan, else vocos")ap.add_argument("--bigvgan", default=None, help="clone of github.com/NVIDIA/BigVGAN (best quality)")ap.add_argument("--repo", default="mmmhusto/TTS-husto", help="Hub repo or local folder with the weights")ap.add_argument("--device", default="cpu")ap.add_argument("--seed", type=int, default=0)a = ap.parse_args(argv)123410 unmodified lines15161718192021"""tts-english "Text to speak." out.wav [--voice en_dt_0] [--style conversational] [--fast]Long texts are read sentence by sentence; ``-`` as the text reads it from standard input."""import argparse10 unmodified linesap.add_argument("--vocoder", default=None, choices=["bigvgan", "vocos"],help="default: bigvgan with --bigvgan, else vocos")ap.add_argument("--bigvgan", default=None, help="clone of github.com/NVIDIA/BigVGAN (best quality)")ap.add_argument("--repo", default="mmmhusto/TTS-English", help="Hub repo or local folder with the weights")ap.add_argument("--device", default="cpu")ap.add_argument("--seed", type=int, default=0)a = ap.parse_args(argv)
123version https://git-lfs.github.com/spec/v1oid sha256:3b51878ad1068ca671b2315eeb78f741cfbbb0ebbc56778f28398d1010e615f3size 54134536123version https://git-lfs.github.com/spec/v1oid sha256:2b7ccdbfc9ed71a47de53851865ca8d7b157460cec9d8b778f564267ff37b9e4size 17205480.gitattributes+6
README.md+159-34
app.pyAdded+178
config.json+259-308
fast_decoder.safetensorsAdded+3
infer.pyAdded+21
model.safetensors+2-2
samples/fast_vocos_story_92.wavAdded+3
samples/numbers_92.wavAdded+3
samples/story_92.wavAdded+3
samples/story_dt0.wavAdded+3
samples/talk_92_conversational.wavAdded+3
samples/talk_dt0.wavAdded+3
tts_english/__init__.py+8-19
tts_english/__main__.py+2-2
vocoder/vocos.safetensorsAdded+3
voice_encoder.safetensorsAdded+3