Spaces:
Sleeping
Voice Isolation App β Build Plan
Project Structure
voice-isolation-live/
βββ backend/
β βββ main.py # FastAPI app entry point
β βββ demucs_runner.py # Demucs model logic
β βββ requirements.txt # Python dependencies
β βββ uploads/ # Temp folder for uploaded audio
β βββ .gitkeep
βββ frontend/
β βββ index.html # Upload form + audio player
β βββ style.css # Basic styling
β βββ app.js # Fetch API calls to backend
βββ docs/
β βββ voiceisolation-idea.md
β βββ build-plan.md # This file
βββ .gitignore
βββ README.md
Step-by-Step Build Guide
Step 1 β Set Up the Python Environment
Goal: Get Demucs installed and running on a local audio file.
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # Linux/Mac venv\Scripts\activate # WindowsInstall Demucs:
pip install demucsTest it on any
.mp3or.wavfile:demucs --two-stems=vocals path/to/audio.mp3- Output lands in
separated/htdemucs/<track-name>/ - You want
vocals.wav(isolated voice) andno_vocals.wav(background)
- Output lands in
Done when: You can run Demucs from the terminal and get a clean vocals file.
Step 2 β Build the FastAPI Backend
Goal: Accept an audio file upload, run Demucs on it, return the clean vocal track.
Install FastAPI and dependencies:
pip install fastapi uvicorn python-multipartCreate
backend/demucs_runner.py:- Function that takes a file path
- Runs Demucs via
subprocessor the Python API - Returns the path to the output
vocals.wav
Create
backend/main.py:POST /uploadβ accepts audio file, saves touploads/, runs Demucs, returns cleaned fileGET /download/{filename}β serves the processed file back to the client- CORS enabled so the frontend can talk to it
Run the server:
uvicorn backend.main:app --reloadTest with curl or Postman:
curl -X POST http://localhost:8000/upload -F "file=@test.mp3"
Done when: Posting an audio file to the API returns a downloadable clean vocal track.
Step 3 β Build the Frontend
Goal: A simple webpage where users upload audio and hear the result.
Create
frontend/index.html:- File input (
<input type="file" accept="audio/*">) - Upload button
- Status message ("Processing..." / "Done!")
- Two audio players: original and cleaned
- File input (
Create
frontend/app.js:- On upload: POST the file to
http://localhost:8000/upload - On response: load the returned audio URL into the second player
- Show a loading spinner while Demucs runs
- On upload: POST the file to
Create
frontend/style.css:- Clean, minimal layout β centered card, readable font
Open
index.htmldirectly in the browser (no server needed for frontend yet).
Done when: You can upload a file in the browser, wait, and play back the isolated voice.
Step 4 β Deploy to Hugging Face Spaces
Goal: Get a live, shareable URL for your demo.
Create a free account at huggingface.co
Create a new Space:
- Type: Docker (gives full control for FastAPI + Demucs)
- Or type: Gradio (easier, but limits your custom frontend)
Add a
Dockerfileto the project root:- Base image:
python:3.11 - Copy backend files
- Install dependencies from
requirements.txt - Expose port 7860 (Spaces default)
- Run:
uvicorn backend.main:app --host 0.0.0.0 --port 7860
- Base image:
Push to the Space's git repo:
git remote add space https://huggingface.co/spaces/<your-username>/<space-name> git push space mainUpdate the frontend
app.jsto point to your live Space URL instead oflocalhost.
Done when: Your Space is live and someone else can upload audio from their browser.
Dependency Checklist
| Package | Purpose |
|---|---|
demucs |
Voice isolation model |
fastapi |
Backend web framework |
uvicorn |
ASGI server to run FastAPI |
python-multipart |
Required for file uploads in FastAPI |
torch |
Demucs dependency (auto-installed) |
Common Pitfalls
- Demucs is slow on CPU β expect 1β3 minutes per track without a GPU. That's fine for a demo; just show a loading indicator.
- File size limits β set a max upload size in FastAPI (
UploadFilehas no limit by default). - CORS errors β add
CORSMiddlewarein FastAPI or the browser will block frontend requests. - Temp file cleanup β delete files from
uploads/after processing so the server doesn't fill up.
CV Skills This Covers
| Skill | Where it shows up |
|---|---|
| Python | Demucs runner, FastAPI backend |
| REST API design | /upload and /download endpoints |
| ML model integration | Running a pretrained model in a pipeline |
| Full-stack thinking | Frontend talking to backend |
| Deployment / MLOps | Hugging Face Spaces, Docker |
Last updated: 2026-05-01