Download README.md from hexorcismos/CoDiCodec-Flow: direct link, hf CLI and curl.
- Browser
- Download file 5.22 kB
-
https://huggingface.co/hexorcismos/CoDiCodec-Flow/resolve/main/README.md
- Command line
-
hf download hf://hexorcismos/CoDiCodec-Flow/README.md
-
curl -L -o README.md https://huggingface.co/hexorcismos/CoDiCodec-Flow/resolve/main/README.md
license: cc-by-nc-4.0
tags:
- audio
- music
- music-generation
- flow-matching
- diffusion-transformer
- realtime
- codicodec
CoDiCodec-Flow
Realtime music generation with a flow-matching diffusion transformer on CoDiCodec latents. It continues an audio prompt (or starts from silence) chunk by chunk, 0.68 s at a time, fast enough to stream live on a laptop, with keyboard controls for steps, temperature, seeds and latent modulation, and swappable LoRA style adapters.
Author: Moisés Horta Valenzuela (hexorcismos) · Code: github.com/moiseshorta/CoDiCodec-Flow
Files
| File | Size | Contents | Use |
|---|---|---|---|
ema.pt |
388 MB | EMA weights, step 140 000 | generation: sample, realtime, server; base for LoRA training |
last.pt |
1.5 GB | raw weights + optimizer + EMA, step 140 000 | resuming or full fine-tuning (train --init-from) |
config.json |
1 KB | architecture and training-objective settings (also stored inside the checkpoints) | reference |
The CoDiCodec checkpoint is not included; it downloads automatically on first use.
Quick start
git clone https://github.com/moiseshorta/CoDiCodec-Flow && cd CoDiCodec-Flow
pip install -r requirements.txt && pip install -e ./codicodec
hf download hexorcismos/CoDiCodec-Flow config.json ema.pt --local-dir weights
# continue a prompt, chunk by chunk (the condition the model was trained on)
python cli.py sample --ckpt weights/ema.pt --prompt-wav prompt.wav \
--duration-s 30 --mode chunked --nfe 8 --solver heun --out out.wav
# unconditional
python cli.py sample --ckpt weights/ema.pt --duration-s 30 --mode chunked --out uncond.wav
# live, with keyboard controls (press ? for help, q to quit)
python cli.py realtime --ckpt weights/ema.pt --nfe 8 --solver heun
Runs on NVIDIA GPUs (CUDA) and Apple Silicon (MPS). On an M4 Max, a 0.68 s chunk takes ~270 ms at the default realtime settings (Euler, 4 steps). Live playback needs macOS or Linux.
LoRA adapters
Teach the model a new style from your own audio without retraining it: the base stays
frozen and small adapters train on top (1.7M parameters at rank 16, about 35 min on an
M4 Max for 45 min of audio). Load any number of adapters into realtime and switch
or blend them live (l next adapter, k/K strength):
python cli.py preprocess --in-dir ./my_audio --out-dir ./data/mine --offsets 2
python cli.py train --lora-base weights/ema.pt --data-dir ./data/mine --out-dir ./runs/mine \
--objective teacher_forcing --crop-tokens 256 --batch-size 8 --grad-accum 1 \
--lr 3e-4 --warmup-steps 100 --max-steps 4000 --val-every 250 --ckpt-every 250
python cli.py realtime --ckpt weights/ema.pt --lora runs/mine/mine.pt
See the "LoRA adapters" section of the GitHub README for details.
Model
FlowDiT, 96.9M parameters: dim 768, 10 layers, 12 heads × 64, block-causal attention
over 8-token chunks, max 1024 tokens (87 s window). It predicts flow-matching
velocities on CoDiCodec's continuous latents (11.7 Hz, 64 channels, 48 kHz stereo);
latent normalization stats are stored in the checkpoint.
Training
Objective: teacher forcing. Every chunk is denoised from its clean preceding chunks, which is exactly how realtime generation runs. Uniform noise levels, AdamW (0.9, 0.95), weight decay 0.01, grad clip 1.0, EMA 0.9999, bf16, 512-token crops (~44 s), dropout 0.1, cosine LR.
| Phase | Steps | Data | Batch | Peak LR |
|---|---|---|---|---|
| 1a | 0 – 14k | FSL10K loops, 80.7 h (offset-augmented ×2) | 16 | 3e-4 |
| 1b | 14k – 17k | same | 128 | 5e-4 |
| 2 | 17k – 140k | FSL10K + 2000 Suno-generated songs: 198.9 h train / 9.5 h val | 32 | 2.5e-4 |
About 48 h of phase 2 on one NVIDIA GB10.
Next-chunk validation loss (held-out recordings): 1.049 (26k) → 1.029 (46k) → 1.024 (66k) → 1.025 (140k). It is flat after ~70k steps: more data, not more steps, is what would improve it.
What to expect
- Strength: timbre and texture. Output sounds codec-clean, with the right instrument colour.
- Weakness: long-range structure. On new prompts, continuations match the timbre but develop rhythm and harmony vaguely and can drift.
- Style bias: about 60 % of phase-2 hours are Suno songs, so unconditioned output is more often song-like (vocals, pop production) than loop-like.
- Loop prompts: loops continue convincingly for a few bars, with limited novelty over time.
- Sampling: use chunked generation (
--mode chunkedorrealtime) with Heun at 8–16 steps; the model was trained only on that condition.
License and data
CC BY-NC 4.0: non-commercial use only. The CoDiCodec codec (Sony CSL Paris) is also CC BY-NC 4.0. Training data: FSL10K (Freesound loops, individually Creative Commons licensed) and 2000 songs generated with Suno.
Credits
- CoDiCodec-Flow: Moisés Horta Valenzuela, 2026
- CoDiCodec: Pasini et al., 2025, CoDiCodec: Unifying Continuous and Discrete Compressed Representations of Audio, github.com/sony/codicodec