Claude
commited on
Add codebase analysis documentation and update gitignore
Browse files- Added Rust build artifact patterns to .gitignore
- Included codebase exploration and analysis documents
- SOURCE_FILE_LISTING.txt: Complete Python source inventory
- DIRECTORY_STRUCTURE.txt: Project structure overview
- CODEBASE_ANALYSIS.md: Architecture and component analysis
- EXPLORATION_SUMMARY.md: Conversion planning notes
- .gitignore +4 -0
- CODEBASE_ANALYSIS.md +594 -0
- DIRECTORY_STRUCTURE.txt +224 -0
- EXPLORATION_SUMMARY.md +283 -0
- SOURCE_FILE_LISTING.txt +513 -0
.gitignore
CHANGED
|
@@ -15,3 +15,7 @@ build/
|
|
| 15 |
.venv
|
| 16 |
checkpoints/*
|
| 17 |
__MACOSX
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
.venv
|
| 16 |
checkpoints/*
|
| 17 |
__MACOSX
|
| 18 |
+
|
| 19 |
+
# Rust build artifacts
|
| 20 |
+
/target/
|
| 21 |
+
**/*.rs.bk
|
CODEBASE_ANALYSIS.md
ADDED
|
@@ -0,0 +1,594 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
| 1 |
+
# IndexTTS-Rust Comprehensive Codebase Analysis
|
| 2 |
+
|
| 3 |
+
## Executive Summary
|
| 4 |
+
|
| 5 |
+
**IndexTTS** is an **industrial-level, controllable, and efficient zero-shot Text-To-Speech (TTS) system** currently implemented in **Python** using PyTorch. The project is being converted to Rust (as indicated by the branch name `claude/convert-to-rust-01USgPYEqMyp5KXjjFNVwztU`).
|
| 6 |
+
|
| 7 |
+
**Key Statistics:**
|
| 8 |
+
- **Total Python Files:** 194
|
| 9 |
+
- **Total Lines of Code:** ~25,000+ (not counting dependencies)
|
| 10 |
+
- **Current Version:** IndexTTS 1.5 (latest with stability improvements, especially for English)
|
| 11 |
+
- **No Rust code exists yet** - this is a fresh conversion project
|
| 12 |
+
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
## 1. PROJECT STRUCTURE
|
| 16 |
+
|
| 17 |
+
### Root Directory Layout
|
| 18 |
+
```
|
| 19 |
+
IndexTTS-Rust/
|
| 20 |
+
βββ indextts/ # Main package (194 .py files)
|
| 21 |
+
β βββ gpt/ # GPT-based model implementation
|
| 22 |
+
β βββ BigVGAN/ # Vocoder for audio synthesis
|
| 23 |
+
β βββ s2mel/ # Semantic-to-Mel spectrogram conversion
|
| 24 |
+
β βββ utils/ # Text processing, feature extraction, utilities
|
| 25 |
+
β βββ vqvae/ # Vector Quantized VAE components
|
| 26 |
+
βββ examples/ # Sample audio files and test cases
|
| 27 |
+
βββ tests/ # Test files for regression testing
|
| 28 |
+
βββ tools/ # Utility scripts and i18n support
|
| 29 |
+
βββ webui.py # Gradio-based web interface (18KB)
|
| 30 |
+
βββ cli.py # Command-line interface
|
| 31 |
+
βββ requirements.txt # Python dependencies
|
| 32 |
+
βββ archive/ # Historical documentation
|
| 33 |
+
```
|
| 34 |
+
|
| 35 |
+
---
|
| 36 |
+
|
| 37 |
+
## 2. CURRENT IMPLEMENTATION (PYTHON)
|
| 38 |
+
|
| 39 |
+
### Programming Language & Framework
|
| 40 |
+
- **Language:** Python 3.x
|
| 41 |
+
- **Deep Learning Framework:** PyTorch (primary dependency)
|
| 42 |
+
- **Model Format:** HuggingFace compatible (.safetensors)
|
| 43 |
+
|
| 44 |
+
### Key Dependencies (requirements.txt)
|
| 45 |
+
|
| 46 |
+
| Dependency | Version | Purpose |
|
| 47 |
+
|-----------|---------|---------|
|
| 48 |
+
| torch | (implicit) | Deep learning framework |
|
| 49 |
+
| transformers | 4.52.1 | HuggingFace transformers library |
|
| 50 |
+
| librosa | 0.10.2.post1 | Audio processing |
|
| 51 |
+
| numpy | 1.26.2 | Numerical computing |
|
| 52 |
+
| accelerate | 1.8.1 | Distributed training/inference |
|
| 53 |
+
| deepspeed | 0.17.1 | Inference optimization |
|
| 54 |
+
| torchaudio | (implicit) | Audio I/O |
|
| 55 |
+
| safetensors | 0.5.2 | Model serialization |
|
| 56 |
+
| gradio | (latest) | Web UI framework |
|
| 57 |
+
| modelscope | 1.27.0 | Model hub integration |
|
| 58 |
+
| jieba | 0.42.1 | Chinese text tokenization |
|
| 59 |
+
| g2p-en | 2.1.0 | English phoneme conversion |
|
| 60 |
+
| sentencepiece | (latest) | BPE tokenization |
|
| 61 |
+
| descript-audiotools | 0.7.2 | Audio manipulation |
|
| 62 |
+
| cn2an | 0.5.22 | Chinese number normalization |
|
| 63 |
+
| WeTextProcessing / wetext | (conditional) | Text normalization (Linux/macOS) |
|
| 64 |
+
|
| 65 |
+
---
|
| 66 |
+
|
| 67 |
+
## 3. MAIN FUNCTIONALITY - THE TTS PIPELINE
|
| 68 |
+
|
| 69 |
+
### What IndexTTS Does
|
| 70 |
+
|
| 71 |
+
**IndexTTS is a zero-shot multi-lingual TTS system that:**
|
| 72 |
+
|
| 73 |
+
1. **Takes text input** (Chinese, English, or mixed)
|
| 74 |
+
2. **Takes a voice reference audio** (speaker prompt)
|
| 75 |
+
3. **Generates high-quality speech** in the speaker's voice
|
| 76 |
+
4. **Supports multiple control mechanisms:**
|
| 77 |
+
- Pinyin-based pronunciation control (for Chinese)
|
| 78 |
+
- Pause control via punctuation
|
| 79 |
+
- Emotion vector manipulation (8 dimensions)
|
| 80 |
+
- Emotion text guidance via Qwen model
|
| 81 |
+
- Style reference audio
|
| 82 |
+
|
| 83 |
+
### Core TTS Pipeline (infer_v2.py - 739 lines)
|
| 84 |
+
|
| 85 |
+
```
|
| 86 |
+
Input Text
|
| 87 |
+
β
|
| 88 |
+
Text Normalization (TextNormalizer)
|
| 89 |
+
ββ Chinese-specific normalization
|
| 90 |
+
ββ English-specific normalization
|
| 91 |
+
ββ Pinyin tone extraction/preservation
|
| 92 |
+
ββ Name entity handling
|
| 93 |
+
β
|
| 94 |
+
Text Tokenization (TextTokenizer + SentencePiece)
|
| 95 |
+
ββ CJK character handling
|
| 96 |
+
ββ BPE encoding
|
| 97 |
+
β
|
| 98 |
+
Semantic Encoding (w2v-BERT model)
|
| 99 |
+
ββ Input: Text tokens + Reference audio
|
| 100 |
+
ββ Process: Semantic codec (RepCodec)
|
| 101 |
+
ββ Output: Semantic codes
|
| 102 |
+
β
|
| 103 |
+
Speaker Conditioning
|
| 104 |
+
ββ Extract features from reference audio
|
| 105 |
+
ββ CAMPPlus speaker embedding
|
| 106 |
+
ββ Emotion embedding (from reference or text)
|
| 107 |
+
ββ Mel spectrogram reference
|
| 108 |
+
β
|
| 109 |
+
GPT-based Sequence Generation (UnifiedVoice)
|
| 110 |
+
ββ Semantic tokens β Mel tokens
|
| 111 |
+
ββ Conformer-based speaker conditioning
|
| 112 |
+
ββ Perceiver-based attention pooling
|
| 113 |
+
ββ Emotion control via vectors or text
|
| 114 |
+
β
|
| 115 |
+
Length Regulation (s2mel)
|
| 116 |
+
ββ Acoustic code expansion
|
| 117 |
+
ββ Flow matching for duration modeling
|
| 118 |
+
ββ CFM (Continuous Flow Matching) estimator
|
| 119 |
+
β
|
| 120 |
+
BigVGAN Vocoder
|
| 121 |
+
ββ Mel spectrogram β Waveform
|
| 122 |
+
ββ Uses anti-aliased activation functions
|
| 123 |
+
ββ Optional CUDA kernel optimization
|
| 124 |
+
ββ Optional DeepSpeed acceleration
|
| 125 |
+
β
|
| 126 |
+
Output Audio Waveform (22050 Hz)
|
| 127 |
+
```
|
| 128 |
+
|
| 129 |
+
---
|
| 130 |
+
|
| 131 |
+
## 4. KEY ALGORITHMS AND COMPONENTS NEEDING RUST CONVERSION
|
| 132 |
+
|
| 133 |
+
### A. Text Processing Pipeline
|
| 134 |
+
|
| 135 |
+
**TextNormalizer (front.py - ~500 lines)**
|
| 136 |
+
- Chinese text normalization using WeTextProcessing/wetext
|
| 137 |
+
- English text normalization
|
| 138 |
+
- Pinyin tone extraction and preservation
|
| 139 |
+
- Name entity detection and preservation
|
| 140 |
+
- Character mapping and replacement
|
| 141 |
+
- Pattern matching using regex
|
| 142 |
+
|
| 143 |
+
**TextTokenizer (front.py - ~200 lines)**
|
| 144 |
+
- SentencePiece BPE tokenization
|
| 145 |
+
- CJK character tokenization
|
| 146 |
+
- Special token handling (BOS, EOS, UNK)
|
| 147 |
+
- Vocabulary management
|
| 148 |
+
|
| 149 |
+
### B. Neural Network Components
|
| 150 |
+
|
| 151 |
+
#### 1. **UnifiedVoice GPT Model** (model_v2.py - 747 lines)
|
| 152 |
+
- Multi-layer transformer (configurable depth)
|
| 153 |
+
- Speaker conditioning via Conformer encoder
|
| 154 |
+
- Perceiver resampler for attention pooling
|
| 155 |
+
- Emotion conditioning encoder
|
| 156 |
+
- Position embeddings (learned)
|
| 157 |
+
- Mel and text embeddings
|
| 158 |
+
- Final layer norm + linear output layer
|
| 159 |
+
|
| 160 |
+
#### 2. **Conformer Encoder** (conformer_encoder.py - 520 lines)
|
| 161 |
+
- Conformer blocks with attention + convolution
|
| 162 |
+
- Multi-head self-attention with relative position bias
|
| 163 |
+
- Positionwise feed-forward networks
|
| 164 |
+
- Layer normalization
|
| 165 |
+
- Subsampling layers (Conv2d with various factors)
|
| 166 |
+
- Positional encoding (absolute and relative)
|
| 167 |
+
|
| 168 |
+
#### 3. **Perceiver Resampler** (perceiver.py - 317 lines)
|
| 169 |
+
- Latent queries (learnable embeddings)
|
| 170 |
+
- Cross-attention with context
|
| 171 |
+
- Feed-forward networks
|
| 172 |
+
- Dimension projection
|
| 173 |
+
|
| 174 |
+
#### 4. **BigVGAN Vocoder** (models.py - ~1000 lines)
|
| 175 |
+
- Multi-scale convolution blocks (AMPBlock1, AMPBlock2)
|
| 176 |
+
- Anti-aliased activation functions (Snake, SnakeBeta)
|
| 177 |
+
- Spectral normalization
|
| 178 |
+
- Transposed convolution upsampling
|
| 179 |
+
- Weight normalization
|
| 180 |
+
- Optional CUDA kernel for activation
|
| 181 |
+
|
| 182 |
+
#### 5. **S2Mel (Semantic-to-Mel) Model** (s2mel/modules/)
|
| 183 |
+
- Flow matching / CFM (Continuous Flow Matching)
|
| 184 |
+
- Length regulator
|
| 185 |
+
- Diffusion transformer
|
| 186 |
+
- Acoustic codec quantization
|
| 187 |
+
- Style embeddings
|
| 188 |
+
|
| 189 |
+
### C. Feature Extraction & Processing
|
| 190 |
+
|
| 191 |
+
**Audio Processing (audio.py)**
|
| 192 |
+
- Mel spectrogram computation using librosa
|
| 193 |
+
- Hann windowing and STFT
|
| 194 |
+
- Dynamic range compression/decompression
|
| 195 |
+
- Spectral normalization
|
| 196 |
+
|
| 197 |
+
**Semantic Models**
|
| 198 |
+
- W2V-BERT (wav2vec 2.0 BERT) embeddings
|
| 199 |
+
- RepCodec (semantic codec with vector quantization)
|
| 200 |
+
- Amphion Codec encoders/decoders
|
| 201 |
+
|
| 202 |
+
**Speaker Features**
|
| 203 |
+
- CAMPPlus speaker embedding (192-dim)
|
| 204 |
+
- Campplus model inference
|
| 205 |
+
- Mel-based reference features
|
| 206 |
+
|
| 207 |
+
### D. Model Loading & Configuration
|
| 208 |
+
|
| 209 |
+
**Checkpoint Loading** (checkpoint.py - ~50 lines)
|
| 210 |
+
- Model weight restoration from .safetensors/.pt files
|
| 211 |
+
|
| 212 |
+
**HuggingFace Integration**
|
| 213 |
+
- Model hub downloads
|
| 214 |
+
- Configuration loading (OmegaConf)
|
| 215 |
+
|
| 216 |
+
**Configuration System** (YAML-based)
|
| 217 |
+
- Model architecture parameters
|
| 218 |
+
- Training/inference settings
|
| 219 |
+
- Dataset configuration
|
| 220 |
+
- Vocoder settings
|
| 221 |
+
|
| 222 |
+
---
|
| 223 |
+
|
| 224 |
+
## 5. EXTERNAL MODELS USED
|
| 225 |
+
|
| 226 |
+
### Pre-trained Models (Downloaded from HuggingFace)
|
| 227 |
+
|
| 228 |
+
| Model | Source | Purpose | Size | Parameters |
|
| 229 |
+
|-------|--------|---------|------|-----------|
|
| 230 |
+
| IndexTTS-2 | IndexTeam/IndexTTS-2 | Main TTS model | ~2GB | Various checkpoints |
|
| 231 |
+
| W2V-BERT-2.0 | facebook/w2v-bert-2.0 | Semantic feature extraction | ~1GB | 614M |
|
| 232 |
+
| MaskGCT | amphion/MaskGCT | Semantic codec | - | - |
|
| 233 |
+
| CAMPPlus | funasr/campplus | Speaker embedding | ~100MB | - |
|
| 234 |
+
| BigVGAN v2 | nvidia/bigvgan_v2_22khz_80band_256x | Vocoder | ~100MB | - |
|
| 235 |
+
| Qwen Model | (via modelscope) | Emotion text guidance | Variable | - |
|
| 236 |
+
|
| 237 |
+
### Model Component Breakdown
|
| 238 |
+
```
|
| 239 |
+
Checkpoint Files Loaded:
|
| 240 |
+
βββ gpt_checkpoint.pth # UnifiedVoice model weights
|
| 241 |
+
βββ s2mel_checkpoint.pth # Semantic-to-Mel model
|
| 242 |
+
βββ bpe_model.model # SentencePiece tokenizer
|
| 243 |
+
βββ emotion_matrix.pt # Emotion embedding vectors (8-dim)
|
| 244 |
+
βββ speaker_matrix.pt # Speaker embedding matrix
|
| 245 |
+
βββ w2v_stat.pt # Semantic model statistics (mean/std)
|
| 246 |
+
βββ qwen_emo_path/ # Qwen-based emotion detector
|
| 247 |
+
βββ vocoder config # BigVGAN vocoder config
|
| 248 |
+
```
|
| 249 |
+
|
| 250 |
+
---
|
| 251 |
+
|
| 252 |
+
## 6. INFERENCE MODES & CAPABILITIES
|
| 253 |
+
|
| 254 |
+
### A. Single Text Generation
|
| 255 |
+
```python
|
| 256 |
+
tts.infer(
|
| 257 |
+
spk_audio_prompt="voice.wav",
|
| 258 |
+
text="Hello world",
|
| 259 |
+
output_path="output.wav",
|
| 260 |
+
emo_audio_prompt=None, # Optional emotion reference
|
| 261 |
+
emo_alpha=1.0, # Emotion weight
|
| 262 |
+
emo_vector=None, # Direct emotion control [0-1 values]
|
| 263 |
+
use_emo_text=False, # Generate emotion from text
|
| 264 |
+
emo_text=None, # Text for emotion extraction
|
| 265 |
+
interval_silence=200 # Silence between segments (ms)
|
| 266 |
+
)
|
| 267 |
+
```
|
| 268 |
+
|
| 269 |
+
### B. Batch/Fast Inference
|
| 270 |
+
```python
|
| 271 |
+
tts.infer_fast(...) # Parallel segment generation
|
| 272 |
+
```
|
| 273 |
+
|
| 274 |
+
### C. Multi-language Support
|
| 275 |
+
- **Chinese (Simplified & Traditional):** Full pinyin support
|
| 276 |
+
- **English:** Phoneme-based
|
| 277 |
+
- **Mixed:** Chinese + English in single utterance
|
| 278 |
+
|
| 279 |
+
### D. Emotion Control Methods
|
| 280 |
+
1. **Reference Audio:** Extract from emotion_audio_prompt
|
| 281 |
+
2. **Emotion Vectors:** Direct 8-dimensional control
|
| 282 |
+
3. **Text-based:** Use Qwen model to detect emotion from text
|
| 283 |
+
4. **Speaker-based:** Use speaker's natural emotion
|
| 284 |
+
|
| 285 |
+
### E. Punctuation-based Pausing
|
| 286 |
+
- Periods, commas, question marks, exclamation marks trigger pauses
|
| 287 |
+
- Pause duration controlled via configuration
|
| 288 |
+
|
| 289 |
+
---
|
| 290 |
+
|
| 291 |
+
## 7. MAJOR COMPONENTS BREAKDOWN
|
| 292 |
+
|
| 293 |
+
### indextts/gpt/ (16,953 lines)
|
| 294 |
+
**Purpose:** GPT-based sequence-to-sequence modeling
|
| 295 |
+
|
| 296 |
+
**Files:**
|
| 297 |
+
- `model_v2.py` (747L) - UnifiedVoice implementation, GPT2InferenceModel
|
| 298 |
+
- `model.py` (713L) - Original model (v1)
|
| 299 |
+
- `conformer_encoder.py` (520L) - Conformer speaker encoder
|
| 300 |
+
- `perceiver.py` (317L) - Perceiver attention mechanism
|
| 301 |
+
- `transformers_*.py` (~13,000L) - HuggingFace transformer implementations (customized)
|
| 302 |
+
|
| 303 |
+
### indextts/BigVGAN/ (6+ files, ~1000+ lines)
|
| 304 |
+
**Purpose:** Neural vocoder for mel-to-audio conversion
|
| 305 |
+
|
| 306 |
+
**Key Files:**
|
| 307 |
+
- `models.py` - BigVGAN architecture with AMPBlocks
|
| 308 |
+
- `ECAPA_TDNN.py` - Speaker encoder
|
| 309 |
+
- `activations.py` - Snake/SnakeBeta activation functions
|
| 310 |
+
- `alias_free_activation/` - Anti-aliasing filters (CUDA + Torch versions)
|
| 311 |
+
- `alias_free_torch/` - Pure PyTorch fallback
|
| 312 |
+
- `nnet/` - Network modules (normalization, CNN, linear)
|
| 313 |
+
|
| 314 |
+
### indextts/s2mel/ (~500+ lines)
|
| 315 |
+
**Purpose:** Semantic tokens β Mel spectrogram conversion
|
| 316 |
+
|
| 317 |
+
**Key Files:**
|
| 318 |
+
- `modules/audio.py` - Mel spectrogram computation
|
| 319 |
+
- `modules/commons.py` - Common utilities
|
| 320 |
+
- `modules/layers.py` - Neural network layers
|
| 321 |
+
- `modules/length_regulator.py` - Duration modeling
|
| 322 |
+
- `modules/flow_matching.py` - Continuous flow matching
|
| 323 |
+
- `modules/diffusion_transformer.py` - Diffusion-based generation
|
| 324 |
+
- `modules/rmvpe.py` - Pitch extraction
|
| 325 |
+
- `modules/bigvgan/` - BigVGAN vocoder
|
| 326 |
+
- `dac/` - DAC (Descript Audio Codec)
|
| 327 |
+
|
| 328 |
+
### indextts/utils/ (12+ files, ~500 lines)
|
| 329 |
+
**Purpose:** Text processing, feature extraction, utilities
|
| 330 |
+
|
| 331 |
+
**Key Files:**
|
| 332 |
+
- `front.py` (700L) - TextNormalizer, TextTokenizer
|
| 333 |
+
- `maskgct_utils.py` (250L) - Semantic codec builders
|
| 334 |
+
- `arch_util.py` - Architecture utilities (AttentionBlock)
|
| 335 |
+
- `checkpoint.py` - Model loading
|
| 336 |
+
- `xtransformers.py` (1600L) - Transformer utilities
|
| 337 |
+
- `feature_extractors.py` - Mel spectrogram features
|
| 338 |
+
- `typical_sampling.py` - Sampling strategies
|
| 339 |
+
- `maskgct/` - MaskGCT codec components (~100+ files)
|
| 340 |
+
|
| 341 |
+
### indextts/utils/maskgct/ (~100+ Python files)
|
| 342 |
+
**Purpose:** MaskGCT (Masked Generative Codec Transformer) implementation
|
| 343 |
+
|
| 344 |
+
**Components:**
|
| 345 |
+
- `models/codec/` - Various audio codecs (Amphion, FACodec, SpeechTokenizer, NS3, VEVo, KMeans)
|
| 346 |
+
- `models/tts/maskgct/` - TTS-specific implementations
|
| 347 |
+
- Multiple codec variants with quantization
|
| 348 |
+
|
| 349 |
+
---
|
| 350 |
+
|
| 351 |
+
## 8. CONFIGURATION & MODEL DOWNLOADING
|
| 352 |
+
|
| 353 |
+
### Configuration System (OmegaConf YAML)
|
| 354 |
+
Example config.yaml structure:
|
| 355 |
+
```yaml
|
| 356 |
+
gpt:
|
| 357 |
+
layers: 8
|
| 358 |
+
model_dim: 512
|
| 359 |
+
heads: 8
|
| 360 |
+
max_text_tokens: 120
|
| 361 |
+
max_mel_tokens: 250
|
| 362 |
+
stop_mel_token: 8193
|
| 363 |
+
conformer_config: {...}
|
| 364 |
+
|
| 365 |
+
vocoder:
|
| 366 |
+
name: "nvidia/bigvgan_v2_22khz_80band_256x"
|
| 367 |
+
|
| 368 |
+
s2mel:
|
| 369 |
+
checkpoint: "models/s2mel.pth"
|
| 370 |
+
preprocess_params:
|
| 371 |
+
sr: 22050
|
| 372 |
+
spect_params:
|
| 373 |
+
n_fft: 1024
|
| 374 |
+
hop_length: 256
|
| 375 |
+
n_mels: 80
|
| 376 |
+
|
| 377 |
+
dataset:
|
| 378 |
+
bpe_model: "models/bpe.model"
|
| 379 |
+
|
| 380 |
+
emotions:
|
| 381 |
+
num: [5, 6, 8, ...] # Emotion vector counts per dimension
|
| 382 |
+
|
| 383 |
+
w2v_stat: "models/w2v_stat.pt"
|
| 384 |
+
```
|
| 385 |
+
|
| 386 |
+
### Model Auto-download
|
| 387 |
+
```python
|
| 388 |
+
download_model_from_huggingface(
|
| 389 |
+
local_path="./checkpoints",
|
| 390 |
+
cache_path="./checkpoints/hf_cache"
|
| 391 |
+
)
|
| 392 |
+
```
|
| 393 |
+
|
| 394 |
+
Preloads from HuggingFace:
|
| 395 |
+
- IndexTeam/IndexTTS-2
|
| 396 |
+
- amphion/MaskGCT
|
| 397 |
+
- funasr/campplus
|
| 398 |
+
- facebook/w2v-bert-2.0
|
| 399 |
+
- nvidia/bigvgan_v2_22khz_80band_256x
|
| 400 |
+
|
| 401 |
+
---
|
| 402 |
+
|
| 403 |
+
## 9. INTERFACES
|
| 404 |
+
|
| 405 |
+
### A. Command Line (cli.py - 64 lines)
|
| 406 |
+
```bash
|
| 407 |
+
python -m indextts.cli "Text to synthesize" \
|
| 408 |
+
-v voice_prompt.wav \
|
| 409 |
+
-o output.wav \
|
| 410 |
+
-c checkpoints/config.yaml \
|
| 411 |
+
--model_dir checkpoints \
|
| 412 |
+
--fp16 \
|
| 413 |
+
-d cuda:0
|
| 414 |
+
```
|
| 415 |
+
|
| 416 |
+
### B. Web UI (webui.py - 18KB)
|
| 417 |
+
Gradio-based interface with:
|
| 418 |
+
- Real-time inference
|
| 419 |
+
- Multiple emotion control modes
|
| 420 |
+
- Example cases loading
|
| 421 |
+
- Language selection (Chinese/English)
|
| 422 |
+
- Batch processing
|
| 423 |
+
- Cache management
|
| 424 |
+
|
| 425 |
+
### C. Python API (infer_v2.py)
|
| 426 |
+
```python
|
| 427 |
+
from indextts.infer_v2 import IndexTTS2
|
| 428 |
+
|
| 429 |
+
tts = IndexTTS2(
|
| 430 |
+
cfg_path="checkpoints/config.yaml",
|
| 431 |
+
model_dir="checkpoints",
|
| 432 |
+
use_fp16=True,
|
| 433 |
+
device="cuda:0"
|
| 434 |
+
)
|
| 435 |
+
|
| 436 |
+
audio = tts.infer(
|
| 437 |
+
spk_audio_prompt="speaker.wav",
|
| 438 |
+
text="Hello",
|
| 439 |
+
output_path="output.wav"
|
| 440 |
+
)
|
| 441 |
+
```
|
| 442 |
+
|
| 443 |
+
---
|
| 444 |
+
|
| 445 |
+
## 10. CRITICAL ALGORITHMS TO IMPLEMENT
|
| 446 |
+
|
| 447 |
+
### Priority 1: Core Inference Pipeline
|
| 448 |
+
1. **Text Normalization** - Pattern matching, phoneme handling
|
| 449 |
+
2. **Text Tokenization** - SentencePiece integration
|
| 450 |
+
3. **Semantic Encoding** - W2V-BERT model inference
|
| 451 |
+
4. **GPT Generation** - Token-by-token generation with sampling
|
| 452 |
+
5. **Vocoder** - BigVGAN mel-to-audio conversion
|
| 453 |
+
|
| 454 |
+
### Priority 2: Feature Extraction
|
| 455 |
+
1. **Mel Spectrogram** - STFT, librosa filters
|
| 456 |
+
2. **Speaker Embeddings** - CAMPPlus inference
|
| 457 |
+
3. **Emotion Encoding** - Vector quantization
|
| 458 |
+
4. **Audio Loading/Processing** - Resampling, normalization
|
| 459 |
+
|
| 460 |
+
### Priority 3: Advanced Features
|
| 461 |
+
1. **Conformer Encoding** - Complex attention mechanism
|
| 462 |
+
2. **Perceiver Pooling** - Cross-attention mechanisms
|
| 463 |
+
3. **Flow Matching** - Continuous diffusion
|
| 464 |
+
4. **Length Regulation** - Duration prediction
|
| 465 |
+
|
| 466 |
+
### Priority 4: Optional Optimizations
|
| 467 |
+
1. **CUDA Kernels** - Anti-aliased activations
|
| 468 |
+
2. **DeepSpeed Integration** - Model parallelism
|
| 469 |
+
3. **KV Cache** - Inference optimization
|
| 470 |
+
|
| 471 |
+
---
|
| 472 |
+
|
| 473 |
+
## 11. DATA FLOW EXAMPLE
|
| 474 |
+
|
| 475 |
+
```
|
| 476 |
+
Input: text="δ½ ε₯½", voice="speaker.wav", emotion="happy"
|
| 477 |
+
|
| 478 |
+
1. TextNormalizer.normalize("δ½ ε₯½")
|
| 479 |
+
β "δ½ ε₯½" (no change needed)
|
| 480 |
+
|
| 481 |
+
2. TextTokenizer.encode("δ½ ε₯½")
|
| 482 |
+
β [token_id_1, token_id_2, ...]
|
| 483 |
+
|
| 484 |
+
3. Audio Loading & Processing:
|
| 485 |
+
- Load speaker.wav β 22050 Hz
|
| 486 |
+
- Extract W2V-BERT features
|
| 487 |
+
- Get semantic codes via RepCodec
|
| 488 |
+
- Extract CAMPPlus embedding (192-dim)
|
| 489 |
+
- Compute mel spectrogram
|
| 490 |
+
|
| 491 |
+
4. Emotion Processing:
|
| 492 |
+
- If emotion vector: scale by emotion_alpha
|
| 493 |
+
- If emotion audio: extract embeddings
|
| 494 |
+
- Create emotion conditioning
|
| 495 |
+
|
| 496 |
+
5. GPT Generation:
|
| 497 |
+
- Input: [semantic_codes, text_tokens]
|
| 498 |
+
- Output: mel_tokens (variable length)
|
| 499 |
+
|
| 500 |
+
6. Length Regulation (s2mel):
|
| 501 |
+
- Input: mel_tokens + speaker_style
|
| 502 |
+
- Output: acoustic_codes (fine-grained tokens)
|
| 503 |
+
|
| 504 |
+
7. BigVGAN Vocoding:
|
| 505 |
+
- Input: acoustic_codes β mel_spectrogram
|
| 506 |
+
- Output: waveform at 22050 Hz
|
| 507 |
+
|
| 508 |
+
8. Post-processing:
|
| 509 |
+
- Optional silence insertion
|
| 510 |
+
- Audio normalization
|
| 511 |
+
- WAV file writing
|
| 512 |
+
```
|
| 513 |
+
|
| 514 |
+
---
|
| 515 |
+
|
| 516 |
+
## 12. TESTING
|
| 517 |
+
|
| 518 |
+
### Regression Tests (regression_test.py)
|
| 519 |
+
Tests various scenarios:
|
| 520 |
+
- Chinese text with pinyin tones
|
| 521 |
+
- English text
|
| 522 |
+
- Mixed Chinese/English
|
| 523 |
+
- Long-form text
|
| 524 |
+
- Names and entities
|
| 525 |
+
- Special punctuation
|
| 526 |
+
|
| 527 |
+
### Padding Tests (padding_test.py)
|
| 528 |
+
- Variable length input handling
|
| 529 |
+
- Batch processing
|
| 530 |
+
- Edge cases
|
| 531 |
+
|
| 532 |
+
---
|
| 533 |
+
|
| 534 |
+
## 13. FILE STATISTICS SUMMARY
|
| 535 |
+
|
| 536 |
+
| Category | Count | Lines |
|
| 537 |
+
|----------|-------|-------|
|
| 538 |
+
| Python Files | 194 | ~25,000+ |
|
| 539 |
+
| GPT Module | 9 | 16,953 |
|
| 540 |
+
| BigVGAN | 6+ | ~1,000+ |
|
| 541 |
+
| Utils | 12+ | ~500 |
|
| 542 |
+
| MaskGCT | 100+ | ~10,000+ |
|
| 543 |
+
| S2Mel | 10+ | ~2,000+ |
|
| 544 |
+
| Root Level | 3 | 730 |
|
| 545 |
+
|
| 546 |
+
---
|
| 547 |
+
|
| 548 |
+
## 14. KEY TECHNICAL CHALLENGES FOR RUST CONVERSION
|
| 549 |
+
|
| 550 |
+
1. **PyTorch Model Loading** β Need ONNX export or custom binary format
|
| 551 |
+
2. **Text Normalization Libraries** β May need Rust bindings or reimplementation
|
| 552 |
+
3. **Complex Attention Mechanisms** β Transformers, Perceiver, Conformer
|
| 553 |
+
4. **Mel Spectrogram Computation** β STFT, librosa filter banks
|
| 554 |
+
5. **Quantization & Codecs** β Multiple codec implementations
|
| 555 |
+
6. **Large Model Inference** β Optimization, batching, caching
|
| 556 |
+
7. **CUDA Kernels** β Custom activation functions (if needed)
|
| 557 |
+
8. **Web Server Integration** β Replace Gradio with Rust web framework
|
| 558 |
+
|
| 559 |
+
---
|
| 560 |
+
|
| 561 |
+
## 15. DEPENDENCY CONVERSION ROADMAP
|
| 562 |
+
|
| 563 |
+
| Python Library | Rust Alternative | Priority |
|
| 564 |
+
|---|---|---|
|
| 565 |
+
| torch/transformers | ort, tch-rs, candle | Critical |
|
| 566 |
+
| librosa | rustfft, dasp_signal | Critical |
|
| 567 |
+
| sentencepiece | sentencepiece, tokenizers | Critical |
|
| 568 |
+
| numpy | ndarray, nalgebra | Critical |
|
| 569 |
+
| jieba | jieba-rs | High |
|
| 570 |
+
| torchaudio | dasp, wav, hound | High |
|
| 571 |
+
| gradio | actix-web, rocket, axum | Medium |
|
| 572 |
+
| OmegaConf | serde, config-rs | Medium |
|
| 573 |
+
| safetensors | safetensors-rs | High |
|
| 574 |
+
|
| 575 |
+
---
|
| 576 |
+
|
| 577 |
+
## Summary
|
| 578 |
+
|
| 579 |
+
IndexTTS is a sophisticated, state-of-the-art TTS system with:
|
| 580 |
+
- **194 Python files** across multiple specialized modules
|
| 581 |
+
- **Multi-stage processing pipeline** from text to audio
|
| 582 |
+
- **Advanced neural architectures** (Conformer, Perceiver, GPT, BigVGAN)
|
| 583 |
+
- **Multi-language support** with emotion control
|
| 584 |
+
- **Production-ready** with web UI and CLI interfaces
|
| 585 |
+
- **Heavy reliance on PyTorch** and HuggingFace ecosystems
|
| 586 |
+
- **Large external models** requiring careful integration
|
| 587 |
+
|
| 588 |
+
The Rust conversion will require careful translation of:
|
| 589 |
+
1. Complex text processing pipelines
|
| 590 |
+
2. Neural network inference engines
|
| 591 |
+
3. Audio DSP operations
|
| 592 |
+
4. Model loading and management
|
| 593 |
+
5. Web interface integration
|
| 594 |
+
|
DIRECTORY_STRUCTURE.txt
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
| 1 |
+
IndexTTS-Rust/ (Complete Directory Structure)
|
| 2 |
+
β
|
| 3 |
+
βββ indextts/ # Main Python package (194 files)
|
| 4 |
+
β β
|
| 5 |
+
β βββ __init__.py # Package initialization
|
| 6 |
+
β βββ cli.py # Command-line interface (64 lines)
|
| 7 |
+
β βββ infer.py # Original inference (v1) - 690 lines
|
| 8 |
+
β βββ infer_v2.py # Main inference v2 - 739 lines βββ
|
| 9 |
+
β β
|
| 10 |
+
β βββ gpt/ # GPT-based TTS model (9 files, 16,953 lines)
|
| 11 |
+
β β βββ __init__.py
|
| 12 |
+
β β βββ model.py # Original UnifiedVoice (713L)
|
| 13 |
+
β β βββ model_v2.py # UnifiedVoice v2 βββ (747L)
|
| 14 |
+
β β βββ conformer_encoder.py # Conformer encoder ββ (520L)
|
| 15 |
+
β β βββ perceiver.py # Perceiver resampler (317L)
|
| 16 |
+
β β βββ conformer_encoder.py # Conformer components
|
| 17 |
+
β β βββ transformers_gpt2.py # GPT2 implementation (1,878L)
|
| 18 |
+
β β βββ transformers_generation_utils.py # Generation utilities (4,747L)
|
| 19 |
+
β β βββ transformers_beam_search.py # Beam search (1,013L)
|
| 20 |
+
β β βββ transformers_modeling_utils.py # Model utilities (5,525L)
|
| 21 |
+
β β
|
| 22 |
+
β βββ BigVGAN/ # Neural Vocoder (6+ files, ~1000+ lines)
|
| 23 |
+
β β βββ __init__.py
|
| 24 |
+
β β βββ models.py # BigVGAN architecture βββ
|
| 25 |
+
β β βββ ECAPA_TDNN.py # Speaker encoder
|
| 26 |
+
β β βββ activations.py # Snake, SnakeBeta activations
|
| 27 |
+
β β βββ utils.py # Helper functions
|
| 28 |
+
β β β
|
| 29 |
+
β β βββ alias_free_activation/ # CUDA kernel variants
|
| 30 |
+
β β β βββ cuda/
|
| 31 |
+
β β β β βββ activation1d.py # CUDA kernel loader
|
| 32 |
+
β β β β βββ load.py
|
| 33 |
+
β β β βββ torch/
|
| 34 |
+
β β β βββ act.py # PyTorch activation
|
| 35 |
+
β β β βββ filter.py # Anti-aliasing filter
|
| 36 |
+
β β β βββ resample.py # Resampling
|
| 37 |
+
β β β
|
| 38 |
+
β β βββ alias_free_torch/ # PyTorch-only fallback
|
| 39 |
+
β β β βββ act.py
|
| 40 |
+
β β β βββ filter.py
|
| 41 |
+
β β β βββ resample.py
|
| 42 |
+
β β β
|
| 43 |
+
β β βββ nnet/ # Network modules
|
| 44 |
+
β β βββ linear.py
|
| 45 |
+
β β βββ normalization.py
|
| 46 |
+
β β βββ CNN.py
|
| 47 |
+
β β
|
| 48 |
+
β βββ s2mel/ # Semantic-to-Mel Models (~500+ lines)
|
| 49 |
+
β β βββ modules/ # Core modules (10+ files)
|
| 50 |
+
β β β βββ audio.py # Mel-spectrogram computation β
|
| 51 |
+
β β β βββ commons.py # Common utilities (21KB)
|
| 52 |
+
β β β βββ layers.py # NN layers (13KB)
|
| 53 |
+
β β β βββ length_regulator.py # Duration modeling
|
| 54 |
+
β β β βββ flow_matching.py # Continuous flow matching
|
| 55 |
+
β β β βββ diffusion_transformer.py # Diffusion model
|
| 56 |
+
β β β βββ rmvpe.py # Pitch extraction (22KB)
|
| 57 |
+
β β β βββ quantize.py # Quantization
|
| 58 |
+
β β β βββ encodec.py # EnCodec codec
|
| 59 |
+
β β β βββ wavenet.py # WaveNet implementation
|
| 60 |
+
β β β β
|
| 61 |
+
β β β βββ bigvgan/ # BigVGAN vocoder
|
| 62 |
+
β β β β βββ modules.py
|
| 63 |
+
β β β β βββ config.json
|
| 64 |
+
β β β β βββ bigvgan.py
|
| 65 |
+
β β β β βββ alias_free_activation/ # Variants
|
| 66 |
+
β β β β βββ models.py
|
| 67 |
+
β β β β
|
| 68 |
+
β β β βββ vocos/ # Vocos codec
|
| 69 |
+
β β β βββ hifigan/ # HiFiGAN vocoder
|
| 70 |
+
β β β βββ openvoice/ # OpenVoice components (11 files)
|
| 71 |
+
β β β βββ campplus/ # CAMPPlus speaker encoder
|
| 72 |
+
β β β β βββ DTDNN.py # DTDNN architecture
|
| 73 |
+
β β β βββ gpt_fast/ # Fast GPT inference
|
| 74 |
+
β β β
|
| 75 |
+
β β βββ dac/ # DAC codec
|
| 76 |
+
β β β βββ model/
|
| 77 |
+
β β β βββ nn/
|
| 78 |
+
β β β βββ utils/
|
| 79 |
+
β β β
|
| 80 |
+
β β ββοΏ½οΏ½οΏ½ (other s2mel implementations)
|
| 81 |
+
β β
|
| 82 |
+
β βββ utils/ # Text & Feature Utils (12+ files, ~500L)
|
| 83 |
+
β β βββ __init__.py
|
| 84 |
+
β β βββ front.py # TextNormalizer, TextTokenizer βββ (700L)
|
| 85 |
+
β β βββ maskgct_utils.py # Semantic codec builders (250L)
|
| 86 |
+
β β βββ arch_util.py # AttentionBlock, utilities
|
| 87 |
+
β β βββ checkpoint.py # Model loading
|
| 88 |
+
β β βββ xtransformers.py # Transformer utils (1,600L)
|
| 89 |
+
β β βββ feature_extractors.py # MelSpectrogramFeatures
|
| 90 |
+
β β βββ common.py # Common functions
|
| 91 |
+
β β βββ text_utils.py # Text utilities
|
| 92 |
+
β β βββ typical_sampling.py # TypicalLogitsWarper sampling
|
| 93 |
+
β β βββ utils.py # General utils
|
| 94 |
+
β β βββ webui_utils.py # Web UI helpers
|
| 95 |
+
β β βββ tagger_cache/ # Text normalization cache
|
| 96 |
+
β β β
|
| 97 |
+
β β βββ maskgct/ # MaskGCT codec (100+ files, 10KB+)
|
| 98 |
+
β β βββ models/
|
| 99 |
+
β β βββ codec/ # Multiple codec implementations
|
| 100 |
+
β β β βββ amphion_codec/ # Amphion codec
|
| 101 |
+
β β β β βββ codec.py
|
| 102 |
+
β β β β βββ vocos.py
|
| 103 |
+
β β β β βββ quantize/ # Quantization
|
| 104 |
+
β β β β βββ vector_quantize.py
|
| 105 |
+
β β β β βββ residual_vq.py
|
| 106 |
+
β β β β βββ factorized_vector_quantize.py
|
| 107 |
+
β β β β βββ lookup_free_quantize.py
|
| 108 |
+
β β β β
|
| 109 |
+
β β β βββ facodec/ # FACodec variant
|
| 110 |
+
β β β β βββ facodec_inference.py
|
| 111 |
+
β β β β βββ modules/
|
| 112 |
+
β β β β β βββ commons.py
|
| 113 |
+
β β β β β βββ attentions.py
|
| 114 |
+
β β β β β βββ layers.py
|
| 115 |
+
β β β β β βββ quantize.py
|
| 116 |
+
β β β β β βββ wavenet.py
|
| 117 |
+
β β β β β βββ style_encoder.py
|
| 118 |
+
β β β β β βββ gradient_reversal.py
|
| 119 |
+
β β β β β βββ JDC/ (pitch detection)
|
| 120 |
+
β β β β βββ alias_free_torch/ # Anti-aliasing
|
| 121 |
+
β β β β
|
| 122 |
+
β β β βββ speechtokenizer/ # Speech Tokenizer codec
|
| 123 |
+
β β β β βββ model.py
|
| 124 |
+
β β β β βββ modules/
|
| 125 |
+
β β β β βββ seanet.py
|
| 126 |
+
β β β β βββ lstm.py
|
| 127 |
+
β β β β βββ norm.py
|
| 128 |
+
β β β β βββ conv.py
|
| 129 |
+
β β β β βββ quantization/
|
| 130 |
+
β β β β
|
| 131 |
+
β β β βββ ns3_codec/ # NS3 codec variant
|
| 132 |
+
β β β βββ vevo/ # VEVo codec
|
| 133 |
+
β β β βββ kmeans/ # KMeans codec
|
| 134 |
+
β β β βββ melvqgan/ # MelVQ-GAN codec
|
| 135 |
+
β β β β
|
| 136 |
+
β β β βββ codec_inference.py
|
| 137 |
+
β β β βββ codec_sampler.py
|
| 138 |
+
β β β βββ codec_trainer.py
|
| 139 |
+
β β β βββ codec_dataset.py
|
| 140 |
+
β β β
|
| 141 |
+
β β βββ tts/
|
| 142 |
+
β β βββ maskgct/
|
| 143 |
+
β β βββ maskgct_s2a.py # Semantic-to-acoustic
|
| 144 |
+
β β βββ ckpt/
|
| 145 |
+
β β
|
| 146 |
+
β βββ vqvae/ # Vector Quantized VAE
|
| 147 |
+
β βββ xtts_dvae.py # Discrete VAE (currently disabled)
|
| 148 |
+
β βββ (other VAE components)
|
| 149 |
+
β
|
| 150 |
+
βββ examples/ # Sample Data & Test Cases
|
| 151 |
+
β βββ cases.jsonl # Example test cases
|
| 152 |
+
β βββ voice_*.wav # Sample voice prompts (12 files)
|
| 153 |
+
β βββ emo_*.wav # Emotion reference samples (2 files)
|
| 154 |
+
β βββ sample_prompt.wav # Default prompt (implied)
|
| 155 |
+
β
|
| 156 |
+
βββ tests/ # Test Suite
|
| 157 |
+
β βββ regression_test.py # Main regression tests β
|
| 158 |
+
β βββ padding_test.py # Padding/batch tests
|
| 159 |
+
β
|
| 160 |
+
βββ tools/ # Utility Scripts & i18n
|
| 161 |
+
β βββ download_files.py # Model downloading from HF
|
| 162 |
+
β βββ i18n/ # Internationalization
|
| 163 |
+
β βββ i18n.py # Translation system
|
| 164 |
+
β βββ scan_i18n.py # i18n scanner
|
| 165 |
+
β βββ locale/
|
| 166 |
+
β βββ en_US.json # English translations
|
| 167 |
+
β βββ zh_CN.json # Chinese translations
|
| 168 |
+
β
|
| 169 |
+
βββ archive/ # Historical Docs
|
| 170 |
+
β βββ README_INDEXTTS_1_5.md # IndexTTS 1.5 documentation
|
| 171 |
+
β
|
| 172 |
+
βββ webui.py # Gradio Web UI βββ (18KB)
|
| 173 |
+
βββ cli.py # Command-line interface
|
| 174 |
+
βββ requirements.txt # Python dependencies
|
| 175 |
+
βββ MANIFEST.in # Package manifest
|
| 176 |
+
βββ .gitignore # Git ignore rules
|
| 177 |
+
βββ .gitattributes # Git attributes
|
| 178 |
+
βββ LICENSE # Apache 2.0 License
|
| 179 |
+
|
| 180 |
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 181 |
+
KEY FILES BY IMPORTANCE:
|
| 182 |
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 183 |
+
|
| 184 |
+
βββ CRITICAL (Core Logic - MUST Convert First)
|
| 185 |
+
1. indextts/infer_v2.py - Main inference pipeline (739L)
|
| 186 |
+
2. indextts/gpt/model_v2.py - UnifiedVoice GPT model (747L)
|
| 187 |
+
3. indextts/utils/front.py - Text processing (700L)
|
| 188 |
+
4. indextts/BigVGAN/models.py - Vocoder (1000+L)
|
| 189 |
+
5. indextts/s2mel/modules/audio.py - Mel-spectrogram (83L, critical DSP)
|
| 190 |
+
|
| 191 |
+
ββ HIGH PRIORITY (Major Components)
|
| 192 |
+
1. indextts/gpt/conformer_encoder.py - Conformer blocks (520L)
|
| 193 |
+
2. indextts/gpt/perceiver.py - Perceiver attention (317L)
|
| 194 |
+
3. indextts/utils/maskgct_utils.py - Codec builders (250L)
|
| 195 |
+
4. indextts/s2mel/modules/commons.py - Common utilities (21KB)
|
| 196 |
+
|
| 197 |
+
β MEDIUM PRIORITY (Utilities & Optimization)
|
| 198 |
+
1. indextts/utils/xtransformers.py - Transformer utils (1,600L)
|
| 199 |
+
2. indextts/BigVGAN/activations.py - Activation functions
|
| 200 |
+
3. indextts/s2mel/modules/rmvpe.py - Pitch extraction (22KB)
|
| 201 |
+
|
| 202 |
+
OPTIONAL (Web UI, Tools)
|
| 203 |
+
1. webui.py - Gradio interface
|
| 204 |
+
2. tools/download_files.py - Model downloading
|
| 205 |
+
|
| 206 |
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 207 |
+
TOTAL STATISTICS:
|
| 208 |
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 209 |
+
Total Python Files: 194
|
| 210 |
+
Total Lines of Code: ~25,000+
|
| 211 |
+
GPT Module: 16,953 lines
|
| 212 |
+
MaskGCT Codecs: ~10,000+ lines
|
| 213 |
+
S2Mel Models: ~2,000+ lines
|
| 214 |
+
BigVGAN: ~1,000+ lines
|
| 215 |
+
Utils: ~500 lines
|
| 216 |
+
Tests: ~100 lines
|
| 217 |
+
|
| 218 |
+
Models Supported: 6 major HuggingFace models
|
| 219 |
+
Languages: Chinese (full), English (full), Mixed
|
| 220 |
+
Emotion Dimensions: 8-dimensional emotion control
|
| 221 |
+
Audio Sample Rate: 22,050 Hz (primary)
|
|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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# IndexTTS-Rust Codebase Exploration - Complete Summary
|
| 2 |
+
|
| 3 |
+
## Overview
|
| 4 |
+
|
| 5 |
+
I have conducted a **comprehensive exploration** of the IndexTTS-Rust codebase. This is a sophisticated zero-shot multi-lingual Text-to-Speech (TTS) system currently implemented in Python that is being converted to Rust.
|
| 6 |
+
|
| 7 |
+
## Key Findings
|
| 8 |
+
|
| 9 |
+
### Project Status
|
| 10 |
+
- **Current State**: Pure Python implementation with PyTorch backend
|
| 11 |
+
- **Target State**: Rust implementation (conversion in progress)
|
| 12 |
+
- **Files**: 194 Python files across multiple specialized modules
|
| 13 |
+
- **Code Volume**: ~25,000+ lines of Python code
|
| 14 |
+
- **No Rust code exists yet** - this is a fresh rewrite opportunity
|
| 15 |
+
|
| 16 |
+
### What IndexTTS Does
|
| 17 |
+
IndexTTS is an **industrial-level text-to-speech system** that:
|
| 18 |
+
1. Takes text input (Chinese, English, or mixed languages)
|
| 19 |
+
2. Takes a reference speaker audio file (voice prompt)
|
| 20 |
+
3. Generates high-quality speech in the speaker's voice with:
|
| 21 |
+
- Pinyin-based pronunciation control (for Chinese)
|
| 22 |
+
- Emotion control via 8-dimensional emotion vectors
|
| 23 |
+
- Text-based emotion guidance (via Qwen model)
|
| 24 |
+
- Punctuation-based pause control
|
| 25 |
+
- Style reference audio support
|
| 26 |
+
|
| 27 |
+
### Performance Metrics
|
| 28 |
+
- **Best in class**: WER 0.821 on Chinese test set, 1.606 on English
|
| 29 |
+
- **Outperforms**: SeedTTS, CosyVoice2, F5-TTS, MaskGCT, others
|
| 30 |
+
- **Multi-language**: Full Chinese + English support, mixed language support
|
| 31 |
+
- **Speed**: Parallel inference available, batch processing support
|
| 32 |
+
|
| 33 |
+
## Architecture Overview
|
| 34 |
+
|
| 35 |
+
### Main Pipeline Flow
|
| 36 |
+
```
|
| 37 |
+
Text Input
|
| 38 |
+
β (TextNormalizer)
|
| 39 |
+
Normalized Text
|
| 40 |
+
β (TextTokenizer + SentencePiece)
|
| 41 |
+
Text Tokens
|
| 42 |
+
β (W2V-BERT)
|
| 43 |
+
Semantic Embeddings
|
| 44 |
+
β (RepCodec)
|
| 45 |
+
Semantic Codes + Speaker Features (CAMPPlus) + Emotion Vectors
|
| 46 |
+
β (UnifiedVoice GPT Model)
|
| 47 |
+
Mel-spectrogram Tokens
|
| 48 |
+
β (S2Mel Length Regulator)
|
| 49 |
+
Acoustic Codes
|
| 50 |
+
β (BigVGAN Vocoder)
|
| 51 |
+
Audio Waveform (22,050 Hz)
|
| 52 |
+
```
|
| 53 |
+
|
| 54 |
+
## Critical Components to Convert
|
| 55 |
+
|
| 56 |
+
### Priority 1: MUST Convert First (Core Pipeline)
|
| 57 |
+
1. **infer_v2.py** (739 lines) - Main inference orchestration
|
| 58 |
+
2. **model_v2.py** (747 lines) - UnifiedVoice GPT model
|
| 59 |
+
3. **front.py** (700 lines) - Text normalization and tokenization
|
| 60 |
+
4. **BigVGAN/models.py** (1000+ lines) - Neural vocoder
|
| 61 |
+
5. **s2mel/modules/audio.py** (83 lines) - Mel-spectrogram DSP
|
| 62 |
+
|
| 63 |
+
### Priority 2: High Priority (Major Components)
|
| 64 |
+
1. **conformer_encoder.py** (520 lines) - Speaker encoder
|
| 65 |
+
2. **perceiver.py** (317 lines) - Attention pooling mechanism
|
| 66 |
+
3. **maskgct_utils.py** (250 lines) - Semantic codec builders
|
| 67 |
+
4. Various supporting modules for codec and transformer utilities
|
| 68 |
+
|
| 69 |
+
### Priority 3: Medium Priority (Optimization & Utilities)
|
| 70 |
+
1. Advanced transformer utilities
|
| 71 |
+
2. Activation functions and filters
|
| 72 |
+
3. Pitch extraction and flow matching
|
| 73 |
+
4. Optional CUDA kernels for optimization
|
| 74 |
+
|
| 75 |
+
## Technology Stack
|
| 76 |
+
|
| 77 |
+
### Current (Python)
|
| 78 |
+
- **Framework**: PyTorch (inference only)
|
| 79 |
+
- **Text Processing**: SentencePiece, WeTextProcessing, regex
|
| 80 |
+
- **Audio**: librosa, torchaudio, scipy
|
| 81 |
+
- **Models**: HuggingFace Transformers
|
| 82 |
+
- **Web UI**: Gradio
|
| 83 |
+
|
| 84 |
+
### Pre-trained Models (6 Major)
|
| 85 |
+
1. **IndexTTS-2** (~2GB) - Main TTS model
|
| 86 |
+
2. **W2V-BERT-2.0** (~1GB) - Semantic features
|
| 87 |
+
3. **MaskGCT** - Semantic codec
|
| 88 |
+
4. **CAMPPlus** (~100MB) - Speaker embeddings
|
| 89 |
+
5. **BigVGAN v2** (~100MB) - Vocoder
|
| 90 |
+
6. **Qwen** (variable) - Emotion detection
|
| 91 |
+
|
| 92 |
+
## File Organization
|
| 93 |
+
|
| 94 |
+
### Core Modules
|
| 95 |
+
- **indextts/gpt/** - GPT-based sequence generation (9 files, 16,953 lines)
|
| 96 |
+
- **indextts/BigVGAN/** - Neural vocoder (6+ files, 1000+ lines)
|
| 97 |
+
- **indextts/s2mel/** - Semantic-to-mel models (10+ files, 2000+ lines)
|
| 98 |
+
- **indextts/utils/** - Text processing and utilities (12+ files, 500 lines)
|
| 99 |
+
- **indextts/utils/maskgct/** - MaskGCT codecs (100+ files, 10000+ lines)
|
| 100 |
+
|
| 101 |
+
### Interfaces
|
| 102 |
+
- **webui.py** (18KB) - Gradio web interface
|
| 103 |
+
- **cli.py** (64 lines) - Command-line interface
|
| 104 |
+
- **infer.py/infer_v2.py** - Python API
|
| 105 |
+
|
| 106 |
+
### Data & Config
|
| 107 |
+
- **examples/** - Sample audio files and test cases
|
| 108 |
+
- **tests/** - Regression and padding tests
|
| 109 |
+
- **tools/** - Model downloading and i18n support
|
| 110 |
+
|
| 111 |
+
## Detailed Documentation Generated
|
| 112 |
+
|
| 113 |
+
Three comprehensive documents have been created and saved to the repository:
|
| 114 |
+
|
| 115 |
+
1. **CODEBASE_ANALYSIS.md** (19 KB)
|
| 116 |
+
- Executive summary
|
| 117 |
+
- Complete project structure
|
| 118 |
+
- Current implementation details
|
| 119 |
+
- TTS pipeline explanation
|
| 120 |
+
- Algorithms and components breakdown
|
| 121 |
+
- Inference modes and capabilities
|
| 122 |
+
- Dependency conversion roadmap
|
| 123 |
+
|
| 124 |
+
2. **DIRECTORY_STRUCTURE.txt** (14 KB)
|
| 125 |
+
- Complete file tree with annotations
|
| 126 |
+
- Files grouped by importance (βββ, ββ, β)
|
| 127 |
+
- Line counts for each file
|
| 128 |
+
- Statistics summary
|
| 129 |
+
|
| 130 |
+
3. **SOURCE_FILE_LISTING.txt** (23 KB)
|
| 131 |
+
- Detailed file-by-file breakdown
|
| 132 |
+
- Classes and methods for each major file
|
| 133 |
+
- Parameter specifications
|
| 134 |
+
- Algorithm descriptions
|
| 135 |
+
- Dependencies for each component
|
| 136 |
+
|
| 137 |
+
## Key Technical Challenges for Rust Conversion
|
| 138 |
+
|
| 139 |
+
### High Complexity
|
| 140 |
+
1. **PyTorch Model Loading** - Need ONNX export or custom format
|
| 141 |
+
2. **Complex Attention Mechanisms** - Transformers, Perceiver, Conformer
|
| 142 |
+
3. **Text Normalization Libraries** - May need Rust bindings or reimplementation
|
| 143 |
+
4. **Mel Spectrogram Computation** - STFT, mel filterbank calculations
|
| 144 |
+
|
| 145 |
+
### Medium Complexity
|
| 146 |
+
1. **Quantization & Codecs** - Multiple codec implementations to translate
|
| 147 |
+
2. **Large Model Inference** - Optimization, batching, caching required
|
| 148 |
+
3. **Audio DSP** - Resampling, filtering, spectral operations
|
| 149 |
+
|
| 150 |
+
### Optimization (Optional)
|
| 151 |
+
1. CUDA kernels for anti-aliased activations
|
| 152 |
+
2. DeepSpeed integration for model parallelism
|
| 153 |
+
3. KV cache for inference optimization
|
| 154 |
+
|
| 155 |
+
## Recommended Rust Libraries
|
| 156 |
+
|
| 157 |
+
| Component | Python Library | Rust Alternative |
|
| 158 |
+
|---|---|---|
|
| 159 |
+
| Model Inference | torch/transformers | **ort**, tch-rs, candle |
|
| 160 |
+
| Audio Processing | librosa | rustfft, dasp_signal |
|
| 161 |
+
| Text Tokenization | sentencepiece | sentencepiece (Rust binding) |
|
| 162 |
+
| Numerical Computing | numpy | **ndarray**, nalgebra |
|
| 163 |
+
| Chinese Text | jieba | **jieba-rs** |
|
| 164 |
+
| Audio I/O | torchaudio | hound, wav |
|
| 165 |
+
| Web Server | Gradio | **axum**, actix-web |
|
| 166 |
+
| Config Files | OmegaConf YAML | **serde**, config-rs |
|
| 167 |
+
| Model Format | safetensors | **safetensors-rs** |
|
| 168 |
+
|
| 169 |
+
## Data Flow Example
|
| 170 |
+
|
| 171 |
+
### Input
|
| 172 |
+
- Text: "δ½ ε₯½" (Chinese for "Hello")
|
| 173 |
+
- Speaker Audio: "speaker.wav" (voice reference)
|
| 174 |
+
- Emotion: "happy" (optional)
|
| 175 |
+
|
| 176 |
+
### Processing Steps
|
| 177 |
+
1. Text Normalization β "δ½ ε₯½" (no change)
|
| 178 |
+
2. Text Tokenization β [token_1, token_2, ...]
|
| 179 |
+
3. Audio Loading & Mel-spectrogram computation
|
| 180 |
+
4. W2V-BERT semantic embedding extraction
|
| 181 |
+
5. Speaker feature extraction (CAMPPlus)
|
| 182 |
+
6. Emotion vector generation
|
| 183 |
+
7. GPT generation of mel-tokens
|
| 184 |
+
8. Length regulation for acoustic codes
|
| 185 |
+
9. BigVGAN vocoding
|
| 186 |
+
10. Audio output at 22,050 Hz
|
| 187 |
+
|
| 188 |
+
### Output
|
| 189 |
+
- Waveform: "output.wav" (high-quality speech)
|
| 190 |
+
|
| 191 |
+
## Test Coverage
|
| 192 |
+
|
| 193 |
+
### Regression Tests Available
|
| 194 |
+
- Chinese text with pinyin tones
|
| 195 |
+
- English text
|
| 196 |
+
- Mixed Chinese-English
|
| 197 |
+
- Long-form text passages
|
| 198 |
+
- Named entities (proper nouns)
|
| 199 |
+
- Special punctuation handling
|
| 200 |
+
|
| 201 |
+
## Performance Characteristics
|
| 202 |
+
|
| 203 |
+
### Speed
|
| 204 |
+
- Single inference: ~2-5 seconds per sentence (GPU)
|
| 205 |
+
- Batch/fast inference: Parallel processing available
|
| 206 |
+
- Caching: Speaker features and mel spectrograms are cached
|
| 207 |
+
|
| 208 |
+
### Quality
|
| 209 |
+
- 22,050 Hz sample rate (CD-quality audio)
|
| 210 |
+
- 80-dimensional mel-spectrogram
|
| 211 |
+
- 8-channel emotion control
|
| 212 |
+
- Natural speech synthesis with speaker similarity
|
| 213 |
+
|
| 214 |
+
### Model Parameters
|
| 215 |
+
- GPT Model: 8 layers, 512 dims, 8 heads
|
| 216 |
+
- Max text tokens: 120
|
| 217 |
+
- Max mel tokens: 250
|
| 218 |
+
- Mel spectrogram bins: 80
|
| 219 |
+
- Emotion dimensions: 8
|
| 220 |
+
|
| 221 |
+
## Next Steps for Rust Conversion
|
| 222 |
+
|
| 223 |
+
### Phase 1: Foundation
|
| 224 |
+
1. Set up Rust project structure
|
| 225 |
+
2. Create model loading infrastructure (ONNX or binary format)
|
| 226 |
+
3. Implement basic tensor operations using ndarray/candle
|
| 227 |
+
|
| 228 |
+
### Phase 2: Core Pipeline
|
| 229 |
+
1. Implement text normalization (regex + patterns)
|
| 230 |
+
2. Implement SentencePiece tokenization
|
| 231 |
+
3. Create mel-spectrogram DSP module
|
| 232 |
+
4. Implement BigVGAN vocoder
|
| 233 |
+
|
| 234 |
+
### Phase 3: Neural Components
|
| 235 |
+
1. Implement transformer layers
|
| 236 |
+
2. Implement Conformer encoder
|
| 237 |
+
3. Implement Perceiver resampler
|
| 238 |
+
4. Implement GPT generation
|
| 239 |
+
|
| 240 |
+
### Phase 4: Integration
|
| 241 |
+
1. Integrate all components
|
| 242 |
+
2. Create CLI interface
|
| 243 |
+
3. Create REST API or server interface
|
| 244 |
+
4. Optimize and profile
|
| 245 |
+
|
| 246 |
+
### Phase 5: Testing & Deployment
|
| 247 |
+
1. Regression testing
|
| 248 |
+
2. Performance benchmarking
|
| 249 |
+
3. Documentation
|
| 250 |
+
4. Deployment optimization
|
| 251 |
+
|
| 252 |
+
## Summary Statistics
|
| 253 |
+
|
| 254 |
+
- **Total Files Analyzed**: 194 Python files
|
| 255 |
+
- **Total Lines of Code**: ~25,000+
|
| 256 |
+
- **Architecture Depth**: 5 major pipeline stages
|
| 257 |
+
- **External Models**: 6 HuggingFace models
|
| 258 |
+
- **Languages Supported**: 2 (Chinese, English, with mixed support)
|
| 259 |
+
- **Dimensions**: Text tokens, mel tokens, emotion vectors, speaker embeddings
|
| 260 |
+
- **DSP Operations**: STFT, mel filterbanks, upsampling, convolution
|
| 261 |
+
- **AI Techniques**: Transformers, Conformers, Perceiver pooling, diffusion-based generation
|
| 262 |
+
|
| 263 |
+
## Conclusion
|
| 264 |
+
|
| 265 |
+
IndexTTS is a **production-ready, state-of-the-art TTS system** with sophisticated architecture and multiple advanced features. The codebase is well-organized with clear separation of concerns, making it suitable for conversion to Rust. The main challenges will be:
|
| 266 |
+
|
| 267 |
+
1. **Model Loading**: Handling PyTorch model weights in Rust
|
| 268 |
+
2. **Text Processing**: Ensuring accuracy in pattern matching and normalization
|
| 269 |
+
3. **Neural Architecture**: Correctly implementing complex attention mechanisms
|
| 270 |
+
4. **Audio DSP**: Precise STFT and mel-spectrogram computation
|
| 271 |
+
|
| 272 |
+
With careful planning and the right library selection, a full Rust conversion is feasible and would offer significant performance benefits and easier deployment.
|
| 273 |
+
|
| 274 |
+
---
|
| 275 |
+
|
| 276 |
+
## Documentation Files
|
| 277 |
+
|
| 278 |
+
All analysis has been saved to the repository:
|
| 279 |
+
- `CODEBASE_ANALYSIS.md` - Comprehensive technical analysis
|
| 280 |
+
- `DIRECTORY_STRUCTURE.txt` - Complete file tree
|
| 281 |
+
- `SOURCE_FILE_LISTING.txt` - Detailed component breakdown
|
| 282 |
+
- `EXPLORATION_SUMMARY.md` - This file
|
| 283 |
+
|
SOURCE_FILE_LISTING.txt
ADDED
|
@@ -0,0 +1,513 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 2 |
+
β DETAILED SOURCE FILE LISTING BY CATEGORY β
|
| 3 |
+
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 4 |
+
|
| 5 |
+
MAIN INFERENCE PIPELINE FILES
|
| 6 |
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 7 |
+
|
| 8 |
+
/home/user/IndexTTS-Rust/indextts/infer_v2.py (739 LINES) βββ CRITICAL
|
| 9 |
+
ββ Purpose: Main TTS inference class (IndexTTS2)
|
| 10 |
+
ββ Key Classes:
|
| 11 |
+
β ββ QwenEmotion (emotion text-to-vector conversion)
|
| 12 |
+
β ββ IndexTTS2 (main inference class)
|
| 13 |
+
β ββ Helper functions for emotion/audio processing
|
| 14 |
+
ββ Key Methods:
|
| 15 |
+
β ββ __init__() - Initialize all models and codecs
|
| 16 |
+
β ββ infer() - Single text generation with emotion control
|
| 17 |
+
β ββ infer_fast() - Parallel segment generation
|
| 18 |
+
β ββ get_emb() - Extract semantic embeddings
|
| 19 |
+
β ββ remove_long_silence() - Silence token removal
|
| 20 |
+
β ββ insert_interval_silence() - Silence insertion
|
| 21 |
+
β ββ Cache management for repeated generation
|
| 22 |
+
ββ Models Loaded:
|
| 23 |
+
β ββ UnifiedVoice (GPT model for mel token generation)
|
| 24 |
+
β ββ W2V-BERT (semantic feature extraction)
|
| 25 |
+
β ββ RepCodec (semantic codec)
|
| 26 |
+
β ββ S2Mel model (semantic-to-mel conversion)
|
| 27 |
+
β ββ CAMPPlus (speaker embedding)
|
| 28 |
+
β ββ BigVGAN vocoder
|
| 29 |
+
β ββ Qwen-based emotion model
|
| 30 |
+
β ββ Emotion/speaker matrices
|
| 31 |
+
ββ External Dependencies: torch, transformers, librosa, safetensors
|
| 32 |
+
|
| 33 |
+
/home/user/IndexTTS-Rust/webui.py (18KB) βββ WEB INTERFACE
|
| 34 |
+
ββ Purpose: Gradio-based web UI for IndexTTS
|
| 35 |
+
ββ Key Components:
|
| 36 |
+
β ββ Model initialization (IndexTTS2 instance)
|
| 37 |
+
β ββ Language selection (Chinese/English)
|
| 38 |
+
β ββ Emotion control modes (4 modes)
|
| 39 |
+
β ββ Example case loading from cases.jsonl
|
| 40 |
+
β ββ Progress bar integration
|
| 41 |
+
β ββ Output management
|
| 42 |
+
ββ Features:
|
| 43 |
+
β ββ Real-time inference
|
| 44 |
+
β ββ Multiple emotion control methods
|
| 45 |
+
β ββ Batch processing
|
| 46 |
+
β ββ Task caching
|
| 47 |
+
β ββ i18n support
|
| 48 |
+
β ββ Pre-loaded example cases
|
| 49 |
+
ββ Web Framework: Gradio 5.34.1
|
| 50 |
+
|
| 51 |
+
/home/user/IndexTTS-Rust/indextts/cli.py (64 LINES)
|
| 52 |
+
ββ Purpose: Command-line interface
|
| 53 |
+
ββ Usage: python -m indextts.cli <text> -v <voice.wav> -o <output.wav> [options]
|
| 54 |
+
ββ Arguments:
|
| 55 |
+
β ββ text: Text to synthesize
|
| 56 |
+
β ββ -v/--voice: Voice reference audio
|
| 57 |
+
β ββ -o/--output_path: Output file path
|
| 58 |
+
β ββ -c/--config: Config file path
|
| 59 |
+
β ββ --model_dir: Model directory
|
| 60 |
+
β ββ --fp16: Use FP16 precision
|
| 61 |
+
β ββ -d/--device: Device (cpu/cuda/mps/xpu)
|
| 62 |
+
β ββ -f/--force: Force overwrite
|
| 63 |
+
ββ Uses: IndexTTS (v1 model)
|
| 64 |
+
|
| 65 |
+
TEXT PROCESSING & NORMALIZATION FILES
|
| 66 |
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 67 |
+
|
| 68 |
+
/home/user/IndexTTS-Rust/indextts/utils/front.py (700 LINES) βββ CRITICAL
|
| 69 |
+
ββ Purpose: Text normalization and tokenization
|
| 70 |
+
ββ Key Classes:
|
| 71 |
+
β ββ TextNormalizer (700+ lines)
|
| 72 |
+
β β ββ Pattern Definitions:
|
| 73 |
+
β β β ββ PINYIN_TONE_PATTERN (regex for pinyin with tones 1-5)
|
| 74 |
+
β β β ββ NAME_PATTERN (regex for Chinese names)
|
| 75 |
+
β β β ββ ENGLISH_CONTRACTION_PATTERN (regex for 's contractions)
|
| 76 |
+
β β ββ Methods:
|
| 77 |
+
β β β ββ normalize() - Main normalization
|
| 78 |
+
β β β ββ use_chinese() - Language detection
|
| 79 |
+
β β β ββ save_pinyin_tones() - Extract pinyin with tones
|
| 80 |
+
β β β ββ restore_pinyin_tones() - Restore pinyin
|
| 81 |
+
β β β ββ save_names() - Extract names
|
| 82 |
+
β β β ββ restore_names() - Restore names
|
| 83 |
+
β β β ββ correct_pinyin() - Phoneme correction (jqxβv)
|
| 84 |
+
β β β ββ char_rep_map - Character replacement dictionary
|
| 85 |
+
β β ββ Normalizers:
|
| 86 |
+
β β ββ zh_normalizer (Chinese) - Uses WeTextProcessing/wetext
|
| 87 |
+
β β ββ en_normalizer (English) - Uses tn library
|
| 88 |
+
β β
|
| 89 |
+
β ββ TextTokenizer (200+ lines)
|
| 90 |
+
β ββ Methods:
|
| 91 |
+
β β ββ encode() - Text to token IDs
|
| 92 |
+
β β ββ decode() - Token IDs to text
|
| 93 |
+
β β ββ convert_tokens_to_ids()
|
| 94 |
+
β β ββ convert_ids_to_tokens()
|
| 95 |
+
β β ββ Vocab management
|
| 96 |
+
β ββ Special Tokens:
|
| 97 |
+
β β βοΏ½οΏ½ BOS: "<s>" (ID 0)
|
| 98 |
+
β β ββ EOS: "</s>" (ID 1)
|
| 99 |
+
β β ββ UNK: "<unk>"
|
| 100 |
+
β ββ Tokenizer: SentencePiece (BPE-based)
|
| 101 |
+
ββ Language Support:
|
| 102 |
+
β ββ Chinese (simplified & traditional)
|
| 103 |
+
β ββ English
|
| 104 |
+
β ββ Mixed Chinese-English
|
| 105 |
+
ββ Critical Pattern Matching:
|
| 106 |
+
ββ Pinyin tone detection
|
| 107 |
+
ββ Name entity detection
|
| 108 |
+
ββ Email matching
|
| 109 |
+
ββ Character replacement
|
| 110 |
+
ββ Punctuation handling
|
| 111 |
+
|
| 112 |
+
GPT MODEL ARCHITECTURE FILES
|
| 113 |
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 114 |
+
|
| 115 |
+
/home/user/IndexTTS-Rust/indextts/gpt/model_v2.py (747 LINES) βββ CRITICAL
|
| 116 |
+
ββ Purpose: UnifiedVoice GPT-based TTS model
|
| 117 |
+
ββ Key Classes:
|
| 118 |
+
β ββ UnifiedVoice (700+ lines)
|
| 119 |
+
β β ββ Architecture:
|
| 120 |
+
β β β ββ Input Embeddings: Text (256 vocab), Mel (8194 vocab)
|
| 121 |
+
β β β ββ Position Embeddings: Learned embeddings for mel/text
|
| 122 |
+
β β β ββ GPT Transformer: Configurable layers/heads
|
| 123 |
+
β β β ββ Conditioning Encoder: Conformer or Perceiver-based
|
| 124 |
+
β β β ββ Emotion Conditioning: Separate conformer + perceiver
|
| 125 |
+
β β β ββ Output Heads: Text prediction, Mel prediction
|
| 126 |
+
β β β
|
| 127 |
+
β β ββ Parameters:
|
| 128 |
+
β β β ββ layers: 8 (transformer depth)
|
| 129 |
+
β β β ββ model_dim: 512 (embedding dimension)
|
| 130 |
+
β β β ββ heads: 8 (attention heads)
|
| 131 |
+
β β β ββ max_text_tokens: 120
|
| 132 |
+
β β β ββ max_mel_tokens: 250
|
| 133 |
+
β β β ββ number_mel_codes: 8194
|
| 134 |
+
β β β ββ condition_type: "conformer_perceiver" or "conformer_encoder"
|
| 135 |
+
β β β ββ Various activation functions
|
| 136 |
+
β β β
|
| 137 |
+
β β ββ Key Methods:
|
| 138 |
+
β β β ββ forward() - Forward pass
|
| 139 |
+
β β β ββ post_init_gpt2_config() - Initialize for inference
|
| 140 |
+
β β β ββ generate_mel() - Mel token generation
|
| 141 |
+
β β β ββ forward_with_cond_scale() - With classifier-free guidance
|
| 142 |
+
β β β ββ Cache management
|
| 143 |
+
β β β
|
| 144 |
+
β β ββ Conditioning System:
|
| 145 |
+
β β ββ Speaker conditioning via mel spectrogram
|
| 146 |
+
β β ββ Conformer encoder for speaker features
|
| 147 |
+
β β ββ Perceiver for attention pooling
|
| 148 |
+
β β ββ Emotion conditioning (separate pathway)
|
| 149 |
+
β β ββ Emotion vector support (8-dimensional)
|
| 150 |
+
β β
|
| 151 |
+
β ββ ResBlock (40+ lines)
|
| 152 |
+
β β ββ Conv1d layers with GroupNorm
|
| 153 |
+
β β ββ ReLU activation with residual connection
|
| 154 |
+
β β
|
| 155 |
+
β ββ GPT2InferenceModel (200+ lines)
|
| 156 |
+
β β ββ Inference wrapper for GPT2
|
| 157 |
+
β β ββ KV cache support
|
| 158 |
+
β β ββ Model parallelism support
|
| 159 |
+
β β ββ Token-by-token generation
|
| 160 |
+
β β
|
| 161 |
+
β ββ ConditioningEncoder (30 lines)
|
| 162 |
+
β β ββ Conv1d initialization
|
| 163 |
+
β β ββ Attention blocks
|
| 164 |
+
β β ββ Optional mean pooling
|
| 165 |
+
β β
|
| 166 |
+
β ββ MelEncoder (30 lines)
|
| 167 |
+
β β ββ Conv1d layers
|
| 168 |
+
β β ββ ResBlocks
|
| 169 |
+
β β ββ 4x reduction
|
| 170 |
+
β β
|
| 171 |
+
β ββ LearnedPositionEmbeddings (15 lines)
|
| 172 |
+
β β ββ Learnable positional embeddings
|
| 173 |
+
β β
|
| 174 |
+
β ββ build_hf_gpt_transformer() (20 lines)
|
| 175 |
+
β ββ Builds HuggingFace GPT2 with custom embeddings
|
| 176 |
+
β
|
| 177 |
+
ββ External Dependencies: torch, transformers, indextts.gpt modules
|
| 178 |
+
ββ Critical Inference Parameters:
|
| 179 |
+
ββ Temperature control for generation
|
| 180 |
+
ββ Top-k/top-p sampling
|
| 181 |
+
ββ Classifier-free guidance scale
|
| 182 |
+
ββ Generation length limits
|
| 183 |
+
|
| 184 |
+
/home/user/IndexTTS-Rust/indextts/gpt/conformer_encoder.py (520 LINES) ββ
|
| 185 |
+
ββ Purpose: Conformer-based speaker conditioning encoder
|
| 186 |
+
ββ Key Classes:
|
| 187 |
+
β ββ ConformerEncoder (main)
|
| 188 |
+
β β ββ Modules:
|
| 189 |
+
β β β ββ Subsampling layer (Conv2d)
|
| 190 |
+
β β β ββ Positional encoding
|
| 191 |
+
β β β ββ Conformer blocks
|
| 192 |
+
β β β ββ Layer normalization
|
| 193 |
+
β β β ββ Optional projection layer
|
| 194 |
+
β β β
|
| 195 |
+
β β ββ Configuration Parameters:
|
| 196 |
+
β β β ββ input_size: 1024 (mel spectrogram bins)
|
| 197 |
+
β β β ββ output_size: depends on config
|
| 198 |
+
β β β ββ linear_units: hidden dim for FFN
|
| 199 |
+
β β β ββ attention_heads: 8
|
| 200 |
+
β β β ββ num_blocks: 4
|
| 201 |
+
β β β ββ input_layer: "linear" or "conv2d"
|
| 202 |
+
β β β
|
| 203 |
+
β β ββ Architecture: Conv β Pos Enc β [Conformer Block] * N β LayerNorm
|
| 204 |
+
β β
|
| 205 |
+
β ββ ConformerBlock (80+ lines)
|
| 206 |
+
β β ββ Residual connections
|
| 207 |
+
β β ββ FFN β Attention β Conv β FFN structure
|
| 208 |
+
β β ββ Feed-forward network (2-layer with dropout)
|
| 209 |
+
β β ββ Multi-head self-attention
|
| 210 |
+
β β ββ Convolution module (depthwise)
|
| 211 |
+
β β ββ Layer normalization
|
| 212 |
+
β β
|
| 213 |
+
β ββ ConvolutionModule (50 lines)
|
| 214 |
+
β β ββ Pointwise Conv 1x1
|
| 215 |
+
β β ββ Depthwise Conv with kernel_size (e.g., 15)
|
| 216 |
+
β β ββ Batch normalization or layer normalization
|
| 217 |
+
β β ββ Activation (ReLU/SiLU)
|
| 218 |
+
β β ββ Projection
|
| 219 |
+
β β
|
| 220 |
+
β ββ PositionwiseFeedForward (15 lines)
|
| 221 |
+
β β ββ Dense layer (idim β hidden)
|
| 222 |
+
β β ββ Activation (ReLU)
|
| 223 |
+
β β ββ Dropout
|
| 224 |
+
β β ββ Dense layer (hidden β idim)
|
| 225 |
+
β β
|
| 226 |
+
β ββ MultiHeadedAttention (custom)
|
| 227 |
+
β ββ Scaled dot-product attention
|
| 228 |
+
β ββ Multiple heads
|
| 229 |
+
β ββ Optional relative position bias
|
| 230 |
+
β
|
| 231 |
+
ββ External Dependencies: torch, custom conformer modules
|
| 232 |
+
ββ Use Case: Processing mel spectrogram to extract speaker features
|
| 233 |
+
|
| 234 |
+
/home/user/IndexTTS-Rust/indextts/gpt/perceiver.py (317 LINES) ββ
|
| 235 |
+
ββ Purpose: Perceiver resampler for attention pooling
|
| 236 |
+
ββ Key Classes:
|
| 237 |
+
β ββ PerceiverResampler (250+ lines)
|
| 238 |
+
β β ββ Architecture:
|
| 239 |
+
β β β ββ Learnable latent queries
|
| 240 |
+
β β β ββ Cross-attention layers
|
| 241 |
+
β β β ββ Feed-forward networks
|
| 242 |
+
β β β ββ Layer normalization
|
| 243 |
+
β β β
|
| 244 |
+
β β ββ Parameters:
|
| 245 |
+
β β β ββ dim: 512 (embedding dimension)
|
| 246 |
+
β β β ββ dim_context: 512 (context dimension)
|
| 247 |
+
β β β ββ num_latents: 32 (number of latent queries)
|
| 248 |
+
β β β ββ num_latent_channels: 64
|
| 249 |
+
β β β ββ num_layers: 6
|
| 250 |
+
β β β ββ ff_mult: 4 (FFN expansion)
|
| 251 |
+
β β β ββ heads: 8
|
| 252 |
+
β β β
|
| 253 |
+
β β ββ Key Methods:
|
| 254 |
+
β β β ββ forward() - Attend and pool
|
| 255 |
+
β β β ββ _cross_attend_block() - Single cross-attention layer
|
| 256 |
+
β β β
|
| 257 |
+
β β ββ Cross-Attention Mechanism:
|
| 258 |
+
β β ββ Queries: Learnable latents
|
| 259 |
+
β β ββ Keys/Values: Input context
|
| 260 |
+
β β ββ Output: Pooled features (num_latents Γ dim)
|
| 261 |
+
β β ββ FFN projection for dimension mixing
|
| 262 |
+
β β
|
| 263 |
+
β ββ FeedForward (15 lines)
|
| 264 |
+
β ββ Dense (dim β hidden)
|
| 265 |
+
β ββ GELU activation
|
| 266 |
+
β ββ Dense (hidden β dim)
|
| 267 |
+
β
|
| 268 |
+
ββ External Dependencies: torch, einsum operations
|
| 269 |
+
ββ Use Case: Pool conditioning encoder output to fixed-size representation
|
| 270 |
+
|
| 271 |
+
VOCODER & AUDIO SYNTHESIS FILES
|
| 272 |
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 273 |
+
|
| 274 |
+
/home/user/IndexTTS-Rust/indextts/BigVGAN/models.py (1000+ LINES) βββ
|
| 275 |
+
ββ Purpose: BigVGAN neural vocoder for mel-to-audio conversion
|
| 276 |
+
ββ Key Classes:
|
| 277 |
+
β ββ BigVGAN (400+ lines)
|
| 278 |
+
β β ββ Architecture:
|
| 279 |
+
β β β ββ Initial Conv1d (80 mel bins β 192 channels)
|
| 280 |
+
β β β ββ Upsampling layers (transposed conv)
|
| 281 |
+
β β β ββ AMP blocks (anti-aliased multi-period)
|
| 282 |
+
β β β ββ Final Conv1d (channels β 1 waveform)
|
| 283 |
+
β β β ββ Tanh activation for output
|
| 284 |
+
β β β
|
| 285 |
+
β β ββ Upsampling: 4x β 8x β 8x β 4x (256x total)
|
| 286 |
+
β β β ββ Maps from 22050 Hz mel frames to audio samples
|
| 287 |
+
β β β ββ Kernel sizes: [16, 16, 4, 4]
|
| 288 |
+
β β β ββ Padding: [6, 6, 2, 2]
|
| 289 |
+
β β β
|
| 290 |
+
β β ββ Parameters:
|
| 291 |
+
β β β ββ num_mels: 80
|
| 292 |
+
β β β ββ num_freq: 513
|
| 293 |
+
β β β ββ num_mels: 80
|
| 294 |
+
β β β ββ n_fft: 1024
|
| 295 |
+
β β β ββ hop_size: 256
|
| 296 |
+
β β β ββ win_size: 1024
|
| 297 |
+
β β β ββ sampling_rate: 22050
|
| 298 |
+
β β β ββ freq_min: 0
|
| 299 |
+
β β β ββ freq_max: None
|
| 300 |
+
β β β ββ use_cuda_kernel: bool
|
| 301 |
+
β β β
|
| 302 |
+
β β ββ Key Methods:
|
| 303 |
+
β β β ββ forward() - Mel β audio waveform
|
| 304 |
+
β β β ββ from_pretrained() - Load from HuggingFace
|
| 305 |
+
β β β ββ remove_weight_norm() - Remove spectral normalization
|
| 306 |
+
β β β ββ eval() - Set to evaluation mode
|
| 307 |
+
β β β
|
| 308 |
+
β β ββ Special Features:
|
| 309 |
+
β β ββ Weight normalization for training stability
|
| 310 |
+
β β ββ Spectral normalization option
|
| 311 |
+
β β ββ CUDA kernel support for activation functions
|
| 312 |
+
β β ββ Snake/SnakeBeta activation (periodic)
|
| 313 |
+
β β ββ Anti-aliasing filters for high-quality upsampling
|
| 314 |
+
β β
|
| 315 |
+
β ββ AMPBlock1 (50 lines)
|
| 316 |
+
β β ββ Architecture: Conv1d Γ 2 with activations
|
| 317 |
+
β β ββ Multiple dilation patterns [1, 3, 5]
|
| 318 |
+
β β ββ Residual connections
|
| 319 |
+
β β ββ Activation1d wrapper for anti-aliasing
|
| 320 |
+
β β ββ Weight normalization
|
| 321 |
+
β β
|
| 322 |
+
β ββ AMPBlock2 (40 lines)
|
| 323 |
+
β β ββ Similar to AMPBlock1 but simpler
|
| 324 |
+
β β ββ Dilation patterns [1, 3]
|
| 325 |
+
β β ββ Residual connections
|
| 326 |
+
β β
|
| 327 |
+
β ββ Activation1d (custom, from alias_free_activation/)
|
| 328 |
+
β β ββ Applies activation function (Snake/SnakeBeta)
|
| 329 |
+
β β ββ Optional anti-aliasing filter
|
| 330 |
+
β β ββ Optional CUDA kernel for efficiency
|
| 331 |
+
β β
|
| 332 |
+
β ββ Snake Activation (from activations.py)
|
| 333 |
+
β β ββ Formula: x + (1/alpha) * sinΒ²(alpha * x)
|
| 334 |
+
β β ββ Periodic nonlinearity
|
| 335 |
+
β β ββ Learnable alpha parameter
|
| 336 |
+
β β
|
| 337 |
+
β ββ SnakeBeta Activation (from activations.py)
|
| 338 |
+
β ββ More complex periodic activation
|
| 339 |
+
β ββ Improved harmonic modeling
|
| 340 |
+
β
|
| 341 |
+
ββ External Dependencies: torch, scipy, librosa
|
| 342 |
+
ββ Model Size: ~100 MB (pretrained weights)
|
| 343 |
+
|
| 344 |
+
/home/user/IndexTTS-Rust/indextts/s2mel/modules/audio.py (83 LINES)
|
| 345 |
+
ββ Purpose: Mel-spectrogram computation (DSP)
|
| 346 |
+
ββ Key Functions:
|
| 347 |
+
β ββ load_wav() - Load WAV file with scipy
|
| 348 |
+
β ββ mel_spectrogram() - Compute mel spectrogram
|
| 349 |
+
β β ββ Parameters:
|
| 350 |
+
β β β ββ y: waveform tensor
|
| 351 |
+
β β β ββ n_fft: 1024
|
| 352 |
+
β β β ββ num_mels: 80
|
| 353 |
+
β β β ββ sampling_rate: 22050
|
| 354 |
+
β β β ββ hop_size: 256
|
| 355 |
+
β β β ββ win_size: 1024
|
| 356 |
+
β β β ββ fmin: 0
|
| 357 |
+
β β β ββ fmax: None or 8000
|
| 358 |
+
β β β
|
| 359 |
+
β β ββ Process:
|
| 360 |
+
β β β 1. Pad input with reflect padding
|
| 361 |
+
β β β 2. Compute STFT (Short-Time Fourier Transform)
|
| 362 |
+
β β β 3. Convert to magnitude spectrogram
|
| 363 |
+
β β β 4. Apply mel filterbank (librosa)
|
| 364 |
+
β β β 5. Apply dynamic range compression (log)
|
| 365 |
+
β β β ββ Output: [1, 80, T] tensor
|
| 366 |
+
β β β
|
| 367 |
+
β β ββ Caching:
|
| 368 |
+
β β ββ Caches mel filterbank matrices
|
| 369 |
+
β β ββ Caches Hann windows
|
| 370 |
+
β β ββ Device-specific caching
|
| 371 |
+
β β
|
| 372 |
+
β ββ dynamic_range_compression() - Log compression
|
| 373 |
+
β ββ dynamic_range_decompression() - Inverse
|
| 374 |
+
β ββ spectral_normalize/denormalize()
|
| 375 |
+
β
|
| 376 |
+
ββ Critical DSP Parameters:
|
| 377 |
+
β ββ STFT Window: Hann window
|
| 378 |
+
β ββ FFT Size: 1024
|
| 379 |
+
β ββ Hop Size: 256 (11.6 ms at 22050 Hz)
|
| 380 |
+
β ββ Mel Bins: 80 (perceptual scale)
|
| 381 |
+
β ββ Min Freq: 0 Hz
|
| 382 |
+
β ββ Max Freq: Variable (8000 Hz or Nyquist)
|
| 383 |
+
β
|
| 384 |
+
ββ External Dependencies: torch, librosa, scipy
|
| 385 |
+
|
| 386 |
+
SEMANTIC CODEC & FEATURE EXTRACTION FILES
|
| 387 |
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 388 |
+
|
| 389 |
+
/home/user/IndexTTS-Rust/indextts/utils/maskgct_utils.py (250 LINES)
|
| 390 |
+
ββ Purpose: Build and manage semantic codecs
|
| 391 |
+
ββ Key Functions:
|
| 392 |
+
β ββ build_semantic_model()
|
| 393 |
+
β β ββ Loads: facebook/w2v-bert-2.0 model
|
| 394 |
+
β β ββ Extracts: wav2vec 2.0 BERT embeddings
|
| 395 |
+
β β ββ Returns: model, mean, std (for normalization)
|
| 396 |
+
β β ββ Output: 1024-dimensional embeddings
|
| 397 |
+
β β
|
| 398 |
+
β ββ build_semantic_codec()
|
| 399 |
+
β β ββ Creates: RepCodec (residual vector quantization)
|
| 400 |
+
β β ββ Quantizes: Semantic embeddings
|
| 401 |
+
β β ββ Returns: Codec model
|
| 402 |
+
β β ββ Output: Discrete tokens
|
| 403 |
+
β β
|
| 404 |
+
β ββ build_s2a_model()
|
| 405 |
+
β β ββ Builds: MaskGCT_S2A (semantic-to-acoustic)
|
| 406 |
+
β β ββ Maps: Semantic codes β acoustic codes
|
| 407 |
+
β β
|
| 408 |
+
β ββ build_acoustic_codec()
|
| 409 |
+
β β ββ Encoder: Encodes acoustic features
|
| 410 |
+
β β ββ Decoder: Decodes codes β audio
|
| 411 |
+
β β ββ Multiple codec variants
|
| 412 |
+
β β
|
| 413 |
+
β ββ Inference_Pipeline (class)
|
| 414 |
+
β ββ Combines all codecs
|
| 415 |
+
β ββ Methods:
|
| 416 |
+
β β ββ get_emb() - Get semantic embeddings
|
| 417 |
+
β β ββ get_scode() - Quantize to semantic codes
|
| 418 |
+
β β ββ semantic2acoustic() - Convert codes
|
| 419 |
+
β β ββ s2a_inference() - Full pipeline
|
| 420 |
+
β ββ Diffusion-based generation options
|
| 421 |
+
β
|
| 422 |
+
ββ External Dependencies: torch, transformers, huggingface_hub
|
| 423 |
+
ββ Pre-trained Models:
|
| 424 |
+
ββ W2V-BERT-2.0: 614M parameters
|
| 425 |
+
ββ MaskGCT: From amphion/MaskGCT
|
| 426 |
+
ββ Various codec checkpoints
|
| 427 |
+
|
| 428 |
+
CONFIGURATION & UTILITY FILES
|
| 429 |
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 430 |
+
|
| 431 |
+
/home/user/IndexTTS-Rust/indextts/utils/checkpoint.py (50 LINES)
|
| 432 |
+
ββ Purpose: Load model checkpoints
|
| 433 |
+
ββ Key Functions:
|
| 434 |
+
β ββ load_checkpoint() - Load weights into model
|
| 435 |
+
β ββ Device handling (CPU/GPU/XPU/MPS)
|
| 436 |
+
ββ Supported Formats: .pth, .safetensors
|
| 437 |
+
|
| 438 |
+
/home/user/IndexTTS-Rust/indextts/utils/arch_util.py
|
| 439 |
+
ββ Purpose: Architecture utility modules
|
| 440 |
+
ββ Key Classes:
|
| 441 |
+
β ββ AttentionBlock - Generic attention layer
|
| 442 |
+
ββ Used in: Conditioning encoder, other modules
|
| 443 |
+
|
| 444 |
+
/home/user/IndexTTS-Rust/indextts/utils/xtransformers.py (1,600 LINES)
|
| 445 |
+
ββ Purpose: Extended transformer utilities
|
| 446 |
+
ββ Key Components:
|
| 447 |
+
β ββ Advanced attention mechanisms
|
| 448 |
+
β ββ Relative position bias
|
| 449 |
+
β ββ Cross-attention patterns
|
| 450 |
+
β ββ Various position encoding schemes
|
| 451 |
+
ββ Used in: GPT model, encoders
|
| 452 |
+
|
| 453 |
+
TESTING FILES
|
| 454 |
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 455 |
+
|
| 456 |
+
/home/user/IndexTTS-Rust/tests/regression_test.py
|
| 457 |
+
ββ Test Cases:
|
| 458 |
+
β ββ Chinese text with pinyin tones (ζ XUAN4)
|
| 459 |
+
β ββ English text
|
| 460 |
+
β ββ Mixed Chinese-English
|
| 461 |
+
β ββ Long-form text with multiple sentences
|
| 462 |
+
β ββ Named entities (Joseph Gordon-Levitt)
|
| 463 |
+
β ββ Chinese names (ηΊ¦η倫·ι«η»-θ±η»΄ηΉ)
|
| 464 |
+
β ββ Extended passages for robustness
|
| 465 |
+
ββ Inference Modes:
|
| 466 |
+
β ββ Single inference (infer)
|
| 467 |
+
β ββ Fast inference (infer_fast)
|
| 468 |
+
ββ Output: WAV files in outputs/ directory
|
| 469 |
+
|
| 470 |
+
/home/user/IndexTTS-Rust/tests/padding_test.py
|
| 471 |
+
ββ Test Scenarios:
|
| 472 |
+
β ββ Variable length inputs
|
| 473 |
+
β ββ Batch processing
|
| 474 |
+
β ββ Edge cases
|
| 475 |
+
β ββ Padding handling
|
| 476 |
+
ββ Purpose: Ensure robust padding mechanics
|
| 477 |
+
|
| 478 |
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 479 |
+
|
| 480 |
+
KEY ALGORITHMS SUMMARY:
|
| 481 |
+
|
| 482 |
+
1. TEXT PROCESSING:
|
| 483 |
+
- Regex-based pattern matching for pinyin/names
|
| 484 |
+
- Character-level CJK tokenization
|
| 485 |
+
- SentencePiece BPE encoding
|
| 486 |
+
- Language detection (Chinese vs English)
|
| 487 |
+
|
| 488 |
+
2. FEATURE EXTRACTION:
|
| 489 |
+
- W2V-BERT semantic embeddings (1024-dim)
|
| 490 |
+
- RepCodec quantization
|
| 491 |
+
- Mel-spectrogram (STFT-based, 80-dim)
|
| 492 |
+
- CAMPPlus speaker embeddings (192-dim)
|
| 493 |
+
|
| 494 |
+
3. SEQUENCE GENERATION:
|
| 495 |
+
- GPT-based autoregressive generation
|
| 496 |
+
- Conformer speaker conditioning
|
| 497 |
+
- Perceiver pooling for attention
|
| 498 |
+
- Classifier-free guidance (optional)
|
| 499 |
+
- Temperature/top-k/top-p sampling
|
| 500 |
+
|
| 501 |
+
4. AUDIO SYNTHESIS:
|
| 502 |
+
- Transposed convolution upsampling (256x)
|
| 503 |
+
- Anti-aliased activation functions
|
| 504 |
+
- Residual connections
|
| 505 |
+
- Weight/spectral normalization
|
| 506 |
+
|
| 507 |
+
5. EMOTION CONTROL:
|
| 508 |
+
- 8-dimensional emotion vectors
|
| 509 |
+
- Text-based emotion detection (via Qwen)
|
| 510 |
+
- Audio-based emotion extraction
|
| 511 |
+
- Emotion matrix interpolation
|
| 512 |
+
|
| 513 |
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|