suno-local — Motor Soberano de IA Musical¶
Sistema tipo Suno/Udio de generación musical end-to-end, construido desde cero sobre PyTorch.
Combina tres arquitecturas SOTA open-source en una única plataforma soberana: 1. ACE-Step híbrido (Planner LM 5 Hz + Diffusion Transformer + Oobleck VAE + DCW). 2. DiffRhythm-style sentence-level lyrics alignment para canciones largas coherentes. 3. SongGen Dual-Track Interleaving para exportar stems vocales/instrumentales separados.
API empresarial async con FastAPI + Celery + Redis, drop-in replacement de la API de Suno AI.
Lectura honesta: este proyecto no reproduce la calidad de Suno V4 (entrenado sobre >100K horas de catálogo comercial con >1000 GPU-días) sin entrenar los modelos sobre un dataset comparable. Lo que entrega es: - MVP funcional en 3 meses (Fases 0-4): codec + lyrics + score + SVS robótico + mezcla DSP. - Plataforma soberana en 6-10 meses (Fases 5-7 + ACE training): canciones 4 minutos coherentes, stems separados, edición latente (inpainting), LoRA por estilo/artista, API empresarial. - Independencia absoluta de SaaS, sin censura, sin ToS depredatorias, propiedad intelectual indiscutible.
Estado de fases¶
MVP (3 meses, M4 Pro + Colab Pro)¶
| Fase | Semanas | Objetivo | Estado |
|---|---|---|---|
| 0 | 1 | Setup repo + datasets | ✅ scaffold listo |
| 1 | 2–5 | Neural Audio Codec (RVQ 24 kHz, 8 cb) | 🟡 código |
| 2 | 6 | Lyric generator (SP + LM 50M) | 🟡 código |
| 3 | 7–10 | Score/REMI generator (LM 80M) | 🟡 código |
| 4 | 11–18 | SVS DiffSinger + HiFi-GAN | 🟡 código |
| 5 | 19–26 | Instrumental AR (MusicGen-like 300M) | 🟡 código |
| 6 | 27–30 | Mixing/Mastering DSP | 🟡 código |
| 7 | 31–34 | Pipeline + UI Gradio + Docker | 🟡 código |
Plataforma Soberana (6-10 meses, A100/H100 cloud)¶
| Fase | Objetivo | Estado |
|---|---|---|
| S1 | Oobleck VAE 44.1 kHz estéreo continuo | 🟡 código |
| S2 | DiT (small / base / XL) + DDIM + CFG | 🟡 código |
| S3 | Planner LM 5 Hz + Sentence-Level Lyrics Alignment | 🟡 código |
| S4 | DCW (Differential Correction Wavelet) + REPA (MERT + m-hubert) | 🟡 código |
| S5 | SongGen Dual-Track Interleaving A-V (stems separados) | 🟡 código |
| S6 | LoRA adapters por estilo/artista + audio inpainting/repainting | 🟡 código |
| S7 | FastAPI + Celery + Redis empresarial + Smart Router | 🟡 código |
🟡 = código de referencia listo, pendiente entrenamiento real con datos.
Quickstart¶
Modo MVP local (Mac M4 Pro / CPU)¶
# 1. Entorno (.venv + torch MPS)
./setup_env.sh
source .venv/bin/activate
# 2. Smoke test puro-Python (sin torch)
python3 scripts/smoke_test.py
# 3. Pipeline E2E con pesos aleatorios → ruido demostrativo
python -m src.pipeline.song_generator \
--prompt "Una bachata romántica en La menor sobre un amor de verano, 125 BPM" \
--duration 20 --out out/
# 4. UI local
python ui/gradio_app.py
Modo Soberano empresarial (Linux + GPU NVIDIA)¶
# 1. Provisioning del servidor (conda + CUDA + flash-attn + Celery + Redis)
./scripts/provision_sovereign.sh
# 2. Redis broker
docker run -p 6379:6379 -d redis:7
# 3. Worker Celery (1 por GPU; usa CUDA_VISIBLE_DEVICES para escalar)
celery -A src.api.worker.app worker -P solo --concurrency=1 --loglevel=info
# 4. FastAPI (1 worker, async, NO toca GPU)
uvicorn src.api.main:app --host 0.0.0.0 --port 8000 --workers 1
# 5. Probar la API
curl -X POST http://localhost:8000/api/v1/generate \
-H "Content-Type: application/json" \
-d '{"prompt":"Bachata 125 BPM en La menor","duration_s":60,"mode":"ace"}'
Modos del SmartRouter¶
mode |
Backend | Cuándo usar |
|---|---|---|
auto |
Heurístico decide | Default si no especificas |
fast |
ACE con n_steps=25 | <15 s de audio, latencia mínima |
stereo_mix |
Pipeline clásico MVP | 15-60 s, sin GPU pesada |
ace |
Planner + DiT + DCW | 60-300 s, máxima calidad |
dual_stem |
SongGen Interleaving | Stems separados para postproducción |
Estructura¶
suno-local/
├── README.md # este archivo
├── MODEL_CARD.md / DATASHEET.md / LICENSE (Apache-2.0)
├── requirements.txt / pyproject.toml
├── setup_env.sh # bootstrap Mac M4 (.venv + torch MPS)
├── colab_bootstrap.py # bootstrap Colab Pro/Pro+
├── scripts/
│ ├── provision_sovereign.sh # bootstrap Linux + CUDA + flash-attn + Celery
│ ├── smoke_test.py # validación puro-Python (no torch)
│ ├── train_hifigan.py # vocoder GAN
│ └── build_lyrics_corpus.py / lmd_to_manifest.py / …
├── configs/
│ ├── ace_xl.yaml # DiT base/large/XL + DCW + REPA
│ ├── songgen.yaml # Dual-Track Interleaving
│ ├── api.yaml # FastAPI + Celery + storage + security
│ └── codec_small / lm_small / lyrics_lm / melody_remi / svs / mixing / genres
├── src/
│ ├── device.py
│ │── (MVP layer)
│ ├── codec/ # SEANet + RVQ + losses + disc
│ ├── lm/ # MusicGen-like AR + delay pattern + RoPE
│ ├── lyrics/ # SP tokenizer + LM + constrained sampling ES
│ ├── melody/ # REMI tokenizer + LM (~80M)
│ ├── svs/ # DiffSinger acoustic + HiFi-GAN + G2P-ES + alignment
│ ├── instrumental/ # wrapper LM + codec
│ ├── mixing/ # pedalboard + dsp_pure Apache fallback
│ ├── pipeline/ # SongGenerator + model_swap + parser
│ │── (Sovereign layer)
│ ├── ace/ # ★ ACE-Step híbrido
│ │ ├── vae.py # AutoencoderOobleck 44.1 kHz estéreo
│ │ ├── vae_registry.py # ★ Downloader Registry intercambiable
│ │ ├── dit.py # ★ DiT con AdaLN-Zero (small / base / XL)
│ │ ├── planner.py # ★ Planner LM 5 Hz Chain-of-Thought
│ │ ├── sampler.py # ★ DDIM + CFG + DCW correction
│ │ ├── dcw.py # ★ Differential Correction Wavelet (Haar 1D)
│ │ ├── repa.py # ★ REPA loss (MERT + m-hubert)
│ │ ├── sentence_align.py # ★ Sentence-Level Lyrics Alignment
│ │ ├── inpaint.py # ★ audio_inpaint latente
│ │ ├── pipeline.py # ★ ACEPipeline orchestrator
│ │ └── train_dit.py # ★ training del DiT con v-objective + REPA
│ ├── songgen/ # ★ SongGen Dual-Track Interleaving A-V
│ │ ├── dual_track.py
│ │ ├── processor.py
│ │ └── generate.py # ★ DualTrackSynthesizer (stems separados)
│ ├── lora/ # ★ LoRA adapters (Hu et al. 2021)
│ │ ├── adapter.py # LoRALinear + apply_lora + save/load/merge
│ │ └── train_lora.py
│ ├── api/ # ★ API empresarial async
│ │ ├── main.py # FastAPI app
│ │ ├── worker.py # Celery worker GPU
│ │ ├── router.py # SmartRouter (auto/ace/fast/dual_stem/stereo)
│ │ ├── registry.py # ModelSingleton (carga VRAM una vez)
│ │ └── schemas.py # Pydantic GenerationPayload / JobStatus
│ ├── training/ # trainer AMP + grad-accum + ckpt Drive
│ ├── watermark/ # AudioSeal (EU AI Act art. 50)
│ ├── eval/ # FAD + CLAP + SI-SDR + MCD
│ └── data/ # manifests + augmentation
├── notebooks/ # demos + Colab training
├── docs/
│ ├── architecture.md / catalog.md / phases.md / datasets.md / legal.md
│ ├── sovereign_architecture.md # ★ ACE / DiffRhythm / SongGen detallado
│ ├── api_reference.md # ★ endpoints + cliente curl + Python
│ ├── dcw.md # ★ algoritmo + resultados FAD/MOS
│ ├── lora_guide.md # ★ recetario fine-tune por estilo
│ ├── sovereign_legal.md # ★ riesgos SaaS vs soberano
│ └── training_guide.md
└── ui/ # Gradio app
Hardware soportado¶
| Tarea | M4 Pro 24 GB MPS | Colab T4 16 GB | Colab A100 40 GB |
|---|---|---|---|
| Inferencia pipeline completo | ✅ con model-swap | ⚠️ ajustado | ✅ |
| Train codec 48 M | ❌ (muy lento) | ⚠️ bs=2, 7 días | ✅ bs=8, ~3 días |
| Train LM 300 M | ❌ | ❌ | ✅ bs=4 + grad-accum |
| Train SVS acoustic 40 M | 🟡 fine-tune LoRA | ✅ bs=8 | ✅ bs=16 |
| Vocoder HiFi-GAN 14 M | 🟡 fine-tune | ✅ | ✅ |
Datasets¶
Listado completo en docs/datasets.md. Resumen:
- Audio CC libre: FMA, MTG-Jamendo, MUSDB18, Slakh2100, NSynth, MedleyDB.
- MIDI CC: LMD, MAESTRO, POP909, GiantMIDI, MetaMIDI, Groove.
- Voz cantada: Opencpop / M4Singer (mandarín, research) + dataset propio en español a grabar (limitación crítica documentada).
- Letras: Project Gutenberg + Wikisource (DP) + generación sintética. NO scraping de Genius/MusixMatch.
Legal y ética¶
- Licencia código: Apache-2.0.
- ⚠️
pedalboardes GPLv3 → en distribución comercial sustituirlo por mezcla conscipy/numpypuro (ya provisto ensrc/mixing/dsp_pure.py). - Watermarking obligatorio (EU AI Act art. 50) vía AudioSeal (MIT, ICML 2024) en cada salida.
- Sin voces de cantantes identificables sin contrato cesión derechos.
- Modelo + datos documentados en MODEL_CARD.md y DATASHEET.md.
Referencias¶
Lista completa de papers + repos open-source en docs/references.md.