Murli-V1.5-Code / config.py
ViuAI's picture
Lock Natural Smooth winning defaults (steps=48, cfg=1.3, temp=0.90, speed=0.92)
5b31e61 verified
Raw History Blame Contribute Delete
3.55 kB
"""
Murli V1.5 Configuration — Single-Speaker Studio-Grade Expressive Hindi TTS.
Targeted fixes for every Murli V1.0 issue while staying lightweight (~20M) for Android ONNX.
"""
from dataclasses import dataclass, field
from typing import Dict, List, Optional
EMOTION_TO_ID: Dict[str, int] = {
"neutral": 0,
"happy": 1,
"sad": 2,
"angry": 3,
"surprise": 4,
"fear": 5,
"disgust": 6,
"story": 7,
}
@dataclass
class AudioConfig:
sample_rate: int = 24000
n_fft: int = 1024
hop_length: int = 256
win_length: int = 1024
n_mels: int = 100
f_min: float = 0.0
f_max: float = 12000.0 # Vocos 24kHz HTK mel: Nyquist (12000 Hz)
mel_scale: str = "htk"
mel_min_clip: float = 1e-5
f0_min: float = 50.0
f0_max: float = 550.0
center: bool = True
mel_mean: float = -6.0
mel_std: float = 2.5
@dataclass
class ModelConfig:
# Unified IPA / Hindi G2P vocabulary (fixes V1 raw char slips: Anusvara, schwa, ड़/ढ़, proper nouns)
vocab_size: int = 256
num_emotions: int = 8
# Text Encoder (6-layer RoPE SwiGLU + 2 local ConvNeXt blocks)
text_dim: int = 320
text_layers: int = 6
text_heads: int = 5
text_ff_mult: float = 2.667
text_dropout: float = 0.05
# Prosody & Alignment (ConvNeXt Prior + Duration + Log-F0 Pitch + Energy + FP32 MAS)
prosody_kernel_size: int = 5
prosody_layers: int = 3
# ConvNeXt-V2 OT-CFM Vector Field (pure Conv1d/Linear/GRN -> fast Android ONNX)
mel_dim: int = 100
cfm_hidden_dim: int = 384
cfm_blocks: int = 12
cfm_kernel_size: int = 7
cfm_time_dim: int = 128
cfg_drop_prob: float = 0.1
# Vocoder
vocoder_repo: str = "charactr/vocos-mel-24khz"
# Inference defaults (V1 lessons: min_frames=2 prevents short/edge char drop, speed=0.92 crisp)
default_speed: float = 0.92
min_frames: int = 2
default_steps: int = 48
default_cfg_scale: float = 1.3
default_temperature: float = 0.90
@dataclass
class TrainConfig:
hf_dataset_name: str = "ViuAI/Murli_TTS_Dataset"
data_subdirs: List[str] = field(default_factory=lambda: ["hindi_50h"])
target_speaker: Optional[str] = "syspin_male_01" # Set to single studio speaker_id for strict 1-speaker training
target_gender: Optional[str] = None # Optional gender filter (e.g. 'female' or 'male') for Rasa
max_samples: Optional[int] = None
cache_dir: str = "cache_v1_5"
checkpoint_dir: str = "checkpoints_v1_5"
sample_dir: str = "samples_v1_5"
batch_size: int = 16
grad_accum_steps: int = 2
num_workers: int = 4
max_epochs: int = 300
max_steps: int = 200_000
lr: float = 2.5e-4
min_lr: float = 1e-5
warmup_steps: int = 2000
weight_decay: float = 0.01
grad_clip: float = 1.0
use_amp: bool = True
# Loss weights
cfm_loss_weight: float = 1.0
prior_loss_weight: float = 0.5
dur_loss_weight: float = 1.0
f0_loss_weight: float = 0.5
energy_loss_weight: float = 0.5
log_every: int = 50
val_every: int = 1000
save_every: int = 2500
sample_every: int = 50_000
hf_backup_every: int = 50_000
hf_sample_repo: Optional[str] = None
seed: int = 42
@dataclass
class MurliV15Config:
audio: AudioConfig = field(default_factory=AudioConfig)
model: ModelConfig = field(default_factory=ModelConfig)
train: TrainConfig = field(default_factory=TrainConfig)