How aslp-lab/diffrhythm works
DiffRhythm generates full-length songs from timed lyrics and style or audio references, with documented text-prompt and instrumental modes, plus song editing and continuation. Inference prepares inputs, converts lyrics to phoneme tokens, and invokes the model utilities; training is a separate capability using a diffusion dataset. The sampled excerpts support the main inference, G2P, model, and training-data connections. Some README-described generation modes and internals are unsampled, so those are represented at the subsystem level rather than as guessed call chains.
Main entry points: infer.py Inference Runner · infer_utils.py Audio and Model Utilities · g2p_generation.py Lyrics G2P · g2p Language Tokenizers
Components 17
Song Inference
- Inference Runner
infer/infer.py - Audio and Model Utilities
infer/infer_utils.py - Generated Song
Lyrics Processing
- Lyrics G2P
g2p/g2p_generation.py - Phoneme Backend
g2p/utils/g2p.py - Language Tokenizers
g2p/g2p - Mandarin Processing
g2p/g2p/mandarin.py - Polyphone Prediction
g2p/g2p/chinese_model_g2p.py - Language Segmentation
thirdparty/LangSegment/LangSegment.py
Diffusion Model
- Flow Matching
model/cfm.py - DiT Network
model/dit.py - Neural Components
model/modules.py - Model Utilities
model/utils.py
Model Training
- Training Entry
train/train.py - Training Orchestrator
model/trainer.py - Diffusion Dataset
dataset/dataset.py
Other components
- Composer
Connections 14
- Composer → Inference Runner: requests generation
Readme.md - Inference Runner → Audio and Model Utilities: uses utilities
infer/infer.py - Audio and Model Utilities → Lyrics G2P: tokenizes lyrics
infer/infer_utils.py - Audio and Model Utilities → Flow Matching: loads model
infer/infer_utils.py - Inference Runner → Generated Song: generates audio
Readme.md - Lyrics G2P → Phoneme Backend: phonemizes text
g2p/g2p_generation.py - Lyrics G2P → Language Tokenizers: uses tokenizer
g2p/g2p_generation.py - Language Tokenizers → Language Segmentation: uses segmentation
g2p/g2p/__init__.py - Language Tokenizers → Mandarin Processing: dispatches language
g2p/g2p/cleaners.py - Mandarin Processing → Polyphone Prediction: predicts pronunciation
g2p/g2p/mandarin.py - Flow Matching → Model Utilities: uses helpers
model/cfm.py - DiT Network → Neural Components: uses components
model/dit.py - Training Entry → Flow Matching: imports model
train/train.py - Training Orchestrator → Diffusion Dataset: loads training data
model/trainer.py