--- title: CODA emoji: 🎵 colorFrom: indigo colorTo: yellow sdk: gradio sdk_version: 6.16.0 python_version: '3.10' app_file: app.py pinned: false license: mit short_description: AI that finishes the song you quit on. models: - stabilityai/stable-audio-3-small-music --- # CODA — the songs you quit on, finished. Everyone who's ever made music has one: the song that stops at 0:47. You ran out of ideas at the bridge, the voice memo got buried, life happened. CODA takes that unfinished clip and continues it into a longer, finished-sounding track — same key, same tempo, same groove — then splices the new part onto your original so cleanly you have to hunt for the seam. One job, done well. No lyric bot, no cover-art printer — just a real, listenable continuation of *your* clip, in 44.1 kHz stereo. ## How it works 1. **Listen.** librosa detects the key, tempo, and meter — pure DSP, no ML. If the recording is lo-fi (a voice memo, a phone capture, an old MP3 rip), CODA cleans a *copy* first — rumble filter, spectral noise gate, level — and conditions on that, so it follows the *song* and not the hiss. Your real original still goes into the final track (tick **remaster my part** to apply the same cleanup to your section too). 2. **Continue.** [Stable Audio 3 Small Music](https://huggingface.co/stabilityai/stable-audio-3-small-music) does the rest in a **single call**. SA3 is a latent-diffusion model with native audio *inpainting*: CODA places your clip at the front of the buffer and masks the region after it, and the model fills that region — conditioned on the whole clip — with a coherent continuation. No 30-second windows, no multi-pass chaining, no energy guards, no re-rolls. Eight diffusion steps with the pingpong sampler, a couple of seconds on a GPU. Leave the vibe box empty for a pure audio-led continuation that holds your key and tempo; type a vibe to creatively steer the new section. 3. **Stitch.** The continuation is loudness-matched to your recording, joined at the seam with a short equal-power crossfade, and faded out to a clean close. Everything is 44.1 kHz stereo — your original is resampled up to meet the SA3 tail, never the other way around. Progress streams through every stage, so you never stare at a dead screen. ## Why Stable Audio 3 (and not MusicGen) CODA's earlier builds fought MusicGen's limits: a 30 s trained window forcing fragile multi-pass chaining, 32 kHz mono output, and a tendency to drift into silence on quiet prompts. SA3 Small Music removes all of it at once: | | MusicGen-medium | SA3 Small Music | |---|---|---| | Continuation | chain 12 s-ctx / 18 s-new passes, compounding drift | one native inpaint call over the whole clip | | Output | 32 kHz **mono** | **44.1 kHz stereo** | | Speed | multiple passes per track | ~8 steps, a couple of seconds | | License | CC-BY-NC (non-commercial) | Stability Community (commercial < $1M revenue) | The hardest, most fragile part of the old build — the windowed chaining with its energy guards and collapse re-rolls — is simply deleted. ## The stack — small on purpose | Component | Size | Job | |---|---|---| | [Stable Audio 3 Small Music](https://huggingface.co/stabilityai/stable-audio-3-small-music) | ~0.6B | native audio-inpaint continuation | | T5Gemma (bundled with SA3) | ~0.5B | optional text conditioning for the vibe box | | librosa + SciPy | 0 params | key/tempo/meter detection, lo-fi cleanup | Well under the 32B cap, runs entirely inside a single ZeroGPU window (generation is seconds, not the whole budget), no cloud APIs. ## What it won't pretend to do SA3 is a *music* model — the continuation is instrumental-leaning, and CODA doesn't fake vocals it can't generate. The honest design choice: **your original recording plays untouched up to the seam**, vocals and all, and the generated section carries the music on from there. The band plays on; you write the next verse. A typed vibe steers the new section creatively but can pull it away from the original's exact key and tempo — that's the trade you're choosing when you use it; leave it empty for a faithful continuation. ## Using it Upload a WAV, MP3, or FLAC (a 15–30 second clip works best), or hit **try the demo — PUSHBACK**. Set the finished length, optionally describe a vibe or tick *remaster my part*, and press **Finish this song**. You'll see the detected key/tempo the moment a clip loads, watch the stages stream, and get a 44.1 kHz stereo track to play or download. Run it locally (needs Python 3.10 and a CUDA GPU; the SA3 weights are gated, so accept the licence on the model page and `huggingface-cli login` first): ```bash pip install -r requirements.txt python app.py ``` Deploying as a Space: because the SA3 weights are gated, add an **`HF_TOKEN`** secret (from an account that has accepted the licence) in the Space settings, or the model download 401s at startup. The bundled demo clip lives outside git (see `.gitignore`) — upload `examples/pushback_demo.mp3` to the Space directly. ## Notes for the curious `verify.py` is a dev-only QA harness: it measures the finished track against the original for silence-collapse, clipping, seam continuity, tempo/key continuity, spectral rolloff, and stereo width, and writes a diagnostic plot. It is not in the app's runtime path — it's how regressions get caught between ear-checks. Code is MIT. SA3 weights are under the [Stability AI Community License](https://stability.ai/license) (free for commercial use under $1M annual revenue) and bundle a T5Gemma encoder under the Gemma Terms of Use — worth knowing if you fork it. **Demo clip credit:** `examples/pushback_demo.mp3` is a clip by the band **PUSHBACK**, sourced from TikTok, included solely as a sample to demonstrate the tool. It is not affiliated with this project and all rights to the music remain with the band. It's a deliberately lo-fi rip — which is the point: low-quality in, finished-sounding out. If you are PUSHBACK and want it removed, say the word. --- Built by Tony Winslow — Black Box Analytics — for the Build Small Hackathon 2026.