File size: 4,295 Bytes
870eedf
850083c
870eedf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
850083c
870eedf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
870a8cd
 
870eedf
 
 
870a8cd
870eedf
 
 
 
 
 
 
 
 
 
 
850083c
870eedf
 
 
 
 
 
475653d
870eedf
 
475653d
 
 
870eedf
475653d
870eedf
 
42e63f8
870eedf
475653d
870eedf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
"""
Murli V1.6 Configuration — 2026 Single-Speaker (syspin_male_01, 49.28h @ 53.1 dB SNR) Only-Hindi Studio TTS.
Hybrid ConvNeXt-V2 + RoPE DiT Self-Attention CFM (AdaLN-Zero) + Smooth Frame-Level Prosody.
"""

from dataclasses import dataclass, field
from typing import Dict, List, Optional, Tuple


EMOTION_TO_ID: Dict[str, int] = {
    "neutral": 0,
    "happy": 1,
    "sad": 2,
    "angry": 3,
    "surprise": 4,
    "fear": 5,
    "disgust": 6,
    "story": 7,
}

# Verified Studio Voices in ViuAI/Murli_TTS_Dataset (~108.8h total across 3 clean speakers)
SPEAKER_TO_ID: Dict[str, int] = {
    "syspin_male_01": 0,             # hindi_50h (49.28h, 53.1 dB SNR Male Studio)
    "kalita_rasa_male_01": 1,        # hindi_kalita (12.88h, 44.4 dB SNR Expressive Rasa Male)
    "iisc_f_hindi_female_spk001": 2, # hindi_female_iisc (46.63h+, 50.0 dB SNR Female Studio)
}

SPEAKER_ALIASES: Dict[str, int] = {
    "syspin_male": 0,
    "male": 0,
    "rasa_male": 1,
    "kalita_male": 1,
    "iisc_female": 2,
    "female": 2,
    **SPEAKER_TO_ID,
}

# Default Single-Speaker Only-Hindi corpus source: (hf_subdir, speaker_filter_or_none)
DEFAULT_CORPUS_SOURCES: List[Tuple[str, Optional[str]]] = [
    ("hindi_50h", "syspin_male_01"),
]


@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
    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:
    vocab_size: int = 256
    num_speakers: int = 4   # 0=syspin_male_01, 1=kalita_rasa_male_01, 2=iisc_female, 3=reserved
    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 (Speaker + Emotion + ConvNeXt Prior + Smooth Frame F0/Energy + MAS)
    prosody_kernel_size: int = 5
    prosody_layers: int = 3

    # 2026 Hybrid ConvNeXt-V2 + RoPE DiT Self-Attention OT-CFM (AdaLN-Zero)
    mel_dim: int = 100
    cfm_hidden_dim: int = 384
    cfm_blocks: int = 12
    cfm_kernel_size: int = 7
    cfm_attn_heads: int = 6
    cfm_attn_every: int = 3   # Insert RoPE DiT Attention every 3 ConvNeXt blocks (4 global attn layers)
    cfm_time_dim: int = 128
    cfg_drop_prob: float = 0.1

    vocoder_repo: str = "charactr/vocos-mel-24khz"

    # Winning Natural Smooth defaults
    default_speed: float = 0.88
    min_frames: int = 2
    default_steps: int = 48
    default_cfg_scale: float = 1.3
    default_temperature: float = 0.88


@dataclass
class TrainConfig:
    hf_dataset_name: str = "ViuAI/Murli_TTS_Dataset"
    data_subdirs: List[str] = field(default_factory=lambda: [
        "hindi_50h",
    ])
    target_speakers: Optional[List[str]] = field(default_factory=lambda: [
        "syspin_male_01",
    ])
    language: Optional[str] = "hi"
    target_gender: Optional[str] = None
    max_samples: Optional[int] = None
    cache_dir: str = "cache_v1_6"
    checkpoint_dir: str = "checkpoints_v1_6"
    sample_dir: str = "samples_v1_6"

    batch_size: int = 32
    grad_accum_steps: int = 1
    num_workers: int = 8
    max_epochs: int = 600
    max_steps: int = 300_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
    ema_decay: float = 0.9995
    use_amp: bool = True
    compile_model: bool = False

    cfm_loss_weight: float = 1.0
    prior_loss_weight: float = 0.5
    dur_loss_weight: float = 1.0
    f0_loss_weight: float = 0.6
    energy_loss_weight: float = 0.5
    frame_prosody_loss_weight: float = 0.4

    log_every: int = 50
    val_every: int = 1000
    save_every: int = 5000
    sample_every: int = 25_000
    hf_backup_every: int = 50_000
    hf_sample_repo: Optional[str] = None
    seed: int = 42


@dataclass
class MurliV16Config:
    audio: AudioConfig = field(default_factory=AudioConfig)
    model: ModelConfig = field(default_factory=ModelConfig)
    train: TrainConfig = field(default_factory=TrainConfig)