File size: 3,088 Bytes
a1cd84e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
"""

Configuration for Murli V2.0 — 50M+ Bilingual (Hindi + English) Zero-Shot DiT TTS.

"""

from dataclasses import dataclass, field


@dataclass
class AudioConfig:
    sample_rate: int = 24000
    n_fft: int = 1024
    win_length: int = 1024
    hop_length: int = 256
    n_mels: int = 100
    f_min: float = 0.0
    f_max: float = 12000.0
    mel_scale: str = "htk"
    center: bool = True
    mel_min_clip: float = 1e-7
    f0_min: float = 50.0
    f0_max: float = 600.0


@dataclass
class ModelConfig:
    # Unified IPA + Prosody vocabulary (matches data/text_cleaner.py)
    vocab_size: int = 256
    max_seq_len: int = 2048
    n_mels: int = 100

    # Bilingual Text Encoder (ConvNeXt-V2 local + RoPE SwiGLU Transformer)
    text_dim: int = 384
    text_layers: int = 6
    text_heads: int = 6
    text_ff_mult: float = 2.667

    # Zero-Shot Speaker / Style Perceiver Resampler
    style_dim: int = 384
    style_tokens: int = 16
    style_layers: int = 4
    style_heads: int = 6

    # Duration + Pitch (F0) + Energy Predictor
    prosody_dim: int = 384
    prosody_layers: int = 4
    prosody_kernel: int = 5
    duration_loss_weight: float = 1.5
    f0_loss_weight: float = 1.0
    energy_loss_weight: float = 0.5
    prior_loss_weight: float = 0.5

    # 2026 Diffusion Transformer (DiT) OT-CFM Vector Field (~66M trainable engine)
    dit_dim: int = 512
    dit_layers: int = 8
    dit_heads: int = 8
    dit_ff_mult: float = 2.667
    dropout: float = 0.05

    # Classifier-Free Guidance & Flow Sampling
    cfg_drop_prob: float = 0.1
    default_ode_steps: int = 32
    default_ode_method: str = "midpoint"  # "euler" or "midpoint"
    default_cfg_scale: float = 1.8
    default_temperature: float = 0.65
    sway_sampling_coef: float = -1.0

    # Vocoder backend: "vocos" (24kHz 100-band) or "bigvgan_v2"
    vocoder_backend: str = "vocos"


@dataclass
class TrainingConfig:
    batch_size: int = 32
    grad_accum_steps: int = 2
    learning_rate: float = 1.5e-4
    min_lr: float = 1e-6
    weight_decay: float = 0.01
    warmup_steps: int = 2000
    max_epochs: int = 200
    max_grad_norm: float = 1.0
    ema_decay: float = 0.9999
    use_bf16: bool = True
    grad_checkpointing: bool = False
    save_every_steps: int = 2500
    log_every_steps: int = 25
    checkpoint_dir: str = "checkpoints"


@dataclass
class HFConfig:
    code_repo_id: str = "ViuAI/Murli-V2-Code"
    release_repo_id: str = "ViuAI/Murli-V2.0"
    dataset_repo_id: str = "ViuAI/Murli_TTS_Dataset"


@dataclass
class MurliV2Config:
    audio: AudioConfig = field(default_factory=AudioConfig)
    model: ModelConfig = field(default_factory=ModelConfig)
    training: TrainingConfig = field(default_factory=TrainingConfig)
    hf: HFConfig = field(default_factory=HFConfig)

    def __post_init__(self):
        if self.model.vocoder_backend == "bigvgan_v2":
            self.audio.mel_scale = "slaney"
            self.audio.center = False
            self.audio.mel_min_clip = 1e-5