v4.0: Slovak, three original voices (sk_f3, sk_f2, sk_m1), ~1 % CER on 281 unseen sentences; onnxruntime package tts_slovak and browser ONNX
Browse filesFiles changed (38)
- README.md+97-24
- config.json+197-310
- model.safetensors+2-2
- povedz.pyDeleted-68
- requirements.txt+1-5
- slovak-frontend.zipDeleted-3
- tts_english/__init__.pyDeleted-244
- tts_english/__main__.pyDeleted-36
- tts_english/frontend.pyDeleted-68
- tts_english/normalize.pyDeleted-234
- tts_english/post.pyDeleted-58
- tts_english/refenc.pyDeleted-170
- tts_english/vocos.pyDeleted-79
- tts_slovak/__init__.pyAdded+209
- tts_slovak/__main__.pyAdded+28
- tts_slovak/frontend/__init__.pyAdded+5
- tts_slovak/frontend/context.pyAdded+129
- tts_slovak/frontend/data/g2p_hard.txtAdded+145
- tts_slovak/frontend/data/nouns.tsvAdded+47
- tts_slovak/frontend/g2p.pyAdded+190
- tts_slovak/frontend/lexicon.pyAdded+204
- tts_slovak/frontend/normalize.pyAdded+478
- tts_slovak/frontend/numbers.pyAdded+322
- tts_slovak/frontend/phonemes.pyAdded+34
- tts_slovak/frontend/pipeline.pyAdded+217
- tts_slovak/frontend/ssml.pyAdded+152
- tts_english/mas.py → tts_slovak/mas.pyRenamed
- tts_english/model.py → tts_slovak/model.pyRenamed+179-8
- vocoder/bigvgan_config.jsonDeleted-46
- vocoder/bigvgan_finetuned.ptDeleted-3
- web/bigvgan.onnx+2-2
- web/decoder.onnx+2-2
- web/g2p/cmudict.txtDeleted
- web/g2p/g2p_oov.binDeleted-3
- web/g2p/homographs.jsonDeleted-1
- web/g2p/tagger.jsonDeleted
- web/text.onnx+2-2
- web/voices.json+1-1
123456789101112131415164 unmodified lines212223242526272829303132333435363738394041424344454647484950515253545556575859---language:- en- sklicense: cc-by-sa-4.0pipeline_tag: text-to-speechtags:- text-to-speech- onnx- bilingual---# TTS English, Slovak by husto## Versions4 unmodified lines| 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` || v2.1 | v2.0 with a fast mode (2-step decoder + Vocos, ~9x real time on a laptop CPU), voice cloning and a measured recipe for adding a voice (5 min of speech) | `hf download mmmhusto/TTS-husto --revision v2.1` || 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.123456789101112131415164 unmodified lines21222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132---language:- sk- enlicense: cc-by-sa-4.0pipeline_tag: text-to-speechtags:- text-to-speech- slovak- onnx---# TTS by husto## Versions4 unmodified lines| 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` || v2.1 | v2.0 with a fast mode (2-step decoder + Vocos, ~9x real time on a laptop CPU), voice cloning and a measured recipe for adding a voice (5 min of speech) | `hf download mmmhusto/TTS-husto --revision v2.1` || v3.0 | First bilingual try: v2.0 plus experimental Slovak (5 voices) | `hf download mmmhusto/TTS-husto --revision v3.0` || **v4.0** | **Slovak: three original Slovak voices, about 1 % character error rate, runs on CPU and in the browser** | `hf download mmmhusto/TTS-husto --revision v4.0` |**This page describes v4.0, the Slovak model.** For English use **v2.1** (or v2.0); the[demo](https://huggingface.co/spaces/mmmhusto/TTS-English-demo) has both languages.## Slovak voices| Voice | Sound | Built from ||---|---|---|| `sk_f3` | woman, clean studio sound | 80 % the Lili recordings (CC0) + 20 % the FLEURS Slovak women (CC BY 4.0) || `sk_f2` | woman, clearest | Slovak pronunciation of three native TrePal speakers; sound from the English studio voices HiFi-TTS 92 and 8051 || `sk_m1` | man | Slovak pronunciation of native TrePal speakers; sound from English studio voices plus the Slovak mix |The voices are synthetic: vectors mixed in the model's voice space and then fine-tuned on their own ASR-checkedspeech. None is meant to imitate a person; please do not use them to impersonate anyone.## Quality281 Slovak sentences the model never trained on (150 FLEURS test, 131 TrePal test, 6-20 words each), scored withthe Slovak Whisper `kinit/whisper-large-v3-turbo-sk` (character error rate), Whisper language identification(probability of Slovak) and TorchAudio SQUIM (PESQ estimate):| Voice | CER, 32 steps | CER, 10 steps | P(Slovak) | PESQ, 32 / 10 steps ||---|---|---|---|---|| sk_f3 | 1.07 % | 1.03 % | 0.99 | 3.59 / 3.55 || sk_f2 | 1.12 % | 1.12 % | 0.99 | 3.72 / 3.68 || sk_m1 | 1.20 % | 1.18 % | 0.99 | 3.07 / 3.01 |10 decoder steps read as well as 32 and are 3x faster, so 10 is the default (`--steps 32` for the last bit of clarity;16 steps: the same CER, PESQ 3.57 / 3.70 / 3.06).SQUIM works at 16 kHz and does not hear noise above 8 kHz.## Use it```shpip install numpy onnxruntime soundfile huggingface_hubhf download mmmhusto/TTS-husto --revision v4.0 --local-dir TTS-hustocd TTS-hustopython -m tts_slovak "Dňa 3. mája o 14:30 prišlo 250 ľudí. Prečo práve tam?" vystup.wav --voice sk_f3``````pythonfrom tts_slovak import SlovakTTStts = SlovakTTS.from_pretrained(".") # the downloaded folderwav = tts("Dobrý deň, ako sa máte?", voice="sk_m1") # float32 numpy array, 24 kHztts.save("Vlak odchádza o 7:45 z druhej koľaje.", "vlak.wav", voice="sk_f2")for chunk in tts.stream("Prvá veta. Druhá veta.", voice="sk_f3"): # one chunk per sentence...````tts_slovak` runs the ONNX graphs in `web/` with onnxruntime (CPU: 0.8x real time on a MacBook at 10 steps), exactlyas the browser demo does; both were checked against the PyTorch model (same durations, mean mel difference under0.001).**Text frontend** (`tts_slovak/frontend`, pure Python): numbers, dates, times, money and percentages read out withSlovak declension, common abbreviations, grapheme-to-phoneme rules with voicing assimilation across words, stress,sentence types (statement, yes/no question, wh-question, exclamation) and pause levels.**Delivery**: the durations the model draws are shaped like people read Slovak, measured on FLEURS: short comma pauses(at most 0.19 s), the last vowel of a sentence at most 1.25x the sentence's median vowel, long vowels 1.12x and shortones 0.85x (the model's own contrast was weak), at least 64 ms per vowel and 32 ms per other sound (short words wereswallowed), a silent lead-in and a silent sentence end.### PyTorch`model.safetensors` + `config.json` hold the acoustic model (41.8 M parameters) for research or fine-tuning; the code is`tts_slovak/model.py`:```pythonimport json, torchfrom safetensors.torch import load_filefrom tts_slovak.model import SkttsV2, natural_skcfg = json.load(open("config.json"))model = SkttsV2(len(cfg["symbols"]), len(cfg["voices"]), cfg["mel_mean"], cfg["mel_std"], cfg=cfg["model"]).eval()model.load_state_dict(load_file("model.safetensors"))kw = natural_sk(cfg["symbols"], cfg["model"]) # pass eq_gain=None for sk_f3 (no s/c/z equaliser)# ids: tts_slovak.SlovakTTS.ids(tokens of the frontend); spks: index into cfg["voices"]```The vocoder is NVIDIA's `nvidia/bigvgan_base_24khz_100band` (MIT); `web/bigvgan.onnx` is its export.## Known limits- Yes/no questions end with a falling melody, as in most of the training speech (Slovak speakers often rise). Apost-processing lift was built and tried, and left out after listening.- 24 kHz audio. Foreign names and words are read with Slovak rules.- Very long sentences without punctuation are read in one piece.## How it was madeThe English base model (v1.0, a 42 M transformer encoder + flow-matching DiT decoder with a duration flow) was taughtSlovak with a shared symbol table (English ids first, then `sk:` phonemes): TrePal (166 speakers, at most 1.5 h each),Lili and FLEURS Slovak, with English replay so English is not forgotten. Each voice was then "locked": 1,800-2,500sentences synthesised in that voice, only takes that the Slovak Whisper transcribed without an error kept, and themodel fine-tuned on them. The last fine-tune (4,000 steps) added Lili's questions and exclamations. Trained on oneRTX 3080.## Data and attribution- [TrePal](https://huggingface.co/datasets/streams-sro/trepal), CC BY 4.0, © Národná rada Slovenskej republiky(nrsr.sk, tv.nrsr.sk), segmentation and alignment by Streams s.r.o.- [Lili](https://huggingface.co/datasets/vsisik/voice-dataset-lili), Open Home Foundation, CC0.- [FLEURS](https://huggingface.co/datasets/google/fleurs) Slovak, Google, CC BY 4.0.- English base model data (HiFi-TTS, DailyTalk and others) and BigVGAN: see[v1.0](https://huggingface.co/mmmhusto/TTS-husto/tree/v1.0) and [v2.0](https://huggingface.co/mmmhusto/TTS-husto/tree/v2.0).- Model license: CC BY-SA 4.0 (inherited from DailyTalk in the English base).
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"}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199{"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": 0,"ctx_dim": 0,"p_ctx_drop": 0.1},"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:<s>","sk:<q>","sk:<wh>","sk:<e>","sk:|1","sk:|2","sk:|3","sk:|4","sk:▁","sk:ˈ","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": ["sk_f3","sk_f2","sk_m1"],"mel_mean": -5.9344089481310744,"mel_std": 2.3695238543771113,"sample_rate": 24000,"hop_length": 256,"n_mels": 100,"delivery": {"n_timesteps": 10,"temperature": 0.667,"dur_temperature": 0.7,"guidance": 1.5,"length_scale": 1.04,"pause_scale": 1.0,"max_pause": 18,"max_final": 1.25,"short_scale": 0.85,"long_scale": 1.12,"min_vowel": 6,"min_phone": 3,"max_tail": 8,"max_stop": 42},"eq_voices": ["sk_f2","sk_m1"],"vocoder": "nvidia/bigvgan_base_24khz_100band","training_step": 4000,"parameters": {"acoustic_model": 41830028},"languages": ["sk"],"note": "Bilingual table (English ids first, then sk:<symbol>); the Slovak frontend's tokens map to sk: ids, <pad> <bos> <eos> <unk> are shared. Voice rows include each voice's own style."}
123version https://git-lfs.github.com/spec/v1oid sha256:0bf6d2bd54ccc5eefc6a40002c0718c0dff26efbeb9a2a5990d2b18085e9859fsize 167340904123version https://git-lfs.github.com/spec/v1oid sha256:45ff279aae3a06a9577bbcac1f4b0f0ef0d220839b3d10c077bc10207d1247f5size 167346960
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768"""Generate speech with the bilingual SkttsV2 checkpoint."""import argparseimport jsonfrom pathlib import Pathimport sysfrom tempfile import TemporaryDirectoryfrom zipfile import ZipFile
import numpy as npimport soundfile as sfimport torch
from tts_english import TTS, SAMPLE_RATE
def slovak(tts, frontend, text, voice): symbols = {token: i for i, token in enumerate(tts.config['symbols'])} speaker = torch.tensor([tts.voices.index(voice)], device=tts.device) delivery = dict(tts.config['delivery']) gap = delivery.pop('sentence_gap') delivery['style_scale'] = .75 if voice == 'sk_dailytalk' else 1. chunks = [] for i, utterance in enumerate(frontend.sentences(text)): phonemes = ['<bos>', *utterance['phones'], '<eos>'] ids = torch.tensor([[symbols[phone] for phone in phonemes]], device=tts.device) torch.manual_seed(450 + i) mel = tts.model.synthesise( ids, torch.tensor([ids.shape[1]], device=tts.device), spks=speaker, pause_tokens=tts._pause, stop_tokens=tts._stop, max_stop=gap*SAMPLE_RATE/256, **delivery, )['mel'][0] chunks.append(tts.render(mel, voice, uniform=0)) return np.concatenate(chunks) if chunks else np.empty(0, dtype='float32')
def main(): root = Path(__file__).resolve().parent cfg = json.loads((root/'config.json').read_text()) parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('text') parser.add_argument('output', type=Path) parser.add_argument('--jazyk', choices=['en','sk'], default='sk') parser.add_argument('--hlas', choices=cfg['voices']) parser.add_argument('--bigvgan', type=Path, default=Path.home()/'sktts-work/bigvgan') parser.add_argument('--device', choices=['cpu','cuda'], default='cpu') args = parser.parse_args() voice = args.hlas or ('sk_muz' if args.jazyk == 'sk' else cfg['languages']['en'][0]) if voice not in cfg['languages'][args.jazyk]: parser.error('Hlas nepatrí do zvoleného jazyka.') if not any(c.isalnum() for c in args.text): parser.error('Zadaj vysloviteľný text.') torch.set_num_threads(4) tts = TTS.from_pretrained(str(root), str(args.bigvgan), device=args.device) if args.jazyk == 'en': wave = tts.long(args.text, voice=voice, seed=450) else: with TemporaryDirectory() as temp: with ZipFile(root/'slovak-frontend.zip') as archive: archive.extractall(temp) sys.path.insert(0,temp) import slovak_frontend wave = slovak(tts, slovak_frontend, args.text, voice) if not wave.size or not np.isfinite(wave).all(): parser.error('Model nevytvoril prehrateľnú nahrávku.') args.output.parent.mkdir(parents=True,exist_ok=True) sf.write(args.output, wave, SAMPLE_RATE)
if __name__ == '__main__': main()12345678torchnumpysoundfilehuggingface_hubsafetensorsg2p_enlibrosamatplotlib1234numpyonnxruntimesoundfilehuggingface_hub
123version https://git-lfs.github.com/spec/v1oid sha256:43ba3e562c087d7188176a904555ed903cc83fbb1f7403980512f51e0fd3683dsize 30394123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244"""mmmhusto TTS English: text -> 24 kHz speech.
from tts_english import TTS tts = TTS.from_pretrained("mmmhusto/TTS-husto", bigvgan_dir="BigVGAN") # a clone of github.com/NVIDIA/BigVGAN wav = tts("Good morning, and welcome.") # float32 numpy array, 24 kHz
tts = TTS.from_pretrained("mmmhusto/TTS-husto", vocoder="vocos") # fast vocoder, no BigVGAN clone needed tts = TTS.from_pretrained("mmmhusto/TTS-husto", vocoder="vocos", fast=True) # + 2-step decoder: fastest
voice = tts.clone_voice(recording, sample_rate) # a voice vector from 5-15 s of someone's speech wav = tts("Now I speak with that voice.", voice=voice)
wav = tts.long(article) # any length: sentence by sentence for chunk in tts.stream(article): play(chunk) # the first sentence is ready long before the last"""
from __future__ import annotations
import jsonimport reimport sys
import numpy as npimport torch
from .frontend import SYMBOLS, encode, phonemizefrom .model import SkttsV2, pause_tokens, stop_tokensfrom .normalize import normalizefrom .post import finish, match_timbre
SAMPLE_RATE = 24000HOP = 256 # mel frame = 256 samples_CONFIG = object() # "take the value from config.json"__all__ = ["SAMPLE_RATE", "TTS", "finish", "load_vocoder", "split_sentences"]_SENTENCE_END = re.compile(r"(?<=[.!?])[\"')\]”’]*\s+(?=[\"'(\[“‘]*[A-Z0-9])")_CLAUSE_END = re.compile(r"(?<=[;:,])\s+")
def split_sentences(text: str, max_chars: int = 250) -> list[tuple[str, bool]]: """(sentence, ends a paragraph) for a text of any length. The text is normalized first, so "Dr. Smith" and "3.14" are already words and do not split; a blank line ends a paragraph. A sentence over ``max_chars`` is cut after ``; : ,`` (the model was trained on clips up to ~25 s).""" out: list[tuple[str, bool]] = [] for para in re.split(r"\n\s*\n", text): para = " ".join(para.split()) if not para: continue parts = [] for sent in _SENTENCE_END.split(normalize(para)): while len(sent) > max_chars: cuts = [m.end() for m in _CLAUSE_END.finditer(sent, 0, max_chars)] cut = cuts[-1] if cuts else (sent.rfind(" ", 0, max_chars) + 1 or max_chars) parts.append(sent[:cut].strip()) sent = sent[cut:] if sent.strip(): parts.append(sent.strip()) out += [(p, k == len(parts) - 1) for k, p in enumerate(parts)] return out
def load_vocoder(bigvgan_dir: str, model_id: str, device: str, weights: str | None = None, config_path: str | None = None): """NVIDIA BigVGAN (MIT) from a clone of its repository, weight norm removed. The weights come from the Hub, or from ``weights``: a generator fine-tuned on this model's own mels (same architecture).""" from huggingface_hub import hf_hub_download
if bigvgan_dir not in sys.path: sys.path.insert(0, bigvgan_dir) import bigvgan from env import AttrDict
h = AttrDict(json.load(open(config_path or hf_hub_download(model_id, "config.json")))) voc = bigvgan.BigVGAN(h, use_cuda_kernel=False) state = torch.load(weights or hf_hub_download(model_id, "bigvgan_generator.pt"), map_location="cpu", weights_only=False) voc.load_state_dict(state["generator"]) voc.remove_weight_norm() return voc.eval().to(device)
class TTS: def __init__(self, model: SkttsV2, config: dict, vocoder, device: str = "cpu"): self.model, self.config, self.vocoder, self.device = model.eval().to(device), config, vocoder, device self.voices = config["voices"] self.styles = config.get("styles", []) # e.g. ["reading", "conversational"]; empty = a model without styles for voice, style in config.get("voice_styles", {}).items(): # voices recorded in another style than reading self.model.spk_style[self.voices.index(voice)] = self.styles.index(style) self._pause, self._stop = pause_tokens(SYMBOLS), stop_tokens(SYMBOLS) self._get, self._refenc = None, None # set by from_pretrained: where the optional files are
@classmethod def 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, self-contained); default: bigvgan when ``bigvgan_dir`` is given, else vocos. ``vocoder_weights``: a checkpoint to use instead of the one config.json names for that vocoder. ``fast``: the distilled decoder (2 steps without guidance instead of 10 with it; ~10x faster acoustic model, equal in a blind test).""" from pathlib import Path
from huggingface_hub import hf_hub_download from safetensors.torch import load_file
def get(name: str) -> str: # a local folder, or a repo on the Hub 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)
config = json.load(open(get("config.json"))) if not config.get("vocos_weights") and vocoder in (None, "bigvgan") and bigvgan_dir is None: import os candidates = [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.* only config = {**config, "delivery": {**config["delivery"], **config["fast"]["delivery"]}} vocoder = vocoder or ("bigvgan" if bigvgan_dir else "vocos") if vocoder == "vocos": from .vocos import load_vocos
voc = load_vocos(vocoder_weights or get(config["vocos_weights"]), device) elif vocoder == "bigvgan" and bigvgan_dir: if vocoder_weights is None and config.get("vocoder_weights"): vocoder_weights = get(config["vocoder_weights"]) voc = load_vocoder(bigvgan_dir, config["vocoder"], device, vocoder_weights, get(config["vocoder_config"]) if config.get("vocoder_config") else None) else: raise ValueError('vocoder must be "vocos", or "bigvgan" together with bigvgan_dir') tts = cls(model, config, voc, device) tts._get = get return tts
def clone_voice(self, wav, sample_rate: int = SAMPLE_RATE, text: str | None = None, steps: int = 200, seed: int = 0) -> torch.Tensor: """A voice vector [1, 256] from a mono recording of one person (best: 5 to 15 s of clean speech). Pass it as ``voice`` to ``tts(...)``. With ``text`` (what the recording says) the vector is then refined for ``steps`` steps against the recording itself: closer to the speaker (speaker similarity 0.43 against 0.34 without), and about 10 to 40 s on a laptop CPU. Needs the "voice_encoder" file named in config.json. Only clone voices you have the right to use.""" if self._refenc is None: from safetensors.torch import load_file
from .refenc import RefEncoder
name = self.config.get("voice_encoder") if not name or self._get is None: raise RuntimeError("this model has no voice encoder (config.json: voice_encoder)") enc = RefEncoder(self.config.get("voice_encoder_cfg")) res = enc.load_state_dict(load_file(self._get(name)), strict=False) assert set(res.missing_keys) <= {"mel_basis"} and not res.unexpected_keys, res # mel_basis is computed self._refenc = enc.eval().to(self.device) vec = self._refenc.from_audio(wav, sample_rate) if not text: return vec from .refenc import fit_voice, mel_from_audio
with torch.inference_mode(): mel = mel_from_audio(torch.as_tensor(wav, dtype=torch.float32).to(self.device), sample_rate, self._refenc.mel_basis) mean, std = (torch.as_tensor(v, dtype=torch.float32, device=self.device) for v in (self.config["mel_mean"], self.config["mel_std"])) if mean.ndim: mean, std = mean[:, None], std[:, None] y = ((mel - mean) / std).clone() ids = encode(phonemize(text)) x = torch.tensor([ids], device=self.device) with torch.inference_mode(False), torch.enable_grad(): return fit_voice(self.model, x, torch.tensor([len(ids)], device=self.device), y, torch.tensor([y.shape[-1]], device=self.device), vec.clone(), steps=steps, anchor=0.1, seed=seed)
@torch.inference_mode() def mel(self, text: str, voice, seed: int | None = 0, sentence_gap=_CONFIG, **settings) -> torch.Tensor: """[100, frames] log-mel. ``settings`` override the delivery in config.json (guidance, length_scale, pause_scale, temperature, dur_temperature, n_timesteps, and with a model that has styles ``style`` (a name from ``tts.styles``) and ``style_scale``). ``sentence_gap`` is the longest pause after . ! ? in seconds (default from config.json; None = stretched by pause_scale like commas, as before).""" if seed is not None: torch.manual_seed(seed) ids = encode(phonemize(text)) x = torch.tensor([ids], device=self.device) kw = {**self.config["delivery"], "pause_tokens": self._pause, **settings} if isinstance(kw.get("style"), str): # style="conversational" (None = the style the voice was recorded in) kw["style"] = self.styles.index(kw["style"]) gap = kw.pop("sentence_gap", None) if sentence_gap is _CONFIG else sentence_gap kw.pop("sentence_gap", None) if gap is not None: kw.update(stop_tokens=self._stop, max_stop=gap * SAMPLE_RATE / HOP) if isinstance(voice, torch.Tensor): # a vector from clone_voice; it speaks in the reading style unless asked who = {"spk_vec": voice.to(self.device).float().reshape(1, -1)} else: who = {"spks": torch.tensor([self.voices.index(voice)], device=self.device)} out = self.model.synthesise(x, torch.tensor([len(ids)], device=self.device), **who, **kw) return out["mel"][0]
@torch.inference_mode() def __call__(self, text: str, voice=None, seed: int | None = 0, raw: bool = False, uniform: float = 0.7, **settings): """float32 waveform at 24 kHz. uniform pulls the sentence's colour towards the voice's average (voices with a profile in config.json; 0 = off); raw skips that and finish (edges, silence, loudness).""" voice = self.config["default_voice"] if voice is None else voice return self.render(self.mel(text, voice, seed, **settings), voice, raw, uniform)
@torch.inference_mode() def render(self, mel: torch.Tensor, voice=None, raw: bool = False, uniform: float = 0.7): """The waveform of a mel from ``mel``: colour matching (``uniform``; named voices with a profile only), the vocoder, then ``finish``.""" wav = self._wave(mel, voice, 0.0 if raw else uniform) return wav if raw else finish(wav, SAMPLE_RATE)
@torch.inference_mode() def _wave(self, mel: torch.Tensor, voice, uniform: float) -> np.ndarray: name = self.config["default_voice"] if voice is None else voice profile = self.config.get("profiles", {}).get(name) if isinstance(name, str) else None if profile and uniform > 0: mel = torch.from_numpy(match_timbre(mel.cpu().numpy(), profile, uniform)).to(self.device) return self.vocoder(mel[None].float()).squeeze().clamp(-1, 1).cpu().numpy()
@torch.inference_mode() def stream(self, text: str, voice=None, seed: int | None = 0, uniform: float = 0.7, sentence_gap=_CONFIG, paragraph_gap: float = 0.7, **settings): """float32 chunks at 24 kHz, one per sentence (``split_sentences``), each ending in its pause: ``sentence_gap`` seconds (default from config.json) or ``paragraph_gap`` after a paragraph. Sentence k uses ``seed + k``, so the sentences do not all share one melody. Joined, the chunks are ``long(text)``.""" voice = self.config["default_voice"] if voice is None else voice gap = self.config["delivery"].get("sentence_gap", 0.35) if sentence_gap is _CONFIG else sentence_gap sentences = [(s, end) for s, end in split_sentences(text) if phonemize(s)] # "🙂" alone has nothing to say for k, (sent, para_end) in enumerate(sentences): mel = self.mel(sent, voice, None if seed is None else seed + k, **settings) pause = paragraph_gap if para_end else (gap if gap is not None else 0.35) yield finish(self._wave(mel, voice, uniform), SAMPLE_RATE, lead=0.15 if k == 0 else 0.0, tail=pause)
def long(self, text: str, voice=None, seed: int | None = 0, **settings) -> np.ndarray: """A text of any length as one waveform (see ``stream``).""" chunks = list(self.stream(text, voice, seed, **settings)) return np.concatenate(chunks) if chunks else np.zeros(0, np.float32)123456789101112131415161718192021222324252627282930313233343536"""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 argparseimport sys
def main(argv=None) -> int: ap = argparse.ArgumentParser(prog="tts-english", description="English text to speech (24 kHz WAV)") ap.add_argument("text", help='the text, or "-" to read it from standard input') ap.add_argument("out", help="output .wav") ap.add_argument("--voice", default=None, help="default: the studio voice en_hifi_92_clean") ap.add_argument("--style", default=None, choices=["reading", "conversational"]) ap.add_argument("--fast", action="store_true", help="distilled 2-pass decoder, ~10x faster acoustic model") ap.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)
import soundfile as sf
from . import SAMPLE_RATE, TTS
text = sys.stdin.read() if a.text == "-" else a.text tts = TTS.from_pretrained(a.repo, a.bigvgan, device=a.device, vocoder=a.vocoder, fast=a.fast) kw = {"style": a.style} if a.style else {} sf.write(a.out, tts.long(text, a.voice, a.seed, **kw), SAMPLE_RATE) print(f"{a.out}: {a.voice or tts.config['default_voice']}") return 0
if __name__ == "__main__": raise SystemExit(main())1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768"""English G2P of mmmhusto TTS English.
ARPAbet with lexical stress from g2p_en (Apache-2.0: CMUdict plus a small neural model for unknown words). Token layout:``<bos>``, phones, ``▁`` between words, kept punctuation, ``<eos>``."""
from __future__ import annotations
import re
from .normalize import normalize
PAD, BOS, EOS, UNK, WORD_SEP = "<pad>", "<bos>", "<eos>", "<unk>", "▁"
VOWELS = ["AA", "AE", "AH", "AO", "AW", "AY", "EH", "ER", "EY", "IH", "IY", "OW", "OY", "UH", "UW"]CONSONANTS = ["B", "CH", "D", "DH", "F", "G", "HH", "JH", "K", "L", "M", "N", "NG", "P", "R", "S", "SH", "T", "TH", "V", "W", "Y", "Z", "ZH"]PUNCTUATION = [",", ".", "!", "?"] # what g2p_en keeps
SYMBOLS = [PAD, BOS, EOS, UNK, WORD_SEP] + PUNCTUATION + [v + s for v in VOWELS for s in "012"] + CONSONANTSSYMBOL_TO_ID = {s: i for i, s in enumerate(SYMBOLS)}
_G2P = None# g2p_en deletes every character outside ``a-z ' . , ? ! -``, so "one; two" loses its pause and "one—two" becomes the# single unknown word "onetwo". Pauses inside a sentence become commas, the rest becomes a space._PAUSE = re.compile(r"\s*(?:[;:()\[\]{}…]|—|–|-{2,}|\.{2,})\s*")_SPACE = re.compile(r"[\"“”„«»*_/\\|~^<>=+#@]|(?<=\w)-(?=\w)|\s+")_RANK = {",": 0, ".": 1, "!": 2, "?": 2}
def clean(text: str) -> str: """Text as g2p_en should see it: numbers, times, units and abbreviations written out (``normalize``), every pause mark it would drop becomes a comma, hyphenated words are split.""" text = normalize(text.replace("’", "'").replace("‘", "'")) text = _PAUSE.sub(", ", text) return _SPACE.sub(" ", text).strip()
def phonemize(text: str) -> list[str]: """Phones of one text, words separated by ``▁``; repeated separators and unknown tokens dropped.""" global _G2P if _G2P is None: from g2p_en import G2p
_G2P = G2p() out: list[str] = [] for t in _G2P(clean(text)): t = WORD_SEP if t == " " else t if t not in SYMBOL_TO_ID or (t == WORD_SEP and (not out or out[-1] == WORD_SEP)): continue if t in PUNCTUATION: while out and out[-1] == WORD_SEP: out.pop() if not out: # nothing to pause after continue if out[-1] in PUNCTUATION: # ", ." or "?!": one mark, the stronger if _RANK[t] > _RANK[out[-1]]: out[-1] = t continue out.append(t) while out and out[-1] == WORD_SEP: out.pop() return out
def encode(phones: list[str]) -> list[int]: unk = SYMBOL_TO_ID[UNK] return [SYMBOL_TO_ID[BOS]] + [SYMBOL_TO_ID.get(p, unk) for p in phones] + [SYMBOL_TO_ID[EOS]]123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234"""English text normalization: what a reader says for numbers, times, dates, units, abbreviations and acronyms.
Every digit is written out here, before g2p_en sees the text: its own number reading turns "45" into the singleunknown word "forty-five" and guesses its sound ("fortivwid"), and reads "1,234" as "twelve thirty-four".
>>> normalize("Dr. Smith paid $1.5 million at 9:30 p.m. on Jan. 5th.") 'Doctor Smith paid one point five million dollars at nine thirty pee em on January fifth.'
Everything is plain rules (no model), in the order of ``normalize``."""
from __future__ import annotations
import re
_ONES = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"]_TENS = ["", "", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"]_SCALES = [(10 ** 12, "trillion"), (10 ** 9, "billion"), (10 ** 6, "million"), (1000, "thousand"), (100, "hundred")]_ORD = {"one": "first", "two": "second", "three": "third", "five": "fifth", "eight": "eighth", "nine": "ninth", "twelve": "twelfth"}LETTERS = {"a": "ay", "b": "bee", "c": "see", "d": "dee", "e": "ee", "f": "eff", "g": "gee", "h": "aitch", "i": "eye", "j": "jay", "k": "kay", "l": "el", "m": "em", "n": "en", "o": "oh", "p": "pee", "q": "cue", "r": "ar", "s": "ess", "t": "tee", "u": "you", "v": "vee", "w": "double you", "x": "ex", "y": "why", "z": "zee"}
def cardinal(n: int) -> str: """0 <= n < 10**15 in words, American style (no "and"): 221 -> "two hundred twenty-one".""" if n < 0: return "minus " + cardinal(-n) if n < 20: return _ONES[n] if n < 100: return _TENS[n // 10] + ("-" + _ONES[n % 10] if n % 10 else "") for value, name in _SCALES: if n >= value: head, rest = divmod(n, value) return f"{cardinal(head)} {name}" + (f" {cardinal(rest)}" if rest else "") raise ValueError(n)
def ordinal(n: int) -> str: """3 -> "third", 21 -> "twenty-first", 100 -> "one hundredth".""" words = cardinal(n) head, sep, last = words.rpartition("-") if "-" in words.split(" ")[-1] else words.rpartition(" ") if last in _ORD: last = _ORD[last] elif last.endswith("y"): last = last[:-1] + "ieth" else: last += "th" return head + sep + last
def year(n: int) -> str: """How a year is said: 1985 -> "nineteen eighty-five", 2005 -> "two thousand five", 2024 -> "twenty twenty-four", 1900 -> "nineteen hundred".""" if 2000 <= n <= 2009 or n < 1000 or n >= 10000: return cardinal(n) hi, lo = divmod(n, 100) if lo == 0: return f"{cardinal(hi)} hundred" return f"{cardinal(hi)} {'oh ' + _ONES[lo] if lo < 10 else cardinal(lo)}"
def plural(words: str) -> str: """ "nineteen ninety" -> "nineteen nineties", "eight" -> "eights".""" return words[:-1] + "ies" if words.endswith("y") else words + "s"
def decimal(text: str) -> str: """ "3.14" -> "three point one four"; "0.5" -> "zero point five".""" whole, _, frac = text.partition(".") return f"{cardinal(int(whole.replace(',', '')))} point {' '.join(_ONES[int(d)] for d in frac)}"
def number(text: str) -> str: """Digits as said in running text: integer or decimal, thousands separators allowed.""" return decimal(text) if "." in text else cardinal(int(text.replace(",", "")))
def spell(letters: str) -> str: return " ".join(LETTERS[c] for c in letters.lower() if c in LETTERS)
# --------------------------------------------------------------------------------------------------- the rules
_ABBREV = [ # (pattern, replacement); patterns are case-sensitive, \b-anchored (r"\bMr\.", "Mister"), (r"\bMrs\.", "Missus"), (r"\bMs\.", "Miz"), (r"\bDr\.", "Doctor"), (r"\bProf\.", "Professor"), (r"\bJr\.", "Junior"), (r"\bSr\.", "Senior"), (r"\bSt\.(?=\s+[A-Z])", "Saint"), (r"\bSt\.", "Street"), (r"\bAve\.", "Avenue"), (r"\bRd\.", "Road"), (r"\bBlvd\.", "Boulevard"), (r"\bMt\.", "Mount"), (r"\b[Aa]pt\.", "apartment"), (r"\bft\.(?=\s)", "feet"), (r"\bvs\.?(?=\s)", "versus"), (r"\betc\.", "et cetera"), (r"\be\.g\.", "for example"), (r"\bi\.e\.", "that is"), (r"\bapprox\.", "approximately"), (r"\bInc\.", "Incorporated"), (r"\bLtd\.", "Limited"), (r"\bCorp\.", "Corporation"), (r"\bDept\.", "Department"), (r"\bGov\.", "Governor"), (r"\bSen\.", "Senator"), (r"\bRep\.", "Representative"), (r"\bGen\.", "General"), (r"\bCapt\.", "Captain"), (r"\bLt\.", "Lieutenant"), (r"\bSgt\.", "Sergeant"), (r"\bNo\.(?=\s*\d)", "number"), (r"#(?=\d)", "number "), (r"\bpp\.(?=\s*\d)", "pages"), (r"\bp\.(?=\s*\d)", "page"), (r"\bvol\.(?=\s*\d)", "volume"), (r"\bch\.(?=\s*\d)", "chapter"), (r"\bfig\.(?=\s*\d)", "figure"),]_MONTHS = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]_MONTH_ABBR = {m[:3]: m for m in _MONTHS} | {"Sept": "September"}_UNITS = { # symbol -> (singular, plural); matched only right after a number "km": ("kilometer", "kilometers"), "cm": ("centimeter", "centimeters"), "mm": ("millimeter", "millimeters"), "m": ("meter", "meters"), "kg": ("kilogram", "kilograms"), "mg": ("milligram", "milligrams"), "g": ("gram", "grams"), "lb": ("pound", "pounds"), "lbs": ("pound", "pounds"), "oz": ("ounce", "ounces"), "mi": ("mile", "miles"), "ft": ("foot", "feet"), "mph": ("mile per hour", "miles per hour"), "km/h": ("kilometer per hour", "kilometers per hour"), "kph": ("kilometer per hour", "kilometers per hour"), "ml": ("milliliter", "milliliters"), "l": ("liter", "liters"), "GB": ("gigabyte", "gigabytes"), "MB": ("megabyte", "megabytes"), "TB": ("terabyte", "terabytes"), "KB": ("kilobyte", "kilobytes"), "kWh": ("kilowatt hour", "kilowatt hours"), "kW": ("kilowatt", "kilowatts"), "W": ("watt", "watts"), "V": ("volt", "volts"), "Hz": ("hertz", "hertz"), "kHz": ("kilohertz", "kilohertz"), "hrs": ("hour", "hours"), "hr": ("hour", "hours"), "min": ("minute", "minutes"), "sec": ("second", "seconds"), "°C": ("degree Celsius", "degrees Celsius"), "°F": ("degree Fahrenheit", "degrees Fahrenheit"), "°": ("degree", "degrees"), "%": ("percent", "percent"), "x": ("times", "times"),}_NUM = r"\d{1,3}(?:,\d{3})+(?:\.\d+)?|\d+(?:\.\d+)?"_ROMAN = re.compile(r"^M{0,3}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$")_ROMAN_KEYS = r"Chapter|Part|Book|Volume|Act|Scene|Section|Article|Phase|Level|Season|Episode|Round|War"_ROMAN_VALUES = {"M": 1000, "D": 500, "C": 100, "L": 50, "X": 10, "V": 5, "I": 1}_CURRENCY = {"$": ("dollar", "dollars"), "£": ("pound", "pounds"), "€": ("euro", "euros")}_CENTS = {"$": ("cent", "cents"), "£": ("penny", "pence"), "€": ("cent", "cents")}
def roman(s: str) -> int: total = 0 for a, b in zip(s, s[1:] + " ", strict=True): v = _ROMAN_VALUES[a] total += -v if b != " " and _ROMAN_VALUES[b] > v else v return total
def _time(m: re.Match) -> str: h, mi, ampm = int(m.group(1)), int(m.group(2)), m.group(3) words = cardinal(h) + (" o'clock" if mi == 0 and not ampm else "" if mi == 0 else f" oh {_ONES[mi]}" if mi < 10 else f" {cardinal(mi)}") if ampm: words += " " + spell(ampm.replace(".", "")) return words
def _date(m: re.Match) -> str: # US order, as the rest of the frontend is American: 12/03/1985 = December 3rd mo, d, y = int(m.group(1)), int(m.group(2)), m.group(3) if not (1 <= mo <= 12 and 1 <= d <= 31): return m.group(0) yy = int(y) + (2000 if len(y) == 2 and int(y) < 50 else 1900 if len(y) == 2 else 0) return f"{_MONTHS[mo - 1]} {ordinal(d)}, {year(yy)}"
def _with_unit(m: re.Match) -> str: sign, num, unit = m.group(1) or "", m.group(2), m.group(3) sing, plur = _UNITS[unit] value = num.replace(",", "") words = number(num) return ("minus " if sign else "") + words + " " + (sing if value in ("1", "1.0") and not sign else plur)
def _money(m: re.Match) -> str: cur, num, scale = m.group(1), m.group(2), m.group(3) sing, plur = _CURRENCY[cur] return f"{number(num)} {scale} {plur}"
def _money_plain(m: re.Match) -> str: # $45.50 -> forty-five dollars and fifty cents cur, whole, cents = m.group(1), int(m.group(2).replace(",", "")), int(m.group(3) or 0) (sing, plur), (csing, cplur) = _CURRENCY[cur], _CENTS[cur] parts = [f"{cardinal(whole)} {sing if whole == 1 else plur}"] if whole or not cents else [] if cents: parts.append(f"{cardinal(cents)} {csing if cents == 1 else cplur}") return " and ".join(parts)
def _integer(m: re.Match) -> str: digits = m.group(0) if "," not in digits and len(digits) > 1 and digits[0] == "0": # 007, 0421: digit by digit return " ".join(_ONES[int(d)] for d in digits) n = int(digits.replace(",", "")) return year(n) if "," not in digits and 1100 <= n <= 2099 else cardinal(n)
def _acronym(m: re.Match) -> str: word = m.group(0) letters = word.replace(".", "") if "." in word or len(letters) <= 3 or not re.search(r"[AEIOU]", letters): return spell(letters) return word # NASA, NATO, UNESCO: said as words; g2p_en has most of them
def normalize(text: str) -> str: t = re.sub(r"(?<=\d)\s?[–—]\s?(?=\d)", "-", text.replace("’", "'")) # other dashes stay: they are pauses for pat, rep in _ABBREV: # an abbreviation's dot that also ends the text stays as the full stop t = re.sub(pat + r"(?=\s*$)", rep + "." if pat.endswith(r"\.") else rep, t) t = re.sub(pat, rep, t) t = re.sub(r"\b(" + "|".join(_MONTH_ABBR) + r")\.(?=\s)", lambda m: _MONTH_ABBR[m.group(1)], t) # times and dates before anything splits their digits t = re.sub(r"\b(\d{1,2}):(\d{2})(?:\s*([ap]\.?m\b\.?))?(?![\d:])", _time, t, flags=re.I) t = re.sub(r"\b(\d{1,2})\s*([ap])\.?m\.?(?=\W|$)", lambda m: f"{cardinal(int(m.group(1)))} {spell(m.group(2) + 'm')}", t, flags=re.I) t = re.sub(r"\b(\d{1,2})/(\d{1,2})/(\d{4}|\d{2})\b", _date, t) t = re.sub(r"\b(" + "|".join(_MONTHS) + r")\s+(\d{1,2})(?:st|nd|rd|th)?\b(?!:)", lambda m: f"{m.group(1)} {ordinal(int(m.group(2)))}", t) # decades: 1990s, '90s, 90s t = re.sub(r"\b(1\d|20)(\d0)s\b", lambda m: plural(year(int(m.group(1) + m.group(2)))), t) t = re.sub(r"(?<![\w])'?([1-9]0)s\b", lambda m: plural(cardinal(int(m.group(1)))), t) # money with a scale word: $1.5 million -> one point five million dollars t = re.sub(r"([$£€])\s?(" + _NUM + r")\s?(thousand|million|billion|trillion)\b", _money, t) # numbers with units and percent; a leading minus only where a number starts units = "|".join(sorted((re.escape(u) for u in _UNITS), key=len, reverse=True)) t = re.sub(r"(?<![\w.])(-)?(" + _NUM + r")\s?(" + units + r")(?![\w/])", _with_unit, t) t = re.sub(r"(?<![\w-])-(?=\d)", "minus ", t) # ranges: 5-10 -> five to ten t = re.sub(r"\b(\d+)\s?-\s?(\d+)\b", lambda m: f"{number(m.group(1))} to {number(m.group(2))}", t) # decimals g2p_en would read as "three point fourteen" t = re.sub(r"(?<![\d.$£€])(\d+\.\d+)(?![\d.])", lambda m: decimal(m.group(1)), t) # a number glued to one capital letter: 221B -> two hundred twenty-one bee t = re.sub(r"\b(\d+)([A-Z])\b", lambda m: f"{cardinal(int(m.group(1)))} {spell(m.group(2))}", t) # Roman numerals: after a keyword (Chapter IV) a number, after a name (Henry VIII) "the eighth" t = re.sub(r"\b(" + _ROMAN_KEYS + r")\s+([IVXLCDM]{1,7})\b", lambda m: f"{m.group(1)} {cardinal(roman(m.group(2)))}" if _ROMAN.match(m.group(2)) else m.group(0), t) t = re.sub(r"\b([A-Z][a-z]{2,})\s+([IVX]{2,5})\b", lambda m: f"{m.group(1)} the {ordinal(roman(m.group(2)))}" if _ROMAN.match(m.group(2)) else m.group(0), t) # money without a scale word, ordinals, then every integer left (four digits 1100-2099 read as a year) t = re.sub(r"([$£€])\s?(\d{1,3}(?:,\d{3})+|\d+)(?:\.(\d{2}))?(?![\d.]*\d)", _money_plain, t) t = re.sub(r"\b(\d{1,3}(?:,\d{3})+|\d+)(?:st|nd|rd|th)\b", lambda m: ordinal(int(m.group(1).replace(",", ""))), t) t = re.sub(r"\d{1,3}(?:,\d{3})+(?!\d)|\d+", _integer, t) # symbols t = re.sub(r"\s*&\s*", " and ", t) t = re.sub(r"(?<=\d)\s*\+\s*(?=\d)", " plus ", t) t = re.sub(r"(?<=\d)\s*=\s*(?=\d)", " equals ", t) t = re.sub(r"\s@\s", " at ", t) # acronyms: U.S., FBI -> spelled; NASA stays a word t = re.sub(r"\b(?:[A-Z]\.){2,}(?=\s*$)", lambda m: _acronym(m) + ".", t) t = re.sub(r"\b(?:[A-Z]\.){2,}|\b[A-Z]{2,6}\b(?!\.\w)", _acronym, t) return re.sub(r"\s{2,}", " ", t).strip()12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758"""What turns a generated mel into a clip a listener accepts as one steady voice (numpy only, no training).
Measured on v2.1 against Kokoro over 30 sentences: our brightness wandered from sentence to sentence 4x more (energyabove 6 kHz +-3.5 dB against +-0.9 dB), because the flow model draws a slightly different "recording" of the voice forevery sentence, and our clips started 80 ms after the file start where Kokoro leaves 0.3-0.5 s of clean silence.
* ``match_timbre``: pull the sentence's long-term spectrum towards the voice's own average (its *profile*). On three studio voices, 10 held-out sentences: spread of the spectral centroid 183 -> 101 Hz, of the energy above 6 kHz +-3.3 -> +-1.8 dB, PESQ unchanged (3.95 -> 3.98)* ``finish``: speech cut to its edges, short fades, clean silence around it, one loudness for every sentence"""
from __future__ import annotations
import numpy as np
def band_mean(mel: np.ndarray) -> np.ndarray: """Mean log-mel per band over the louder 60 % of the frames (pauses do not count). mel [bands, frames].""" energy = mel.mean(0) return mel[:, energy > np.percentile(energy, 40)].mean(1)
def voice_profile(mels: list[np.ndarray]) -> list[float]: """The profile of a voice: the average ``band_mean`` over a set of its generated sentences (20 are enough).""" return [round(float(v), 4) for v in np.mean([band_mean(m) for m in mels], 0)]
def match_timbre(mel: np.ndarray, profile, strength: float = 0.7, sigma: float = 5.0, limit: float = 1.2): """mel + a smooth per-band offset towards ``profile``. The offset is smoothed over ~``sigma`` bands and limited to ``limit`` (log-amplitude, ~10 dB), so it corrects the tilt and the broad colour and leaves what the sentence itself contributes (a sentence full of "s" is rightly brighter); ``strength`` 1 would remove the whole broad difference.""" diff = np.asarray(profile, dtype=np.float32) - band_mean(mel) half = int(3 * sigma) kernel = np.exp(-0.5 * (np.arange(-half, half + 1) / sigma) ** 2) diff = np.convolve(np.pad(diff, half, mode="edge"), kernel / kernel.sum(), mode="valid") return (mel + strength * np.clip(diff, -limit, limit)[:, None]).astype(np.float32)
def finish(wav: np.ndarray, sr: int = 24000, lead: float = 0.15, tail: float = 0.3, level_db: float = -27.0, peak: float = 0.95) -> np.ndarray: """Speech cut to its edges (40 dB under the loudest 20 ms frame), 10 ms fades, ``lead``/``tail`` seconds of silence, and the loud half of the frames brought to ``level_db`` (peak-limited).""" n = sr // 50 frames = wav[:len(wav) // n * n].reshape(-1, n) rms = np.sqrt((frames ** 2).mean(1) + 1e-12) if rms.size == 0 or rms.max() < 1e-4: # nothing but silence return wav on = np.nonzero(rms > rms.max() * 10 ** (-40 / 20))[0] x = wav[max(0, (on[0] - 1) * n):min(len(wav), (on[-1] + 3) * n)].astype(np.float32).copy() fade = min(sr // 100, len(x) // 2) x[:fade] *= np.linspace(0, 1, fade, dtype=np.float32) x[-fade:] *= np.linspace(1, 0, fade, dtype=np.float32) active = np.sort(rms[on[0]:on[-1] + 1]) active = active[len(active) // 2:] gain = 10 ** (level_db / 20) / max(float(np.sqrt((active ** 2).mean())), 1e-5) x *= min(gain, peak / max(float(np.abs(x).max()), 1e-5)) return np.concatenate([np.zeros(int(lead * sr), np.float32), x, np.zeros(int(tail * sr), np.float32)])123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170"""Voice from a recording: a reference encoder that turns a few seconds of someone's mel into the model's voice vector.
The acoustic model takes its voice from a table (``spk_emb``, one learned 256-d vector per training speaker), so itcan only speak with the voices it was trained on. ``RefEncoder`` maps a log-mel of any length to a vector in the samespace, which ``SkttsV2.synthesise(spk_vec=...)`` and ``SkttsV2.forward(spk_vec=...)`` accept instead of a table row:
vec = refenc(mel_from_audio(wav, 24000)) # [1, 256] mel = model.synthesise(x, x_lengths, spk_vec=vec, ...)["mel"]
Two ways to get a voice, both with the acoustic model untouched:
* ``RefEncoder``: instant, from audio alone. Trained (``sktts.train.refenc``) through the frozen acoustic model: the vector it makes from one clip of a speaker must let the model reproduce *another* clip of that speaker (the flow-matching and prior losses).* ``fit_voice``: slower and closer. Gradient descent on the vector itself against the reference clip and its transcript, started from the encoder's answer (the same idea as training a new table row, in a few hundred steps).
The level of the reference does not matter (the mel's mean is removed); its spectrum, pitch and pace do."""
from __future__ import annotations
import math
import torchimport torch.nn as nnimport torch.nn.functional as F
SR, N_FFT, HOP, N_MELS, FMAX = 24000, 1024, 256, 100, 12000REFENC_DEFAULT = {"dim": 256, "layers": 6, "kernel": 5, "out_dim": 256, "dropout": 0.1}
def slaney_mel_basis() -> torch.Tensor: """librosa.filters.mel(sr=24000, n_fft=1024, n_mels=100, fmin=0, fmax=12000) (Slaney scale and norm) without librosa: [100, 513].""" def hz_to_mel(f): f = torch.as_tensor(f, dtype=torch.float64) lin = f / (200.0 / 3) log = 15.0 + torch.log(f.clamp(min=1e-10) / 1000.0) / (math.log(6.4) / 27.0) return torch.where(f >= 1000.0, log, lin)
def mel_to_hz(m): lin = m * (200.0 / 3) log = 1000.0 * torch.exp((math.log(6.4) / 27.0) * (m - 15.0)) return torch.where(m >= 15.0, log, lin)
freqs = torch.linspace(0, SR / 2, N_FFT // 2 + 1, dtype=torch.float64) pts = mel_to_hz(torch.linspace(float(hz_to_mel(0.0)), float(hz_to_mel(float(FMAX))), N_MELS + 2, dtype=torch.float64)) diff = pts[1:] - pts[:-1] ramps = pts[:, None] - freqs[None, :] lower, upper = -ramps[:-2] / diff[:-1, None], ramps[2:] / diff[1:, None] basis = torch.clamp(torch.minimum(lower, upper), min=0) return (basis * (2.0 / (pts[2:] - pts[:-2]))[:, None]).float()
def level(x: torch.Tensor, target_db: float = -24.0, peak: float = 0.95) -> torch.Tensor: """The loudness step of the training features (``sktts.data.english.level``): gain to ``target_db`` RMS measured on the loud half of the 50 ms frames, peak-limited.""" n = x.shape[-1] // 1200 if n < 2: return x rms = (x[..., :n * 1200].reshape(n, 1200) ** 2).mean(1).add(1e-12).sqrt() active = rms.sort().values[n // 2:] gain = 10 ** (target_db / 20) / max(float((active ** 2).mean().sqrt()), 1e-5) return x * min(gain, peak / max(float(x.abs().max()), 1e-5))
def mel_from_audio(wav: torch.Tensor, sr: int = SR, basis: torch.Tensor | None = None) -> torch.Tensor: """Mono waveform [n] in [-1, 1] at ``sr`` -> log-mel [1, 100, n // 256] in the training format (BigVGAN's ``mel_spectrogram``: 24 kHz, n_fft 1024, hop 256, Slaney bands to 12 kHz, reflect padding, log clamp 1e-5), levelled like the training clips.""" wav = torch.as_tensor(wav, dtype=torch.float32).flatten() if sr != SR: import torchaudio.functional as AF
wav = AF.resample(wav, sr, SR) wav = level(wav) basis = slaney_mel_basis() if basis is None else basis pad = (N_FFT - HOP) // 2 y = F.pad(wav[None, None], (pad, pad), mode="reflect")[:, 0] spec = torch.stft(y, N_FFT, hop_length=HOP, win_length=N_FFT, window=torch.hann_window(N_FFT, device=wav.device), center=False, return_complex=True) mag = torch.sqrt(spec.real ** 2 + spec.imag ** 2 + 1e-9) return torch.log(torch.clamp(basis.to(mag) @ mag, min=1e-5))
class _Res(nn.Module): """Two convolutions with a per-frame layer norm (nothing is averaged over time, so padding cannot leak in)."""
def __init__(self, dim: int, kernel: int, dropout: float): super().__init__() self.conv1, self.conv2 = (nn.Conv1d(dim, dim, kernel, padding=kernel // 2) for _ in range(2)) self.norm1, self.norm2 = nn.LayerNorm(dim), nn.LayerNorm(dim) self.drop = nn.Dropout(dropout)
def forward(self, x, mask): h = self.conv1(F.gelu(self.norm1(x.transpose(1, 2))).transpose(1, 2) * mask) h = self.conv2(self.drop(F.gelu(self.norm2(h.transpose(1, 2)))).transpose(1, 2) * mask) return (x + h) * mask
class RefEncoder(nn.Module): """log-mel [b, 100, T] (raw, as in the feature shards) -> voice vector [b, out_dim].
Convolutions over time, then attentive statistics pooling (a weighted mean and deviation of every channel, so pauses can be ignored), then a linear layer added to ``base``: the mean voice of the acoustic model's table. The last layer starts at zero, so an untrained encoder is exactly the mean voice."""
def __init__(self, cfg: dict | None = None, base: torch.Tensor | None = None): super().__init__() self.cfg = c = {**REFENC_DEFAULT, **(cfg or {})} dim = c["dim"] self.inp = nn.Conv1d(N_MELS, dim, c["kernel"], padding=c["kernel"] // 2) self.blocks = nn.ModuleList(_Res(dim, c["kernel"], c["dropout"]) for _ in range(c["layers"])) self.att = nn.Sequential(nn.Conv1d(dim, dim // 4, 1), nn.Tanh(), nn.Conv1d(dim // 4, dim, 1)) self.out = nn.Sequential(nn.Linear(2 * dim, dim), nn.GELU(), nn.Linear(dim, c["out_dim"])) nn.init.zeros_(self.out[-1].weight) nn.init.zeros_(self.out[-1].bias) self.register_buffer("base", torch.zeros(c["out_dim"]) if base is None else base.detach().clone().float()) self.register_buffer("mel_basis", slaney_mel_basis()) # travels with the weights: no librosa at inference
def forward(self, mel: torch.Tensor, lengths: torch.Tensor | None = None) -> torch.Tensor: mask = (torch.ones(mel.shape[0], 1, mel.shape[2], device=mel.device, dtype=mel.dtype) if lengths is None else (torch.arange(mel.shape[2], device=mel.device)[None, :] < lengths[:, None])[:, None].to(mel.dtype)) n = mask.sum((1, 2), keepdim=True).clamp(min=1) mean = (mel * mask).sum((1, 2), keepdim=True) / (n * mel.shape[1]) # the clip's level: one number h = self.inp((mel - mean) / 2.4 * mask) * mask for blk in self.blocks: h = blk(h, mask) w = self.att(h).masked_fill(mask == 0, -1e4).softmax(-1) mu = (h * w).sum(-1) sd = ((h ** 2 * w).sum(-1) - mu ** 2).clamp(min=1e-5).sqrt() return self.base + self.out(torch.cat([mu, sd], -1))
@torch.inference_mode() def from_audio(self, wav, sr: int = SR) -> torch.Tensor: """Voice vector [1, out_dim] of a mono recording (best: 5 to 15 s of clean speech of one person).""" dev = self.base.device return self(mel_from_audio(torch.as_tensor(wav, dtype=torch.float32).to(dev), sr, self.mel_basis))
def fit_voice(model, x, x_lengths, y, y_lengths, init: torch.Tensor, steps: int = 200, lr: float = 0.02, anchor: float = 0.0, seed: int = 0) -> torch.Tensor: """Refine a voice vector on reference clips: ``x`` token ids, ``y`` normalized mels [b, 100, t] of the *same* speaker (as ``SkttsV2.forward`` takes them), ``init`` [1, spk_dim] (the encoder's answer or the mean voice). Minimises the model's own flow-matching + prior loss over the vector alone; ``anchor`` pulls it back to ``init`` (useful with a single short clip). The model's weights do not change. -> [1, spk_dim]""" gen = torch.Generator(device="cpu").manual_seed(seed) was_training = model.training model.eval() need = [p.requires_grad for p in model.parameters()] for p in model.parameters(): p.requires_grad_(False) vec = init.detach().clone().float().requires_grad_(True) opt = torch.optim.Adam([vec], lr=lr) b = x.shape[0] try: for _ in range(steps): torch.manual_seed(int(torch.randint(0, 2 ** 31 - 1, (1,), generator=gen))) _, prior, flow, _ = model(x, x_lengths, y, y_lengths, spk_vec=vec.expand(b, -1)) loss = flow + prior + anchor * ((vec - init) ** 2).mean() opt.zero_grad(set_to_none=True) loss.backward() opt.step() finally: for p, r in zip(model.parameters(), need, strict=True): p.requires_grad_(r) model.train(was_training) return vec.detach()12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879"""Vocos (Siuzdak 2023, MIT): ConvNeXt backbone + inverse-STFT head, fine-tuned on this model's mel.
Self-contained (no ``vocos`` package, no BigVGAN clone): it predicts a short-time spectrum per mel frame and turns itinto audio with one inverse FFT, so on a CPU it runs ~25-170x faster than BigVGAN. Architecture and weights follow``charactr/vocos-mel-24khz`` (13.5M parameters), fine-tuned on our mel format."""
from __future__ import annotations
import torchfrom torch import nn
HOP, N_FFT, N_MELS = 256, 1024, 100
class ConvNeXtBlock(nn.Module): def __init__(self, dim: int, intermediate_dim: int): super().__init__() self.dwconv = nn.Conv1d(dim, dim, kernel_size=7, padding=3, groups=dim) self.norm = nn.LayerNorm(dim, eps=1e-6) self.pwconv1 = nn.Linear(dim, intermediate_dim) self.act = nn.GELU() self.pwconv2 = nn.Linear(intermediate_dim, dim) self.gamma = nn.Parameter(torch.ones(dim))
def forward(self, x: torch.Tensor) -> torch.Tensor: y = self.norm(self.dwconv(x).transpose(1, 2)) y = self.gamma * self.pwconv2(self.act(self.pwconv1(y))) return x + y.transpose(1, 2)
class Backbone(nn.Module): def __init__(self, dim: int = 512, intermediate_dim: int = 1536, num_layers: int = 8): super().__init__() self.embed = nn.Conv1d(N_MELS, dim, kernel_size=7, padding=3) self.norm = nn.LayerNorm(dim, eps=1e-6) self.convnext = nn.ModuleList([ConvNeXtBlock(dim, intermediate_dim) for _ in range(num_layers)]) self.final_layer_norm = nn.LayerNorm(dim, eps=1e-6)
def forward(self, x: torch.Tensor) -> torch.Tensor: # [b, 100, T] -> [b, T, dim] x = self.norm(self.embed(x).transpose(1, 2)).transpose(1, 2) for block in self.convnext: x = block(x) return self.final_layer_norm(x.transpose(1, 2))
class Head(nn.Module): def __init__(self, dim: int = 512): super().__init__() self.out = nn.Linear(dim, N_FFT + 2) self.register_buffer("window", torch.hann_window(N_FFT), persistent=False)
def forward(self, x: torch.Tensor) -> torch.Tensor: # [b, T, dim] -> [b, (T - 1) * HOP] mag, phase = self.out(x).transpose(1, 2).chunk(2, dim=1) spec = torch.polar(torch.exp(mag).clamp(max=1e2), phase) return torch.istft(spec, N_FFT, HOP, N_FFT, self.window, center=True)
class Vocos(nn.Module): """[b, 100, T] log-mel -> [b, 1, T * 256] audio in [-1, 1], like BigVGAN's call."""
def __init__(self): super().__init__() self.backbone, self.head = Backbone(), Head()
def forward(self, mel: torch.Tensor) -> torch.Tensor: audio = self.head(self.backbone(mel)) n = mel.shape[-1] * HOP audio = audio[..., :n] if audio.shape[-1] >= n else nn.functional.pad(audio, (0, n - audio.shape[-1])) return audio[:, None]
def load_vocos(path: str, device: str = "cpu") -> Vocos: """Weights from a .safetensors file (backbone.* and head.out.*).""" from safetensors.torch import load_file
v = Vocos() v.load_state_dict(load_file(path)) return v.eval().to(device)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209"""Slovak text-to-speech by husto (TTS-husto v4.0): three original Slovak voices, 24 kHz.
from tts_slovak import SlovakTTS tts = SlovakTTS.from_pretrained("path/to/TTS-husto") # or SlovakTTS.from_pretrained() to download it wav = tts("Dobrý deň, ako sa máte?", voice="sk_f3") # float32 numpy array, 24 000 Hz tts.save("Dobrý deň.", "out.wav", voice="sk_m1")
Runs on onnxruntime (CPU by default) with the same graphs and the same steps as the browser demo (web/tts.js): theproject's Slovak frontend (numbers with declension, abbreviations, G2P) -> text encoder and duration flow -> theSlovak delivery (natural_sk: vowel length, short comma pauses, duration floors, silent sentence ends) -> flow-matchingdecoder with classifier-free guidance -> BigVGAN (nvidia/bigvgan_base_24khz_100band, MIT) -> trimmed, levelled audio."""
from __future__ import annotations
import jsonfrom pathlib import Path
import numpy as np
__all__ = ["SAMPLE_RATE", "SlovakTTS"]__version__ = "4.0"
SAMPLE_RATE, HOP, N_MELS = 24000, 256, 100MEL_FLOOR = float(np.log(1e-5))REPO = "mmmhusto/TTS-husto"
def _round_half_even(x: np.ndarray) -> np.ndarray: return np.round(x) # numpy rounds half to even, as torch.round
def durations(ids: list[int], w: np.ndarray, d: dict, sets: dict) -> np.ndarray: """Frames per token from the drawn ones, with the delivery settings in the order of SkttsV2.synthesise.""" ids = np.asarray(ids) x = np.asarray(w, dtype=np.float64) * d["length_scale"] has = {k: np.isin(ids, list(v)) for k, v in sets.items()} stop, punct = has["stop"], has["pause"] & ~has["stop"] x = np.where(has["short"], x * d["short_scale"], x) x = np.where(has["long"], x * d["long_scale"], x) x = np.where(punct, x * d["pause_scale"], x) x = np.where(stop, np.minimum(x, d["max_stop"]), x) x = np.where(punct, np.minimum(x, d["max_pause"]), x) vow = has["vowel"] if vow.any(): cap = d["max_final"] * np.sort(x[vow])[(vow.sum() - 1) // 2] # torch.median: the lower middle value last = -1 for i in range(len(ids)): if vow[i]: last = i elif stop[i] and last >= 0: x[last] = min(x[last], cap) last = -1 x = np.where(has["phone"], np.maximum(x, d["min_phone"]), x) x = np.where(vow, np.maximum(x, d["min_vowel"]), x) x = np.where(has["tail"], np.minimum(x, d["max_tail"]), x) return np.maximum(1, _round_half_even(x)).astype(np.int64)
def phone_position(dur: np.ndarray) -> np.ndarray: """[F, 18]: where each frame is inside its token (sin/cos of 8 harmonics, the fraction, log length / 3).""" out = [] for di in dur: r = np.clip((np.arange(di) + 0.5) / di, 0, 1)[:, None] k = np.arange(1, 9)[None, :] out.append(np.concatenate([np.sin(r * np.pi * k), np.cos(r * np.pi * k), r, np.full_like(r, np.log(di) / 3)], 1)) return np.concatenate(out).astype(np.float32)
def finish(wav: np.ndarray, lead: float = 0.15, tail: float = 0.3, level_db: float = -27.0, peak: float = 0.95) -> np.ndarray: """Cut to the speech (20 ms frames over -40 dB of the loudest), 10 ms fades, silence around, one loudness.""" n = SAMPLE_RATE // 50 frames = len(wav) // n if not frames: return wav rms = np.sqrt((wav[:frames * n].reshape(frames, n).astype(np.float64) ** 2).mean(1) + 1e-12) if rms.max() < 1e-4: return wav on = np.where(rms > rms.max() * 10 ** (-40 / 20))[0] x = wav[max(0, (on[0] - 1) * n):min(len(wav), (on[-1] + 3) * n)].astype(np.float32).copy() fade = min(SAMPLE_RATE // 100, len(x) // 2) ramp = np.arange(fade) / max(1, fade - 1) x[:fade] *= ramp x[len(x) - fade:] *= ramp[::-1] active = np.sort(rms[on[0]:on[-1] + 1])[(on[-1] - on[0] + 1) // 2:] loud = np.sqrt((active ** 2).mean()) gain = min(10 ** (level_db / 20) / max(loud, 1e-5), peak / max(np.abs(x).max(), 1e-5)) lead_n, tail_n = round(lead * SAMPLE_RATE), round(tail * SAMPLE_RATE) return np.concatenate([np.zeros(lead_n, np.float32), x * gain, np.zeros(tail_n, np.float32)]).astype(np.float32)
class SlovakTTS: def __init__(self, path: str | Path, providers: list[str] | None = None): import onnxruntime as ort
from .frontend import Frontend
self.path = Path(path) web = self.path / "web" self.meta = json.loads((web / "voices.json").read_text(encoding="utf-8")) opts = ort.SessionOptions() providers = providers or ["CPUExecutionProvider"] self.text, self.decoder, self.vocoder = ( ort.InferenceSession(str(web / f"{n}.onnx"), opts, providers=providers) for n in ("text", "decoder", "bigvgan")) self.frontend = Frontend() m = self.meta self.id = {s: i for i, s in enumerate(m["symbols"])} self.sets = {k: set(v) for k, v in m["token_sets"].items()} self.sets.update(pause=set(m["pause_tokens"]), stop=set(m["stop_tokens"])) self.voices = list(m["voices"])
@classmethod def from_pretrained(cls, path: str | Path | None = None, revision: str = "v4.0", **kw) -> SlovakTTS: if path is None or not Path(path).is_dir(): from huggingface_hub import snapshot_download
path = snapshot_download(path or REPO, revision=revision, allow_patterns=["web/*"]) return cls(path, **kw)
def ids(self, tokens: list[str]) -> list[int]: """Frontend tokens -> ids of the bilingual table (sk:<symbol>; <pad> <bos> <eos> <unk> are shared).""" shared, unk = set(self.meta["symbols"][:4]), self.id["<unk>"] return [self.id[t] if t in shared else self.id.get("sk:" + t, unk) for t in tokens]
def sentences(self, text: str) -> list[tuple[str, list[str], bool]]: """(normalized sentence, tokens, last of its paragraph) for every sentence of the text.""" out = [] for u in self.frontend.process(text): t = u.tokens() out.append((u.text, t, "|4" in t[-2:])) return out
def mel(self, tokens: list[str], voice: str = "sk_f3", seed: int = 0, steps: int | None = None, length_scale: float | None = None, noise: dict | None = None) -> tuple[np.ndarray, np.ndarray]: """One sentence -> (mel [100, F] in mel units, frames per token). ``noise`` {dur, z}: given draws (tests).""" m, d = self.meta, dict(self.meta["delivery"]) if length_scale is not None: d["length_scale"] = length_scale rng = np.random.default_rng(seed) ids = self.ids(tokens) n = len(ids) spk = np.asarray([m["voices"][voice]], np.float32) zd = (np.asarray(noise["dur"], np.float32) if noise else rng.standard_normal(n).astype(np.float32)) h, w = self.text.run(None, {"ids": np.asarray([ids], np.int64), "spk": spk, "z": (zd * m["dur_temperature"]).astype(np.float32)[None]}) dur = durations(ids, w[0], d, self.sets) idx = np.repeat(np.arange(n), dur) F = len(idx) cond, pos = h[0][idx][None].astype(np.float32), phone_position(dur)[None] steps = steps or d["n_timesteps"] t = np.linspace(0, 1, steps + 1) ts = t + m["sway"] * (np.cos(np.pi / 2 * t) - 1 + t) z = (np.asarray(noise["z"], np.float32).reshape(1, F, N_MELS) if noise else rng.standard_normal((1, F, N_MELS)).astype(np.float32)) * np.float32(d["temperature"]) zero_cond, zero_pos = np.zeros_like(cond), np.zeros_like(pos) g = d["guidance"] for i in range(steps): feeds = {"z": z, "cond": cond, "t": np.asarray([ts[i]], np.float32), "spk": spk, "pos": pos} (v,) = self.decoder.run(None, feeds) if g > 0: (u,) = self.decoder.run(None, {**feeds, "cond": zero_cond, "pos": zero_pos}) v = v + g * (v - u) z = (z + (ts[i + 1] - ts[i]) * v).astype(np.float32) mel = (z[0] * m["mel_std"] + m["mel_mean"]).T.copy() # [100, F] frame_tok = np.asarray(ids)[idx] if voice in m.get("eq_voices", []): # the s/c/z equaliser, faded in and out over 5 frames hit = np.isin(frame_tok, list(self.sets["eq"])).astype(np.float32) weight = np.convolve(hit, np.ones(5) / 5, mode="same") mel += weight[None, :] * np.asarray(m["eq_gain"], np.float32)[:, None] k = 0 while k < n and ids[k] in self.sets["lead"]: k += 1 mel[:, :int(dur[:k].sum())] = MEL_FLOOR # the lead-in (<bos>, sentence type, stress) as silence mel[:, np.isin(frame_tok, list(self.sets["tail"]))] = MEL_FLOOR # and the <eos> tail return mel.astype(np.float32), dur
def wave(self, mel: np.ndarray, block: int = 128, context: int = 32) -> np.ndarray: """BigVGAN in blocks of 128 frames with 32 frames of context on each side (bounded memory, same samples).""" F = mel.shape[1] out = np.zeros(F * HOP, np.float32) for start in range(0, F, block): end = min(start + block, F) left, right = max(0, start - context), min(F, end + context) (w,) = self.vocoder.run(None, {"mel": mel[None, :, left:right]}) out[start * HOP:end * HOP] = w[0, 0, (start - left) * HOP:(end - left) * HOP] return np.clip(out, -1, 1)
def stream(self, text: str, voice: str = "sk_f3", seed: int = 0, sentence_gap: float | None = None, paragraph_gap: float = 0.7, **kw): """One float32 chunk per sentence, each ending in its pause.""" if voice not in self.voices: raise ValueError(f"unknown voice {voice!r}; this model has {', '.join(self.voices)}") gap = self.meta["delivery"]["sentence_gap"] if sentence_gap is None else sentence_gap for k, (_, tokens, para_end) in enumerate(self.sentences(text)): mel, _ = self.mel(tokens, voice, seed + k, **kw) yield finish(self.wave(mel), 0.15 if k == 0 else 0.0, paragraph_gap if para_end else gap)
def __call__(self, text: str, voice: str = "sk_f3", **kw) -> np.ndarray: chunks = list(self.stream(text, voice, **kw)) return np.concatenate(chunks) if chunks else np.zeros(0, np.float32)
def save(self, text: str, path: str | Path, voice: str = "sk_f3", **kw) -> Path: import soundfile as sf
sf.write(str(path), self(text, voice, **kw), SAMPLE_RATE, subtype="PCM_16") return Path(path)12345678910111213141516171819202122232425262728"""python -m tts_slovak "Dobrý deň." out.wav [--voice sk_f3|sk_f2|sk_m1] [--seed 0] [--steps 10] [--model DIR]"""import argparseimport time
from . import SAMPLE_RATE, SlovakTTS
def main() -> None: ap = argparse.ArgumentParser(description="Slovak text-to-speech (TTS-husto v4.0)") ap.add_argument("text") ap.add_argument("out", help="output .wav (24 kHz)") ap.add_argument("--voice", default="sk_f3", choices=["sk_f3", "sk_f2", "sk_m1"]) ap.add_argument("--seed", type=int, default=0) ap.add_argument("--steps", type=int, default=None, help="decoder steps (default from voices.json)") ap.add_argument("--model", default=None, help="folder of the downloaded repository (default: download v4.0)") a = ap.parse_args() tts = SlovakTTS.from_pretrained(a.model) t0 = time.perf_counter() wav = tts(a.text, a.voice, seed=a.seed, steps=a.steps) dt = time.perf_counter() - t0 import soundfile as sf
sf.write(a.out, wav, SAMPLE_RATE, subtype="PCM_16") print(f"{a.out}: {len(wav) / SAMPLE_RATE:.1f} s of speech in {dt:.1f} s")
if __name__ == "__main__": main()12345"""Slovak text frontend: normalization, G2P, prosody tags, SSML-lite."""
from .pipeline import Frontend, Utterance, Word
__all__ = ["Frontend", "Utterance", "Word"]123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129"""Case / gender / animacy inference for numerals from their neighbouring words.
The inference is rule based: a preposition before the number fixes (or narrows) the case, and theending of the word after the number gives extra evidence. An optional morphological tagger canreplace it later, behind the same interface (:func:`infer_case`)."""
from __future__ import annotations
import re
from .lexicon import ( ABBREV_GENDER, ANIMATE_ACC_PL, ANIMATE_NOM_PL, APPOSITION_HEADS, GENDER_WORDS, MONTH_FORMS, MONTH_LOC, MONTHS_GEN, MONTHS_NOM, NOUN_BY_FORM, PREP_AMBIGUOUS, PREP_FIXED,)
_WORD = r"[^\W\d_]+"_PREV_RE = re.compile(rf"({_WORD}|§)\.?[\s ]*$")_NEXT_RE = re.compile(rf"[\s ]*({_WORD})")
_LOC_PL = ("ách", "och")_INS_PL = ("ami", "mi", "ými", "ími")_DAT_PL = ("ám", "am", "om", "iam", "ým", "ím")
def prev_word(text: str, pos: int) -> str: """Lowercased word right before ``pos`` (only whitespace between), or ''.""" m = _PREV_RE.search(text, 0, pos) return m.group(1).lower() if m else ""
def prev_word_raw(text: str, pos: int) -> str: m = _PREV_RE.search(text, 0, pos) return m.group(1) if m else ""
def next_word(text: str, pos: int) -> str: """Lowercased alphabetic word right after ``pos`` (only whitespace between), or ''.""" m = _NEXT_RE.match(text, pos) return m.group(1).lower() if m else ""
def _plural_case_evidence(word: str) -> str | None: if word.endswith(_LOC_PL): return "loc" if word.endswith(_INS_PL): return "ins" if word.endswith(_DAT_PL): return "dat" return None
def _singular_case_evidence(word: str) -> str | None: """Weak evidence for a singular noun following an ordinal/1: locative -e/-í/-i vs accusative -o/-u/-a/-y.""" if word in MONTH_FORMS: return "gen" if word in MONTHS_GEN else "loc" if word in MONTH_LOC else "nom" if word.endswith(("e", "í", "i")): return "loc" if word.endswith(("o", "u", "a", "y")): return "acc" return None
def infer_case(prev: str, nxt: str, kind: str = "cardinal") -> str: """Case of a numeral. ``kind`` is 'cardinal' or 'ordinal'.""" if prev in APPOSITION_HEADS or prev in MONTH_FORMS: return "nom" if prev in PREP_FIXED: return PREP_FIXED[prev] if prev in PREP_AMBIGUOUS: options = PREP_AMBIGUOUS[prev] evidence = ( _singular_case_evidence(nxt) if kind == "ordinal" and nxt else _plural_case_evidence(nxt) ) if evidence in options: return evidence if kind == "ordinal" and "loc" in options and prev in ("v", "vo", "po", "na"): return "loc" if prev != "na" or evidence != "acc" else "acc" return options[0] if nxt and kind == "cardinal": evidence = _plural_case_evidence(nxt) if evidence: return evidence return "nom"
def infer_gender(nxt: str) -> str: """Grammatical gender of the noun after a numeral (m/f/n); masculine inanimate by default.""" if len(nxt) < 3: # function words: a, i, v, o ... return "m" if nxt in MONTH_FORMS: return "m" if nxt in ABBREV_GENDER: return ABBREV_GENDER[nxt] noun = NOUN_BY_FORM.get(nxt) if noun: return noun.gender if nxt in GENDER_WORDS: return GENDER_WORDS[nxt] if nxt.endswith(("ie", "é", "o")): return "n" if nxt.endswith(("á", "a", "ej", "ou")): return "f" return "m"
def is_animate_plural(nxt: str) -> bool: return nxt in ANIMATE_NOM_PL
def is_animate_accusative(nxt: str) -> bool: """Plural masculine animate noun in a genitive-like form: 'dvoch psov', not 'dva psov'.""" return nxt in ANIMATE_ACC_PL
__all__ = [ "MONTHS_NOM", "infer_case", "infer_gender", "is_animate_accusative", "is_animate_plural", "next_word", "prev_word", "prev_word_raw",]123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145# Words (or prefixes ending with *) in which d, t, n, l stay HARD before e/i/í.# This is a seed list; phase 2 of the project learns pronunciation probabilities from TrePal with# a forced aligner and overrides it. One entry per line, '#' starts a comment.telef*telev*telegr*telekom*telekon*telepat*teleskop*tech*tenis*tender*tenor*terap*termín*termo*terén*terorist*teror*teritór*téz*text*test*téma*tém*teór*teori*politi*polit*kritik*kritic*praktik*štatist*statist*logik*fyzik*mechanik*ekonomik*gramatik*matematik*elektronik*taktik*etik*dynamik*akademik*automatik*informatik*romantik*demokr*demonštr*dezert*delegát*delegác*deleg*decemberdecembr*definíc*defin*deficit*degrad*dekór*deklar*dekrét*dekád*inštit*študent*prezident*rezident*internet*nerv*neg*neutr*lekc*lektor*leg*tit*# --- added 2026-11-02 (frontend audit): frequent loans that were wrongly softenedpeterliter*literat*moder*materiál*matemat*medic*meditác*médi*energ*minist*inžinier*dent*ideál*ideaideol*gener*neurón*neurol*neutr*akadémi*akademik*študent*prezident*kandidát*detail*detekt*defin*demokra*dizajn*diplom*dialóg*diskus*titul*text*test*tím*teór*teoret*tendenc*tém*moment*argument*dokument*element*inštrument*komentár*komentát*talent*pacient*klient*agent*kontinent*incident*parlament*percent*realit*kvalit*špecialist*socialist*turist*žurnalist*lingvist*inter*ateliér*kontext*petíc*1234567891011121314151617181920212223242526272829303132333435363738394041424344454647# key<TAB>gender<TAB>singular nom,gen,dat,acc,loc,ins<TAB>plural nom,gen,dat,acc,loc,insmeter m meter,metra,metru,meter,metri,metrom metre,metrov,metrom,metre,metroch,metramicentimeter m centimeter,centimetra,centimetru,centimeter,centimetri,centimetrom centimetre,centimetrov,centimetrom,centimetre,centimetroch,centimetramimilimeter m milimeter,milimetra,milimetru,milimeter,milimetri,milimetrom milimetre,milimetrov,milimetrom,milimetre,milimetroch,milimetramikilometer m kilometer,kilometra,kilometru,kilometer,kilometri,kilometrom kilometre,kilometrov,kilometrom,kilometre,kilometroch,kilometramiliter m liter,litra,litru,liter,litri,litrom litre,litrov,litrom,litre,litroch,litramimililiter m mililiter,mililitra,mililitru,mililiter,mililitri,mililitrom mililitre,mililitrov,mililitrom,mililitre,mililitroch,mililitramigram m gram,gramu,gramu,gram,grame,gramom gramy,gramov,gramom,gramy,gramoch,gramamikilogram m kilogram,kilogramu,kilogramu,kilogram,kilograme,kilogramom kilogramy,kilogramov,kilogramom,kilogramy,kilogramoch,kilogramamimiligram m miligram,miligramu,miligramu,miligram,miligrame,miligramom miligramy,miligramov,miligramom,miligramy,miligramoch,miligramamibajt m bajt,bajtu,bajtu,bajt,bajte,bajtom bajty,bajtov,bajtom,bajty,bajtoch,bajtamikilobajt m kilobajt,kilobajtu,kilobajtu,kilobajt,kilobajte,kilobajtom kilobajty,kilobajtov,kilobajtom,kilobajty,kilobajtoch,kilobajtamimegabajt m megabajt,megabajtu,megabajtu,megabajt,megabajte,megabajtom megabajty,megabajtov,megabajtom,megabajty,megabajtoch,megabajtamigigabajt m gigabajt,gigabajtu,gigabajtu,gigabajt,gigabajte,gigabajtom gigabajty,gigabajtov,gigabajtom,gigabajty,gigabajtoch,gigabajtamiterabajt m terabajt,terabajtu,terabajtu,terabajt,terabajte,terabajtom terabajty,terabajtov,terabajtom,terabajty,terabajtoch,terabajtamibod m bod,bodu,bodu,bod,bode,bodom body,bodov,bodom,body,bodoch,bodmikus m kus,kusu,kusu,kus,kuse,kusom kusy,kusov,kusom,kusy,kusoch,kusmihektár m hektár,hektára,hektáru,hektár,hektári,hektárom hektáre,hektárov,hektárom,hektáre,hektároch,hektármidolár m dolár,dolára,doláru,dolár,doláre,dolárom doláre,dolárov,dolárom,doláre,dolároch,dolármicent m cent,centu,centu,cent,cente,centom centy,centov,centom,centy,centoch,centamideň m deň,dňa,dňu,deň,dni,dňom dni,dní,dňom,dni,dňoch,dňamitýždeň m týždeň,týždňa,týždňu,týždeň,týždni,týždňom týždne,týždňov,týždňom,týždne,týždňoch,týždňamimesiac m mesiac,mesiaca,mesiacu,mesiac,mesiaci,mesiacom mesiace,mesiacov,mesiacom,mesiace,mesiacoch,mesiacmirok m rok,roka,roku,rok,roku,rokom roky,rokov,rokom,roky,rokoch,rokmistupeň m stupeň,stupňa,stupňu,stupeň,stupni,stupňom stupne,stupňov,stupňom,stupne,stupňoch,stupňamimilión m milión,milióna,miliónu,milión,milióne,miliónom milióny,miliónov,miliónom,milióny,miliónoch,miliónmitisíc m tisíc,tisíc,tisíc,tisíc,tisíc,tisíc tisíc,tisíc,tisíc,tisíc,tisíc,tisíchodina f hodina,hodiny,hodine,hodinu,hodine,hodinou hodiny,hodín,hodinám,hodiny,hodinách,hodinamiminúta f minúta,minúty,minúte,minútu,minúte,minútou minúty,minút,minútam,minúty,minútach,minútamisekunda f sekunda,sekundy,sekunde,sekundu,sekunde,sekundou sekundy,sekúnd,sekundám,sekundy,sekundách,sekundamitona f tona,tony,tone,tonu,tone,tonou tony,ton,tonám,tony,tonách,tonamikoruna f koruna,koruny,korune,korunu,korune,korunou koruny,korún,korunám,koruny,korunách,korunamilibra f libra,libry,libre,libru,libre,librou libry,libier,librám,libry,librách,libramimiliarda f miliarda,miliardy,miliarde,miliardu,miliarde,miliardou miliardy,miliárd,miliardám,miliardy,miliardách,miliardamieuro n euro,eura,euru,euro,eure,eurom eurá,eur,eurám,eurá,eurách,euramipercento n percento,percenta,percentu,percento,percente,percentom percentá,percent,percentám,percentá,percentách,percentamimeter štvorcový m meter štvorcový,metra štvorcového,metru štvorcovému,meter štvorcový,metri štvorcovom,metrom štvorcovým metre štvorcové,metrov štvorcových,metrom štvorcovým,metre štvorcové,metroch štvorcových,metrami štvorcovýmimeter kubický m meter kubický,metra kubického,metru kubickému,meter kubický,metri kubickom,metrom kubickým metre kubické,metrov kubických,metrom kubickým,metre kubické,metroch kubických,metrami kubickýmicentimeter štvorcový m centimeter štvorcový,centimetra štvorcového,centimetru štvorcovému,centimeter štvorcový,centimetri štvorcovom,centimetrom štvorcovým centimetre štvorcové,centimetrov štvorcových,centimetrom štvorcovým,centimetre štvorcové,centimetroch štvorcových,centimetrami štvorcovýmicentimeter kubický m centimeter kubický,centimetra kubického,centimetru kubickému,centimeter kubický,centimetri kubickom,centimetrom kubickým centimetre kubické,centimetrov kubických,centimetrom kubickým,centimetre kubické,centimetroch kubických,centimetrami kubickýmikilometer štvorcový m kilometer štvorcový,kilometra štvorcového,kilometru štvorcovému,kilometer štvorcový,kilometri štvorcovom,kilometrom štvorcovým kilometre štvorcové,kilometrov štvorcových,kilometrom štvorcovým,kilometre štvorcové,kilometroch štvorcových,kilometrami štvorcovýmikilometer kubický m kilometer kubický,kilometra kubického,kilometru kubickému,kilometer kubický,kilometri kubickom,kilometrom kubickým kilometre kubické,kilometrov kubických,kilometrom kubickým,kilometre kubické,kilometroch kubických,kilometrami kubickýmistupeň Celzia m stupeň Celzia,stupňa Celzia,stupňu Celzia,stupeň Celzia,stupni Celzia,stupňom Celzia stupne Celzia,stupňov Celzia,stupňom Celzia,stupne Celzia,stupňoch Celzia,stupňami Celziakilometer za hodinu m kilometer za hodinu,kilometra za hodinu,kilometru za hodinu,kilometer za hodinu,kilometri za hodinu,kilometrom za hodinu kilometre za hodinu,kilometrov za hodinu,kilometrom za hodinu,kilometre za hodinu,kilometroch za hodinu,kilometrami za hodinumeter za sekundu m meter za sekundu,metra za sekundu,metru za sekundu,meter za sekundu,metri za sekundu,metrom za sekundu metre za sekundu,metrov za sekundu,metrom za sekundu,metre za sekundu,metroch za sekundu,metrami za sekundučlovek m človek,človeka,človeku,človeka,človeku,človekom ľudia,ľudí,ľuďom,ľudí,ľuďoch,ľuďmiosoba f osoba,osoby,osobe,osobu,osobe,osobou osoby,osôb,osobám,osoby,osobách,osobami123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190"""Slovak grapheme-to-phoneme conversion.
Slovak orthography is nearly phonemic, so most of the work is rule based:
* softening of d, t, n, l before e/i/í/ia/ie/iu (native words); loan words keep them hard (list in ``data/g2p_hard.txt``, replaced by a corpus-learned lexicon in the data pipeline)* digraphs ch, dz, dž; diphthongs ia, ie, iu, ô* syllabic r and l (vlk, krk, prst) and long ŕ, ĺ* voicing assimilation inside clusters and across word boundaries, final devoicing, v -> w/f* a word-final paired obstruent is voiced before a vowel or sonorant of the next word (s otcom -> z otcom)* n before k/g -> ŋ"""
from __future__ import annotations
import reimport unicodedatafrom functools import lru_cachefrom pathlib import Path
from .phonemes import ( DEVOICE, OBSTRUENTS, VOICE, VOICED_OBSTRUENTS, VOICELESS_OBSTRUENTS, VOWEL_LIKE,)
_SOFT_TRIGGER = set("eéiíě")_SOFTEN = {"d": "ɟ", "t": "c", "n": "ɲ", "l": "ʎ"}_SIMPLE = { "a": ["a"], "á": ["aː"], "ä": ["e"], "e": ["e"], "é": ["eː"], "i": ["i"], "í": ["iː"], "o": ["o"], "ó": ["oː"], "ô": ["uo"], "u": ["u"], "ú": ["uː"], "y": ["i"], "ý": ["iː"], "p": ["p"], "b": ["b"], "t": ["t"], "d": ["d"], "ť": ["c"], "ď": ["ɟ"], "k": ["k"], "g": ["g"], "c": ["ts"], "č": ["tʃ"], "f": ["f"], "v": ["v"], "w": ["v"], "s": ["s"], "z": ["z"], "š": ["ʃ"], "ž": ["ʒ"], "h": ["ɦ"], "m": ["m"], "n": ["n"], "ň": ["ɲ"], "l": ["l"], "ľ": ["ʎ"], "ĺ": ["l̩ː"], "r": ["r"], "ŕ": ["r̩ː"], "j": ["j"], "q": ["k", "v"], "x": ["k", "s"],}# Prefixes after which "dz"/"dž" are two separate sounds (pod-zemie, nad-žalovať)._DZ_PREFIXES = ("pod", "nad", "od", "pred", "ob")
_HARD_FILE = Path(__file__).parent / "data" / "g2p_hard.txt"
@lru_cache(maxsize=1)def _hard_lexicon() -> tuple[frozenset[str], tuple[str, ...]]: exact, prefixes = set(), [] for line in _HARD_FILE.read_text(encoding="utf-8").splitlines(): line = line.strip() if not line or line.startswith("#"): continue if line.endswith("*"): prefixes.append(line[:-1]) else: exact.add(line) return frozenset(exact), tuple(prefixes)
def is_hard_loan(word: str) -> bool: exact, prefixes = _hard_lexicon() return word in exact or word.startswith(prefixes)
def _graphemes_to_phonemes(word: str) -> list[str]: hard = is_hard_loan(word) out: list[str] = [] i, n = 0, len(word) while i < n: c = word[i] two = word[i:i + 2] if two == "ch": out.append("x") i += 2 continue if two in ("dz", "dž") and word[: i + 1] not in _DZ_PREFIXES: out.append("dz" if two == "dz" else "dʒ") i += 2 continue if two in ("ia", "ie", "iu"): if hard and word[i + 2:] in ("", "m"): # loan endings -ia/-ie/-iu/-ium: energia -> e n e r g i j a out.extend(["i", "j", two[1]]) else: out.append(two) i += 2 continue if c in _SOFTEN: nxt = word[i + 1] if i + 1 < n else "" soft = nxt in _SOFT_TRIGGER if soft and not hard: # "ste" is pronounced hard: ste, stena if not (c == "t" and nxt == "e" and i > 0 and word[i - 1] == "s"): out.append(_SOFTEN[c]) i += 1 continue if c in _SIMPLE: out.extend(_SIMPLE[c]) i += 1 return out
def _syllabic(ph: list[str]) -> list[str]: res = list(ph) for k, p in enumerate(res): if p not in ("r", "l"): continue prev = res[k - 1] if k > 0 else None nxt = res[k + 1] if k + 1 < len(res) else None if (prev is None or prev not in VOWEL_LIKE) and (nxt is None or nxt not in VOWEL_LIKE): if prev is None and nxt is None: continue res[k] = p + "̩" return res
def _assimilate(ph: list[str], protect_last: bool = False) -> list[str]: """Regressive voicing assimilation over obstruent clusters (right to left).
With ``protect_last`` the final element is only a context (the next word's first sound) and is not changed. """ res = list(ph) for k in range(len(res) - (2 if protect_last else 1), -1, -1): cur = res[k] if cur not in OBSTRUENTS: continue nxt = res[k + 1] if k + 1 < len(res) else "SIL" if nxt == "SIL" or nxt in VOICELESS_OBSTRUENTS: res[k] = DEVOICE.get(cur, cur) elif nxt in VOICED_OBSTRUENTS: res[k] = VOICE.get(cur, cur) return res
_V_KEEP = frozenset(["m", "n", "ɲ", "l", "ʎ", "r", "j"])
def _v_pass(ph: list[str], next_first: str | None) -> list[str]: res = list(ph) for k, p in enumerate(res): if p != "v": continue nxt = res[k + 1] if k + 1 < len(res) else next_first prev = res[k - 1] if k > 0 else None coda = prev is not None and prev in VOWEL_LIKE if coda and (nxt in VOICED_OBSTRUENTS or nxt in _V_KEEP): pass # before a voiced obstruent or a sonorant it stays [v]: pravda, slávny, krvný (the codified [u̯] # there came out as "prauda" from the model, and most speakers say [v]) elif coda and nxt not in VOWEL_LIKE: res[k] = "w" # after a vowel before a voiceless consonant or a pause: dávka, ovca, dav, domov elif nxt in VOICELESS_OBSTRUENTS: res[k] = "f" # vták, všetko elif nxt is None or nxt == "SIL": res[k] = "w" if prev is not None else "v" # otherwise (before vowels, sonorants, voiced obstruents) it stays [v] return res
def _nasal(ph: list[str]) -> list[str]: res = list(ph) for k in range(len(res) - 1): if res[k] == "n" and res[k + 1] in ("k", "g"): res[k] = "ŋ" return res
@lru_cache(maxsize=50000)def g2p_word(word: str) -> tuple[str, ...]: """Lexical phonemes of one lowercase orthographic word (before cross-word sandhi).""" word = unicodedata.normalize("NFC", word.lower()) word = re.sub(r"[^a-záäčďéíľĺňóôŕšťúýž]", "", word) ph = _graphemes_to_phonemes(word) ph = _nasal(_syllabic(ph)) return tuple(ph)
def apply_sandhi(left: list[str], right_first: str | None) -> list[str]: """Final adjustments of a word given what follows.
``right_first`` is the first phoneme of the next word in the same phrase, or None/``"SIL"`` before a pause. Voiced obstruents devoice before a pause and assimilate to a following obstruent. Unlike Czech, Slovak also voices a final paired obstruent before a vowel or sonorant of the next word: s otcom [z otcom], vlak ide [vlag iɟe], k nám [g naːm]. ``v`` at the start of the next word counts as a sonorant here. """ if not left: return left nxt = right_first or "SIL" ph = _assimilate(list(left) + [nxt], protect_last=True)[:-1] if nxt != "SIL" and nxt not in OBSTRUENTS and ph[-1] in VOICE: ph[-1] = VOICE[ph[-1]] return _v_pass(ph, nxt if nxt != "SIL" else None)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204"""Static linguistic data for the Slovak frontend (nouns, prepositions, abbreviations, ...)."""
from __future__ import annotations
from dataclasses import dataclassfrom pathlib import Path
from .numbers import CASES
DATA_DIR = Path(__file__).parent / "data"
# ---------------------------------------------------------------------------------------------# Nouns used after numbers (units, currencies, time words) and for gender/animacy lookup# ---------------------------------------------------------------------------------------------
@dataclass(frozen=True)class Noun: key: str gender: str sg: tuple[str, ...] # nom gen dat acc loc ins pl: tuple[str, ...]
def _load_nouns() -> dict[str, Noun]: nouns: dict[str, Noun] = {} for line in (DATA_DIR / "nouns.tsv").read_text(encoding="utf-8").splitlines(): if not line.strip() or line.startswith("#"): continue key, gender, sg, pl = line.split("\t") nouns[key] = Noun(key, gender, tuple(sg.split(",")), tuple(pl.split(","))) return nouns
NOUNS: dict[str, Noun] = _load_nouns()
def _first_word_index() -> dict[str, Noun]: """Any inflected form of the (first word of a) noun -> the noun; used to find gender of the word after a number.""" index: dict[str, Noun] = {} for noun in NOUNS.values(): if noun.key.count(" ") and noun.key not in ("meter štvorcový", "meter kubický"): continue for form in noun.sg + noun.pl: index.setdefault(form.split(" ")[0], noun) return index
NOUN_BY_FORM: dict[str, Noun] = _first_word_index()
# Nominative plural forms of masculine persons: "dvaja muži", "traja poslanci".ANIMATE_NOM_PL = frozenset( "muži poslanci ľudia študenti žiaci učitelia lekári ministri občania chlapci páni " "hráči vojaci policajti spisovatelia herci zamestnanci kolegovia bratia synovia".split())
# Masculine persons/animals in the plural that look like a genitive plural: after 2-4 without a preposition the# numeral takes the accusative-genitive form ("vidím dvoch študentov"), unlike inanimate nouns ("dva stoly").ANIMATE_ACC_PL = frozenset( "ľudí mužov poslancov študentov žiakov učiteľov lekárov ministrov občanov chlapcov pánov hráčov vojakov " "policajtov spisovateľov hercov zamestnancov kolegov bratov synov psov vlkov medveďov koní".split())
# Gender of the noun a case-dependent abbreviation stands for (the word after a number is the abbreviation).ABBREV_GENDER = {"písm": "n", "č": "n", "str": "f", "kap": "f"}
# Nouns that carry a number as an apposition ("v roku 2020", "paragraf 5"): the number stays nominative.APPOSITION_HEADS = frozenset( "rok roku roky rokov rokom číslo čísla číslu číslom paragraf paragrafu paragrafom odsek odseku odsekom " "písmeno písmena písmenu strana strany strane stranu stranou článok článku článkom kapitola kapitoly " "kapitole kapitolu kapitolou bod bodu bodom verzia verzie verzii verziu linka linky linke linku " "tlač tlače tlači izba izby izbe dom domu domom ulica ulice ulici".split())
# ---------------------------------------------------------------------------------------------# Months, prepositions# ---------------------------------------------------------------------------------------------
MONTHS_NOM = ["január", "február", "marec", "apríl", "máj", "jún", "júl", "august", "september", "október", "november", "december"]MONTHS_GEN = ["januára", "februára", "marca", "apríla", "mája", "júna", "júla", "augusta", "septembra", "októbra", "novembra", "decembra"]MONTH_FORMS = {w: i + 1 for i, w in enumerate(MONTHS_GEN)} | {w: i + 1 for i, w in enumerate(MONTHS_NOM)}MONTH_LOC = ["januári", "februári", "marci", "apríli", "máji", "júni", "júli", "auguste", "septembri", "októbri", "novembri", "decembri"]MONTH_FORMS |= {w: i + 1 for i, w in enumerate(MONTH_LOC)}
# Prepositions that fix one case.PREP_FIXED = { **dict.fromkeys("bez do od okolo u vedľa podľa počas pomocou mimo okrem z zo spomedzi naproti pozdĺž koncom".split(), "gen"), **dict.fromkeys("k ku proti voči vďaka kvôli napriek oproti".split(), "dat"), **dict.fromkeys("pre cez skrz".split(), "acc"), **dict.fromkeys("s so spolu".split(), "ins"), **dict.fromkeys("pri popri".split(), "loc"),}# Prepositions with two candidate cases (first is the default).PREP_AMBIGUOUS = { "na": ("acc", "loc"), "v": ("loc", "acc"), "vo": ("loc", "acc"), "po": ("loc", "acc"), "o": ("acc", "loc"), "za": ("acc", "ins", "gen"), "pod": ("ins", "acc"), "nad": ("ins", "acc"), "pred": ("ins", "acc"), "medzi": ("ins", "acc"),}PREPOSITIONS = frozenset(PREP_FIXED) | frozenset(PREP_AMBIGUOUS)# Monosyllabic proclitics for stress placement (not "pre", "cez", ... which are real syllables, still proclitic).PROCLITICS = frozenset("v vo k ku s so z zo u o na do od po za pri pre bez cez nad pod pred medzi".split())# Monosyllabic conjunctions are weak words: they take no stress and do not steal it from the next word.CONJUNCTIONS = frozenset("a i aj že ak ako ale".split())ENCLITICS = frozenset("sa si som si je sme ste sú by bol bola bolo boli mi ti mu ju ho nám vám im ich ma ťa nás vás".split())
# ---------------------------------------------------------------------------------------------# Abbreviations# ---------------------------------------------------------------------------------------------
# Case-independent abbreviations: written form (without trailing dot) -> spoken form.ABBREVIATIONS: dict[str, str] = { "napr": "napríklad", "tzn": "to znamená", "tj": "to jest", "atď": "a tak ďalej", "atp": "a tak podobne", "resp": "respektíve", "príp": "prípadne", "popr": "poprípade", "pozn": "poznámka", "cca": "približne", "spol": "spoločnosť", "tel": "telefón", "max": "maximálne", "t. j": "to jest", "t. č": "toho času", "a. s": "akciová spoločnosť", "s. r. o": "spoločnosť s ručením obmedzeným", "v. o. s": "verejná obchodná spoločnosť", "Z. z": "zbierky zákonov", "hl. m": "hlavné mesto", "m. r": "minulého roku", "o. z": "občianske združenie", "n. o": "nezisková organizácia",}
# Case-dependent abbreviations: spoken forms (nom, gen, dat, acc, loc, ins), singular.CASED_ABBREVIATIONS: dict[str, tuple[str, ...]] = { "§": ("paragraf", "paragrafu", "paragrafu", "paragraf", "paragrafe", "paragrafom"), "ods": ("odsek", "odseku", "odseku", "odsek", "odseku", "odsekom"), "písm": ("písmeno", "písmena", "písmenu", "písmeno", "písmene", "písmenom"), "č": ("číslo", "čísla", "číslu", "číslo", "čísle", "číslom"), "čl": ("článok", "článku", "článku", "článok", "článku", "článkom"), "str": ("strana", "strany", "strane", "stranu", "strane", "stranou"), "kap": ("kapitola", "kapitoly", "kapitole", "kapitolu", "kapitole", "kapitolou"), "Ing": ("inžinier", "inžiniera", "inžinierovi", "inžiniera", "inžinierovi", "inžinierom"), "Mgr": ("magister", "magistra", "magistrovi", "magistra", "magistrovi", "magistrom"), "Bc": ("bakalár", "bakalára", "bakalárovi", "bakalára", "bakalárovi", "bakalárom"), "Dr": ("doktor", "doktora", "doktorovi", "doktora", "doktorovi", "doktorom"), "JUDr": ("doktor práv", "doktora práv", "doktorovi práv", "doktora práv", "doktorovi práv", "doktorom práv"), "MUDr": ("doktor medicíny", "doktora medicíny", "doktorovi medicíny", "doktora medicíny", "doktorovi medicíny", "doktorom medicíny"), "PhDr": ("doktor filozofie", "doktora filozofie", "doktorovi filozofie", "doktora filozofie", "doktorovi filozofie", "doktorom filozofie"), "RNDr": ("doktor prírodných vied", "doktora prírodných vied", "doktorovi prírodných vied", "doktora prírodných vied", "doktorovi prírodných vied", "doktorom prírodných vied"), "prof": ("profesor", "profesora", "profesorovi", "profesora", "profesorovi", "profesorom"), "doc": ("docent", "docenta", "docentovi", "docenta", "docentovi", "docentom"),}# Written form (with its dots) exactly as it appears before the case-dependent lookup.TITLE_KEYS = frozenset("Ing Mgr Bc Dr JUDr MUDr PhDr RNDr prof doc".split())
# Quantity words after a number: "5 mil." -> "päť miliónov"QUANTITY_ABBREVIATIONS = {"mil": "milión", "mld": "miliarda", "tis": "tisíc"}
# Abbreviations after a name that are read as letters: "PhD." "CSc."POSTNOMINAL_SPELLED = {"PhD": "pé há dé", "CSc": "cé es cé", "MBA": "em bé á", "DrSc": "dé er es cé"}
# ---------------------------------------------------------------------------------------------# Initialisms and letter names# ---------------------------------------------------------------------------------------------
LETTER_NAMES = { "a": "á", "á": "á", "ä": "é", "b": "bé", "c": "cé", "č": "čé", "d": "dé", "ď": "ďé", "e": "é", "é": "é", "f": "ef", "g": "gé", "h": "há", "i": "í", "í": "í", "j": "jé", "k": "ká", "l": "el", "ĺ": "el", "ľ": "eľ", "m": "em", "n": "en", "ň": "eň", "o": "ó", "ó": "ó", "ô": "ó", "p": "pé", "q": "kvé", "r": "er", "ŕ": "er", "s": "es", "š": "eš", "t": "té", "ť": "ťé", "u": "ú", "ú": "ú", "v": "vé", "w": "dvojité vé", "x": "iks", "y": "ypsilon", "ý": "ypsilon", "z": "zet", "ž": "žet",}
# All-caps tokens that are read as ordinary words (everything else is spelled by the heuristic in normalize.py).ACRONYM_WORDS = frozenset("NATO UNESCO OPEC UNICEF COVID IKEA NASA FIFA UEFA".split())
# Initialisms with an explicit reading (checked before the heuristic).ACRONYM_SPECIAL = { "SR": "es er", "EÚ": "é ú", "SK": "es ká", "ČR": "čé er", "USA": "ú es á", "DPH": "dé pé há", "SMS": "es em es", "PIN": "pin", "KDH": "ká dé há", "SNS": "es en es", "PS": "pé es", "SaS": "sas", "OĽaNO": "oľano", "OSN": "ó es en", "SIS": "sis", "SAV": "sav",}
DIGIT_WORDS = ["nula", "jeden", "dva", "tri", "��tyri", "päť", "šesť", "sedem", "osem", "deväť"]
VALID_CASES = CASES
# ---------------------------------------------------------------------------------------------# Grammatical gender of frequent nouns (nominative/accusative forms), for "jedna žena / dve ženy / dva stoly"# ---------------------------------------------------------------------------------------------
_FEMININE = """žena ženy ženu žien ulica ulice ulicu škola školy školu hra hry hru kniha knihy knihu otázka otázkyotázku cesta cesty cestu práca práce prácu rodina rodiny rodinu firma firmy firmu stránka stránky stránku správasprávy správu vec veci vojna vojny vojnu škoda škody dcéra dcéry dcéru mama mamy mamu sestra sestry sestrukamarátka kamarátky pesnička pesničky strana strany stranu izba izby izbu kancelária kancelárie kanceláriuslovenčina banka banky banku pošta pošty poštu lekáreň lekárne noc noci hodina hodiny minúta minútysekunda sekundy koruna koruny korunu zmluva zmluvy zmluvu zákazka zákazky novela novely sloboda slobodyspoločnosť spoločnosti obec obce obce družina družiny skupina skupiny skupinu smernica smernice smernicuúloha úlohy úlohu chyba chyby chybu správa tabuľa tabule tabuľu televízia televízie""".split()_NEUTER = """mesto mestá miesto miesta dieťa deti okno okná slovo slová kolo kolá auto autá dielo dielasrdce srdcia more moria euro eurá percento percentá storočie storočia poschodie poschodia pole poliačíslo čísla vajce vajcia jedlo jedlá zariadenie zariadenia opatrenie opatrenia obdobie obdobiarozhodnutie rozhodnutia uznesenie uznesenia pravidlo pravidlá nariadenie nariadenia""".split()
GENDER_WORDS: dict[str, str] = {w: "f" for w in _FEMININE} | {w: "n" for w in _NEUTER}# Neuter -o nouns look feminine in several other cases (kola, miesta); add those forms explicitly.for _lemma in ("mesto", "miesto", "slovo", "okno", "kolo", "auto", "dielo", "pole", "jedlo", "pravidlo"): for _end in ("a", "u", "e"): GENDER_WORDS.setdefault(_lemma[:-1] + _end, "n")123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478"""Text normalization: written Slovak -> text exactly as it is spoken.
Everything that is not plain words (numbers, dates, times, money, units, abbreviations, roman numerals,initialisms, URLs, phone numbers, symbols) is rewritten to words, with correct case and gender wherethe surrounding words allow us to infer them. See :mod:`sktts.frontend.context`."""
from __future__ import annotations
import reimport unicodedatafrom fractions import Fraction
from . import numbers as Nfrom .context import ( infer_case, infer_gender, is_animate_accusative, is_animate_plural, next_word, prev_word, prev_word_raw,)from .lexicon import ( ABBREVIATIONS, ACRONYM_SPECIAL, ACRONYM_WORDS, CASED_ABBREVIATIONS, DIGIT_WORDS, LETTER_NAMES, MONTH_FORMS, MONTH_LOC, MONTHS_GEN, NOUNS, POSTNOMINAL_SPELLED, TITLE_KEYS, Noun,)
CAPS = "A-ZÁČĎÉÍĽĹŇÓÔŔŠŤÚÝŽÄ"LOWER = "a-záäčďéíľĺňóôŕšťúýž"LETTER = rf"{CAPS}{LOWER}"
# ---------------------------------------------------------------------------------------------# Units# ---------------------------------------------------------------------------------------------
CURRENCY = {"€": ("euro", "cent"), "EUR": ("euro", "cent"), "eur": ("euro", "cent"), "$": ("dolár", "cent"), "USD": ("dolár", "cent")}UNITS: dict[str, str] = { "%": "percento", "°C": "stupeň Celzia", "°": "stupeň", "£": "libra", "kg": "kilogram", "mg": "miligram", "g": "gram", "t": "tona", "ml": "mililiter", "l": "liter", "km/h": "kilometer za hodinu", "m/s": "meter za sekundu", "km²": "kilometer štvorcový", "km2": "kilometer štvorcový", "cm²": "centimeter štvorcový", "cm2": "centimeter štvorcový", "m²": "meter štvorcový", "m2": "meter štvorcový", "km³": "kilometer kubický", "cm³": "centimeter kubický", "m³": "meter kubický", "m3": "meter kubický", "km": "kilometer", "cm": "centimeter", "mm": "milimeter", "m": "meter", "ha": "hektár", "hod": "hodina", "h": "hodina", "min": "minúta", "sek": "sekunda", "kB": "kilobajt", "MB": "megabajt", "GB": "gigabajt", "TB": "terabajt", "ks": "kus",}UNITS.update({k: v[0] for k, v in CURRENCY.items()})QUANTITY = {"mil.": 10**6, "mld.": 10**9, "tis.": 10**3}
_UNIT_ALT = "|".join(re.escape(u) for u in sorted(UNITS, key=len, reverse=True))_CURRENCY_ALT = "|".join(re.escape(u) for u in sorted(CURRENCY, key=len, reverse=True))_QTY_ALT = "|".join(re.escape(u) for u in QUANTITY)
# ---------------------------------------------------------------------------------------------# The master pattern: alternatives are tried in this order at each position# ---------------------------------------------------------------------------------------------
_NUM = r"\d{1,3}(?:[ ]\d{3})+(?:,\d+)?|\d+(?:[,.]\d+)?"_NOT_WORD_BEFORE = rf"(?<![\w{LETTER}])"_NOT_WORD_AFTER = rf"(?![\w{LETTER}])"
def _abbr_pattern(key: str) -> str: pattern = re.escape(key).replace(r"\ ", r"\s?") if key[0].islower(): pattern = f"[{key[0].upper()}{key[0]}]" + pattern[len(re.escape(key[0])):] return pattern
_abbr_alt = "|".join(_abbr_pattern(k) for k in sorted(ABBREVIATIONS, key=len, reverse=True))_cased_alt = "|".join(sorted((k for k in CASED_ABBREVIATIONS if k != "§"), key=len, reverse=True))_post_alt = "|".join(POSTNOMINAL_SPELLED)
_MASTER = re.compile( rf""" (?P<url>(?:https?://|www\.)[^\s<>"']*[A-Za-z0-9/]) | (?P<email>[A-Za-z0-9._%+\-]+@[A-Za-z0-9\-]+(?:\.[A-Za-z0-9\-]+)*\.[A-Za-z]{{2,}}) | (?P<phone>(?<![\w])(?:(?:\+|00)\d{{3}}(?:[ ]?\d{{3}}){{3}}|0\d{{3}}[ /]?\d{{3}}[ ]?\d{{3}})(?!\d)) | (?P<date_iso>(?<![\d.\-])(?P<iy>\d{{4}})-(?P<im>0[1-9]|1[0-2])-(?P<id>0[1-9]|[12]\d|3[01])(?![\d\-])) | (?P<date_dmy>(?<![\d.])(?P<dd>0?[1-9]|[12]\d|3[01])\.\s?(?P<dm>0?[1-9]|1[0-2])\.(?:\s?(?P<dy>\d{{4}})(?!\d))?) | (?P<time>(?<![\d:.])(?P<th>[01]?\d|2[0-3]):(?P<tm>[0-5]\d)(?::(?P<tsec>[0-5]\d))?(?![\d:])(?:[ ]?(?:hod\.?|h)(?![\w{LETTER}]))?) | (?P<slashnum>(?<![\d/.,])\d{{1,4}}/\d{{4}}(?![\d/])) | (?P<frac>(?<![\d/.,])(?P<fn>\d{{1,3}})/(?P<fd>\d{{1,3}})(?![\d/])) | (?P<num> (?P<sign>(?<![\w.,)])[-−+](?=\d))? (?P<n1>{_NUM}) (?:(?P<rsep>-|[ ]?[–—][ ]?)(?P<n2>{_NUM}))? (?: [ ]?(?P<qty>{_QTY_ALT})(?:[ ]?(?P<cur2>{_CURRENCY_ALT})(?![\w{LETTER}]))? | [ ]?(?P<unit>{_UNIT_ALT})(?![\w{LETTER}]) | (?P<ordot>\.(?=\s+[{LOWER}])) )? ) | (?P<cased>§|{_NOT_WORD_BEFORE}(?:{_cased_alt})\.) | (?P<post>{_NOT_WORD_BEFORE}(?:{_post_alt})\.?) | (?P<abbr>{_NOT_WORD_BEFORE}(?:{_abbr_alt})\.) | (?P<abbr0>{_NOT_WORD_BEFORE}[Cc]ca{_NOT_WORD_AFTER}) | (?P<initial>{_NOT_WORD_BEFORE}[{CAPS}]\.(?=\s+[{CAPS}][{LOWER}])) | (?P<mixed>{_NOT_WORD_BEFORE}(?:SaS|OĽaNO){_NOT_WORD_AFTER}) | (?P<caps>{_NOT_WORD_BEFORE}(?P<cw>[{CAPS}]{{2,}}){_NOT_WORD_AFTER}(?P<rdot>\.(?=\s+[{LOWER}]))?) | (?P<roman1>{_NOT_WORD_BEFORE}[IVXLCDM]\.(?=\s+[{LOWER}])) """, re.VERBOSE,)
_ROMAN_VALID = re.compile(r"^M{0,3}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$")_ROMAN_VALUES = {"I": 1, "V": 5, "X": 10, "L": 50, "C": 100, "D": 500, "M": 1000}_PRONOUNCEABLE = re.compile(r"^(?:[BCDFGHJKLMNPRSTVZŠČŽĎŤŇĽ][AEIOUYÁÉÍÓÚÝÄ])+[BCDFGHJKLMNPRSTVZŠČŽĎŤŇĽ]?$")# Abbreviations that may end a sentence: keep the full stop after expanding._SENTENCE_FINAL = {"atď", "atp"}
_SYMBOLS = {"&": " a ", "=": " rovná sa ", "×": " krát ", "÷": " delené ", "±": " plus mínus ", "@": " zavináč ", "+": " plus "}_URL_CHARS = {".": "bodka", "/": "lomka", "-": "pomlčka", "_": "podčiarnik", "@": "zavináč", ":": "dvojbodka", "?": "otáznik", "=": "rovná sa", "&": "a", "#": "mriežka"}_TLD = {"sk": "es ká", "cz": "cé zet", "eu": "é ú", "com": "kom", "org": "org", "net": "net", "info": "info", "gov": "gov", "de": "dé é"}
# ---------------------------------------------------------------------------------------------# Quantity phrases# ---------------------------------------------------------------------------------------------
def _case_idx(case: str) -> int: return N.CASES.index(case)
def number_with_noun(whole: int, frac: str | None, noun: Noun, case: str) -> str: """'5 km' -> 'päť kilometrov'. The noun agrees with the numeral (Slovak government rules).""" ci = _case_idx(case) if frac is not None: return f"{N.decimal(whole, frac, case)} {noun.sg[_case_idx('gen')]}" n = abs(whole) sign = "mínus " if whole < 0 else "" num = N.cardinal(n, case, noun.gender) if n == 1: return sign + f"{num} {noun.sg[ci]}" if case in ("nom", "acc"): few = n % 10 in (2, 3, 4) and n % 100 not in (12, 13, 14) form = noun.pl[ci] if few else noun.pl[_case_idx("gen")] else: form = noun.pl[ci] return sign + f"{num} {form}"
def _parse(token: str) -> tuple[int, str | None]: token = re.sub(r"[ ]", "", token) if "," in token or "." in token: whole, frac = re.split(r"[,.]", token, maxsplit=1) return int(whole), frac return int(token), None
def _as_fraction(whole: int, frac: str | None) -> Fraction: value = Fraction(whole) if frac: value += Fraction(int(frac), 10 ** len(frac)) return value
def _spell_letters(token: str) -> str: return " ".join(LETTER_NAMES.get(ch.lower(), ch) for ch in token if ch.isalpha())
def _clean(text: str) -> str: text = unicodedata.normalize("NFC", text) text = re.sub(r"[-]", "", text) text = text.replace("\r\n", "\n").replace("\r", "\n") text = re.sub(r"[„“”«»‚‘’\"`´]", "", text) text = re.sub(r"(?<=\w)'(?=\w)", "", text) text = text.replace("...", "…") text = re.sub(r"([€$£])(\d+(?:[,.]\d+)?)", r"\2 \1", text) # "$10" -> "10 $" text = re.sub(r"[ \t ]+", " ", text) return text
class Normalizer: """Rule-based normalizer. Stateless and thread-safe."""
def normalize(self, text: str) -> str: text = _clean(text) out: list[str] = [] pos = 0 for m in _MASTER.finditer(text): out.append(text[pos:m.start()]) out.append(self._dispatch(m, text)) pos = m.end() out.append(text[pos:]) result = "".join(out) for sym, spoken in _SYMBOLS.items(): result = result.replace(sym, spoken) result = re.sub(r"(?<=[\wáäčďéíľĺňóôŕšťúýž])/(?=[\wáäčďéíľĺňóôŕšťúýž])", " ", result) result = re.sub( r"\b(písmen[aeou]|písmeno) ([a-zA-Z])\)", lambda mm: f"{mm.group(1)} {LETTER_NAMES[mm.group(2).lower()]}", result, ) result = re.sub(r"[ ]*\n[ ]*", "\n", result) result = re.sub(r"[ ]{2,}", " ", result) result = re.sub(r"\s+([,.;:!?…])", r"\1", result) return result.strip()
# ------------------------------------------------------------------ dispatch
def _dispatch(self, m: re.Match, text: str) -> str: kind = "" for name in ("url", "email", "phone", "date_iso", "date_dmy", "time", "slashnum", "frac", "num", "cased", "post", "abbr", "abbr0", "initial", "mixed", "caps", "roman1"): if m.group(name) is not None: kind = name break return getattr(self, f"_h_{kind}")(m, text)
# ------------------------------------------------------------------ simple patterns
def _h_url(self, m: re.Match, text: str) -> str: return self._spell_web(m.group("url"))
def _h_email(self, m: re.Match, text: str) -> str: return self._spell_web(m.group("email"))
def _spell_web(self, s: str) -> str: s = re.sub(r"^https?://", "", s) words: list[str] = [] for tok in re.findall(r"[A-Za-z0-9]+|[^A-Za-z0-9]", s): if tok == "www": words.append("vé vé vé") elif tok.isdigit(): words.append(N.digits(tok)) elif tok.isalpha(): low = tok.lower() if low in _TLD and (not words or words[-1] == "bodka"): words.append(_TLD[low]) elif len(low) <= 2 or not re.search(r"[aeiouy]", low): words.append(_spell_letters(low)) else: words.append(low) elif tok in _URL_CHARS: words.append(_URL_CHARS[tok]) return " ".join(words)
def _h_phone(self, m: re.Match, text: str) -> str: raw = m.group("phone") plus = raw.startswith("+") groups = re.findall(r"\d+", raw) if raw.startswith("+") or raw.startswith("00"): first = groups[0].lstrip("0") if raw.startswith("00") else groups[0] groups = [first] + groups[1:] spoken = ", ".join(N.digits(g) for g in groups) return ("plus " if plus else "") + spoken
# ------------------------------------------------------------------ dates, times
def _date_text(self, d: int, mo: int, y: int | None) -> str: out = f"{N.ordinal(d, 'gen', 'm')} {MONTHS_GEN[mo - 1]}" if y: out += " " + N.cardinal(y) return out
def _h_date_iso(self, m: re.Match, text: str) -> str: return self._date_text(int(m.group("id")), int(m.group("im")), int(m.group("iy")))
def _h_date_dmy(self, m: re.Match, text: str) -> str: y = m.group("dy") out = self._date_text(int(m.group("dd")), int(m.group("dm")), int(y) if y else None) if not y and re.match(r"\s+[A-ZÁČĎÉÍĽĹŇÓÔŔŠŤÚÝŽ]", text[m.end():]): out += "." # "do 1. 5. Potom ..." the last dot also ends the sentence return out
def _h_time(self, m: re.Match, text: str) -> str: h, mi = int(m.group("th")), int(m.group("tm")) prev = prev_word(text, m.start()) has_prep = prev in {"o", "od", "do", "okolo", "po", "pred", "pri", "k", "ku", "za", "v", "vo", "na"} parts: list[str] = [] if has_prep: case = infer_case(prev, "", "ordinal") if prev in ("o", "v", "vo", "po", "pri"): case = "loc" elif prev in ("pred", "za"): case = "ins" if prev == "pred" else "acc" elif prev in ("k", "ku"): case = "dat" parts.append(N.ordinal(h, case, "f") if h else "polnoci" if case == "loc" else "nula") if mi: parts.append(self._minutes(mi)) else: parts.append(N.cardinal(h)) parts.append(self._minutes(mi) if mi else "nula nula") if m.group("tsec"): parts.append(N.cardinal(int(m.group("tsec")))) return " ".join(parts)
@staticmethod def _minutes(mi: int) -> str: return ("nula " if mi < 10 else "") + N.cardinal(mi)
# ------------------------------------------------------------------ numbers
def _h_slashnum(self, m: re.Match, text: str) -> str: a, b = m.group("slashnum").split("/") return f"{N.cardinal(int(a))} lomeno {N.cardinal(int(b))}"
def _h_frac(self, m: re.Match, text: str) -> str: spoken = N.fraction(int(m.group("fn")), int(m.group("fd"))) return spoken or f"{N.cardinal(int(m.group('fn')))} lomeno {N.cardinal(int(m.group('fd')))}"
def _h_num(self, m: re.Match, text: str) -> str: prev = prev_word(text, m.start()) nxt = next_word(text, m.end()) sign = {"-": "mínus ", "−": "mínus ", "+": "plus ", None: ""}[m.group("sign")] w1, f1 = _parse(m.group("n1")) w2, f2 = _parse(m.group("n2")) if m.group("n2") else (None, None)
if m.group("ordot") and w2 is None and f1 is None: return sign + self._ordinal(w1, prev, nxt) + ""
multiplier = QUANTITY.get(m.group("qty")) if m.group("qty") else None unit = m.group("unit") cur2 = m.group("cur2") if multiplier: unit = cur2 w1, f1 = self._scale(w1, f1, multiplier) if w2 is not None: w2, f2 = self._scale(w2, f2, multiplier) if cur2 is None: unit = None case = infer_case(prev, "", "cardinal") if unit else infer_case(prev, nxt, "cardinal")
if unit: noun_key = UNITS[unit] noun = NOUNS[noun_key] render = lambda w, f: self._unit_phrase(w, f, unit, noun, case) # noqa: E731 if w2 is not None: first = N.cardinal(w1, case, noun.gender) if f1 is None else N.decimal(w1, f1, case) return sign + f"{first} až {render(w2, f2)}" return sign + render(w1, f1)
gender = infer_gender(nxt) animate = is_animate_plural(nxt) and case == "nom" num_case = case if case == "nom" and is_animate_accusative(nxt): # "vidím dvoch študentov": accusative = genitive form animate, num_case = True, "acc"
def plain(w: int, f: str | None) -> str: return N.decimal(w, f, case) if f is not None else N.cardinal(w, num_case, gender, animate)
if w2 is not None: return sign + f"{plain(w1, f1)} až {plain(w2, f2)}" return sign + plain(w1, f1)
@staticmethod def _scale(whole: int, frac: str | None, factor: int) -> tuple[int, str | None]: value = _as_fraction(whole, frac) * factor if value.denominator == 1: return int(value), None digits = str(int((value - int(value)) * 10 ** 6)).zfill(6).rstrip("0") # keep leading zeros: 1000,05 return int(value), digits
def _unit_phrase(self, whole: int, frac: str | None, unit: str, noun: Noun, case: str) -> str: if unit in CURRENCY: sub_key = CURRENCY[unit][1] if frac is not None: cents = int((frac + "0")[:2]) head = number_with_noun(whole, None, noun, case) if cents == 0: return head return f"{head} a {number_with_noun(cents, None, NOUNS[sub_key], case)}" return number_with_noun(whole, frac, noun, case)
def _ordinal(self, n: int, prev: str, nxt: str) -> str: if nxt in MONTH_FORMS: case = "gen" if nxt in MONTHS_GEN else "loc" if nxt in MONTH_LOC else "nom" return N.ordinal(n, case, "m") case = infer_case(prev, nxt, "ordinal") return N.ordinal(n, case, infer_gender(nxt))
# ------------------------------------------------------------------ abbreviations
def _h_abbr(self, m: re.Match, text: str) -> str: raw = m.group("abbr")[:-1] key = re.sub(r"\.\s?", ". ", raw).strip() key = key if key in ABBREVIATIONS else key[0].lower() + key[1:] spoken = ABBREVIATIONS.get(key, raw) if raw[0].isupper() and key[0].islower(): spoken = spoken[0].upper() + spoken[1:] rest = text[m.end():] if re.match(r"[ ]*(\n|$)", rest): # the abbreviation's dot is also the sentence's full stop return spoken + "." if key in _SENTENCE_FINAL and re.match(r"\s+[A-ZÁČĎÉÍĽĹŇÓÔŔŠŤÚÝŽ]", rest): return spoken + "." return spoken
def _h_abbr0(self, m: re.Match, text: str) -> str: return "Približne" if m.group("abbr0")[0] == "C" else "približne"
def _h_cased(self, m: re.Match, text: str) -> str: raw = m.group("cased") key = raw.rstrip(".") forms = CASED_ABBREVIATIONS[key] prev = prev_word(text, m.start()) nxt = next_word(text, m.end()) case = infer_case(prev, "", "cardinal") if case == "nom" and key in TITLE_KEYS: if nxt.endswith("ovi"): case = "dat" elif nxt.endswith("om"): case = "ins" return forms[_case_idx(case)]
def _h_post(self, m: re.Match, text: str) -> str: return POSTNOMINAL_SPELLED[m.group("post").rstrip(".")]
def _h_initial(self, m: re.Match, text: str) -> str: return LETTER_NAMES.get(m.group("initial")[0].lower(), m.group("initial")[0])
def _h_mixed(self, m: re.Match, text: str) -> str: return ACRONYM_SPECIAL[m.group("mixed")]
# ------------------------------------------------------------------ caps: roman numerals / initialisms
def _roman(self, token: str, has_dot: bool, m: re.Match, text: str) -> str | None: if not _ROMAN_VALID.match(token): return None value = sum( (-1 if i + 1 < len(token) and _ROMAN_VALUES[token[i]] < _ROMAN_VALUES[token[i + 1]] else 1) * _ROMAN_VALUES[ch] for i, ch in enumerate(token) ) prev_raw = prev_word_raw(text, m.start()) name_before = len(prev_raw) >= 3 and prev_raw[0].isupper() and prev_raw[1:].islower() if not (has_dot or name_before): return None nxt = next_word(text, m.end()) if name_before: # "Karol IV." -- a ruler's number: masculine, same case as the name (nominative by default) out = N.ordinal(value, "nom", "m") return out + "." if has_dot and not re.match(r"\s+[a-záäčďéíľĺňóôŕšťúýž]", text[m.end():]) else out out = N.ordinal(value, infer_case(prev_raw.lower(), nxt, "ordinal"), infer_gender(nxt)) return out
def _h_caps(self, m: re.Match, text: str) -> str: token = m.group("cw") has_dot = m.group("rdot") is not None roman = self._roman(token, has_dot, m, text) if roman is not None: return roman spoken = self._initialism(token) # the dot after an acronym is a full stop only when it was not consumed as an ordinal dot return spoken + ("." if has_dot else "")
def _h_roman1(self, m: re.Match, text: str) -> str: token = m.group("roman1")[0] nxt = next_word(text, m.end()) prev = prev_word(text, m.start()) return N.ordinal(_ROMAN_VALUES[token], infer_case(prev, nxt, "ordinal"), infer_gender(nxt))
@staticmethod def _initialism(token: str) -> str: if token in ACRONYM_SPECIAL: return ACRONYM_SPECIAL[token] if token in ACRONYM_WORDS: return token.lower() if len(token) >= 5 and re.search(r"[AEIOUYÁÉÍÓÚÝÄ]", token): return token.lower() if len(token) >= 3 and _PRONOUNCEABLE.match(token): return token.lower() return _spell_letters(token)
__all__ = ["Normalizer", "number_with_noun", "DIGIT_WORDS"]123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322"""Slovak numerals: cardinals, ordinals, decimals, with case/gender agreement.
Conventions-----------* Cases are the strings ``nom gen dat acc loc ins``.* Genders are ``m`` (masculine), ``f`` (feminine), ``n`` (neuter).* Compound numerals up to 999 999 are written as one word in the nominative (``dvadsaťjeden``, ``dvetisícdvadsaťšesť``) as the orthography prescribes; millions and above are separate words.* In oblique cases only the last two-digit part declines (``stodvadsiatich piatich``); hundreds and thousands stay invariable. Millions are declined in the genitive only, other cases fall back to the nominative."""
from __future__ import annotations
import re
CASES = ("nom", "gen", "dat", "acc", "loc", "ins")
_ONES = ["nula", "jeden", "dva", "tri", "štyri", "päť", "šesť", "sedem", "osem", "deväť"]_TEENS = { 10: "desať", 11: "jedenásť", 12: "dvanásť", 13: "trinásť", 14: "štrnásť", 15: "pätnásť", 16: "šestnásť", 17: "sedemnásť", 18: "osemnásť", 19: "devätnásť",}_TENS = { 2: "dvadsať", 3: "tridsať", 4: "štyridsať", 5: "päťdesiat", 6: "šesťdesiat", 7: "sedemdesiat", 8: "osemdesiat", 9: "deväťdesiat",}_HUNDREDS = { 1: "sto", 2: "dvesto", 3: "tristo", 4: "štyristo", 5: "päťsto", 6: "šesťsto", 7: "sedemsto", 8: "osemsto", 9: "deväťsto",}# Stems of 5..99 that take the plural adjective-like endings -ich/-im/-imi._OBLIQUE_STEM = { "päť": "piat", "šesť": "šiest", "sedem": "siedm", "osem": "ôsm", "deväť": "deviat", "desať": "desiat", "jedenásť": "jedenást", "dvanásť": "dvanást", "trinásť": "trinást", "štrnásť": "štrnást", "pätnásť": "pätnást", "šestnásť": "šestnást", "sedemnásť": "sedemnást", "osemnásť": "osemnást", "devätnásť": "devätnást", "dvadsať": "dvadsiat", "tridsať": "tridsiat", "štyridsať": "štyridsiat", "päťdesiat": "päťdesiat", "šesťdesiat": "šesťdesiat", "sedemdesiat": "sedemdesiat", "osemdesiat": "osemdesiat", "deväťdesiat": "deväťdesiat",}_PLURAL_END = {"gen": "ich", "loc": "ich", "dat": "im", "ins": "imi"}
_ONE = { # jeden / jedna / jedno "m": {"nom": "jeden", "gen": "jedného", "dat": "jednému", "acc": "jeden", "loc": "jednom", "ins": "jedným"}, "f": {"nom": "jedna", "gen": "jednej", "dat": "jednej", "acc": "jednu", "loc": "jednej", "ins": "jednou"}, "n": {"nom": "jedno", "gen": "jedného", "dat": "jednému", "acc": "jedno", "loc": "jednom", "ins": "jedným"},}_TWO = { "m": {"nom": "dva", "gen": "dvoch", "dat": "dvom", "acc": "dva", "loc": "dvoch", "ins": "dvoma"}, "f": {"nom": "dve", "gen": "dvoch", "dat": "dvom", "acc": "dve", "loc": "dvoch", "ins": "dvoma"}, "n": {"nom": "dve", "gen": "dvoch", "dat": "dvom", "acc": "dve", "loc": "dvoch", "ins": "dvoma"},}_THREE = {"nom": "tri", "gen": "troch", "dat": "trom", "acc": "tri", "loc": "troch", "ins": "troma"}_FOUR = {"nom": "štyri", "gen": "štyroch", "dat": "štyrom", "acc": "štyri", "loc": "štyroch", "ins": "štyrmi"}# masculine persons, nominative: dvaja muži, traja muži, štyria muži_ANIMATE_NOM = {2: "dvaja", 3: "traja", 4: "štyria"}# masculine persons, accusative equals the genitive: vidím dvoch mužov_ANIMATE_ACC = {2: "dvoch", 3: "troch", 4: "štyroch"}
def _small(n: int, case: str, gender: str, animate: bool, nominal: bool = False) -> str: """Declined word(s) for 1..99, no fusing with hundreds.""" if n < 10: if n == 1: return _ONE[gender][case] if n == 2: if animate and case == "nom": return _ANIMATE_NOM[2] if animate and case == "acc": return _ANIMATE_ACC[2] return _TWO[gender][case] if n == 3: if animate and case == "nom": return _ANIMATE_NOM[3] if animate and case == "acc": return _ANIMATE_ACC[3] return _THREE[case] if n == 4: if animate and case == "nom": return _ANIMATE_NOM[4] if animate and case == "acc": return _ANIMATE_ACC[4] return _FOUR[case] return _decline_plain(_ONES[n], case) if n < 20: return _decline_plain(_TEENS[n], case) tens, ones = divmod(n, 10) t = _decline_plain(_TENS[tens], case) if ones == 0: return t sep = "" if case in ("nom", "acc") else " " return t + sep + _small(ones, case, gender, animate)
def _decline_plain(word: str, case: str) -> str: if case in ("nom", "acc"): return word return _OBLIQUE_STEM[word] + _PLURAL_END[case]
def _hundreds_and_below(n: int, case: str, gender: str, animate: bool) -> str: """1..999 as one fused word (nominative) or fused hundreds + declined tail.""" h, rest = divmod(n, 100) if h == 0: return _small(rest, case, gender, animate) head = _HUNDREDS[h] if rest == 0: return head tail = _small(rest, case, gender, animate) if " " in tail: first, second = tail.split(" ", 1) return head + first + " " + second return head + tail
def _count_before_thousand(n: int) -> str: """Multiplier in front of 'tisíc' (neuter 2 -> dve, 1 -> jeden when part of a larger count).""" words = _hundreds_and_below(n, "nom", "n", False) # 'dve' for ...2 and 'jeden' for ...1 are already what gender 'n' / 'm' would give if n % 10 == 1 and n % 100 != 11: words = words[: -len("jedno")] + "jeden" return words
_BIG = [ # (power of 1000, singular, nominative 2-4, genitive plural, genitive singular, noun gender) (4, "bilión", "bilióny", "biliónov", "bilióna", "m"), (3, "miliarda", "miliardy", "miliárd", "miliardy", "f"), (2, "milión", "milióny", "miliónov", "milióna", "m"),]
def _big_group(count: int, sg: str, pl24: str, plgen: str, gensg: str, gender: str, case: str) -> str: """'dva milióny', 'päť miliónov', ... Only the genitive is declined; other oblique cases use the nominative.""" if case == "gen": return gensg if count == 1 else cardinal(count, "gen", gender) + " " + plgen if count == 1: return sg counted = cardinal(count, "nom", gender) if count % 10 in (2, 3, 4) and count % 100 not in (12, 13, 14): return counted + " " + pl24 return counted + " " + plgen
def cardinal(n: int, case: str = "nom", gender: str = "m", animate: bool = False) -> str: """Spell out an integer as Slovak cardinal words.""" if n < 0: return "mínus " + cardinal(-n, case, gender, animate) if n == 0: return "nula" words: list[str] = [] rest = n for power, sg, pl24, plgen, gensg, g in _BIG: count, rest = divmod(rest, 1000 ** power) if count: words.append(_big_group(count, sg, pl24, plgen, gensg, g, case)) thousands, below = divmod(rest, 1000) if thousands: head = "tisíc" if thousands == 1 else _count_before_thousand(thousands) + "tisíc" # the tail is fused to 'tisíc'; when it is declined it may contain one space (tens + units) words.append(head + (_hundreds_and_below(below, case, gender, animate) if below else "")) elif below: words.append(_hundreds_and_below(below, case, gender, animate)) return " ".join(words)
# ---------------------------------------------------------------------------------------------# Ordinals# ---------------------------------------------------------------------------------------------
# Canonical masculine nominative with the *long* ending (-ý / -í); the rhythmic law is applied in# decline_adjective() (piatý -> piaty, piateho; jedenástý -> jedenásty)._ORD_UNITS = { 1: "prvý", 2: "druhý", 3: "tretí", 4: "štvrtý", 5: "piatý", 6: "šiestý", 7: "siedmý", 8: "ôsmý", 9: "deviatý", 10: "desiatý", 11: "jedenástý", 12: "dvanástý", 13: "trinástý", 14: "štrnástý", 15: "pätnástý", 16: "šestnástý", 17: "sedemnástý", 18: "osemnástý", 19: "devätnástý",}_ORD_TENS = { 2: "dvadsiatý", 3: "tridsiatý", 4: "štyridsiatý", 5: "päťdesiatý", 6: "šesťdesiatý", 7: "sedemdesiatý", 8: "osemdesiatý", 9: "deväťdesiatý",}_ORD_HUNDRED_PREFIX = {2: "dvoj", 3: "troj", 4: "štvor", 5: "päť", 6: "šesť", 7: "sedem", 8: "osem", 9: "deväť"}
_HARD = { # vzor pekný: (case, gender) -> ending after the stem ("nom", "m"): "ý", ("gen", "m"): "ého", ("dat", "m"): "ému", ("acc", "m"): "ý", ("loc", "m"): "om", ("ins", "m"): "ým", ("nom", "f"): "á", ("gen", "f"): "ej", ("dat", "f"): "ej", ("acc", "f"): "ú", ("loc", "f"): "ej", ("ins", "f"): "ou", ("nom", "n"): "é", ("gen", "n"): "ého", ("dat", "n"): "ému", ("acc", "n"): "é", ("loc", "n"): "om", ("ins", "n"): "ým",}_SOFT = { # vzor cudzí (tretí, tisíci) ("nom", "m"): "í", ("gen", "m"): "ieho", ("dat", "m"): "iemu", ("acc", "m"): "í", ("loc", "m"): "om", ("ins", "m"): "ím", ("nom", "f"): "ia", ("gen", "f"): "ej", ("dat", "f"): "ej", ("acc", "f"): "iu", ("loc", "f"): "ej", ("ins", "f"): "ou", ("nom", "n"): "ie", ("gen", "n"): "ieho", ("dat", "n"): "iemu", ("acc", "n"): "ie", ("loc", "n"): "om", ("ins", "n"): "ím",}_HARD_PL = {"nom": "é", "gen": "ých", "dat": "ým", "acc": "é", "loc": "ých", "ins": "ými"}_SOFT_PL = {"nom": "ie", "gen": "ích", "dat": "ím", "acc": "ie", "loc": "ích", "ins": "ími"}
_LONG_NUCLEUS = re.compile(r"(ia|ie|iu|ô|[áéíóúýŕĺ]|[aeiouyä])[^aeiouyáéíóúýôäŕĺ]*$")_SHORTEN = str.maketrans("áéíóúý", "aeiouy")
def _stem_is_long(stem: str) -> bool: m = _LONG_NUCLEUS.search(stem) return bool(m) and (len(m.group(1)) == 2 or m.group(1) in "áéíóúýôŕĺ")
def _shorten(ending: str, soft: bool) -> str: """Rhythmic law: after a long syllable the ending vowels are short.""" if soft and ending[:1] == "i" and len(ending) > 1 and ending[1] in "aeu": ending = ending[1:] return ending.translate(_SHORTEN)
def decline_adjective(word: str, case: str, gender: str, plural: bool = False, animate: bool = False) -> str: """Decline an ordinal-like adjective given as masculine nominative singular with the long ending.""" soft = word.endswith("í") stem = word[:-1] if plural: table = _SOFT_PL if soft else _HARD_PL key = "gen" if animate and case == "acc" else case ending = "í" if animate and case == "nom" else table[key] else: table = _SOFT if soft else _HARD key = (("gen" if animate and gender == "m" and case == "acc" else case), gender) ending = table[key] if soft and stem.endswith("t") and ending == "om": # treťom return stem[:-1] + "ťom" if _stem_is_long(stem): ending = _shorten(ending, soft) return stem + ending
def _ordinal_words(n: int) -> tuple[str, list[str]]: """Return (invariable cardinal prefix, [ordinal words]) for 1..999 999.""" prefix = "" thousands, rest = divmod(n, 1000) if thousands and rest == 0: if thousands == 1: return "", ["tisíc" + "í"] if thousands in (2, 3, 4): return "", [_ORD_HUNDRED_PREFIX[thousands] + "tisíc" + "í"] return "", [_count_before_thousand(thousands) + "tisíc" + "í"] if thousands: prefix = "tisíc" if thousands == 1 else _count_before_thousand(thousands) + "tisíc" n = rest h, below = divmod(n, 100) if h and below == 0: word = "stý" if h == 1 else _ORD_HUNDRED_PREFIX[h] + "stý" return prefix, [word] if h: prefix += _HUNDREDS[h] words: list[str] = [] if below < 20: words.append(_ORD_UNITS[below]) else: tens, ones = divmod(below, 10) words.append(_ORD_TENS[tens]) if ones: words.append(_ORD_UNITS[ones]) return prefix, words
def ordinal(n: int, case: str = "nom", gender: str = "m", plural: bool = False, animate: bool = False) -> str: """Spell an ordinal ("1." -> "prvý") agreeing in case/gender/number.""" if n <= 0 or n >= 1_000_000: return cardinal(n, "nom") prefix, words = _ordinal_words(n) out = [decline_adjective(w, case, gender, plural, animate) for w in words] out[0] = prefix + out[0] return " ".join(out)
# ---------------------------------------------------------------------------------------------# Decimals, fractions# ---------------------------------------------------------------------------------------------
_CELE = { # "celé" agrees with the whole part (1 -> celá; 2-4 -> celé; 0, 5+ -> celých) "nom": ("celá", "celé", "celých"), "gen": ("celej", "celých", "celých"), "dat": ("celej", "celým", "celým"), "acc": ("celú", "celé", "celých"), "loc": ("celej", "celých", "celých"), "ins": ("celou", "celými", "celými"),}
def decimal(whole: int, frac_digits: str, case: str = "nom") -> str: """"3,5" -> "tri celé päť"; zero-padded fractions are read digit by digit ("0,05" -> "nula celých nula päť").""" abs_whole = abs(whole) idx = 0 if abs_whole == 1 else 1 if 2 <= abs_whole <= 4 else 2 frac_val = int(frac_digits) if frac_val == 0: frac_txt = " ".join(["nula"] * len(frac_digits)) else: zeros = len(frac_digits) - len(frac_digits.lstrip("0")) frac_txt = " ".join(["nula"] * zeros + [cardinal(frac_val, "nom", "f")]) return f"{cardinal(whole, case, 'f')} {_CELE[case][idx]} {frac_txt}"
_FRACTION_NOUN = { 2: ("polovica", "polovice", "polovíc"), 3: ("tretina", "tretiny", "tretín"), 4: ("štvrtina", "štvrtiny", "štvrtín"), 5: ("pätina", "pätiny", "pätín"), 6: ("šestina", "šestiny", "šestín"), 7: ("sedmina", "sedminy", "sedmín"), 8: ("osmina", "osminy", "osmín"), 9: ("devätina", "devätiny", "devätín"), 10: ("desatina", "desatiny", "desatín"),}
def fraction(num: int, den: int) -> str | None: """"3/4" -> "tri štvrtiny"; denominators 2..10 only (otherwise None).""" if den not in _FRACTION_NOUN or num < 1: return None sg, pl, gen_pl = _FRACTION_NOUN[den] if num == 1: return f"jedna {sg}" count = cardinal(num, "nom", "f") return f"{count} {pl if num in (2, 3, 4) else gen_pl}"
def digits(s: str) -> str: """Read a digit string digit by digit ("905" -> "deväť nula päť").""" return " ".join(_ONES[int(c)] for c in s if c.isdigit())12345678910111213141516171819202122232425262728293031323334"""Phoneme inventory and token vocabulary of the Slovak acoustic model."""
from __future__ import annotations
VOWELS = ["a", "e", "i", "o", "u", "aː", "eː", "iː", "oː", "uː"]DIPHTHONGS = ["ia", "ie", "iu", "uo"]SYLLABIC = ["r̩", "r̩ː", "l̩", "l̩ː"]CONSONANTS = [ "p", "b", "t", "d", "c", "ɟ", "k", "g", "ts", "dz", "tʃ", "dʒ", "f", "v", "w", "s", "z", "ʃ", "ʒ", "x", "ɦ", "m", "n", "ɲ", "ŋ", "l", "ʎ", "r", "j",]PHONEMES = VOWELS + DIPHTHONGS + SYLLABIC + CONSONANTS
PAD, BOS, EOS, UNK = "<pad>", "<bos>", "<eos>", "<unk>"SENTENCE_TYPES = ["<s>", "<q>", "<wh>", "<e>"] # statement, yes/no question, wh-question, exclamationBOUNDARIES = ["|1", "|2", "|3", "|4"] # weak, comma/colon, sentence end, paragraph endWORD_SEP, STRESS = "▁", "ˈ"
SYMBOLS = [PAD, BOS, EOS, UNK] + SENTENCE_TYPES + BOUNDARIES + [WORD_SEP, STRESS] + PHONEMESSYMBOL_TO_ID = {s: i for i, s in enumerate(SYMBOLS)}
VOWEL_LIKE = frozenset(VOWELS + DIPHTHONGS + SYLLABIC)SONORANTS = frozenset(["m", "n", "ɲ", "ŋ", "l", "ʎ", "r", "j", "v", "w"])VOICED_OBSTRUENTS = frozenset(["b", "d", "ɟ", "g", "z", "ʒ", "dz", "dʒ", "ɦ"])VOICELESS_OBSTRUENTS = frozenset(["p", "t", "c", "k", "s", "ʃ", "ts", "tʃ", "x", "f"])OBSTRUENTS = VOICED_OBSTRUENTS | VOICELESS_OBSTRUENTSDEVOICE = {"b": "p", "d": "t", "ɟ": "c", "g": "k", "z": "s", "ʒ": "ʃ", "dz": "ts", "dʒ": "tʃ", "ɦ": "x"}VOICE = {v: k for k, v in DEVOICE.items()}
def encode(tokens: list[str]) -> list[int]: unk = SYMBOL_TO_ID[UNK] return [SYMBOL_TO_ID.get(t, unk) for t in tokens]123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217"""The complete text frontend: text -> normalized sentences -> phoneme token sequences."""
from __future__ import annotations
import refrom dataclasses import dataclass, fieldfrom pathlib import Path
from . import numbers as Nfrom . import ssmlfrom .g2p import apply_sandhi, g2p_wordfrom .lexicon import CONJUNCTIONS, ENCLITICS, PROCLITICSfrom .normalize import Normalizerfrom .phonemes import ( BOS, EOS, SENTENCE_TYPES, STRESS, SYMBOL_TO_ID, VOWEL_LIKE, WORD_SEP, encode,)
_WORD_CHARS = "A-Za-záäčďéíľĺňóôŕšťúýžÁÄČĎÉÍĽĹŇÓÔŔŠŤÚÝŽ"_TOKEN_RE = re.compile(rf"⟦[a-j]+⟧|⟦[a-z]+⟧|[{_WORD_CHARS}]+|[,;:()–—…!?.]")_BOUNDARY_LEVEL = {",": 2, ";": 2, ":": 2, "(": 2, ")": 2, "–": 2, "—": 2, "…": 3, ".": 3, "!": 3, "?": 3}_SENTENCE_RE = re.compile(r"[^.!?…]+[.!?…]*|[.!?…]+")_WH_WORDS = frozenset( "kto koho komu kom kým čo čoho čomu čom čím kde kedy prečo ako koľko koľkí kam odkiaľ dokedy načo začo " "ktorý ktorá ktoré ktorí ktorého ktorej ktorému ktorú ktorom ktorým ktorých ktorými " "aký aká aké akí akého akej akému akú akom akým akých akými čí čia čie čiu čieho".split())_QUESTION_LEAD = frozenset("a no tak veď".split()) # "A kde si bol?", "No a čo?": skip to the question word
@dataclassclass Word: text: str phonemes: list[str] boundary: int = 0 # 0 none, 2 comma-like, 3 sentence end, 4 paragraph end pause_ms: int = 0 # explicit <break> stressed: bool = False fixed: bool = False # explicit phonemes from a lexicon or SSML: no sandhi
@dataclassclass Utterance: text: str # normalized sentence words: list[Word] sentence_type: str = "<s>" rate: float = 1.0 pitch_st: float = 0.0 leading_pause_ms: int = 0 # <break> at the very start; process() moves it to the previous utterance
def tokens(self) -> list[str]: out = [BOS, self.sentence_type] for i, w in enumerate(self.words): if w.stressed: out.append(STRESS) out.extend(w.phonemes) if i + 1 < len(self.words): out.append(f"|{w.boundary}" if w.boundary else WORD_SEP) else: out.append(f"|{w.boundary or 3}") out.append(EOS) return out
def ids(self) -> list[int]: return encode(self.tokens())
def phoneme_string(self) -> str: return " ".join(t for t in self.tokens() if t not in (BOS, EOS))
@dataclassclass Frontend: """Slovak TTS frontend.
``user_lexicon`` maps a word to a respelling ("peugeot" -> "pežó") or to explicit phonemes ("/p e ʒ o:/"), and takes precedence over the rules. """
user_lexicon: dict[str, str] = field(default_factory=dict) normalizer: Normalizer = field(default_factory=Normalizer)
@classmethod def with_lexicon_file(cls, path: str | Path) -> Frontend: lex: dict[str, str] = {} for line in Path(path).read_text(encoding="utf-8").splitlines(): if line.strip() and not line.startswith("#") and "\t" in line: word, spoken = line.split("\t", 1) lex[word.strip().lower()] = spoken.strip() return cls(user_lexicon=lex)
# ------------------------------------------------------------------ public API
def normalize(self, text: str) -> str: """Plain text (no SSML) -> text exactly as spoken.""" return self.normalizer.normalize(text)
def process(self, text: str) -> list[Utterance]: utterances: list[Utterance] = [] for seg in ssml.parse(text): normalized = self.normalizer.normalize(seg.text) for paragraph in re.split(r"\n+", normalized): paragraph = paragraph.strip() if not paragraph: continue sentences = [s.strip() for s in _SENTENCE_RE.findall(paragraph) if s.strip()] for k, sentence in enumerate(sentences): utt = self._utterance(sentence, seg, last_in_paragraph=k == len(sentences) - 1) if utt.leading_pause_ms and utterances: utterances[-1].words[-1].pause_ms += utt.leading_pause_ms if utt.words: utterances.append(utt) return utterances
def tokens(self, text: str) -> list[list[str]]: return [u.tokens() for u in self.process(text)]
# ------------------------------------------------------------------ internals
def _utterance(self, sentence: str, seg: ssml.Segment, last_in_paragraph: bool) -> Utterance: sentence = re.sub(r"\d+", lambda m: " " + N.digits(m.group()) + " ", sentence) # safety net raw_tokens = _TOKEN_RE.findall(sentence) words: list[Word] = [] leading_pause = 0 for tok in raw_tokens: if tok in _BOUNDARY_LEVEL: if words: words[-1].boundary = max(words[-1].boundary, _BOUNDARY_LEVEL[tok]) continue m = ssml.PAUSE_RE.fullmatch(tok) if m: if words: words[-1].pause_ms += ssml.decode(m.group(1)) words[-1].boundary = max(words[-1].boundary, 2) else: leading_pause += ssml.decode(m.group(1)) continue word = tok.lower() override = seg.phonemes.get(tok) or self.user_lexicon.get(word) ph = self._lexical(word, override) if not ph: continue words.append(Word(word, ph, fixed=bool(override) and override.strip().startswith("/"))) if not words: return Utterance(sentence, [], leading_pause_ms=leading_pause) last_punct = sentence.rstrip()[-1:] if sentence.rstrip() else "." words[-1].boundary = 4 if last_in_paragraph else max(words[-1].boundary, 3) self._stress_and_sandhi(words) text = ssml.PAUSE_RE.sub("", sentence) for marker, original in seg.originals.items(): # <phoneme> placeholders go back to the written word text = text.replace(marker, original) return Utterance( text=text.strip(), words=words, sentence_type=self._sentence_type([w.text for w in words], last_punct), rate=seg.rate, pitch_st=seg.pitch_st, leading_pause_ms=leading_pause, )
def _lexical(self, word: str, ssml_override: str | None) -> list[str]: override = ssml_override or self.user_lexicon.get(word) if override: override = override.strip() if override.startswith("/") and override.endswith("/"): ph = override.strip("/").replace(":", "ː").split() # ASCII length mark, as in "/p e ʒ o:/" unknown = [p for p in ph if p not in SYMBOL_TO_ID] if unknown: raise ValueError(f"unknown phonemes {unknown} in override {override!r} for {word!r}") return ph return list(g2p_word(override.lower())) return list(g2p_word(word))
@staticmethod def _sentence_type(words: list[str], punct: str) -> str: if punct == "?": lead = list(words[:3]) while lead and lead[0] in _QUESTION_LEAD: lead.pop(0) return "<wh>" if lead and lead[0] in _WH_WORDS else "<q>" if punct == "!": return "<e>" return "<s>"
@staticmethod def _stress_and_sandhi(words: list[Word]) -> None: lexical = [list(w.phonemes) for w in words] for i, w in enumerate(words): nxt = None if i + 1 < len(words) and w.boundary == 0 and lexical[i + 1]: nxt = lexical[i + 1][0] w.phonemes = lexical[i] if w.fixed else apply_sandhi(lexical[i], nxt)
# Phonological words: a proclitic joins the next word, an enclitic the previous one. pending_start: int | None = None for i, w in enumerate(words): is_last = i == len(words) - 1 if w.text in CONJUNCTIONS: # weak word: no stress of its own, the next word keeps its stress continue if w.text in PROCLITICS and w.boundary == 0 and not is_last: if pending_start is None: pending_start = i continue enclitic = w.text in ENCLITICS and i > 0 and words[i - 1].boundary == 0 if enclitic and pending_start is None: continue start = i if pending_start is None else pending_start if any(p in VOWEL_LIKE for p in w.phonemes) or start != i: words[start].stressed = True pending_start = None
__all__ = ["Frontend", "Utterance", "Word", "SENTENCE_TYPES", "SYMBOL_TO_ID"]123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152"""SSML-lite: a small, forgiving subset of SSML.
Supported: ``<speak>``, ``<break time="500ms"|strength="...">``, ``<sub alias="...">``,``<say-as interpret-as="characters|digits|cardinal|ordinal|telephone|date">``,``<phoneme ph="respelling or /ph o n/">`` and ``<prosody rate="..." pitch="...">``.
The parser is regex based on purpose: input that is not SSML (a stray ``<``) must never fail.Pauses and phoneme overrides travel through normalization as letter-only markers``⟦...⟧`` (digits are encoded as letters a-j so the normalizer leaves them alone)."""
from __future__ import annotations
import mathimport refrom dataclasses import dataclass, field
from . import numbers as Nfrom .lexicon import LETTER_NAMES
_DIGIT_LETTERS = "abcdefghij"PAUSE_RE = re.compile(r"⟦p([a-j]+)⟧")PHONEME_RE = re.compile(r"⟦x([a-j]+)⟧")
_STRENGTH_MS = {"none": 0, "x-weak": 100, "weak": 200, "medium": 400, "strong": 700, "x-strong": 1000}_RATE_WORDS = {"x-slow": 0.6, "slow": 0.8, "medium": 1.0, "fast": 1.25, "x-fast": 1.5}
_TAG_HINT = re.compile(r"</?(speak|break|sub|say-as|phoneme|prosody|emphasis|emotion|voice|lang|audio|mark|p|s|" r"nonverbal|whisper)\b[^<>]*>", re.I)# any element left after the supported ones are replaced (unknown, nested or not yet implemented): never read aloud_ANY_TAG = re.compile(r"</?[A-Za-z][\w:-]*(?:\s[^<>]*)?/?>")_SPEAK = re.compile(r"</?speak[^>]*>", re.I)_BREAK = re.compile(r"<break\b([^>]*?)/?>", re.I)_SUB = re.compile(r'<sub\s+alias="([^"]*)"\s*>(.*?)</sub>', re.I | re.S)_SAYAS = re.compile(r'<say-as\s+interpret-as="([^"]+)"[^>]*>(.*?)</say-as>', re.I | re.S)_PHONEME = re.compile(r'<phoneme\s+ph="([^"]*)"\s*>(.*?)</phoneme>', re.I | re.S)_PROSODY = re.compile(r"<prosody\b([^>]*)>(.*?)</prosody>", re.I | re.S)_ATTR = re.compile(r'([\w-]+)\s*=\s*"([^"]*)"')
@dataclassclass Segment: text: str rate: float = 1.0 pitch_st: float = 0.0 phonemes: dict[str, str] = field(default_factory=dict) # marker -> ph string originals: dict[str, str] = field(default_factory=dict) # marker -> the word the <phoneme> element wrapped
def _encode(number: int) -> str: return "".join(_DIGIT_LETTERS[int(d)] for d in str(number))
def decode(letters: str) -> int: return int("".join(str(_DIGIT_LETTERS.index(c)) for c in letters))
def _parse_time(attrs: dict[str, str]) -> int: if "time" in attrs: m = re.fullmatch(r"\s*([\d.]+)\s*(ms|s)\s*", attrs["time"]) if m: value = float(m.group(1)) return int(value if m.group(2) == "ms" else value * 1000) return _STRENGTH_MS.get(attrs.get("strength", "medium"), 400)
def _parse_rate(value: str) -> float: value = value.strip().lower() if value in _RATE_WORDS: return _RATE_WORDS[value] m = re.fullmatch(r"([+-]?)(\d+(?:\.\d+)?)%", value) if m: pct = float(m.group(2)) if m.group(1) == "+": return 1 + pct / 100 if m.group(1) == "-": return max(0.2, 1 - pct / 100) return pct / 100 return 1.0
def _parse_pitch(value: str) -> float: value = value.strip().lower() m = re.fullmatch(r"([+-]?\d+(?:\.\d+)?)st", value) if m: return float(m.group(1)) m = re.fullmatch(r"([+-])(\d+(?:\.\d+)?)%", value) if m: factor = 1 + float(m.group(2)) / 100 * (1 if m.group(1) == "+" else -1) return 12 * math.log2(max(factor, 0.1)) return {"x-low": -4.0, "low": -2.0, "medium": 0.0, "high": 2.0, "x-high": 4.0}.get(value, 0.0)
def _say_as(kind: str, content: str) -> str: kind = kind.lower() content = content.strip() digits = re.sub(r"\D", "", content) if kind == "characters": return " ".join( N.digits(ch) if ch.isdigit() else LETTER_NAMES.get(ch.lower(), ch) for ch in content if ch.isalnum() ) if kind == "digits": return N.digits(content) if kind == "cardinal" and digits: return N.cardinal(int(digits)) if kind == "ordinal" and digits: return N.ordinal(int(digits)) if kind == "telephone": return ", ".join(N.digits(g) for g in re.findall(r"\d+", content)) return content
def _inline(text: str, seg: Segment) -> str: """Replace the inline elements of one segment.""" text = _SPEAK.sub(" ", text) text = _SUB.sub(lambda m: m.group(1), text) text = _SAYAS.sub(lambda m: _say_as(m.group(1), m.group(2)), text)
def phoneme(m: re.Match) -> str: marker = f"⟦x{_encode(len(seg.phonemes))}⟧" seg.phonemes[marker] = m.group(1).strip() seg.originals[marker] = m.group(2).strip() return marker
text = _PHONEME.sub(phoneme, text) text = _BREAK.sub(lambda m: f" ⟦p{_encode(_parse_time(dict(_ATTR.findall(m.group(1)))))}⟧ ", text) return _ANY_TAG.sub(" ", text)
def parse(text: str) -> list[Segment]: """Split input into segments with uniform prosody. Plain text yields one segment.""" if not _TAG_HINT.search(text): return [Segment(text)] segments: list[Segment] = [] pos = 0 for m in _PROSODY.finditer(text): before = text[pos:m.start()] if before.strip(): seg = Segment("") seg.text = _inline(before, seg) segments.append(seg) attrs = dict(_ATTR.findall(m.group(1))) seg = Segment("", rate=_parse_rate(attrs.get("rate", "1")), pitch_st=_parse_pitch(attrs.get("pitch", "0st"))) seg.text = _inline(m.group(2), seg) segments.append(seg) pos = m.end() rest = text[pos:] if rest.strip() or not segments: seg = Segment("") seg.text = _inline(rest, seg) segments.append(seg) return segments254 unmodified lines2552562572582592602612622632642652662672682692702712722732742752769 unmodified lines28628728828929029125 unmodified lines3173183193203213223233243255 unmodified lines3313323333343353363373383393403413423433443453463473489 unmodified lines3583593603613623633642 unmodified lines3673683693703713723731 unmodified line3753763773783793803812 unmodified lines3843853863873883893903913923933948 unmodified lines403404405406407408254 unmodified linesNATURAL = {"guidance": 1.5, "length_scale": 1.08, "pause_scale": 4.0}def pause_tokens(symbols: list[str]) -> tuple[int, ...]:"""Ids of the punctuation symbols of a checkpoint's symbol table (what ``pause_scale`` stretches)."""return tuple(i for i, sym in enumerate(symbols) if sym in {",", ".", "!", "?", ";", ":"})def stop_tokens(symbols: list[str]) -> tuple[int, ...]:"""Ids of the sentence ends (``. ! ?``). The audiobooks teach a pause of about a second between sentences, which``pause_scale`` would stretch to 2-3 s: with ``stop_tokens`` given these are left out of ``pause_scale`` andcapped at ``max_stop`` frames instead."""return tuple(i for i, sym in enumerate(symbols) if sym in {".", "!", "?"})# Longest pause after a sentence end, in mel frames (hop 256 at 24 kHz): 42 frames = 0.45 s.MAX_STOP = 42# The same for a model with sampled durations (v2.1, 20k fine-tune): its own pace is close to the audiobook data, a# little fast and with short comma pauses (0.306 s/word, pauses 5.5 % of the speech). Measured on the same bench:# length 1.04 + pauses x2.5 gave the fewest real word errors (2 of 1 260), PESQ 3.81, 0.336 s/word, pauses 7.7 %;9 unmodified lines**overrides}class SkttsV2(nn.Module):def __init__(self, n_vocab: int, n_spks: int, mel_mean: float = 0.0, mel_std: float = 1.0, cfg: dict | None = None):super().__init__()25 unmodified lineselse torch.full((batch,), int(style), device=device))return vec + style_scale * self.style_emb(sid)def forward(self, x, x_lengths, y, y_lengths, spks=None, spk_vec=None, ctx=None):"""(duration loss, prior loss, flow-matching loss, alignment); ``y`` [b, n_feats, t] normalized. ``spk_vec``[b, spk_dim] replaces the voice table (a reference encoder's output); the style of ``spks`` is still added."""spk = self._speaker(spks, spk_vec, x.shape[0], x.device, style=None if spk_vec is None or spks is None else -1)if ctx is not None and self.training and self.cfg["p_ctx_drop"] > 0: # some clips train without contextkeep = torch.rand(x.shape[0], device=x.device) >= self.cfg["p_ctx_drop"]5 unmodified lines# MAS on the Gaussian log-likelihood of every frame under every token's mu (unit variance); fp32 alwaysfrom .mas import maximum_path # training only (numba)with torch.no_grad(), torch.autocast(device_type=y.device.type, enabled=False):mu, yf = mu_x.float(), y.float()ll = (-0.5 * (yf ** 2).sum(-1)[:, None, :] + torch.matmul(mu, yf.transpose(1, 2))- 0.5 * (mu ** 2).sum(-1)[:, :, None] - 0.5 * math.log(2 * math.pi) * self.n_feats)attn = maximum_path(ll, pair).detach() # [b, t_text, t_mel]xm, ym = x_mask.float(), y_mask.float()dur = attn.sum(-1)dur_loss = (((logw - torch.log(dur + 1e-8)) * xm) ** 2).sum() / x_lengths.sum()if self.dur_flow is not None: # beside the regression head, which stays as the deterministic fallbackdur_loss = dur_loss + self.dur_flow.loss(dur, h_x.detach(), x_mask)mu_y = torch.matmul(attn.transpose(1, 2).to(mu_x.dtype), mu_x) # [b, t_mel, n]prior_loss = (0.5 * ((y - mu_y) ** 2 + math.log(2 * math.pi)) * ym[..., None]).sum() / (ym.sum() * self.n_feats)# flow matching: straight path from noise x0 to the mel, time from a logit-normal (more weight mid-path)b = y.shape[0]9 unmodified linescond = cond * keep[:, None, None]pos = pos * keep[:, None, None] if pos is not None else Nonev = self.decoder(xt, cond, t, spk, y_mask, pos)flow_loss = (((v.float() - (y - x0).float()) ** 2) * ym[..., None]).sum() / (ym.sum() * self.n_feats)return dur_loss, prior_loss, flow_loss, attn@torch.inference_mode()2 unmodified linespause_scale: float = 1.0, pause_tokens: tuple[int, ...] = (), t_min: float = 0.0,dur_temperature: float | None = 0.7, stop_tokens: tuple[int, ...] = (),max_stop: float | None = None, style: int | None = None, style_scale: float = 1.0,ctx=None) -> dict:"""``guidance`` 0 = plain conditional sampling; ``sway`` < 0 spends more steps near the noise end;``pause_scale`` stretches the tokens in ``pause_tokens`` (the punctuation ids) on top of ``length_scale``:the model learns short pauses from read audiobooks, a longer pause at commas reads more naturally.1 unmodified linealmost never gives exactly 0, where the first solver step starts. With a ``dur_flow`` head the durations aresampled at ``dur_temperature`` (None = the regression head, as in v2). ``stop_tokens`` (sentence ends) arenot stretched by ``pause_scale`` but capped at ``max_stop`` frames (None = no cap). ``style`` is an index into``STYLES`` (None = the style the voice was recorded in), ``style_scale`` its strength (1 = as trained)."""spk = self._speaker(spks, spk_vec, x.shape[0], x.device, style, style_scale)h_x, _, logw, x_mask = self.encoder(x, x_lengths, spk, ctx)# rounded, not ceiled: ceil adds half a frame to every token on average (~6 % slower speech)2 unmodified lineselse:w = torch.exp(logw) * length_scalestop = torch.isin(x, torch.tensor(stop_tokens, dtype=x.dtype, device=x.device))if pause_scale != 1.0 and pause_tokens:punct = torch.isin(x, torch.tensor(pause_tokens, dtype=x.dtype, device=x.device)) & ~stopw = torch.where(punct, w * pause_scale, w)if max_stop is not None:w = torch.where(stop, w.clamp_max(max_stop), w)dur = (torch.round(w).clamp_min(1) * x_mask).long()cond, pos, y_mask, y_lengths = self.expand(h_x, dur)no_pos = torch.zeros_like(pos) if pos is not None else None8 unmodified linesv = v + guidance * (v - self.decoder(z, torch.zeros_like(cond), t, spk, y_mask, no_pos))z = z + (ts[i + 1] - ts[i]) * vmel = (z * self.mel_std + self.mel_mean) * y_mask[..., None]# the durations and the starting noise come back too: with them the sample can be reproduced (distillation)return {"mel": mel.transpose(1, 2), "mel_lengths": y_lengths, "dur": dur, "noise": noise}254 unmodified lines2552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023039 unmodified lines31331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638725 unmodified lines4134144154164174184194204214224235 unmodified lines4294304314324334344354364374384394404414424434444454464474484494504519 unmodified lines4614624634644654664672 unmodified lines4704714724734744754764774784794804814824831 unmodified line4854864874884894904914924934944954964974984995005015022 unmodified lines5055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435448 unmodified lines553554555556557558559560561562563564565566567568569570571572573574575576577578579254 unmodified linesNATURAL = {"guidance": 1.5, "length_scale": 1.08, "pause_scale": 4.0}SK_BOUNDARY = {"|2": ",", "|3": ".", "|4": "."} # Slovak frontend boundaries as the English punctuation they playdef _punct(sym: str) -> str:"""The punctuation a symbol stands for: itself, or a Slovak boundary of a bilingual table (``sk:|3`` -> ``.``)."""return SK_BOUNDARY.get(sym[3:], "") if sym.startswith("sk:") else symdef pause_tokens(symbols: list[str]) -> tuple[int, ...]:"""Ids of the punctuation symbols of a checkpoint's symbol table (what ``pause_scale`` stretches)."""return tuple(i for i, sym in enumerate(symbols) if _punct(sym) in {",", ".", "!", "?", ";", ":"})def stop_tokens(symbols: list[str]) -> tuple[int, ...]:"""Ids of the sentence ends (``. ! ?``). The audiobooks teach a pause of about a second between sentences, which``pause_scale`` would stretch to 2-3 s: with ``stop_tokens`` given these are left out of ``pause_scale`` andcapped at ``max_stop`` frames instead."""return tuple(i for i, sym in enumerate(symbols) if _punct(sym) in {".", "!", "?"})# Longest pause after a sentence end, in mel frames (hop 256 at 24 kHz): 42 frames = 0.45 s.MAX_STOP = 42VOWEL_CHARS = set("aeiouyæɑɒɔəɛɜɪʊʌøœɐɨʉɯɤ")def vowel_tokens(symbols: list[str]) -> tuple[int, ...]:"""Ids of vowels and syllabic consonants (what ``max_final`` measures and caps)."""def vowel(sym):s = sym.removeprefix("sk:")return not s.startswith(("<", "|")) and (any(c in VOWEL_CHARS for c in s) or "\u0329" in s)return tuple(i for i, sym in enumerate(symbols) if vowel(sym))def lead_tokens(symbols: list[str]) -> tuple[int, ...]:"""Ids that can come before the first phone (<bos>, the Slovak sentence-type markers, stress): their frames aresilenced with ``lead_tokens``. Models trained on clips cut out of running speech (TrePal) draw a 30-50 ms burstthere that listeners and ASR hear as a syllable."""return tuple(i for i, s in enumerate(symbols)if s in ("<bos>", "sk:ˈ", "ˈ") or (s.startswith("sk:<") and s != "sk:<unk>"))# The same for a model with sampled durations (v2.1, 20k fine-tune): its own pace is close to the audiobook data, a# little fast and with short comma pauses (0.306 s/word, pauses 5.5 % of the speech). Measured on the same bench:# length 1.04 + pauses x2.5 gave the fewest real word errors (2 of 1 260), PESQ 3.81, 0.336 s/word, pauses 7.7 %;9 unmodified lines**overrides}# Slovak reading, measured against people reading the same 50 FLEURS sentences: with the English settings the comma# pause was 0.68 s (people: median 0.05 s, 90 % under 0.29 s) and the last vowel of a sentence 1.7x the sentence's# median vowel (people: 1.14x). No extra stretch at commas, commas capped at 0.27 s, the last vowel at 1.25x.SK_DELIVERY = {"pause_scale": 1.0, "max_pause": 18, "max_final": 1.25, "short_scale": 0.85, "long_scale": 1.12,"min_vowel": 6, "min_phone": 3, "max_tail": 8}# Short against long vowels (vowel_len.py, 50 sentences): ours 64 against 75-85 ms, a ratio of 1.17, where Slovak# long vowels run about 1.5-2x the short ones; a short vowel then sounds long ("pravda" heard as "právda").# 0.85 and 1.12 bring the ratio to about 1.55.# Short words after a sentence-type marker came out swallowed: "Kto ty si a prečo ty?" drew k 1, t 2, o 1 frames# (43 ms for the whole word, heard as a sentence read far too fast). Floors: a vowel at least 6 frames (64 ms), any# other phone at least 3 (63 sentences: 6.41 -> 5.68 syllables/s, people ~5; CER 0.63 -> 0.60 %; 4 / 2 gave 6.12).# s / c / z / dz against lili's studio recordings (diag.py, mean log-mel of their frames relative to the frame mean,# bands 0-2, 2-4, 4-6, 6-8, 8-12 kHz): ours had about 1 dB (log-mel) too much above 6 kHz and too little at 2-4 kHz,# a hissing s; š / č / ž already matched. The gain (log-mel units) added to those frames, per band edge in Hz;# a first version without the 4-6 kHz lift fixed the top but left 4-6 kHz 0.8 below lili.SK_S_EQ = ((0, 0.0), (2000, 0.5), (4000, 0.45), (5600, 0.4), (6600, -0.9), (8000, -0.95), (12000, -0.95))def length_tokens(symbols: list[str]) -> tuple[tuple[int, ...], tuple[int, ...]]:"""Ids of the Slovak short vowels and of the long vowels and diphthongs (what short_scale / long_scale scale)."""short = {"a", "e", "i", "o", "u", "æ"}long = {"aː", "eː", "iː", "oː", "uː", "ia", "ie", "iu", "uo"}return (tuple(i for i, s in enumerate(symbols) if s.startswith("sk:") and s[3:] in short),tuple(i for i, s in enumerate(symbols) if s.startswith("sk:") and s[3:] in long))def s_tokens(symbols: list[str]) -> tuple[int, ...]:"""Ids of the Slovak s-like sibilants (s c z dz), the frames ``eq_gain`` reshapes."""return tuple(i for i, s in enumerate(symbols) if s in ("sk:s", "sk:ts", "sk:z", "sk:dz"))def band_gain(points, n_feats: int, fmax: float = 12000.0) -> list[float]:"""A gain per mel band, linearly interpolated over ``points`` ((Hz, gain), ...) at the bands' centre frequencies(a mel scale from 0 to ``fmax``)."""mel = lambda f: 2595.0 * math.log10(1 + f / 700.0) # noqa: E731top = mel(fmax)out = []for k in range(n_feats):hz = 700.0 * (10 ** ((top * (k + 1) / (n_feats + 1)) / 2595.0) - 1)for (f0, g0), (f1, g1) in zip(points, points[1:], strict=False):if f0 <= hz <= f1:out.append(g0 + (g1 - g0) * (hz - f0) / max(f1 - f0, 1e-6))breakelse:out.append(points[-1][1])return outdef phone_tokens(symbols: list[str]) -> tuple[int, ...]:"""Ids of the Slovak phones (no markers, stress, word boundary or punctuation): what ``min_phone`` floors."""return tuple(i for i, s in enumerate(symbols) if s.startswith("sk:") and s not in ("sk:ˈ", "sk:▁", "sk:<unk>")and not s[3:].startswith(("<", "|")))def question_tokens(symbols: list[str]) -> tuple[int, ...]:"""Id of the Slovak yes/no question marker (``final_free_tokens``)."""return tuple(i for i, s in enumerate(symbols) if s == "sk:<q>")def natural_sk(symbols: list[str], cfg: dict | None = None, **overrides) -> dict:"""``natural`` with the Slovak reading settings and the silenced lead-in."""n_feats = (cfg or {}).get("n_feats", 100)return natural(symbols, cfg, **SK_DELIVERY, vowel_tokens=vowel_tokens(symbols), lead_tokens=lead_tokens(symbols),eq_tokens=s_tokens(symbols), eq_gain=band_gain(SK_S_EQ, n_feats) if n_feats == 100 else None,short_tokens=length_tokens(symbols)[0], long_tokens=length_tokens(symbols)[1],phone_tokens=phone_tokens(symbols), tail_tokens=(symbols.index("<eos>"),), **overrides)class SkttsV2(nn.Module):def __init__(self, n_vocab: int, n_spks: int, mel_mean: float = 0.0, mel_std: float = 1.0, cfg: dict | None = None):super().__init__()25 unmodified lineselse torch.full((batch,), int(style), device=device))return vec + style_scale * self.style_emb(sid)def forward(self, x, x_lengths, y, y_lengths, spks=None, spk_vec=None, ctx=None, feat_mask=None):"""(duration loss, prior loss, flow-matching loss, alignment); ``y`` [b, n_feats, t] normalized. ``spk_vec``[b, spk_dim] replaces the voice table (a reference encoder's output); the style of ``spks`` is still added.``feat_mask`` [b, n_feats] (1 = use the band) leaves bands out of the alignment and the losses: the empty topbands of a clip recorded at a lower rate (16 kHz TrePal) would otherwise teach the model to muffle."""spk = self._speaker(spks, spk_vec, x.shape[0], x.device, style=None if spk_vec is None or spks is None else -1)if ctx is not None and self.training and self.cfg["p_ctx_drop"] > 0: # some clips train without contextkeep = torch.rand(x.shape[0], device=x.device) >= self.cfg["p_ctx_drop"]5 unmodified lines# MAS on the Gaussian log-likelihood of every frame under every token's mu (unit variance); fp32 alwaysfrom .mas import maximum_path # training only (numba)fm = None if feat_mask is None else feat_mask.float()[:, None, :] # [b, 1, n]with torch.no_grad(), torch.autocast(device_type=y.device.type, enabled=False):mu, yf = mu_x.float(), y.float()if fm is not None: # a left-out band adds the same constant to every log-likelihood: drop itmu, yf = mu * fm, yf * fmll = (-0.5 * (yf ** 2).sum(-1)[:, None, :] + torch.matmul(mu, yf.transpose(1, 2))- 0.5 * (mu ** 2).sum(-1)[:, :, None] - 0.5 * math.log(2 * math.pi) * self.n_feats)attn = maximum_path(ll, pair).detach() # [b, t_text, t_mel]xm, ym = x_mask.float(), y_mask.float()w = ym[..., None] if fm is None else ym[..., None] * fm # [b, t, 1 or n]: what the mel losses countw_sum = w.sum() * (self.n_feats if fm is None else 1)dur = attn.sum(-1)dur_loss = (((logw - torch.log(dur + 1e-8)) * xm) ** 2).sum() / x_lengths.sum()if self.dur_flow is not None: # beside the regression head, which stays as the deterministic fallbackdur_loss = dur_loss + self.dur_flow.loss(dur, h_x.detach(), x_mask)mu_y = torch.matmul(attn.transpose(1, 2).to(mu_x.dtype), mu_x) # [b, t_mel, n]prior_loss = (0.5 * ((y - mu_y) ** 2 + math.log(2 * math.pi)) * w).sum() / w_sum# flow matching: straight path from noise x0 to the mel, time from a logit-normal (more weight mid-path)b = y.shape[0]9 unmodified linescond = cond * keep[:, None, None]pos = pos * keep[:, None, None] if pos is not None else Nonev = self.decoder(xt, cond, t, spk, y_mask, pos)flow_loss = (((v.float() - (y - x0).float()) ** 2) * w).sum() / w_sumreturn dur_loss, prior_loss, flow_loss, attn@torch.inference_mode()2 unmodified linespause_scale: float = 1.0, pause_tokens: tuple[int, ...] = (), t_min: float = 0.0,dur_temperature: float | None = 0.7, stop_tokens: tuple[int, ...] = (),max_stop: float | None = None, style: int | None = None, style_scale: float = 1.0,ctx=None, max_pause: float | None = None, vowel_tokens: tuple[int, ...] = (),max_final: float | None = None, lead_tokens: tuple[int, ...] = (),eq_tokens: tuple[int, ...] = (), eq_gain: list[float] | None = None,short_tokens: tuple[int, ...] = (), short_scale: float = 1.0,long_tokens: tuple[int, ...] = (), long_scale: float = 1.0,min_vowel: float = 0.0, min_phone: float = 0.0, phone_tokens: tuple[int, ...] = (),final_free_tokens: tuple[int, ...] = (), tail_tokens: tuple[int, ...] = (),max_tail: float | None = None) -> dict:"""``guidance`` 0 = plain conditional sampling; ``sway`` < 0 spends more steps near the noise end;``pause_scale`` stretches the tokens in ``pause_tokens`` (the punctuation ids) on top of ``length_scale``:the model learns short pauses from read audiobooks, a longer pause at commas reads more naturally.1 unmodified linealmost never gives exactly 0, where the first solver step starts. With a ``dur_flow`` head the durations aresampled at ``dur_temperature`` (None = the regression head, as in v2). ``stop_tokens`` (sentence ends) arenot stretched by ``pause_scale`` but capped at ``max_stop`` frames (None = no cap). ``style`` is an index into``STYLES`` (None = the style the voice was recorded in), ``style_scale`` its strength (1 = as trained).``max_pause`` caps the other punctuation (commas) in frames after ``pause_scale``; ``max_final`` caps the lastof the ``vowel_tokens`` before each sentence end at that many times the sentence's median vowel (the drawn-outsentence ending); the frames of a leading run of ``lead_tokens`` come out as silence; the frames of``eq_tokens`` get ``eq_gain`` (one log-mel offset per band) added: a phone-exact equaliser (all off bydefault). ``short_scale`` / ``long_scale`` stretch the ``short_tokens`` / ``long_tokens`` (vowel length isphonemic in Slovak, and the model's contrast came out weak). ``min_vowel`` floors the ``vowel_tokens`` and``min_phone`` the ``phone_tokens`` (frames; 0 = off): short words drawn at one frame per phone are swallowed.An input holding one of ``final_free_tokens`` (the yes/no question marker) keeps its last vowel uncapped by``max_final``: a rising question needs that time for the rise. ``tail_tokens`` (the end of a sentence,<eos>) are capped at ``max_tail`` frames and come out as silence: sk_f3 drew 59 frames there, a 0.6 s faintcreak after every sentence."""spk = self._speaker(spks, spk_vec, x.shape[0], x.device, style, style_scale)h_x, _, logw, x_mask = self.encoder(x, x_lengths, spk, ctx)# rounded, not ceiled: ceil adds half a frame to every token on average (~6 % slower speech)2 unmodified lineselse:w = torch.exp(logw) * length_scalestop = torch.isin(x, torch.tensor(stop_tokens, dtype=x.dtype, device=x.device))for tokens, scale in ((short_tokens, short_scale), (long_tokens, long_scale)):if tokens and scale != 1.0:w = torch.where(torch.isin(x, torch.tensor(tokens, dtype=x.dtype, device=x.device)), w * scale, w)if pause_scale != 1.0 and pause_tokens:punct = torch.isin(x, torch.tensor(pause_tokens, dtype=x.dtype, device=x.device)) & ~stopw = torch.where(punct, w * pause_scale, w)if max_stop is not None:w = torch.where(stop, w.clamp_max(max_stop), w)if max_pause is not None and pause_tokens:punct = torch.isin(x, torch.tensor(pause_tokens, dtype=x.dtype, device=x.device)) & ~stopw = torch.where(punct, w.clamp_max(max_pause), w)if max_final is not None and vowel_tokens:w = w.clone()vow = torch.isin(x, torch.tensor(vowel_tokens, dtype=x.dtype, device=x.device)) & x_mask.bool()free = torch.isin(x, torch.tensor(final_free_tokens, dtype=x.dtype, device=x.device)).any(1) \if final_free_tokens else torch.zeros(x.shape[0], dtype=torch.bool, device=x.device)for b in range(x.shape[0]):if not vow[b].any() or free[b]:continuecap = max_final * w[b][vow[b]].median()last = -1for p in range(int(x_lengths[b])):if vow[b, p]:last = pelif stop[b, p] and last >= 0:w[b, last] = w[b, last].clamp_max(cap)last = -1for tokens, floor in ((phone_tokens, min_phone), (vowel_tokens, min_vowel)):if tokens and floor > 0:w = torch.where(torch.isin(x, torch.tensor(tokens, dtype=x.dtype, device=x.device)),w.clamp_min(floor), w)tail = torch.isin(x, torch.tensor(tail_tokens, dtype=x.dtype, device=x.device)) if tail_tokens else Noneif tail is not None and max_tail is not None:w = torch.where(tail, w.clamp_max(max_tail), w)dur = (torch.round(w).clamp_min(1) * x_mask).long()cond, pos, y_mask, y_lengths = self.expand(h_x, dur)no_pos = torch.zeros_like(pos) if pos is not None else None8 unmodified linesv = v + guidance * (v - self.decoder(z, torch.zeros_like(cond), t, spk, y_mask, no_pos))z = z + (ts[i + 1] - ts[i]) * vmel = (z * self.mel_std + self.mel_mean) * y_mask[..., None]if eq_tokens and eq_gain is not None:hit = torch.isin(x, torch.tensor(eq_tokens, dtype=x.dtype, device=x.device)).long()frame_hit = torch.repeat_interleave(hit[0], dur[0]) if x.shape[0] == 1 else Nonegain = torch.tensor(eq_gain, dtype=mel.dtype, device=mel.device)ramp = torch.ones(1, 1, 5, dtype=mel.dtype, device=mel.device) / 5 # fade the gain in and out over 5 framesfor b in range(x.shape[0]):fh = frame_hit if frame_hit is not None else torch.repeat_interleave(hit[b], dur[b])n = min(len(fh), mel.shape[1])weight = F.conv1d(fh[:n].to(mel.dtype)[None, None], ramp, padding=2)[0, 0]mel[b, :n] += weight[:, None] * gainif lead_tokens:lead = torch.isin(x, torch.tensor(lead_tokens, dtype=x.dtype, device=x.device))for b in range(x.shape[0]):k = int(torch.cumprod(lead[b].long(), 0).sum()) # length of the leading runn = int(dur[b, :k].sum())if n:mel[b, :n] = math.log(1e-5) # the mel floor: silenceif tail is not None:for b in range(x.shape[0]):frame_tail = torch.repeat_interleave(tail[b], dur[b])[:mel.shape[1]]mel[b, frame_tail] = math.log(1e-5)# the durations and the starting noise come back too: with them the sample can be reproduced (distillation)return {"mel": mel.transpose(1, 2), "mel_lengths": y_lengths, "dur": dur, "noise": noise}
12345678910111213141516171819202122232425262728293031323334353637383940414243444546{ "resblock": "1", "num_gpus": 0, "batch_size": 32, "learning_rate": 0.0001, "adam_b1": 0.8, "adam_b2": 0.99, "lr_decay": 0.999, "seed": 1234,
"upsample_rates": [8,8,2,2], "upsample_kernel_sizes": [16,16,4,4], "upsample_initial_channel": 512, "resblock_kernel_sizes": [3,7,11], "resblock_dilation_sizes": [[1,3,5], [1,3,5], [1,3,5]],
"activation": "snakebeta", "snake_logscale": true,
"discriminator": "mrd", "resolutions": [[1024, 120, 600], [2048, 240, 1200], [512, 50, 240]], "mpd_reshapes": [2, 3, 5, 7, 11], "use_spectral_norm": false, "discriminator_channel_mult": 1,
"segment_size": 8192, "num_mels": 100, "num_freq": 1025, "n_fft": 1024, "hop_size": 256, "win_size": 1024,
"sampling_rate": 24000,
"fmin": 0, "fmax": 12000, "fmax_for_loss": null,
"num_workers": 4,
"dist_config": { "dist_backend": "nccl", "dist_url": "tcp://localhost:54321", "world_size": 1 }}123version https://git-lfs.github.com/spec/v1oid sha256:d3e9a51fb19d1866e7a419404d4ebbb0419aabb8d9ce731b1b0830e91f2c4eccsize 56297131123version https://git-lfs.github.com/spec/v1oid sha256:bc26a58b3d18eaa78647aa751415fcadd785c478f74c157b16bd4f002a488065size 56850025123version https://git-lfs.github.com/spec/v1oid sha256:0e559e93410200d265005e489579008ca9d05ece6ed0d4696f921a5bb6b761absize 28880914
123version https://git-lfs.github.com/spec/v1oid sha256:23e15ddbda405258fcd49e08949a032231a80435103a22dceab506fc1657fafdsize 140121963123version https://git-lfs.github.com/spec/v1oid sha256:5340414ca01b34dffa5a985d1a4121bfeb45cd84a0a0f3b28eca6eac7c826a71size 70259571
123version https://git-lfs.github.com/spec/v1oid sha256:9216fed77d19d94395f148c9a4fab3553dd0a90298fe833f38f2dc0d707c8369size 33395601{"absent": ["AH1 B S AE1 N T", "AE1 B S AH0 N T", "V"], "abstract": ["AE0 B S T R AE1 K T", "AE1 B S T R AE2 K T", "V"], "abstracts": ["AE0 B S T R AE1 K T S", "AE1 B S T R AE0 K T S", "V"], "abuse": ["AH0 B Y UW1 Z", "AH0 B Y UW1 S", "V"], "abuses": ["AH0 B Y UW1 Z IH0 Z", "AH0 B Y UW1 S IH0 Z", "V"], "accent": ["AH0 K S EH1 N T", "AE1 K S EH2 N T", "V"], "accents": ["AE1 K S EH0 N T S", "AE1 K S EH0 N T S", "V"], "addict": ["AH0 D IH1 K T", "AE1 D IH2 K T", "V"], "addicts": ["AH0 D IH1 K T S", "AE1 D IH2 K T S", "V"], "advocate": ["AE1 D V AH0 K EY2 T", "AE1 D V AH0 K AH0 T", "V"], "advocates": ["AE1 D V AH0 K EY2 T S", "AE1 D V AH0 K AH0 T S", "V"], "affect": ["AH0 F EH1 K T", "AE1 F EH0 K T", "V"], "affects": ["AH0 F EH1 K T S", "AE1 F EH0 K T S", "V"], "affix": ["AH0 F IH1 K S", "AE1 F IH0 K S", "V"], "affixes": ["AH0 F IH1 K S IH0 Z", "AE1 F IH0 K S IH0 Z", "V"], "agglomerate": ["AH0 G L AA1 M ER0 EY2 T", "AH0 G L AA1 M ER0 AH0 T", "V"], "aggregate": ["AE1 G R AH0 G EY0 T", "AE1 G R AH0 G AH0 T", "V"], "aggregates": ["AE1 G R AH0 G EY2 T S", "AE1 G R AH0 G IH0 T S", "V"], "allies": ["AH0 L AY1 Z", "AE1 L AY0 Z", "V"], "alloy": ["AH0 L OY1", "AE1 L OY2", "V"], "alloys": ["AH0 L OY1 Z", "AE1 L OY2 Z", "V"], "ally": ["AH0 L AY1", "AE1 L AY0", "V"], "alternate": ["AO1 L T ER0 N EY2 T", "AO0 L T ER1 N AH0 T", "V"], "analyses": ["AH0 N AE1 L IH0 S IY2 Z", "AE1 N AH0 L AY0 Z IH2 Z", "V"], "animate": ["AE1 N AH0 M EY2 T", "AE1 N AH0 M AH0 T", "V"], "annex": ["AH0 N EH1 K S", "AE1 N EH2 K S", "V"], "annexes": ["AH0 N EH1 K S IH0 Z", "AE1 N EH2 K S IH0 Z", "V"], "appropriate": ["AH0 P R OW1 P R IY0 EY2 T", "AH0 P R OW1 P R IY0 AH0 T", "V"], "approximate": ["AH0 P R AA1 K S AH0 M EY2 T", "AH0 P R AA1 K S AH0 M AH0 T", "V"], "articulate": ["AA0 R T IH1 K Y AH0 L AH0 T", "AA0 R T IH1 K Y AH0 L EY2 T", "V"], "aspirate": ["AE1 S P ER0 EY2 T", "AE1 S P ER0 AH0 T", "V"], "aspirates": ["AE1 S P ER0 EY2 T S", "AE1 S P ER0 AH0 T S", "V"], "associate": ["AH0 S OW1 S IY0 EY2 T", "AH0 S OW1 S IY0 AH0 T", "V"], "associates": ["AH0 S OW1 S IY0 EY2 T S", "AH0 S OW1 S IY0 AH0 T S", "V"], "attribute": ["AH0 T R IH1 B Y UW2 T", "AE1 T R IH0 B Y UW0 T", "V"], "attributes": ["AH0 T R IH1 B Y UW2 T S", "AE1 T R IH0 B Y UW0 T S", "V"], "baths": ["B AE1 TH S", "B AE1 DH Z", "V"], "blessed": ["B L EH1 S IH0 D", "B L EH1 S T", "V"], "certificate": ["S ER0 T IH1 F IH0 K AH0 T", "S ER0 T IH1 F IH0 K EY2 T", "V"], "certificates": ["S ER0 T IH1 F IH0 K EY2 T S", "S ER0 T IH1 F IH0 K AH0 T S", "V"], "close": ["K L OW1 Z", "K L OW1 S", "V"], "closer": ["K L OW1 Z ER0", "K L OW1 S ER0", "N"], "closes": ["K L OW1 Z IH0 Z", "K L OW1 S IH0 Z", "V"], "collect": ["K AH0 L EH1 K T", "K AA1 L EH0 K T", "V"], "collects": ["K AH0 L EH1 K T S", "K AA1 L EH0 K T S", "V"], "combat": ["K AH0 M B AE1 T", "K AA1 M B AE0 T", "V"], "combats": ["K AH0 M B AE1 T S", "K AH1 M B AE0 T S", "V"], "combine": ["K AH0 M B AY1 N", "K AA1 M B AY0 N", "V"], "commune": ["K AH0 M Y UW1 N", "K AA1 M Y UW0 N", "V"], "communes": ["K AH0 M Y UW1 N Z", "K AA1 M Y UW0 N Z", "V"], "compact": ["K AH0 M P AE1 K T", "K AA1 M P AE0 K T", "V"], "compacts": ["K AH0 M P AE1 K T S", "K AA1 M P AE0 K T S", "V"], "complex": ["K AH0 M P L EH1 K S", "K AA1 M P L EH0 K S", "ADJ"], "compliment": ["K AA1 M P L AH0 M EH0 N T", "K AA1 M P L AH0 M AH0 N T", "V"], "compliments": ["K AA1 M P L AH0 M EH0 N T S", "K AA1 M P L AH0 M AH0 N T S", "V"], "compound": ["K AH0 M P AW1 N D", "K AA1 M P AW0 N D", "V"], "compounds": ["K AH0 M P AW1 N D Z", "K AA1 M P AW0 N D Z", "V"], "compress": ["K AH0 M P R EH1 S", "K AA1 M P R EH0 S", "V"], "compresses": ["K AH0 M P R EH1 S IH0 Z", "K AA1 M P R EH0 S AH0 Z", "V"], "concert": ["K AH0 N S ER1 T", "K AA1 N S ER0 T", "V"], "concerts": ["K AH0 N S ER1 T S", "K AA1 N S ER0 T S", "V"], "conduct": ["K AA0 N D AH1 K T", "K AA1 N D AH0 K T", "V"], "confederate": ["K AH0 N F EH1 D ER0 EY2 T", "K AH0 N F EH1 D ER0 AH0 T", "V"], "confederates": ["K AH0 N F EH1 D ER0 EY2 T S", "K AH0 N F EH1 D ER0 AH0 T S", "V"], "confines": ["K AH0 N F AY1 N Z", "K AA1 N F AY2 N Z", "V"], "conflict": ["K AH0 N F L IH1 K T", "K AA1 N F L IH0 K T", "V"], "conflicts": ["K AH0 N F L IH1 K T S", "K AA1 N F L IH0 K T S", "V"], "conglomerate": ["K AH0 N G L AA1 M ER0 EY2 T", "K AH0 N G L AA1 M ER0 AH0 T", "V"], "conglomerates": ["K AH0 N G L AA1 M ER0 EY2 T S", "K AH0 N G L AA1 M ER0 AH0 T S", "V"], "conscript": ["K AH0 N S K R IH1 P T", "K AA1 N S K R IH0 P T", "V"], "conscripts": ["K AH0 N S K R IH1 P T S", "K AA1 N S K R IH0 P T S", "V"], "console": ["K AH0 N S OW1 L", "K AA1 N S OW0 L", "V"], "consoles": ["K AH0 N S OW1 L Z", "K AA1 N S OW0 L Z", "V"], "consort": ["K AH0 N S AO1 R T", "K AA1 N S AO0 R T", "V"], "construct": ["K AH0 N S T R AH1 K T", "K AA1 N S T R AH0 K T", "V"], "constructs": ["K AH0 N S T R AH1 K T S", "K AA1 N S T R AH0 K T S", "V"], "consummate": ["K AA1 N S AH0 M EY2 T", "K AA0 N S AH1 M AH0 T", "V"], "content": ["K AA1 N T EH0 N T", "K AH0 N T EH1 N T", "N"], "contents": ["K AH0 N T EH1 N T S", "K AA1 N T EH0 N T S", "V"], "contest": ["K AH0 N T EH1 S T", "K AA1 N T EH0 S T", "V"], "contests": ["K AH0 N T EH1 S T S", "K AA1 N T EH0 S T S", "V"], "contract": ["K AH0 N T R AE1 K T", "K AA1 N T R AE2 K T", "V"], "contracts": ["K AH0 N T R AE1 K T S", "K AA1 N T R AE2 K T S", "V"], "contrast": ["K AH0 N T R AE1 S T", "K AA1 N T R AE0 S T", "V"], "contrasts": ["K AH0 N T R AE1 S T S", "K AA1 N T R AE0 S T S", "V"], "converse": ["K AH0 N V ER1 S", "K AA1 N V ER0 S", "V"], "convert": ["K AH0 N V ER1 T", "K AA1 N V ER0 T", "V"], "converts": ["K AH0 N V ER1 T S", "K AA1 N V ER0 T S", "V"], "convict": ["K AH0 N V IH1 K T", "K AA1 N V IH0 K T", "V"], "convicts": ["K AH0 N V IH1 K T S", "K AA1 N V IH0 K T S", "V"], "coordinate": ["K OW0 AO1 R D AH0 N EY2 T", "K OW0 AO1 R D AH0 N AH0 T", "V"], "coordinates": ["K OW0 AO1 R D AH0 N EY2 T S", "K OW0 AO1 R D AH0 N AH0 T S", "V"], "counterbalance": ["K AW1 N T ER0 B AE2 L AH0 N S", "K AW2 N T ER0 B AE1 L AH0 N S", "V"], "counterbalances": ["K AW2 N T ER0 B AE1 L AH0 N S IH0 Z", "K AW1 N T ER0 B AE2 L AH0 N S IH0 Z", "V"], "crabbed": ["K R AE1 B D", "K R AE1 B IH0 D", "V"], "crooked": ["K R UH1 K T", "K R UH1 K AH0 D", "V"], "curate": ["K Y UH0 R AH1 T", "K Y UH1 R AH0 T", "V"], "cursed": ["K ER1 S T", "K ER1 S IH0 D", "V"], "decoy": ["D IY0 K OY1", "D IY1 K OY0", "V"], "decoys": ["D IY0 K OY1 Z", "D IY1 K OY0 Z", "V"], "decrease": ["D IH0 K R IY1 S", "D IY1 K R IY2 S", "V"], "decreases": ["D IH0 K R IY1 S IH0 Z", "D IY1 K R IY2 S IH0 Z", "V"], "defect": ["D IH0 F EH1 K T", "D IY1 F EH0 K T", "V"], "defects": ["D IH0 F EH1 K T S", "D IY1 F EH0 K T S", "V"], "degenerate": ["D IH0 JH EH1 N ER0 EY2 T", "D IH0 JH EH1 N ER0 AH0 T", "V"], "degenerates": ["D IH0 JH EH1 N ER0 EY2 T S", "D IH0 JH EH1 N ER0 AH0 T S", "V"], "delegate": ["D EH1 L AH0 G EY2 T", "D EH1 L AH0 G AH0 T", "V"], "delegates": ["D EH1 L AH0 G EY2 T S", "D EH1 L AH0 G AH0 T S", "V"], "deliberate": ["D IH0 L IH1 B ER0 EY2 T", "D IH0 L IH1 B ER0 AH0 T", "V"], "desert": ["D IH0 Z ER1 T", "D EH1 Z ER0 T", "V"], "deserts": ["D IH0 Z ER1 T S", "D EH1 Z ER0 T S", "V"], "desolate": ["D EH1 S AH0 L EY2 T", "D EH1 S AH0 L AH0 T", "V"], "diagnoses": ["D AY1 AH0 G N OW2 Z IY0 Z", "D AY2 AH0 G N OW1 S IY0 Z", "V"], "dictate": ["D IH0 K T EY1 T", "D IH1 K T EY2 T", "V"], "dictates": ["D IH0 K T EY1 T S", "D IH1 K T EY2 T S", "V"], "diffuse": ["D IH0 F Y UW1 Z", "D IH0 F Y UW1 S", "V"], "digest": ["D AY0 JH EH1 S T", "D AY1 JH EH0 S T", "V"], "digests": ["D AY2 JH EH1 S T S", "D AY1 JH EH0 S T S", "V"], "discard": ["D IH0 S K AA1 R D", "D IH1 S K AA0 R D", "V"], "discards": ["D IH0 S K AA1 R D Z", "D IH1 S K AA0 R D Z", "V"], "discharge": ["D IH0 S CH AA1 R JH", "D IH1 S CH AA2 R JH", "V"], "discharges": ["D IH0 S CH AA1 R JH AH0 Z", "D IH1 S CH AA2 R JH AH0 Z", "V"], "discount": ["D IH0 S K AW1 N T", "D IH1 S K AW0 N T", "V"], "discounts": ["D IH0 S K AW1 N T S", "D IH1 S K AW2 N T S", "V"], "discourse": ["D IH0 S K AO1 R S", "D IH1 S K AO0 R S", "V"], "discourses": ["D IH0 S K AO1 R S IH0 Z", "D IH1 S K AO0 R S IH0 Z", "V"], "document": ["D AA1 K Y UW0 M EH0 N T", "D AA1 K Y AH0 M AH0 N T", "V"], "documents": ["D AA1 K Y UW0 M EH0 N T S", "D AA1 K Y AH0 M AH0 N T S", "V"], "dogged": ["D AO1 G IH0 D", "D AO1 G D", "V"], "duplicate": ["D UW1 P L AH0 K EY2 T", "D UW1 P L AH0 K AH0 T", "V"], "duplicates": ["D UW1 P L AH0 K EY2 T S", "D UW1 P L AH0 K AH0 T S", "V"], "ejaculate": ["IH0 JH AE1 K Y UW0 L EY2 T", "IH0 JH AE1 K Y UW0 L AH0 T", "V"], "ejaculates": ["IH0 JH AE1 K Y UW0 L EY2 T S", "IH0 JH AE1 K Y UW0 L AH0 T S", "V"], "elaborate": ["IH0 L AE1 B ER0 EY2 T", "IH0 L AE1 B R AH0 T", "V"], "entrance": ["IH0 N T R AH1 N S", "EH1 N T R AH0 N S", "V"], "entrances": ["IH0 N T R AH1 N S AH0 Z", "EH1 N T R AH0 N S AH0 Z", "V"], "envelope": ["IH0 N V EH1 L AH0 P", "EH1 N V AH0 L OW2 P", "V"], "envelopes": ["IH0 N V EH1 L AH0 P S", "EH1 N V AH0 L OW2 P S", "V"], "escort": ["EH0 S K AO1 R T", "EH1 S K AO0 R T", "V"], "escorts": ["EH0 S K AO1 R T S", "EH1 S K AO0 R T S", "V"], "essay": ["EH0 S EY1", "EH1 S EY2", "V"], "essays": ["EH0 S EY1 Z", "EH1 S EY2 Z", "V"], "estimate": ["EH1 S T AH0 M EY2 T", "EH1 S T AH0 M AH0 T", "V"], "estimates": ["EH1 S T AH0 M EY2 T S", "EH1 S T AH0 M AH0 T S", "V"], "excess": ["IH0 K S EH1 S", "EH1 K S EH2 S", "V"], "excise": ["EH0 K S AY1 S", "EH1 K S AY0 Z", "V"], "excuse": ["IH0 K S K Y UW1 Z", "IH0 K S K Y UW1 S", "V"], "excuses": ["IH0 K S K Y UW1 Z IH0 Z", "IH0 K S K Y UW1 S IH0 Z", "V"], "expatriate": ["EH0 K S P EY1 T R IY0 EY2 T", "EH0 K S P EY1 T R IY0 AH0 T", "V"], "expatriates": ["EH0 K S P EY1 T R IY0 EY2 T S", "EH0 K S P EY1 T R IY0 AH0 T S", "V"], "exploit": ["EH1 K S P L OY2 T", "EH2 K S P L OY1 T", "V"], "exploits": ["EH1 K S P L OY2 T S", "EH2 K S P L OY1 T S", "V"], "export": ["IH0 K S P AO1 R T", "EH1 K S P AO0 R T", "V"], "exports": ["IH0 K S P AO1 R T S", "EH1 K S P AO0 R T S", "V"], "extract": ["IH0 K S T R AE1 K T", "EH1 K S T R AE2 K T", "V"], "extracts": ["IH0 K S T R AE1 K T S", "EH1 K S T R AE2 K T S", "V"], "ferment": ["F ER0 M EH1 N T", "F ER1 M EH0 N T", "V"], "ferments": ["F ER0 M EH1 N T S", "F ER1 M EH0 N T S", "V"], "fragment": ["F R AE1 G M AH0 N T", "F R AE0 G M EH1 N T", "V"], "fragments": ["F R AE0 G M EH1 N T S", "F R AE1 G M AH0 N T S", "V"], "frequent": ["F R IY1 K W EH2 N T", "F R IY1 K W AH0 N T", "V"], "graduate": ["G R AE1 JH AH0 W EY2 T", "G R AE1 JH AH0 W AH0 T", "V"], "graduates": ["G R AE1 JH AH0 W EY2 T S", "G R AE1 JH AH0 W AH0 T S", "V"], "house": ["HH AW1 Z", "HH AW1 S", "V"], "impact": ["IH2 M P AE1 K T", "IH1 M P AE0 K T", "V"], "impacts": ["IH2 M P AE1 K T S", "IH1 M P AE0 K T S", "V"], "implant": ["IH2 M P L AE1 N T", "IH1 M P L AE2 N T", "V"], "implants": ["IH2 M P L AE1 N T S", "IH1 M P L AE2 N T S", "V"], "implement": ["IH1 M P L AH0 M EH0 N T", "IH1 M P L AH0 M AH0 N T", "V"], "implements": ["IH1 M P L AH0 M EH0 N T S", "IH1 M P L AH0 M AH0 N T S", "V"], "import": ["IH2 M P AO1 R T", "IH1 M P AO2 R T", "V"], "imports": ["IH2 M P AO1 R T S", "IH1 M P AO2 R T S", "V"], "impress": ["IH0 M P R EH1 S", "IH1 M P R EH0 S", "V"], "imprint": ["IH1 M P R IH0 N T", "IH2 M P R IH1 N T", "V"], "imprints": ["IH2 M P R IH1 N T S", "IH1 M P R IH0 N T S", "V"], "incense": ["IH2 N S EH1 N S", "IH1 N S EH2 N S", "V"], "incline": ["IH2 N K L AY1 N", "IH1 N K L AY0 N", "V"], "inclines": ["IH2 N K L AY1 N Z", "IH1 N K L AY0 N Z", "V"], "incorporate": ["IH2 N K AO1 R P ER0 EY2 T", "IH2 N K AO1 R P ER0 AH0 T", "V"], "increase": ["IH2 N K R IY1 S", "IH1 N K R IY2 S", "V"], "increases": ["IH2 N K R IY1 S IH0 Z", "IH1 N K R IY2 S IH0 Z", "V"], "indent": ["IH2 N D EH1 N T", "IH1 N D EH0 N T", "V"], "indents": ["IH2 N D EH1 N T S", "IH1 N D EH0 N T S", "V"], "inebriate": ["IH2 N EH1 B R IY0 EY2 T", "IH2 N EH1 B R IY0 AH0 T", "V"], "inebriates": ["IH2 N EH1 B R IY0 EY2 T S", "IH2 N EH1 B R IY0 AH0 T S", "V"], "initiate": ["IH2 N IH1 SH IY0 EY2 T", "IH2 N IH1 SH IY0 AH0 T", "V"], "initiates": ["IH2 N IH1 SH IY0 EY2 T S", "IH2 N IH1 SH IY0 AH0 T S", "V"], "inlay": ["IH2 N L EY1", "IH1 N L EY2", "V"], "inlays": ["IH2 N L EY1 Z", "IH1 N L EY2 Z", "V"], "insert": ["IH2 N S ER1 T", "IH1 N S ER2 T", "V"], "inserts": ["IH2 N S ER1 T S", "IH1 N S ER2 T S", "V"], "inset": ["IH2 N S EH1 T", "IH1 N S EH2 T", "V"], "insets": ["IH2 N S EH1 T S", "IH1 N S EH2 T S", "V"], "instinct": ["IH2 N S T IH1 NG K T", "IH1 N S T IH0 NG K T", "V"], "insult": ["IH2 N S AH1 L T", "IH1 N S AH2 L T", "V"], "insults": ["IH2 N S AH1 L T S", "IH1 N S AH2 L T S", "V"], "interchange": ["IH2 T ER0 CH EY1 N JH", "IH1 N T ER0 CH EY2 N JH", "V"], "interchanges": ["IH2 T ER0 CH EY1 N JH IH0 Z", "IH1 N T ER0 CH EY2 N JH IH0 Z", "V"], "interdict": ["IH2 N T ER0 D IH1 K T", "IH1 N T ER0 D IH2 K T", "V"], "interdicts": ["IH2 N T ER0 D IH1 K T S", "IH1 N T ER0 D IH2 K T S", "V"], "intern": ["IH0 N T ER1 N", "IH1 N T ER0 N", "V"], "interns": ["IH0 N T ER1 N Z", "IH1 N T ER0 N Z", "V"], "intimate": ["IH1 N T IH0 M EY2 T", "IH1 N T AH0 M AH0 T", "V"], "intimates": ["IH1 N T IH0 M EY2 T S", "IH1 N T AH0 M AH0 T S", "V"], "introvert": ["IH2 N T R AO0 V ER1 T", "IH1 N T R AO0 V ER2 T", "V"], "introverts": ["IH2 N T R AO0 V ER1 T S", "IH1 N T R AO0 V ER2 T S", "V"], "inverse": ["IH1 N V ER0 S", "IH2 N V ER1 S", "V"], "invite": ["IH2 N V AY1 T", "IH1 N V AY0 T", "V"], "invites": ["IH2 N V AY1 T S", "IH1 N V AY0 T S", "V"], "jagged": ["JH AE1 G D", "JH AE1 G IH0 D", "V"], "learned": ["L ER1 N IH0 D", "L ER1 N D", "V"], "legitimate": ["L AH0 JH IH1 T AH0 M EY2 T", "L AH0 JH IH1 T AH0 M AH0 T", "V"], "mandate": ["M AE1 N D EY2 T", "M AE2 N D EY1 T", "V"], "misconduct": ["M IH2 S K AA1 N D AH0 K T", "M IH2 S K AA0 N D AH1 K T", "V"], "misprint": ["M IH2 S P R IH1 N T", "M IH1 S P R IH0 N T", "V"], "misprints": ["M IH2 S P R IH1 N T S", "M IH1 S P R IH0 N T S", "V"], "misuse": ["M IH0 S Y UW1 S", "M IH0 S Y UW1 Z", "V"], "misuses": ["M IH0 S Y UW1 Z IH0 Z", "M IH0 S Y UW1 S IH0 Z", "V"], "moderate": ["M AA1 D ER0 EY2 T", "M AA1 D ER0 AH0 T", "V"], "moderates": ["M AA1 D ER0 EY2 T S", "M AA1 D ER0 AH0 T S", "V"], "mouth": ["M AW1 TH", "M AW1 DH", "V"], "mouths": ["M AW1 DH Z", "M AW1 TH S", "V"], "object": ["AA1 B JH EH0 K T", "AH0 B JH EH1 K T", "V"], "objects": ["AH0 B JH EH1 K T S", "AA1 B JH EH0 K T S", "V"], "ornament": ["AO1 R N AH0 M EH0 N T", "AO1 R N AH0 M AH0 N T", "V"], "ornaments": ["AO1 R N AH0 M EH0 N T S", "AO1 R N AH0 M AH0 N T S", "V"], "overcharge": ["OW2 V ER0 CH AA1 R JH", "OW1 V ER0 CH AA2 R JH", "V"], "overcharges": ["OW2 V ER0 CH AA1 R JH IH0 Z", "OW1 V ER0 CH AA2 R JH IH0 Z", "V"], "overflow": ["OW2 V ER0 F L OW1", "OW1 V ER0 F L OW2", "V"], "overflows": ["OW2 V ER0 F L OW1 Z", "OW1 V ER0 F L OW2 Z", "V"], "overhang": ["OW2 V ER0 HH AE1 NG", "OW1 V ER0 HH AE2 NG", "V"], "overhangs": ["OW2 V ER0 HH AE1 NG Z", "OW1 V ER0 HH AE2 NG Z", "V"], "overhaul": ["OW2 V ER0 HH AO1 L", "OW1 V ER0 HH AO2 L", "V"], "overhauls": ["OW2 V ER0 HH AO1 L Z", "OW1 V ER0 HH AO2 L Z", "V"], "overlap": ["OW2 V ER0 L AE1 P", "OW1 V ER0 L AE2 P", "V"], "overlaps": ["OW2 V ER0 L AE1 P S", "OW1 V ER0 L AE2 P S", "V"], "overlay": ["OW2 V ER0 L EY1", "OW1 V ER0 L EY2", "V"], "overlays": ["OW2 V ER0 L EY1 Z", "OW1 V ER0 L EY2 Z", "V"], "overwork": ["OW2 V ER0 W ER1 K", "OW1 V ER0 W ER2 K", "V"], "perfect": ["P ER0 F EH1 K T", "P ER1 F IH2 K T", "V"], "perfume": ["P ER0 F Y UW1 M", "P ER1 F Y UW0 M", "V"], "perfumes": ["P ER0 F Y UW1 M Z", "P ER1 F Y UW0 M Z", "V"], "permit": ["P ER0 M IH1 T", "P ER1 M IH2 T", "V"], "permits": ["P ER0 M IH1 T S", "P ER1 M IH2 T S", "V"], "pervert": ["P ER0 V ER1 T", "P ER1 V ER0 T", "V"], "perverts": ["P ER0 V ER1 T S", "P ER1 V ER0 T S", "V"], "pontificate": ["P AA0 N T IH1 F AH0 K AH0 T", "P AA0 N T IH1 F AH0 K EY2 T", "V"], "pontificates": ["P AA0 N T IH1 F AH0 K EY2 T S", "P AA0 N T IH1 F AH0 K AH0 T S", "V"], "precipitate": ["P R IH0 S IH1 P IH0 T AH0 T", "P R IH0 S IH1 P IH0 T EY2 T", "V"], "predicate": ["P R EH1 D IH0 K AH0 T", "P R EH1 D AH0 K EY2 T", "V"], "predicates": ["P R EH1 D AH0 K EY2 T S", "P R EH1 D IH0 K AH0 T S", "V"], "prefix": ["P R IY2 F IH1 K S", "P R IY1 F IH0 K S", "V"], "prefixes": ["P R IY2 F IH1 K S IH0 JH", "P R IY1 F IH0 K S IH0 JH", "V"], "presage": ["P R EH2 S IH1 JH", "P R EH1 S IH0 JH", "V"], "presages": ["P R EH2 S IH1 JH IH0 JH", "P R EH1 S IH0 JH IH0 JH", "V"], "present": ["P R IY0 Z EH1 N T", "P R EH1 Z AH0 N T", "V"], "presents": ["P R IY0 Z EH1 N T S", "P R EH1 Z AH0 N T S", "V"], "proceeds": ["P R AH0 S IY1 D Z", "P R OW1 S IY0 D Z", "V"], "process": ["P R AO2 S EH1 S", "P R AA1 S EH2 S", "V"], "processes": ["P R AA1 S EH0 S AH0 Z", "P R AO2 S EH1 S AH0 Z", "V"], "processing": ["P R AA0 S EH1 S IH0 NG", "P R AA1 S EH0 S IH0 NG", "V"], "produce": ["P R AH0 D UW1 S", "P R OW1 D UW0 S", "V"], "progress": ["P R AH0 G R EH1 S", "P R AA1 G R EH2 S", "V"], "progresses": ["P R OW0 G R EH1 S AH0 Z", "P R AA1 G R EH2 S AH0 Z", "V"], "project": ["P R AA0 JH EH1 K T", "P R AA1 JH EH0 K T", "V"], "projects": ["P R AA0 JH EH1 K T S", "P R AA1 JH EH0 K T S", "V"], "prospect": ["P R AH2 S P EH1 K T", "P R AA1 S P EH0 K T", "V"], "prospects": ["P R AH2 S P EH1 K T S", "P R AA1 S P EH0 K T S", "V"], "prostrate": ["P R AA0 S T R EY1 T", "P R AA1 S T R EY0 T", "V"], "protest": ["P R AH0 T EH1 S T", "P R OW1 T EH2 S T", "V"], "protests": ["P R AH0 T EH1 S T S", "P R OW1 T EH2 S T S", "V"], "purport": ["P ER0 P AO1 R T", "P ER1 P AO2 R T", "V"], "quadruple": ["K W AA1 D R UW0 P AH0 L", "K W AA0 D R UW1 P AH0 L", "V"], "quadruples": ["K W AA0 D R UW1 P AH0 L Z", "K W AA1 D R UW0 P AH0 L Z", "V"], "ragged": ["R AE1 G D", "R AE1 G AH0 D", "V"], "rampage": ["R AE2 M P EY1 JH", "R AE1 M P EY2 JH", "V"], "rampages": ["R AE2 M P EY1 JH IH0 Z", "R AE1 M P EY2 JH IH0 Z", "V"], "read": ["R IY1 D", "R EH1 D", "VBD"], "rebel": ["R EH1 B AH0 L", "R IH0 B EH1 L", "V"], "rebels": ["R IH0 B EH1 L Z", "R EH1 B AH0 L Z", "V"], "rebound": ["R IY0 B AW1 N D", "R IY1 B AW0 N D", "V"], "rebounds": ["R IY0 B AW1 N D Z", "R IY1 B AW0 N D Z", "V"], "recall": ["R IH0 K AO1 L", "R IY1 K AO2 L", "V"], "recalls": ["R IH0 K AO1 L Z", "R IY1 K AO2 L Z", "V"], "recap": ["R IH0 K AE1 P", "R IY1 K AE2 P", "V"], "recapped": ["R IH0 K AE1 P T", "R IY1 K AE2 P T", "V"], "recapping": ["R IH0 K AE1 P IH0 NG", "R IY1 K AE2 P IH0 NG", "V"], "recaps": ["R IH0 K AE1 P S", "R IY1 K AE2 P S", "V"], "recount": ["R IY2 K AW1 N T", "R IH1 K AW0 N T", "V"], "recounts": ["R IY2 K AW1 N T S", "R IH1 K AW0 N T S", "V"], "record": ["R IH0 K AO1 R D", "R EH1 K ER0 D", "V"], "records": ["R IH0 K AO1 R D Z", "R EH1 K ER0 D Z", "V"], "refill": ["R IY0 F IH1 L", "R IY1 F IH0 L", "V"], "refills": ["R IY0 F IH1 L Z", "R IY1 F IH0 L Z", "V"], "refit": ["R IY0 F IH1 T", "R IY1 F IH0 T", "V"], "refits": ["R IY0 F IH1 T S", "R IY1 F IH0 T S", "V"], "refresh": ["R IH0 F R EH1 SH", "R IH1 F R EH0 SH", "V"], "refund": ["R IH0 F AH1 N D", "R IY1 F AH2 N D", "V"], "refunds": ["R IH0 F AH1 N D Z", "R IY1 F AH2 N D Z", "V"], "refuse": ["R IH0 F Y UW1 Z", "R EH1 F Y UW2 Z", "V"], "regenerate": ["R IY0 JH EH1 N ER0 EY2 T", "R IY0 JH EH1 N ER0 AH0 T", "V"], "rehash": ["R IY0 HH AE1 SH", "R IY1 HH AE0 SH", "V"], "rehashes": ["R IY0 HH AE1 SH IH0 Z", "R IY1 HH AE0 SH IH0 Z", "V"], "reincarnate": ["R IY2 IH0 N K AA1 R N EY2 T", "R IY2 IH0 N K AA1 R N AH0 T", "V"], "reject": ["R IH0 JH EH1 K T", "R IY1 JH EH0 K T", "V"], "rejects": ["R IH0 JH EH1 K T S", "R IY1 JH EH0 K T S", "V"], "relay": ["R IY2 L EY1", "R IY1 L EY2", "V"], "relaying": ["R IY2 L EY1 IH0 NG", "R IY1 L EY2 IH0 NG", "V"], "relays": ["R IY2 L EY1 Z", "R IY1 L EY2 Z", "V"], "remake": ["R IY2 M EY1 K", "R IY1 M EY0 K", "V"], "remakes": ["R IY2 M EY1 K S", "R IY1 M EY0 K S", "V"], "replay": ["R IY0 P L EY1", "R IY1 P L EY0", "V"], "replays": ["R IY0 P L EY1 Z", "R IY1 P L EY0 Z", "V"], "reprint": ["R IY0 P R IH1 N T", "R IY1 P R IH0 N T", "V"], "reprints": ["R IY0 P R IH1 N T S", "R IY1 P R IH0 N T S", "V"], "rerun": ["R IY2 R AH1 N", "R IY1 R AH0 N", "V"], "reruns": ["R IY2 R AH1 N Z", "R IY1 R AH0 N Z", "V"], "resume": ["R IY0 Z UW1 M", "R EH1 Z AH0 M EY2", "V"], "retake": ["R IY0 T EY1 K", "R IY1 T EY0 K", "V"], "retakes": ["R IY0 T EY1 K S", "R IY1 T EY0 K S", "V"], "rethink": ["R IY2 TH IH1 NG K", "R IY1 TH IH0 NG K", "V"], "rethinks": ["R IY2 TH IH1 NG K S", "R IY1 TH IH0 NG K S", "V"], "retread": ["R IY2 T R EH1 D", "R IY1 T R EH0 D", "V"], "retreads": ["R IY2 T R EH1 D Z", "R IY1 T R EH0 D Z", "V"], "rewrite": ["R IY0 R AY1 T", "R IY1 R AY2 T", "V"], "rewrites": ["R IY0 R AY1 T S", "R IY1 R AY2 T S", "V"], "segment": ["S EH1 G M AH0 N T", "S EH2 G M EH1 N T", "V"], "segments": ["S EH2 G M EH1 N T S", "S EH1 G M AH0 N T S", "V"], "separate": ["S EH1 P ER0 EY2 T", "S EH1 P ER0 IH0 T", "V"], "separates": ["S EH1 P ER0 EY2 T S", "S EH1 P ER0 IH0 T S", "V"], "subcontract": ["S AH0 B K AA1 N T R AE2 K T", "S AH2 B K AA0 N T R AE1 K T", "V"], "subcontracts": ["S AH2 B K AA0 N T R AE1 K T S", "S AH0 B K AA1 N T R AE2 K T S", "V"], "subject": ["S AH0 B JH EH1 K T", "S AH1 B JH IH0 K T", "V"], "subjects": ["S AH0 B JH EH1 K T S", "S AH1 B JH IH0 K T S", "V"], "subordinate": ["S AH0 B AO1 R D AH0 N EY2 T", "S AH0 B AO1 R D AH0 N AH0 T", "V"], "subordinates": ["S AH0 B AO1 R D AH0 N EY2 T S", "S AH0 B AO1 R D AH0 N AH0 T S", "V"], "supplement": ["S AH1 P L AH0 M EH0 N T", "S AH1 P L AH0 M AH0 N T", "V"], "supplements": ["S AH1 P L AH0 M EH0 N T S", "S AH1 P L AH0 M AH0 N T S", "V"], "surmise": ["S ER0 M AY1 Z", "S ER1 M AY0 Z", "V"], "surmises": ["S ER0 M AY1 Z IH0 Z", "S ER1 M AY0 Z IH0 Z", "V"], "survey": ["S ER0 V EY1", "S ER1 V EY2", "V"], "surveys": ["S ER0 V EY1 Z", "S ER1 V EY2 Z", "V"], "suspect": ["S AH0 S P EH1 K T", "S AH1 S P EH2 K T", "V"], "suspects": ["S AH0 S P EH1 K T S", "S AH1 S P EH2 K T S", "V"], "syndicate": ["S IH1 N D AH0 K EY2 T", "S IH1 N D IH0 K AH0 T", "V"], "syndicates": ["S IH1 N D IH0 K EY2 T S", "S IH1 N D IH0 K AH0 T S", "V"], "torment": ["T AO1 R M EH2 N T", "T AO0 R M EH1 N T", "V"], "transfer": ["T R AE0 N S F ER1", "T R AE1 N S F ER0", "V"], "transfers": ["T R AE0 N S F ER1 Z", "T R AE1 N S F ER0 Z", "V"], "transplant": ["T R AE0 N S P L AE1 N T", "T R AE1 N S P L AE0 N T", "V"], "transplants": ["T R AE0 N S P L AE1 N T S", "T R AE1 N S P L AE0 N T S", "V"], "transport": ["T R AE0 N S P AO1 R T", "T R AE1 N S P AO0 R T", "V"], "transports": ["T R AE0 N S P AO1 R T S", "T R AE1 N S P AO0 R T S", "V"], "triplicate": ["T R IH1 P L IH0 K EY2 T", "T R IH1 P L IH0 K AH0 T", "V"], "triplicates": ["T R IH1 P L IH0 K EY2 T S", "T R IH1 P L IH0 K AH0 T S", "V"], "undercut": ["AH2 N D ER0 K AH1 T", "AH1 N D ER0 K AH2 T", "V"], "underestimate": ["AH1 N D ER0 EH1 S T AH0 M EY2 T", "AH1 N D ER0 EH1 S T AH0 M AH0 T", "V"], "underestimates": ["AH1 N D ER0 EH1 S T AH0 M EY2 T S", "AH1 N D ER0 EH1 S T AH0 M AH0 T S", "V"], "underline": ["AH2 N D ER0 L AY1 N", "AH1 N D ER0 L AY2 N", "V"], "underlines": ["AH2 N D ER0 L AY1 N Z", "AH1 N D ER0 L AY2 N Z", "V"], "undertaking": ["AH2 N D ER0 T EY1 K IH0 NG", "AH1 N D ER0 T EY2 K IH0 NG", "V"], "undertakings": ["AH2 N D ER0 T EY1 K IH0 NG Z", "AH1 N D ER0 T EY2 K IH0 NG Z", "V"], "unused": ["AH0 N Y UW1 Z D", "AH0 N Y UW1 S T", "V"], "upgrade": ["AH0 P G R EY1 D", "AH1 P G R EY0 D", "V"], "upgrades": ["AH0 P G R EY1 D Z", "AH1 P G R EY0 D Z", "V"], "uplift": ["AH2 P L IH1 F T", "AH1 P L IH0 F T", "V"], "upset": ["AH0 P S EH1 T", "AH1 P S EH2 T", "V"], "upsets": ["AH0 P S EH1 T S", "AH1 P S EH2 T S", "V"], "use": ["Y UW1 Z", "Y UW1 S", "V"], "used": ["Y UW1 Z D", "Y UW1 S T", "VBN"], "uses": ["Y UW1 Z IH0 Z", "Y UW1 S IH0 Z", "V"]}123version https://git-lfs.github.com/spec/v1oid sha256:79c86305b0362baa3d240e170b3d2a1f8dd41ac41785eecf906c073f0fea8332size 26606398123version https://git-lfs.github.com/spec/v1oid sha256:cfdb578c34ac9cf800b6d932fb348ce001ca71043c081580864d5f94eaedc0c6size 13750842
1{"vocoder": "bigvgan", "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": [1.517135739326477, -0.13676996529102325, 0.7104240655899048, -1.0211386680603027, -1.2979412078857422, 0.6969794034957886, 2.629335880279541, -0.5175697803497314, -0.18775086104869843, -0.39136093854904175, 1.000474214553833, 0.6733542680740356, 0.9993650317192078, 1.3729512691497803, 1.3069961071014404, 0.4037739336490631, -2.2330708503723145, 0.9730550050735474, 1.3362807035446167, -0.20327846705913544, -1.0511982440948486, -0.5581808090209961, -0.01984601840376854, -0.54954594373703, -1.0296556949615479, 0.03622017428278923, -0.15091975033283234, 1.2565995454788208, 0.1671142876148224, 0.05559859052300453, 1.020487666130066, -0.04479750618338585, 0.1660420447587967, -0.42305171489715576, -0.7050654888153076, -0.24013154208660126, 0.3935807943344116, -0.7203192114830017, 0.006444160360842943, -1.37712562084198, -1.1258444786071777, 0.8341322541236877, -0.6729311943054199, -0.35056596994400024, -0.14962553977966309, 1.0627118349075317, -0.37647929787635803, -0.1871318817138672, 0.6136325597763062, 0.7054733633995056, -0.9523283839225769, -0.2834770977497101, 1.1726950407028198, -0.41300898790359497, 0.7443657517433167, 0.04685285687446594, -0.4023880958557129, -0.08158937841653824, 0.9583489894866943, 0.4035065174102783, -0.08146708458662033, -0.8704973459243774, -0.43055522441864014, -1.069414734840393, 0.02594902366399765, 1.3954213857650757, 0.703378438949585, 0.8924898505210876, -0.9876169562339783, -1.1677652597427368, 0.6289923787117004, -0.38550713658332825, -0.8375033140182495, 0.19416093826293945, -1.3541477918624878, 0.05713648349046707, 2.5260097980499268, 0.25359073281288147, 1.677894115447998, -0.1115121841430664, 0.0314653255045414, -1.395507574081421, -0.3482338488101959, 2.5413079261779785, -0.9457523822784424, -0.8733658194541931, -0.9595149755477905, 1.130806803703308, 1.150924801826477, -1.7917988300323486, 0.056330084800720215, -0.47718489170074463, 0.48053455352783203, -0.22822995483875275, -1.171648621559143, 0.43271154165267944, 1.4253312349319458, -1.3607594966888428, 0.588348925113678, 0.9813690781593323, -0.0038840738125145435, 0.005481800064444542, 0.21286913752555847, 1.481754183769226, -0.7587358355522156, -0.4735797941684723, 1.222178339958191, -1.5924363136291504, -1.2176563739776611, 1.3699251413345337, -0.44557029008865356, 0.6977190971374512, -0.1381129026412964, -0.4678879678249359, 0.042917799204587936, -0.9870441555976868, 1.1190840005874634, -1.7517114877700806, -0.5673269629478455, -0.7384687662124634, -0.9444963335990906, -0.31767696142196655, 1.7322577238082886, -0.6648698449134827, 0.265015572309494, -0.8357384204864502, -1.2696208953857422, 0.13310927152633667, 0.8608494400978088, 1.180632472038269, -0.6072689890861511, 0.06035879999399185, -0.7713728547096252, 0.5739036798477173, -0.7701807618141174, -0.08896621316671371, -0.12433744221925735, -0.5324658155441284, -0.34517282247543335, -0.2639816403388977, -0.4856407940387726, 1.0118904113769531, 0.8781872987747192, -1.3694580793380737, 0.3828267753124237, -0.0027343255933374166, 0.5059343576431274, -2.276094913482666, 1.0336859226226807, -1.321044683456421, -0.2834933400154114, 1.2114955186843872, -0.8743243217468262, 1.305618405342102, -0.4819450080394745, 1.416811466217041, 1.9176825284957886, -1.2754184007644653, 0.6546903848648071, 1.0437403917312622, -0.6859720945358276, -0.013358453288674355, 1.4868298768997192, 0.11408063769340515, 1.818628191947937, -0.6988835334777832, 0.3417071998119354, -0.6773056983947754, 0.11081106215715408, -0.627101480960846, -1.3162205219268799, 1.554015040397644, -0.3907366991043091, 1.8751202821731567, 0.10351476073265076, 1.0917837619781494, 1.7145531177520752, -0.8930505514144897, -0.41033482551574707, -0.16653971374034882, 0.037117164582014084, 0.18788036704063416, -1.7565058469772339, -0.11627396196126938, 0.3837178647518158, 0.6750530004501343, -0.6893131136894226, -1.1095569133758545, 0.9882324934005737, 0.5243624448776245, 1.0486615896224976, -0.2824309170246124, -2.1622235774993896, 2.1525373458862305, -1.4725050926208496, -1.625070333480835, 0.45594897866249084, -0.7237941026687622, -0.6158376932144165, 1.1711299419403076, -0.008647063747048378, -0.8469019532203674, -0.4603850245475769, 0.8113527297973633, 0.014283635653555393, -1.658649206161499, -2.2638187408447266, -0.5551836490631104, -0.49584564566612244, -0.6184626817703247, 1.249353289604187, 1.202476978302002, 1.8944573402404785, -0.3904252052307129, 0.2895037829875946, 1.645256757736206, 1.34177565574646, -2.0033135414123535, -0.649159848690033, 0.25293058156967163, 2.384093999862671, 0.4729669988155365, 0.6878471970558167, 1.0640108585357666, -0.4980822205543518, -1.2664059400558472, 0.5809507369995117, 0.42656368017196655, -0.7607245445251465, 0.3366648852825165, 0.31306198239326477, -2.0872607231140137, -0.8785051703453064, -0.38986968994140625, 0.37869948148727417, 0.5903581976890564, 0.37086889147758484, -1.1556354761123657, 1.3251758813858032, -0.6774435639381409, -0.6435075998306274, -0.1706003099679947, -0.7104052305221558, 0.8054185509681702, -0.8027863502502441, 0.05043184012174606, 0.6044769287109375, 1.9464150667190552, -0.2921018898487091, -0.1531902551651001, -1.572484016418457, -1.5556130409240723, -0.6137648820877075, 0.4821133017539978, -0.7853714227676392, 1.040672779083252], "en_dt_0": [-1.4915268421173096, -0.8611135482788086, -0.29240676760673523, -0.938353419303894, 0.500876784324646, 0.6051709055900574, -0.0963180661201477, -0.4962393641471863, -0.5205127000808716, 0.6274233460426331, 0.10558360069990158, -0.2794381380081177, -0.7245016694068909, -0.21702173352241516, -0.9810303449630737, 0.3859805166721344, -0.9245855808258057, -0.8246148228645325, -0.5994485020637512, -1.6628482341766357, 0.8775049448013306, 0.4069702923297882, -0.05417443439364433, 0.8088504672050476, 0.12263141572475433, -0.9025903344154358, 0.37246525287628174, -0.16410107910633087, -0.13867148756980896, 2.0808451175689697, -0.630859375, 1.8141423463821411, 2.2471094131469727, -1.0404343605041504, -2.0467183589935303, -0.5562160611152649, 2.1028225421905518, 0.9943655133247375, -1.273667335510254, 0.7854529023170471, 0.09937482327222824, -0.6949840188026428, -0.5022562742233276, -0.60673588514328, -1.8398053646087646, -0.14330826699733734, 0.8824586272239685, 0.044414687901735306, 0.8837533593177795, -1.5617904663085938, -1.942071557044983, 0.10835278779268265, 1.1442499160766602, -1.0513511896133423, 0.6291072368621826, 0.15261363983154297, -0.5777620673179626, 0.5406466722488403, 1.1699684858322144, 1.7359217405319214, 0.7956220507621765, 1.5185530185699463, -0.3318198621273041, 0.2819146513938904, -0.7867832183837891, -1.1655173301696777, 0.18664094805717468, 0.457249253988266, 0.002393862698227167, -0.676572322845459, 1.9469386339187622, 0.6913491487503052, -1.9153556823730469, -1.5781824588775635, 1.4280211925506592, 1.1638315916061401, -0.5364463329315186, -0.40001705288887024, -0.10363087058067322, 0.6083913445472717, -0.11944755166769028, -1.8097096681594849, -1.7570353746414185, 0.5558013319969177, -0.19190052151679993, 0.13222187757492065, -0.9006234407424927, 1.0114623308181763, 0.15243057906627655, 0.26732003688812256, -0.7594209909439087, 0.6770891547203064, -0.5735980868339539, -1.1151323318481445, 1.993723750114441, 0.8227366805076599, -1.0410633087158203, 0.3736626207828522, -1.1389861106872559, -0.6800134181976318, 0.26945993304252625, 0.1934867650270462, -0.5496739745140076, 0.3868688941001892, 1.5582866668701172, -1.0138297080993652, 0.5063135623931885, 1.1294939517974854, -0.9101585149765015, -1.4379106760025024, -0.6620741486549377, -0.3853905498981476, 0.7942690253257751, 1.545246958732605, 0.9642992615699768, -1.555477261543274, 1.324795126914978, -1.4831132888793945, -0.5913090109825134, -0.36076802015304565, 0.028747541829943657, -0.26599982380867004, 0.8875336050987244, -0.1460573673248291, 0.7526191473007202, -0.19691652059555054, -0.6592060327529907, 0.0351443774998188, 1.663083791732788, 1.3846904039382935, 0.698961079120636, 1.4615356922149658, 0.9006299376487732, -0.6642977595329285, 1.527906060218811, -0.23139303922653198, 1.0793983936309814, -1.2894045114517212, 0.315496027469635, -0.5312328934669495, 1.2181681394577026, 0.2317470759153366, -1.52862548828125, -0.5155810713768005, 1.3727256059646606, 0.2524593472480774, 0.9161039590835571, -1.0527902841567993, -0.13921047747135162, -0.27351945638656616, 1.152783989906311, 0.3700161576271057, 2.1814815998077393, -1.1384360790252686, 0.7859686017036438, -0.5316978096961975, -0.5108523368835449, -1.2208080291748047, -0.30102741718292236, -0.06079898774623871, -0.37022560834884644, -0.8930694460868835, -0.4236339032649994, -1.279360294342041, -2.163722515106201, 0.08113119006156921, 0.6167083978652954, -0.1979731023311615, 0.9161040186882019, -1.6986812353134155, 1.4462090730667114, 0.614028811454773, -1.4125185012817383, -0.299731969833374, -0.21911977231502533, -0.61290043592453, -0.21616576611995697, -0.9919126033782959, -1.0622929334640503, -0.37110528349876404, 0.5475912690162659, -0.08509673178195953, 2.549772024154663, -0.7434760928153992, 1.6541942358016968, -1.3889878988265991, 1.1226701736450195, 0.40755680203437805, -0.9493269920349121, -0.6515926122665405, -0.8696969747543335, -0.44002383947372437, -0.6045804619789124, -0.9996944069862366, 0.7861863970756531, -0.5370808243751526, -0.9388073086738586, 0.7984612584114075, 2.2049968242645264, -0.2636611759662628, 0.8254526853561401, -0.15740826725959778, 0.14688245952129364, 1.1003470420837402, -2.10957407951355, 1.6082737445831299, -1.0259146690368652, 1.4259860515594482, 1.8909679651260376, -0.8328949809074402, -0.8699131608009338, -0.9641899466514587, -1.4988280534744263, 1.48003351688385, -0.0859370082616806, 1.285139799118042, -0.054531924426555634, -0.7452571392059326, 1.0337740182876587, -0.9057188034057617, -0.5133793354034424, 0.1656876802444458, 1.2803561687469482, -0.30763283371925354, 0.5633583068847656, -1.171238660812378, 0.21892297267913818, 1.5166352987289429, -0.7768316864967346, -0.16602322459220886, -0.27495741844177246, 0.910499095916748, -0.8369986414909363, -1.362383484840393, 0.20054462552070618, -2.25677490234375, -1.0163202285766602, 0.2873484492301941, -0.7903630137443542, 1.2633681297302246, -0.2309107929468155, 0.019623415544629097, 0.647269070148468, -0.5985904335975647, 1.6638299226760864, -1.3345463275909424, -3.0573570728302, 1.3870387077331543, -0.9744512438774109, 0.047786105424165726, -1.2789344787597656, -1.4868483543395996, 2.2122979164123535, -1.1292518377304077, 0.6647367477416992, -0.20892541110515594], "sk_cori": [1.5267881155014038, -0.16193968057632446, 0.738034725189209, -1.0382388830184937, -1.2920007705688477, 0.6825258135795593, 2.6223208904266357, -0.4929620325565338, -0.1666349321603775, -0.4111168086528778, 1.0081045627593994, 0.6875749230384827, 0.9763250946998596, 1.3686436414718628, 1.3189269304275513, 0.42503416538238525, -2.2162210941314697, 0.9503701329231262, 1.3451189994812012, -0.21353809535503387, -1.0753755569458008, -0.5561211109161377, 0.011770269833505154, -0.5509502291679382, -1.0495353937149048, 0.021203909069299698, -0.1767147183418274, 1.2606898546218872, 0.18747153878211975, 0.03293473646044731, 1.0527586936950684, -0.06435485184192657, 0.1980655938386917, -0.4454558491706848, -0.6842965483665466, -0.24248354136943817, 0.370479017496109, -0.7429649233818054, 0.008429097943007946, -1.3977941274642944, -1.1504662036895752, 0.8375352025032043, -0.6625978946685791, -0.3203868567943573, -0.14487095177173615, 1.0885460376739502, -0.35519739985466003, -0.21411246061325073, 0.5926212668418884, 0.7248903512954712, -0.9635187387466431, -0.26346731185913086, 1.1852078437805176, -0.41188448667526245, 0.7541787624359131, 0.05958639830350876, -0.38869449496269226, -0.07273931801319122, 0.9306450486183167, 0.37531810998916626, -0.07832874357700348, -0.8950357437133789, -0.4168771803379059, -1.0897784233093262, -0.006238230038434267, 1.4001355171203613, 0.7100886106491089, 0.905661940574646, -1.0052516460418701, -1.143939733505249, 0.6281721591949463, -0.40053460001945496, -0.8562412261962891, 0.20251312851905823, -1.338381052017212, 0.045731399208307266, 2.5175507068634033, 0.24969464540481567, 1.6651524305343628, -0.10807860642671585, 0.00730788242071867, -1.4091267585754395, -0.363128125667572, 2.53765869140625, -0.9264343976974487, -0.8493070602416992, -0.9869125485420227, 1.1528667211532593, 1.1757261753082275, -1.7751858234405518, 0.07077935338020325, -0.46113547682762146, 0.4801139533519745, -0.19307684898376465, -1.1538044214248657, 0.4242479205131531, 1.3988271951675415, -1.3878488540649414, 0.5768739581108093, 0.9528168439865112, 0.014663372188806534, 0.009239441715180874, 0.24316368997097015, 1.4640259742736816, -0.7874007821083069, -0.49649500846862793, 1.230190396308899, -1.5773099660873413, -1.2192941904067993, 1.36622953414917, -0.44175153970718384, 0.7017276883125305, -0.15112121403217316, -0.49435946345329285, 0.036409296095371246, -0.9668551683425903, 1.138997197151184, -1.766475796699524, -0.5905604362487793, -0.7224790453910828, -0.9722755551338196, -0.3280336260795593, 1.7219672203063965, -0.6309555768966675, 0.2357492744922638, -0.8138995170593262, -1.2570480108261108, 0.11201683431863785, 0.8713865280151367, 1.1729217767715454, -0.579033613204956, 0.039978839457035065, -0.7779730558395386, 0.5622552037239075, -0.7522538900375366, -0.06721831113100052, -0.12276845425367355, -0.5092595815658569, -0.3237836956977844, -0.28064262866973877, -0.4942340552806854, 0.9945305585861206, 0.8946239352226257, -1.376020073890686, 0.4007215201854706, -0.02945760264992714, 0.5247060060501099, -2.283832311630249, 1.0406492948532104, -1.3282876014709473, -0.28088727593421936, 1.2316584587097168, -0.8671650886535645, 1.2885836362838745, -0.45989614725112915, 1.434160828590393, 1.9277745485305786, -1.2632917165756226, 0.6531884670257568, 1.0171196460723877, -0.6607105731964111, -0.0244034081697464, 1.5050718784332275, 0.13178057968616486, 1.8180382251739502, -0.7226760387420654, 0.3182576894760132, -0.662481963634491, 0.13687919080257416, -0.6054752469062805, -1.3264061212539673, 1.5633125305175781, -0.40638303756713867, 1.8496206998825073, 0.10323810577392578, 1.0629106760025024, 1.6963527202606201, -0.8772003054618835, -0.423870712518692, -0.13437502086162567, 0.041724227368831635, 0.17009417712688446, -1.7389659881591797, -0.09066222608089447, 0.39193201065063477, 0.6931933164596558, -0.7032787203788757, -1.123884916305542, 1.0020668506622314, 0.5308930277824402, 1.0397957563400269, -0.26937079429626465, -2.1368134021759033, 2.179385185241699, -1.4631164073944092, -1.618609070777893, 0.484291672706604, -0.7229553461074829, -0.5860654711723328, 1.1560802459716797, -0.010213845409452915, -0.8423984050750732, -0.44482147693634033, 0.7992594838142395, 0.03493523225188255, -1.679184079170227, -2.269558906555176, -0.563368558883667, -0.5208152532577515, -0.6450950503349304, 1.263863444328308, 1.193926453590393, 1.9126056432724, -0.3647119104862213, 0.2908610999584198, 1.6620187759399414, 1.3376063108444214, -2.0190367698669434, -0.6489274501800537, 0.23517858982086182, 2.37095308303833, 0.47183409333229065, 0.6723036170005798, 1.0796467065811157, -0.4805464446544647, -1.287398099899292, 0.56461101770401, 0.41195693612098694, -0.7650368213653564, 0.34498506784439087, 0.29443660378456116, -2.060828924179077, -0.905872642993927, -0.4067716598510742, 0.4054795205593109, 0.5770789384841919, 0.35872381925582886, -1.147665023803711, 1.3414722681045532, -0.646579384803772, -0.6571804285049438, -0.15667392313480377, -0.6867812871932983, 0.8184535503387451, -0.8119783997535706, 0.060375578701496124, 0.6035537123680115, 1.9661818742752075, -0.3077709972858429, -0.13177187740802765, -1.5728710889816284, -1.5616211891174316, -0.6166055798530579, 0.4931155741214752, -0.8050754070281982, 1.066322684288025], "sk_dailytalk": [-1.497115135192871, -0.8515430688858032, -0.286843478679657, -0.9392603039741516, 0.507318377494812, 0.6057249307632446, -0.09506996721029282, -0.5009286403656006, -0.5242894291877747, 0.6276190280914307, 0.1014157310128212, -0.28665563464164734, -0.7201741933822632, -0.2099367380142212, -0.980206310749054, 0.38196614384651184, -0.9229596853256226, -0.8237161040306091, -0.6017648577690125, -1.6577174663543701, 0.8832183480262756, 0.4042300283908844, -0.05661185830831528, 0.8155841827392578, 0.1292041689157486, -0.9013199806213379, 0.3823152780532837, -0.16755490005016327, -0.14019429683685303, 2.081101179122925, -0.6319764852523804, 1.8114441633224487, 2.2397854328155518, -1.0357097387313843, -2.04473614692688, -0.5590529441833496, 2.10729718208313, 0.9962106943130493, -1.2696532011032104, 0.78243088722229, 0.1009616106748581, -0.694139301776886, -0.5035102367401123, -0.612826406955719, -1.8388605117797852, -0.14689025282859802, 0.8756431937217712, 0.05492790788412094, 0.8876194357872009, -1.5610640048980713, -1.9353474378585815, 0.10419023036956787, 1.1355819702148438, -1.0530041456222534, 0.6231509447097778, 0.14221125841140747, -0.5828790664672852, 0.5389465689659119, 1.1775678396224976, 1.7335563898086548, 0.798380434513092, 1.5246514081954956, -0.33662140369415283, 0.2818365693092346, -0.7942380309104919, -1.1725397109985352, 0.1805514097213745, 0.45432335138320923, 0.005609292071312666, -0.6807626485824585, 1.9496742486953735, 0.6941843032836914, -1.9086095094680786, -1.5833983421325684, 1.4244163036346436, 1.1730539798736572, -0.5357309579849243, -0.390216588973999, -0.10020554065704346, 0.6117500066757202, -0.11483705043792725, -1.8081409931182861, -1.751322627067566, 0.5465855002403259, -0.18988506495952606, 0.12480507791042328, -0.8983331322669983, 1.0085283517837524, 0.15515799820423126, 0.2724815905094147, -0.7632961273193359, 0.6715444922447205, -0.571772038936615, -1.1125162839889526, 1.9842970371246338, 0.8168684840202332, -1.0382282733917236, 0.38466042280197144, -1.134791374206543, -0.6792038679122925, 0.25753054022789, 0.19367514550685883, -0.5553088784217834, 0.39037904143333435, 1.5640008449554443, -1.009770393371582, 0.504917323589325, 1.1374890804290771, -0.9064651727676392, -1.4358917474746704, -0.6540995240211487, -0.3848336935043335, 0.7947736978530884, 1.549910068511963, 0.9653117060661316, -1.557104468345642, 1.3182822465896606, -1.483763337135315, -0.5856635570526123, -0.3571130931377411, 0.038431067019701004, -0.25913769006729126, 0.8936489820480347, -0.1511208415031433, 0.7521827220916748, -0.1998053342103958, -0.658137857913971, 0.038538914173841476, 1.661807656288147, 1.3810535669326782, 0.6924691200256348, 1.4620248079299927, 0.8952803015708923, -0.6582620739936829, 1.5193742513656616, -0.23410186171531677, 1.082659125328064, -1.2922269105911255, 0.3051447570323944, -0.5261521339416504, 1.2166835069656372, 0.23314805328845978, -1.5300873517990112, -0.5188709497451782, 1.3664159774780273, 0.2516978085041046, 0.9139853715896606, -1.0482896566390991, -0.1408076286315918, -0.27421870827674866, 1.1492037773132324, 0.3727300465106964, 2.181033134460449, -1.1302282810211182, 0.785880446434021, -0.5334650874137878, -0.5136998295783997, -1.2191327810287476, -0.3005800247192383, -0.06152642145752907, -0.3753325641155243, -0.8841235637664795, -0.42521655559539795, -1.2815351486206055, -2.163451671600342, 0.08304936438798904, 0.6271904706954956, -0.1934657096862793, 0.9151418805122375, -1.6987841129302979, 1.4468499422073364, 0.6123109459877014, -1.4057008028030396, -0.30132856965065, -0.21170783042907715, -0.6042223572731018, -0.20623770356178284, -0.9963172674179077, -1.0648193359375, -0.36793845891952515, 0.5501977801322937, -0.08196959644556046, 2.5427017211914062, -0.7486370205879211, 1.6456111669540405, -1.3959243297576904, 1.1315855979919434, 0.40462949872016907, -0.9454775452613831, -0.6474595069885254, -0.8676167130470276, -0.4412367045879364, -0.6114221811294556, -1.0037356615066528, 0.7787641286849976, -0.5370262265205383, -0.9397671818733215, 0.7966590523719788, 2.200920820236206, -0.26547688245773315, 0.8222547173500061, -0.16270431876182556, 0.14155858755111694, 1.1036548614501953, -2.1149065494537354, 1.6143070459365845, -1.0242117643356323, 1.4220144748687744, 1.894620656967163, -0.8328860998153687, -0.8743013143539429, -0.9597107172012329, -1.4955143928527832, 1.4754377603530884, -0.08644714951515198, 1.2820321321487427, -0.054013852030038834, -0.7381068468093872, 1.033911943435669, -0.9033114910125732, -0.5111413598060608, 0.169407457113266, 1.278365135192871, -0.3086334764957428, 0.555846095085144, -1.1686967611312866, 0.22460490465164185, 1.5078800916671753, -0.7778195142745972, -0.16646039485931396, -0.2805478274822235, 0.9101107120513916, -0.8336955904960632, -1.3624279499053955, 0.19828349351882935, -2.2544031143188477, -1.0109502077102661, 0.29392415285110474, -0.7861645221710205, 1.2595971822738647, -0.23121975362300873, 0.020062057301402092, 0.6380577087402344, -0.6009706258773804, 1.6614580154418945, -1.3411282300949097, -3.0628230571746826, 1.3877357244491577, -0.968194842338562, 0.04298758506774902, -1.277366042137146, -1.492342233657837, 2.2108893394470215, -1.1313589811325073, 0.6681788563728333, -0.21717801690101624], "sk_muz": [-1.462493658065796, -0.8737621307373047, -0.30913007259368896, -0.93115234375, 0.4836311638355255, 0.6162307858467102, -0.09262450039386749, -0.49449825286865234, -0.5318992733955383, 0.6043444275856018, 0.11077519506216049, -0.2672193646430969, -0.7384926080703735, -0.2100638598203659, -1.0071154832839966, 0.3713463246822357, -0.9347819089889526, -0.8294883966445923, -0.5706435441970825, -1.6813404560089111, 0.8777211904525757, 0.4070274531841278, -0.05985134840011597, 0.8195071220397949, 0.10683491080999374, -0.8884080052375793, 0.35772469639778137, -0.1714228093624115, -0.14810314774513245, 2.0813558101654053, -0.6311343908309937, 1.8230769634246826, 2.2486050128936768, -1.0352137088775635, -2.0262234210968018, -0.5341218709945679, 2.1059865951538086, 0.9722864627838135, -1.2996723651885986, 0.8071727752685547, 0.10486426949501038, -0.6714288592338562, -0.47408920526504517, -0.6032573580741882, -1.832442283630371, -0.1272720992565155, 0.8817400336265564, 0.03691314533352852, 0.88921058177948, -1.5502067804336548, -1.9442399740219116, 0.1083168238401413, 1.1571136713027954, -1.0664663314819336, 0.6390424370765686, 0.16939032077789307, -0.5669420957565308, 0.5543041825294495, 1.1589218378067017, 1.7275421619415283, 0.765699565410614, 1.5173124074935913, -0.32951393723487854, 0.2963661253452301, -0.7528794407844543, -1.1635284423828125, 0.1928499937057495, 0.4459523558616638, 0.016700703650712967, -0.6732876896858215, 1.9416557550430298, 0.6825704574584961, -1.9163802862167358, -1.5380398035049438, 1.4261635541915894, 1.146874189376831, -0.5462904572486877, -0.4264908730983734, -0.09060549736022949, 0.6233058571815491, -0.12583734095096588, -1.7921067476272583, -1.7443972826004028, 0.5489201545715332, -0.17726795375347137, 0.13424304127693176, -0.8892837762832642, 1.0026648044586182, 0.11595557630062103, 0.258331298828125, -0.7433364987373352, 0.708304762840271, -0.578503429889679, -1.0953575372695923, 1.9966390132904053, 0.840283989906311, -1.027251124382019, 0.3617776334285736, -1.1419934034347534, -0.7065234184265137, 0.2784046232700348, 0.21286383271217346, -0.5210413336753845, 0.3708747923374176, 1.5457110404968262, -1.031436800956726, 0.5318974256515503, 1.0972568988800049, -0.9207640886306763, -1.4553862810134888, -0.682905375957489, -0.39655250310897827, 0.807877242565155, 1.543836236000061, 0.9373997449874878, -1.5493348836898804, 1.330244541168213, -1.4981398582458496, -0.5915407538414001, -0.3636372983455658, 0.025977080687880516, -0.2831200659275055, 0.8693307042121887, -0.14211001992225647, 0.7607691884040833, -0.16998815536499023, -0.6405761241912842, 0.04350876435637474, 1.6419557332992554, 1.3970050811767578, 0.6976847052574158, 1.4490998983383179, 0.8912976980209351, -0.6882296204566956, 1.541574239730835, -0.2209342122077942, 1.0745503902435303, -1.2817267179489136, 0.3376842737197876, -0.5504816770553589, 1.226967692375183, 0.23961977660655975, -1.5303764343261719, -0.4889754354953766, 1.3791608810424805, 0.2428409904241562, 0.9015772938728333, -1.0756586790084839, -0.140981987118721, -0.30629271268844604, 1.1400564908981323, 0.3357778489589691, 2.1588494777679443, -1.1364994049072266, 0.7726666927337646, -0.538476824760437, -0.49658167362213135, -1.2439156770706177, -0.28275272250175476, -0.04586252570152283, -0.3668966591358185, -0.900915801525116, -0.4295594096183777, -1.2881120443344116, -2.170703411102295, 0.07353448122739792, 0.5987653732299805, -0.16969707608222961, 0.9146636128425598, -1.7117410898208618, 1.407373309135437, 0.6072284579277039, -1.405730962753296, -0.304138720035553, -0.229450985789299, -0.631237268447876, -0.23265953361988068, -1.0018956661224365, -1.0342769622802734, -0.3764438331127167, 0.5426181554794312, -0.08953604102134705, 2.568425416946411, -0.7454723715782166, 1.6654220819473267, -1.3772084712982178, 1.0923339128494263, 0.4286743104457855, -0.9733759164810181, -0.6568002700805664, -0.8538340926170349, -0.45532333850860596, -0.5897260904312134, -0.9953768849372864, 0.8098354935646057, -0.538453996181488, -0.9411428570747375, 0.7915164828300476, 2.203317642211914, -0.28220173716545105, 0.842307448387146, -0.15258271992206573, 0.1413838416337967, 1.1099193096160889, -2.109008550643921, 1.5968366861343384, -1.0142909288406372, 1.4243906736373901, 1.8837414979934692, -0.809982419013977, -0.8501894474029541, -0.957956850528717, -1.477653980255127, 1.4771214723587036, -0.10967092216014862, 1.2825576066970825, -0.02963194251060486, -0.7432858347892761, 1.0095425844192505, -0.9125780463218689, -0.5377869009971619, 0.14295631647109985, 1.2983219623565674, -0.3277147114276886, 0.5737255215644836, -1.159612774848938, 0.17971394956111908, 1.546060562133789, -0.773106038570404, -0.1864316314458847, -0.24778158962726593, 0.9172183871269226, -0.8298093676567078, -1.3550606966018677, 0.19460226595401764, -2.2420873641967773, -1.02742338180542, 0.2788657546043396, -0.8009849786758423, 1.2710280418395996, -0.2257375419139862, -0.005072885192930698, 0.6559833884239197, -0.6002368330955505, 1.671382188796997, -1.303428053855896, -3.030906915664673, 1.3974692821502686, -0.9657677412033081, 0.0359598770737648, -1.2758774757385254, -1.4741848707199097, 2.202880382537842, -1.1388323307037354, 0.6791577339172363, -0.20421963930130005]}, "styles": ["reading", "conversational"], "style_vectors": [[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [-0.03634423017501831, 0.06649415194988251, -0.06118689849972725, -0.028940552845597267, -0.023855796083807945, -0.021191133186221123, 0.04007142782211304, -0.05220461264252663, -0.08176762610673904, 0.012818305753171444, -0.044452302157878876, -0.05725877359509468, 0.04655009135603905, 0.027588747441768646, -0.04076893627643585, -0.06661313027143478, 0.0397041030228138, 0.03510405123233795, -0.016960857436060905, 0.028350830078125, 0.07313822954893112, -0.059395913034677505, -0.07719741761684418, 0.045182377099990845, 0.07191877067089081, 0.030244005843997, 0.07179022580385208, -0.05788756161928177, -0.019575098529458046, 0.035666171461343765, -0.08065792918205261, -0.009308232925832272, -0.07198897004127502, 0.06770167499780655, 0.0435570664703846, -0.009525989182293415, 0.06173057109117508, 0.03326909989118576, -0.02154822088778019, 0.057211983948946, 0.050268445163965225, 0.06492748856544495, -0.011217587627470493, -0.05718115717172623, -0.046468764543533325, -0.05477771908044815, -0.023377636447548866, 0.07905787229537964, 0.04879434034228325, -0.0035694516263902187, 0.062074966728687286, -0.052609533071517944, -0.06187576428055763, -0.026148375123739243, -0.037471771240234375, -0.06976259499788284, -0.03865585848689079, -0.018538884818553925, 0.05523638427257538, 0.033119022846221924, 0.00023602446890436113, 0.06290540844202042, -0.02696959115564823, 0.06382686644792557, 0.032871197909116745, -0.022695807740092278, -0.036203160881996155, -0.06003277748823166, 0.05398346856236458, -0.04546898230910301, 0.026085883378982544, 0.046841781586408615, 0.07356984913349152, 0.025938892737030983, -0.0554269403219223, 0.07174842804670334, -0.04466740041971207, 0.010747316293418407, 0.049152929335832596, 0.0038447489496320486, 0.02803080901503563, 0.05717505142092705, 0.036907926201820374, -0.05549461022019386, 0.016043921932578087, -0.03667572885751724, 0.06038430705666542, -0.062457773834466934, -0.015206178650259972, 0.04307083785533905, -0.05434846505522728, -0.06281337141990662, -0.025212470442056656, 0.010052621364593506, -0.06605158746242523, 0.026767725124955177, 0.040810953825712204, 0.062009260058403015, 0.023794958367943764, 0.04098672792315483, -0.08305040746927261, -0.011248606257140636, -0.056905169039964676, -0.032156310975551605, 0.05588800460100174, 0.06600131839513779, -0.036810021847486496, -0.00146695866715163, 0.04902678728103638, -0.011050122790038586, 0.05183933675289154, -0.06174659729003906, 0.03095889277756214, 0.05613704398274422, -0.03241848945617676, -0.03678770363330841, -0.060584355145692825, -0.0031173601746559143, 0.021784283220767975, 0.0399567112326622, 0.08351129293441772, 0.04062851518392563, 0.042673852294683456, -0.07154136151075363, 0.05385468527674675, -0.052881065756082535, 0.02711031585931778, 0.0832342803478241, -0.034875523298978806, 0.008992712944746017, -0.07306571304798126, -0.027732955291867256, 0.04062475264072418, 0.007409840822219849, -0.05146653205156326, -0.0570756159722805, 0.022415099665522575, -0.047325607389211655, -0.05461861938238144, 0.04325537383556366, -0.032707612961530685, 0.04410066083073616, -0.03274601325392723, -0.008261600509285927, -0.058934714645147324, 0.03660257160663605, -0.03390805050730705, 0.0630125105381012, -0.02268395945429802, 0.02410741150379181, -0.040389273315668106, -0.018026575446128845, -0.033321358263492584, 0.06978096812963486, -0.05324963480234146, -0.021338531747460365, -0.03241380304098129, -0.03026883490383625, 0.05433507636189461, 0.05795668065547943, -0.07222369313240051, 0.0700155571103096, -0.04508829489350319, -0.07450864464044571, -0.026615522801876068, 0.058600254356861115, 0.058233343064785004, 0.03400418534874916, -0.04360615462064743, -0.06848041713237762, 0.014617258682847023, -0.009442970156669617, 0.015590183436870575, 0.009199271909892559, 0.023154744878411293, 0.016688818112015724, 0.074589803814888, -0.056081414222717285, -0.01675405353307724, 0.021103935316205025, -0.00016599839727859944, 0.041559722274541855, -0.0647837221622467, -0.0582645945250988, -0.04850415512919426, -0.052244387567043304, 0.04297661408782005, 0.002311539836227894, -0.026421168819069862, -0.026300230994820595, 0.03186972811818123, -0.04921511933207512, -0.016530882567167282, -0.06527073681354523, -0.04596728831529617, -0.025272587314248085, -0.056690994650125504, 0.03204444795846939, -0.05595414340496063, -0.02197171188890934, -0.03934423252940178, -0.0060449703596532345, -0.06319450587034225, 0.05779023468494415, -0.0515255443751812, 0.05156579613685608, 0.04665214195847511, -0.0414668545126915, 0.04806646704673767, 0.048491474241018295, -0.0542277917265892, 0.025873497128486633, -0.004470932297408581, -0.04398893937468529, -0.030044492334127426, -0.04876682162284851, 0.021589629352092743, 0.05018770322203636, -0.023709380999207497, 0.018695609644055367, -0.01719202846288681, 0.00016610464081168175, -0.04401663318276405, -0.018760574981570244, -0.07213355600833893, 0.07218039780855179, 0.009828298352658749, -0.011517426930367947, 0.016159243881702423, -0.03611057251691818, 0.029493028298020363, -0.01853090152144432, 0.07011532783508301, 0.00859227403998375, -0.05390245094895363, 0.030609816312789917, 0.03625847026705742, 0.03679495304822922, -0.015797162428498268, -0.05629131942987442, 0.061379674822092056, -0.04605403169989586, -0.06960749626159668, -0.0049569206312298775, 0.045031312853097916, -0.01935964822769165, -0.027847174555063248, -0.04735251143574715, 0.07406947761774063, -0.06080444157123566, 0.05420190468430519, 0.014791207388043404, -0.05648787319660187, -0.054819293320178986, 0.05069972574710846, -0.06792574375867844]], "voice_styles": {"en_dt_0": "conversational", "sk_cori": "reading", "sk_dailytalk": "conversational", "sk_muz": "reading"}, "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}, "mel_mean": -5.934409141540527, "mel_std": 2.369523763656616, "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]}, "pause_tokens": [5, 6, 7, 8], "stop_tokens": [6, 7, 8], "dur_temperature": 0.7, "sway": -1.0, "sample_rate": 24000, "hop": 256, "languages": {"en": ["en_hifi_92_clean", "en_dt_0"], "sk": ["sk_cori", "sk_dailytalk", "sk_muz"]}}1{"language": "sk", "vocoder": "bigvgan", "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:<s>", "sk:<q>", "sk:<wh>", "sk:<e>", "sk:|1", "sk:|2", "sk:|3", "sk:|4", "sk:▁", "sk:ˈ", "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": {"sk_f3": [0.0069220950827002525, 0.025969285517930984, 0.08535561710596085, -0.09493527561426163, -0.14596465229988098, 0.00032224622555077076, 0.08764629811048508, -0.03438185155391693, 0.09686848521232605, 0.06196203455328941, 0.12122627347707748, -0.06127996742725372, 0.10377505421638489, -0.01582501083612442, 0.06028405576944351, 0.027843158692121506, -0.08210922032594681, 0.03653174638748169, -0.018876979127526283, 0.05382998287677765, -0.06425376236438751, 0.004607432056218386, 0.03896747902035713, -0.11966422200202942, 0.06343807280063629, -0.12184412032365799, -0.02126498892903328, 0.07495327293872833, 0.022044310346245766, -0.08201880753040314, 0.07486635446548462, -0.0819067656993866, 0.09514299035072327, -0.061507850885391235, 0.02417520247399807, 0.002311374293640256, -0.09207151085138321, 0.007653384003788233, -0.15520614385604858, -0.1480940878391266, 0.002546643139794469, -0.009824864566326141, -0.1772390902042389, 0.026085006073117256, 0.026416392996907234, -0.013845834881067276, 0.054473839700222015, -0.0779697373509407, -0.0978066474199295, -0.0837216004729271, -0.017712270841002464, 0.023772289976477623, -0.0055798315443098545, 0.06802446395158768, 0.022231435403227806, -0.07259859889745712, -0.03732074797153473, -0.08997371792793274, -0.03945454582571983, 0.10520587116479874, 0.1145419329404831, -0.048494163900613785, 0.03043532371520996, -0.06480081379413605, -0.08295542001724243, 0.05099185183644295, 0.0916825607419014, 0.09053876250982285, -0.03743071109056473, 0.08533451706171036, 0.12690933048725128, -0.007914270274341106, -0.06867715716362, -0.07989329844713211, 0.029588399454951286, -0.043726690113544464, 0.08121353387832642, 0.062097661197185516, -0.09368886798620224, -0.10700567066669464, -0.04510211572051048, -0.052244316786527634, -0.09686923027038574, 0.07206062972545624, -0.021960511803627014, 0.17842909693717957, -0.12118241935968399, 0.0341760478913784, 0.12143102288246155, -0.024871744215488434, -0.015425002202391624, -0.058072056621313095, -0.07772723585367203, -0.03486534208059311, 0.017253687605261803, 0.030715281143784523, -0.00817838218063116, 0.03271663933992386, 0.07943491637706757, 0.04381219670176506, -0.0075861369259655476, -0.030322184786200523, -0.05918130278587341, 0.034897010773420334, -0.06694208830595016, 0.022675972431898117, -0.1466275155544281, 0.04075567424297333, -0.0462232306599617, 0.12151164561510086, 0.15512670576572418, 0.1148054450750351, 0.003235230688005686, -0.10640178620815277, 0.06144479662179947, 0.0031708208844065666, -0.04580552130937576, 0.026719121262431145, -0.08421687036752701, 0.06003719940781593, -0.07768043130636215, -0.028076047077775, 0.09770499169826508, 0.06046808883547783, -0.11217805743217468, -0.0842382088303566, -0.10238291323184967, -0.07293198257684708, 0.08308366686105728, -0.07062023878097534, 0.09781237691640854, 0.059962738305330276, 0.07842554152011871, 0.024967463687062263, 0.03208184614777565, 0.08186769485473633, -0.038767892867326736, -0.05660480633378029, -0.13511717319488525, -0.02679261937737465, -0.059443678706884384, -0.012461567297577858, 0.03912317752838135, -0.050175223499536514, 0.06664767116308212, 0.03994154557585716, 0.058831747621297836, 0.014645740389823914, 0.03166384994983673, 0.11226306855678558, 0.03234376758337021, 0.05169070512056351, 0.0733196884393692, -0.052095700055360794, 0.03154715895652771, 0.08816029131412506, 0.021930737420916557, 0.059319522231817245, 0.021856624633073807, -0.0697982907295227, 0.0827752947807312, -0.016794124618172646, 0.1373288333415985, 0.047362037003040314, 0.10703173279762268, 0.10932779312133789, 0.0390084944665432, -0.04382721334695816, 0.03785355016589165, 0.08803846687078476, -0.051568321883678436, 0.11728514730930328, -0.07688966393470764, -0.03130396082997322, -0.025611117482185364, -0.004799845162779093, -0.0206914059817791, 0.06866998970508575, 0.025913121178746223, 0.02568175457417965, 0.025991586968302727, -0.010967152193188667, -0.0034555925521999598, 0.07785943895578384, 0.022330626845359802, 0.005075695924460888, 0.103604756295681, -0.13793043792247772, 0.06114722043275833, 0.06387419253587723, -0.08323141932487488, 0.0440208837389946, -0.05241548642516136, -0.01854764111340046, -0.07451599091291428, -0.016836775466799736, 0.012907693162560463, -0.10157483071088791, 0.09838944673538208, 0.03780096024274826, -0.044474583119153976, 0.006056552287191153, -0.025014474987983704, -0.1231941357254982, 0.10177677869796753, 0.08554479479789734, 0.01990067958831787, -0.03043481521308422, -0.05259972810745239, -0.048060495406389236, 0.10816875100135803, 0.03521691635251045, -0.002017595339566469, 0.024097785353660583, 0.07850710302591324, 0.1226380467414856, -0.09665429592132568, -0.09156115353107452, 0.016159996390342712, -0.12041638046503067, 0.08137863129377365, 0.09571825712919235, -0.07472876459360123, -0.0928075909614563, 0.08536958694458008, -0.07941228896379471, 0.06431327760219574, -0.07708175480365753, -0.14428292214870453, 0.01991124451160431, -0.04411928355693817, 0.0230460986495018, -0.0853683352470398, 0.04575435817241669, 0.04512261226773262, -0.1003434807062149, 0.09046773612499237, -0.04525180533528328, 0.0271983053535223, -0.01599619910120964, -0.12744814157485962, -0.043206531554460526, 0.0386822409927845, 0.03523113951086998, 0.013651641085743904, -0.0555524043738842, -0.11787251383066177, 0.0008374134195037186, -0.12753580510616302, 0.04498244822025299, -0.0733710452914238, -0.012414051219820976, 0.053098078817129135, 0.09323238581418991, -0.005115098785609007, 0.0914095938205719], "sk_f2": [0.024097561836242676, 0.030168669298291206, 0.043650928884744644, -0.027951136231422424, -0.07817357778549194, -0.005449120420962572, 0.05257202684879303, -0.045568615198135376, 0.0738847404718399, -0.02667238935828209, 0.04473037272691727, -0.009615535847842693, 0.0383019745349884, -0.0027216521557420492, 0.03313062712550163, -0.01756933145225048, -0.05668586120009422, 0.01242008339613676, 0.030627205967903137, 0.00429007550701499, -0.036590512841939926, 0.023337097838521004, 0.014491959474980831, -0.06983091682195663, 0.03388449549674988, -0.09208258986473083, -0.008395465090870857, 0.0684259906411171, 0.03183995559811592, -0.05619150400161743, -0.002181802410632372, -0.041507985442876816, 0.04100802168250084, -0.019180219620466232, 0.0207273717969656, 0.07022634893655777, -0.07003574073314667, -0.0462697297334671, -0.09469541907310486, -0.10863298922777176, -0.016562674194574356, 0.019701670855283737, -0.12199992686510086, 0.008158247917890549, -0.023660710081458092, -0.017495064064860344, 0.034658126533031464, -0.023781631141901016, -0.04877622798085213, -0.026612434536218643, 0.012298217043280602, -0.02441677451133728, 0.048689790070056915, -0.0058479392901062965, -0.04646887630224228, -0.040177006274461746, -0.03928855434060097, -0.00804735068231821, -0.06016168370842934, 0.0495726615190506, 0.04329775273799896, -0.0120718814432621, -0.027341952547430992, -0.008509863168001175, -0.034739404916763306, -0.019885430112481117, 0.04748579114675522, 0.060399141162633896, 0.03364885598421097, 0.04357143118977547, 0.09640394151210785, -0.004484984558075666, -0.032641321420669556, -0.010708846151828766, 0.014448054134845734, -0.03689482808113098, 0.02170329913496971, -0.014699080027639866, -0.04527376592159271, -0.04999920353293419, -0.02163383550941944, -0.025249382480978966, -0.08334973454475403, 0.01766347698867321, -0.03356679528951645, 0.14948655664920807, -0.03974779322743416, 0.035962022840976715, 0.07903093844652176, -0.05388018116354942, -0.008143189363181591, -0.03537096455693245, -0.01526119839400053, -0.024802232161164284, -0.0021449504420161247, 0.09032466262578964, 0.06179432570934296, 0.001414844999089837, 0.05074925720691681, -0.008059952408075333, -0.006018988788127899, -0.007039212621748447, 0.01743687130510807, -0.014672081917524338, -0.049365509301424026, 0.039760954678058624, -0.09551216661930084, -0.03767023980617523, -0.010618026368319988, 0.09264171123504639, 0.11118534952402115, 0.10678435117006302, 0.049383897334337234, -0.052618350833654404, 0.011095641180872917, -0.03801474720239639, -0.025791538879275322, 0.03572089225053787, 0.005060484632849693, 0.0027973472606390715, -0.05591229721903801, -0.016014473512768745, 0.040837861597537994, 0.055352430790662766, -0.06306610256433487, -0.03682548925280571, -0.03343666344881058, -0.03121863305568695, 0.03609577193856239, -0.0048875049687922, 0.05425698682665825, 0.05175263062119484, 0.034288689494132996, 0.06929577887058258, 0.004533826373517513, 0.017628263682127, 0.014835023321211338, -0.04960944876074791, -0.12282758951187134, 0.010756325908005238, -0.008512694388628006, 0.013570980168879032, 0.00494487676769495, -0.035868700593709946, 0.020549559965729713, -0.0060182493180036545, 0.002885116497054696, -0.0206423532217741, -0.004758887924253941, 0.06703010201454163, 0.023000327870249748, 0.0552949421107769, 0.006436473224312067, -0.05298313871026039, -0.017114970833063126, 0.06149057298898697, 0.0024807883892208338, -0.008851351216435432, 0.036341115832328796, -0.04187731817364693, 0.05857101455330849, -0.009575247764587402, 0.06979426741600037, 0.04412073642015457, 0.053835079073905945, 0.05447831749916077, 0.06466595828533173, 0.001393102458678186, 0.03768660128116608, 0.0497903935611248, -0.06561547517776489, 0.10653814673423767, -0.01632833667099476, -0.056834906339645386, 0.023267190903425217, -0.020999951288104057, 0.014423804357647896, 0.029890552163124084, 0.05836153402924538, -0.0363486222922802, -0.02021036110818386, 0.035614073276519775, 0.020065926015377045, 0.0402769036591053, 0.01385585404932499, 0.057882703840732574, 0.050061605870723724, -0.09888768941164017, 0.019632741808891296, 0.010783595964312553, -0.04448627680540085, -0.01927703619003296, -0.030326789245009422, 0.01217689923942089, -0.032602980732917786, -0.013396689668297768, -0.03419116884469986, -0.04791100695729256, 0.058380283415317535, -0.0239116083830595, -0.03705713897943497, -0.0017270477255806327, -0.061741795390844345, -0.06591153889894485, 0.06776439398527145, 0.011767944321036339, 0.025723110884428024, 0.0013535335892811418, -0.05649380385875702, 0.008991016075015068, 0.11289903521537781, 0.022137749940156937, -0.04243382439017296, -0.012099899351596832, 0.03529380261898041, 0.04291291534900665, -0.012041104957461357, -0.03380099684000015, 0.028327303007245064, -0.0565875843167305, 0.020075833424925804, 0.03536389023065567, -0.02333691716194153, -0.10384808480739594, 0.04787662625312805, -0.029503753408789635, 0.0301466453820467, -0.02378085069358349, -0.07087701559066772, -0.02837279625236988, 0.03160630911588669, -0.019020047038793564, -0.0654759332537651, -0.011184139177203178, 0.06354306638240814, -0.043409351259469986, 0.05378085747361183, -0.015591144561767578, 0.046996790915727615, -0.03613948076963425, -0.09587481617927551, -0.05033108964562416, 0.03762822970747948, 0.004437517374753952, -0.030090471729636192, 0.022450359538197517, -0.09572584182024002, -0.01724437065422535, -0.07913604378700256, 0.03368911147117615, -0.03670649603009224, -0.029693806543946266, -0.012964166700839996, 0.034330278635025024, -0.012777972966432571, 0.04804672673344612], "sk_m1": [-0.6594359874725342, -0.8590675592422485, -0.3340880870819092, -0.4216928482055664, -0.4292481541633606, 0.561245858669281, -0.039768535643815994, -0.20545461773872375, -0.9284155964851379, 0.483791321516037, -0.10321065038442612, -0.3578355014324188, -0.37743765115737915, 0.34199556708335876, -0.058229461312294006, -0.5965105295181274, -1.071380615234375, -0.9979472160339355, -0.338621586561203, -0.7843340039253235, 0.45100098848342896, -0.44724756479263306, 0.6141610741615295, 0.5597532987594604, -0.005405937787145376, -0.7225935459136963, 0.04538361355662346, -0.1388455629348755, -0.1515306532382965, 0.8850967288017273, -0.2957577109336853, 0.6978495717048645, 1.1830191612243652, 0.12686192989349365, -0.9305142760276794, -0.15785901248455048, 0.7685427069664001, 0.41990283131599426, -0.828966498374939, 0.3956412076950073, 0.269621878862381, -0.12421183288097382, -0.26868411898612976, -0.4826836884021759, -0.33832335472106934, -0.3880341351032257, 0.45399555563926697, 0.09130784869194031, 0.00019212972256354988, -1.3175843954086304, -0.9867952466011047, 0.1939685046672821, 0.3604903519153595, -0.32406437397003174, 0.29462534189224243, 0.367031067609787, -0.48818376660346985, 0.4234353303909302, 0.9175636172294617, 1.0814405679702759, 0.8130167722702026, 0.4963688552379608, -0.16454117000102997, 0.418791264295578, -0.18220359086990356, -0.7526606917381287, -0.21244041621685028, 0.3942188024520874, 0.038714297115802765, -0.23450683057308197, 1.3822678327560425, 0.38818857073783875, -0.5134894847869873, -0.6253427863121033, 0.630483090877533, 0.4273097515106201, -0.584699809551239, 0.42638710141181946, -0.4047740399837494, 0.2640407383441925, -0.0010079138446599245, -0.9372542500495911, -0.6283785700798035, 0.16921688616275787, -0.07024975121021271, 0.17044329643249512, -0.11768178641796112, 0.48079028725624084, -0.1153411790728569, 0.07285873591899872, -0.7333114147186279, 0.13695073127746582, -0.23452982306480408, -0.47011855244636536, 0.8837440013885498, 0.35419970750808716, -0.5191027522087097, 0.3435491621494293, -0.048973239958286285, -0.44073987007141113, -0.15618360042572021, -0.3343803882598877, -0.5010102987289429, -0.3668557107448578, 0.7347089648246765, -0.49756771326065063, -0.11815501004457474, 0.11792640388011932, -0.5298041105270386, 0.10647834092378616, -0.343199759721756, 0.14111639559268951, 0.33461794257164, 0.20267637073993683, 0.5916112661361694, -0.44652387499809265, 0.8188480138778687, -0.7516932487487793, -0.12890860438346863, -0.9457066059112549, 0.38750073313713074, 0.000907783629372716, 0.08444958925247192, -0.1295805126428604, 0.20477737486362457, 0.1588626503944397, -0.27976375818252563, -0.18955564498901367, 0.8502081036567688, 0.5553237199783325, 0.2922928035259247, 0.9646939039230347, 0.18258938193321228, 0.15660107135772705, 0.5594731569290161, 0.02666294388473034, 0.8473917245864868, -0.49906715750694275, 0.1970818191766739, -0.08225897699594498, 0.868649423122406, 0.582898736000061, -0.5011805891990662, -0.5194291472434998, 0.17157600820064545, -0.029250143095850945, 0.20678633451461792, 0.3596228361129761, -0.19917751848697662, -0.4170529842376709, 0.33080706000328064, 0.3589215576648712, 0.7303389310836792, -0.4868207573890686, 0.15980181097984314, 0.0011628622887656093, -0.6348559260368347, -0.619333028793335, -0.3582775294780731, -0.01990852691233158, -0.25675466656684875, -0.2944406569004059, -0.6637600660324097, -0.584166944026947, -0.46662166714668274, -0.132478728890419, 0.3964209258556366, -0.30076107382774353, 0.10123525559902191, -0.8328986763954163, 0.9588265419006348, 0.21397049725055695, -0.5614163279533386, 0.2203303724527359, 0.09515456110239029, -0.23302061855793, -0.2981974482536316, -0.2324647754430771, -0.1621292382478714, 0.268691748380661, 0.7389184832572937, 0.4840203821659088, 0.6937673687934875, -0.4113222360610962, 0.6561809182167053, -1.2155946493148804, 0.8793654441833496, 0.35360175371170044, -0.436225026845932, -0.556606650352478, -0.4510931968688965, -0.5128986239433289, -0.21721333265304565, -0.7819942235946655, 0.4346346855163574, -0.4476339519023895, -0.5610625743865967, 0.14093586802482605, 0.8294968605041504, 0.1518557071685791, 0.07351728528738022, -0.03982733562588692, -0.36518386006355286, 0.06151654198765755, -0.7278828620910645, 0.2685856223106384, -0.534945011138916, 1.069612979888916, 0.7044892311096191, -0.679125964641571, -0.6881814002990723, -0.28567633032798767, -0.6514680981636047, 0.9735426306724548, -0.891938328742981, 0.4702104926109314, -0.274715393781662, -0.27546995878219604, 0.7771115899085999, -0.2808266580104828, -0.37654513120651245, -0.2170010805130005, 0.5293588638305664, -0.03979289531707764, -0.4564104378223419, -1.1188852787017822, 0.08321906626224518, 0.7889278531074524, -0.08276275545358658, -0.08456353843212128, 0.037263236939907074, 0.18487927317619324, 0.039911288768053055, -0.588462233543396, -0.11964796483516693, -1.5144703388214111, -0.9792431592941284, 0.4126518666744232, -0.6432049870491028, 0.6586396098136902, -0.27811792492866516, 0.04909246414899826, 0.6623432040214539, -0.24891167879104614, 0.23794648051261902, -0.8212035298347473, -0.7160554528236389, 0.4204083979129791, 0.08378566056489944, -0.17133833467960358, -0.5402119159698486, -0.6000930666923523, 0.9218289852142334, -0.40126389265060425, 0.1807071715593338, -0.05342463031411171]}, "delivery": {"guidance": 1.5, "length_scale": 1.04, "pause_scale": 1.0, "max_pause": 18, "max_final": 1.25, "short_scale": 0.85, "long_scale": 1.12, "min_vowel": 6, "min_phone": 3, "max_tail": 8, "max_stop": 42, "n_timesteps": 10, "temperature": 0.667, "sentence_gap": 0.35}, "mel_mean": -5.934409141540527, "mel_std": 2.369523763656616, "pause_tokens": [5, 6, 7, 8, 83, 84, 85], "stop_tokens": [6, 7, 8, 84, 85], "token_sets": {"vowel": [88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105], "short": [88, 89, 90, 91, 92], "long": [93, 94, 95, 96, 97, 98, 99, 100, 101], "phone": [88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134], "lead": [1, 78, 79, 80, 81, 87], "tail": [2], "eq": [114, 115, 121, 122]}, "eq_gain": [0.005094512977431282, 0.010337334883303817, 0.01573278321339248, 0.02128530115226229, 0.026999461232257754, 0.032879969099011246, 0.03893166738657084, 0.04515953970533884, 0.051568714746105394, 0.0581644705035566, 0.06495223862273523, 0.07193760887203357, 0.07912633374640173, 0.08652433320456218, 0.09413769954413191, 0.10197270241866667, 0.1100357940007587, 0.11833361429544038, 0.12687299660826865, 0.13566097317259376, 0.1447047809406464, 0.1540118675432118, 0.1635898974227992, 0.17344675814535673, 0.18359056689573044, 0.1940296771622146, 0.20477268561570136, 0.21582843918909062, 0.22720604236279368, 0.23891486466232814, 0.2509645483741792, 0.2633650164862816, 0.27612648085966, 0.2892594506379597, 0.3027747409017895, 0.31668348157500686, 0.3309971265902782, 0.3457274633214616, 0.3608866222905818, 0.3764870871573887, 0.3925417049997264, 0.40906369689318106, 0.4260666687987172, 0.4435646227672683, 0.4615719684705124, 0.48010353506732384, 0.49917458341567583, 0.498119918135995, 0.4961001596935298, 0.4940216030476564, 0.49188253649431607, 0.4896811984991724, 0.4874157762469774, 0.48508440414870724, 0.48268516230523784, 0.48021607492629675, 0.4776751087033875, 0.4750601711353478, 0.4723691088051621, 0.46959970560660946, 0.46674968091928676, 0.4638166877305037, 0.4607983107025037, 0.45769206418341835, 0.45449539016031826, 0.4512056561526736, 0.447275191305613, 0.4429201160666713, 0.43843825804302977, 0.4338259263973056, 0.4290793228462938, 0.4241945385330571, 0.419167550807959, 0.41399421991598717, 0.40867028558764007, 0.4031913635305685, 0.2982023796739416, 0.05681569062831121, -0.19159812767401585, -0.44724364552556906, -0.7103313885675037, -0.9022274178889768, -0.909882046010775, -0.9177595118600242, -0.9258663025778351, -0.9342090941557443, -0.9427947569334342, -0.95, -0.95, -0.95, -0.95, -0.95, -0.95, -0.95, -0.95, -0.95, -0.95, -0.95, -0.95, -0.95], "eq_voices": ["sk_f2", "sk_m1"], "dur_temperature": 0.7, "sway": -1.0, "sample_rate": 24000, "hop": 256, "source": {"checkpoint": "run_f4_best.pt", "step": 4000}}
README.md+97-24
config.json+197-310
model.safetensors+2-2
povedz.pyDeleted-68
requirements.txt+1-5
slovak-frontend.zipDeleted-3
tts_english/__init__.pyDeleted-244
tts_english/__main__.pyDeleted-36
tts_english/frontend.pyDeleted-68
tts_english/normalize.pyDeleted-234
tts_english/post.pyDeleted-58
tts_english/refenc.pyDeleted-170
tts_english/vocos.pyDeleted-79
tts_slovak/__init__.pyAdded+209
tts_slovak/__main__.pyAdded+28
tts_slovak/frontend/__init__.pyAdded+5
tts_slovak/frontend/context.pyAdded+129
tts_slovak/frontend/data/g2p_hard.txtAdded+145
tts_slovak/frontend/data/nouns.tsvAdded+47
tts_slovak/frontend/g2p.pyAdded+190
tts_slovak/frontend/lexicon.pyAdded+204
tts_slovak/frontend/normalize.pyAdded+478
tts_slovak/frontend/numbers.pyAdded+322
tts_slovak/frontend/phonemes.pyAdded+34
tts_slovak/frontend/pipeline.pyAdded+217
tts_slovak/frontend/ssml.pyAdded+152
tts_english/mas.py → tts_slovak/mas.pyRenamed
tts_english/model.py → tts_slovak/model.pyRenamed+179-8
vocoder/bigvgan_config.jsonDeleted-46
vocoder/bigvgan_finetuned.ptDeleted-3
web/bigvgan.onnx+2-2
web/decoder.onnx+2-2
web/g2p/cmudict.txtDeleted
web/g2p/g2p_oov.binDeleted-3
web/g2p/homographs.jsonDeleted-1
web/g2p/tagger.jsonDeleted
web/text.onnx+2-2
web/voices.json+1-1