Generate brat-style lyric videos from a Spotify track link.
This project runs a local FastAPI app with a small frontend. You paste a
Spotify track URL; the backend fetches track metadata, finds or downloads
audio, transcribes word-level lyric timing with Whisper (LRCLIB as fallback),
renders the animated text to frames with Pillow, and muxes them with the song
using ffmpeg into an .mp4.
Real pipeline output — Radiohead, No Surprises (1080×1920, character-by- character typewriter timing synced to the vocal):
flowchart LR
A([Spotify track URL]) --> B[Spotify API<br/>metadata]
B --> C{Local audio<br/>in library?}
C -- yes --> D[Use local file]
C -- no --> E[yt-dlp<br/>download MP3]
D --> F[Whisper<br/>word-level timing]
E --> F
F -- fails --> G[LRCLIB<br/>synced / plain fallback]
F --> H[Pillow<br/>frame layout]
G --> H
H --> I[ffmpeg<br/>encode + mux audio]
I --> J([🎬 1080×1920 MP4<br/>lyric video])
Each failure path produces a clear job error — never a crash or a blank video.
- Accepts a Spotify track URL
- Fetches song metadata with the Spotify API
- Reuses local audio from
data/library/when available - Falls back to
yt-dlpto download audio if no local match is found - Transcribes word-level lyric timing with
openai-whisper - Falls back to LRCLIB synced/plain lyrics if Whisper fails
- Renders lyric frames with Pillow and encodes the video with
ffmpeg
- Python 3.10+
- FastAPI + Uvicorn
- Static frontend in
frontend/ openai-whisperfor word-level lyric timing- Pillow for frame rendering
ffmpegfor final video encodingyt-dlpfor download fallback
- Python 3.10 or newer
ffmpegavailable on yourPATHyt-dlpavailable on yourPATHif you want automatic audio downloads- Spotify API credentials (client ID + secret)
This project uses standard Spotify API app credentials: a client_id and
client_secret (not a "bot token").
- Go to
https://developer.spotify.com/dashboard. - Log in with your Spotify account.
- Click
Create app. - Enter any app name and description.
- Accept Spotify's terms and create the app.
- Open the app and copy the
Client ID. - Click
View client secretand copy theClient Secret. - Create a local
.envfrom.env.exampleand paste both values.
SPOTIFY_CLIENT_ID=your_client_id_here
SPOTIFY_CLIENT_SECRET=your_client_secret_hereThese values stay local. Do not commit them to GitHub.
One-step (creates venv/, installs everything, checks ffmpeg):
bash setup.sh # core + Whisper
bash setup.sh --no-whisper # skip the heavy torch/Whisper stackOr manually:
python -m venv venv
# activate — Windows: .\venv\Scripts\Activate.ps1 POSIX: source venv/bin/activate
python -m pip install --upgrade pip
pip install -e ".[whisper,test]" # or ".[test]" to skip Whisper
cp .env.example .env # Windows: Copy-Item .env.example .envDependencies are defined in pyproject.toml. [whisper] (local
word-level transcription, pulls torch) is optional — without it the
pipeline falls back to LRCLIB lyrics.
Then edit .env:
SPOTIFY_CLIENT_ID=your_spotify_client_id
SPOTIFY_CLIENT_SECRET=your_spotify_client_secret
# tiny | base | small | medium | large-v3
WHISPER_MODEL=base
# blank = auto-select (CUDA if available, else CPU); or force cpu / cuda
WHISPER_DEVICE=
# prune finished/failed jobs from memory after this many hours
JOB_TTL_HOURS=24Smaller WHISPER_MODEL values (tiny, base) are faster and lighter on
memory; larger ones are more accurate but need more RAM/VRAM. Whisper
downloads the chosen model on first run.
python -m uvicorn backend.main:app --reload --port 8000Open http://localhost:8000. On Windows you can also use
start.bat after creating the venv and installing deps.
python generate.py <spotify_url>backend/services/spotify.pyvalidates the Spotify URL and fetches metadata.backend/services/library.pyscansdata/library/for a matching local file.backend/services/downloader.pyusesyt-dlpif no local match is found.backend/services/lyrics.pytranscribes word-level timing with Whisper, falling back to LRCLIB synced/plain lyrics if Whisper fails.backend/services/layout.pylays out the lyric frames.backend/services/render.pyrenders frames with Pillow andffmpegcombines them with the audio intodata/outputs/.
The web app (backend/main.py) wraps this in an in-memory job queue;
generate.py runs the same pipeline from the CLI.
backend/ FastAPI app, pipeline, models, services
frontend/ Static UI served by FastAPI
tests/ Test suite (pytest)
data/{library,outputs,temp}/ Runtime dirs (audio in, mp4 out, scratch)
fonts/ Bundled render font
assets/ README media (demo GIF)
generate.py CLI entry point (same pipeline as the web app)
pyproject.toml Packaging, dependencies, pytest config
.github/workflows/ CI (pytest on push/PR)
ffmpegis required for final.mp4output. The job fails with a clear message if it is missing fromPATH.yt-dlpis optional but strongly recommended. Without it, place audio files indata/library/manually.- Whisper (
openai-whisper) provides word-level timing. If it fails, the app falls back to LRCLIB synced lyrics, then LRCLIB plain lyrics.
pytest # full suite
pytest -m "not live" # skip tests that hit live Spotify/LRCLIB (this is what CI runs)live-marked tests need network access and valid Spotify credentials; CI
skips them and runs the rest on every push.
- Designed to run locally, not as a stateless cloud deployment.
- Background jobs are in-memory only; restarting the server loses job status.
Jobs are pruned after
JOB_TTL_HOURS. - Output filenames are generated from song metadata and may be long.
Released under the MIT License.
