"""VTX-TTS Configuration & Text Processing System. Defines VTXConfig and text symbol tokenization. """ from __future__ import annotations import json from dataclasses import dataclass from pathlib import Path from typing import Any, Dict # Symbol definitions for VTX-TTS phoneme tokenization _pad = "_" _punctuation = ";:,.!?¡¿—…\"«»“” " _letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" _letters_ipa = "ɑɐɒæɓʙβɔɕçɗɖðʤəɘɚɛɜɝɞɟʄɡɠɢʛɦɧħɥʜɨɪʝɭɬɫɮʟɱɯɰŋɳɲɴøɵɸθœɶʘɹɺɾɻʀʁɽʂʃʈʧʉʊʋⱱʌɣɤʍχʎʏʑʐʒʔʡʕʢǀǁǂǃˈˌːˑʼʴʰʱʲʷˠˤ˞↓↑→↗↘'̩'ᵻ" symbols = [_pad] + list(_punctuation) + list(_letters) + list(_letters_ipa) _symbol_to_id = {s: i for i, s in enumerate(symbols)} def cleaned_text_to_sequence(cleaned_text: str) -> list[int]: """Converts a string of text to a sequence of IDs corresponding to the symbols in the text.""" sequence = [] for symbol in cleaned_text: if symbol in _symbol_to_id: sequence.append(_symbol_to_id[symbol]) return sequence class HParams: def __init__(self, **kwargs): for k, v in kwargs.items(): if isinstance(v, dict): v = HParams(**v) self[k] = v def __getitem__(self, key): return getattr(self, key) def __setitem__(self, key, value): return setattr(self, key, value) def __contains__(self, key): return hasattr(self, key) def __repr__(self): return self.__dict__.__repr__() def get_hparams_from_file(config_path: str | Path) -> HParams: with open(config_path, "r", encoding="utf-8") as f: data = f.read() config = json.loads(data) return HParams(**config)