Skip to content

Python Flask backend for UnTypeBeats - Spleeter stem separation, audio mastering, Cloud Run, Cloud Tasks, and GCP integration

Notifications You must be signed in to change notification settings

UnTypeBeats/untypebeats-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UnTypeBeats Backend - Audio Processing Service

Python Flask backend service for AI-powered audio processing deployed on Google Cloud Run.

Features

  • Stem Separation: Separate audio into vocals, drums, bass, and other using Spleeter
  • Audio Mastering: AI-powered mastering and effects
  • Async Processing: Cloud Tasks queue for long-running jobs
  • Cloud Storage: Direct GCS upload/download with signed URLs
  • Firebase Auth: Secure authentication with social providers

Tech Stack

  • Runtime: Python 3.11
  • Framework: Flask 3.0
  • AI/ML: Spleeter, Demucs, Librosa, Pedalboard
  • Cloud: GCP Cloud Run, Cloud Storage, Cloud Tasks, Firestore
  • Auth: Firebase Admin SDK

Local Development

Prerequisites

  • Python 3.11+
  • FFmpeg
  • GCP account with project setup
  • Firebase project

Setup

  1. Install dependencies:
pip install -r requirements.txt
  1. Set environment variables:
cp .env.example .env
# Edit .env with your GCP/Firebase credentials
  1. Run development server:
export FLASK_APP=app
export FLASK_ENV=development
flask run --port=8080

API Endpoints

Health Check

GET /health

Upload Audio

POST /api/upload
Authorization: Bearer <firebase-token>
Body: { "filename": "audio.mp3", "contentType": "audio/mpeg" }
Response: { "uploadUrl": "...", "fileId": "...", "gcsPath": "..." }

Process Audio

POST /api/process
Authorization: Bearer <firebase-token>
Body: { "fileId": "...", "jobType": "stem-separation" | "mastering" }
Response: { "jobId": "...", "status": "pending" }

Get Job Status

GET /api/jobs/<job_id>
Authorization: Bearer <firebase-token>
Response: { "id": "...", "status": "...", "progress": 0-100, "outputUrls": {...} }

Deployment

Cloud Run

gcloud builds submit --config cloudbuild.yaml

Environment Variables (Cloud Run)

  • GCP_PROJECT_ID: Your GCP project ID
  • GCS_UPLOADS_BUCKET: Upload bucket name
  • GCS_PROCESSED_BUCKET: Processed files bucket
  • CLOUD_TASKS_QUEUE: Queue name
  • CLOUD_TASKS_LOCATION: Queue region
  • SERVICE_URL: Cloud Run service URL

Architecture

Client → Cloud Run (Flask) → Cloud Tasks → Worker (Flask)
                ↓                              ↓
           Firestore (jobs)              Cloud Storage

License

MIT

About

Python Flask backend for UnTypeBeats - Spleeter stem separation, audio mastering, Cloud Run, Cloud Tasks, and GCP integration

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published