A full-stack audio fingerprinting application that identifies songs using advanced signal processing and machine learning. This project implements the Shazam algorithm to create unique audio fingerprints and match them against a database of known songs.
Add your application screenshots and demo images here:
| Feature | Image |
|---|---|
| Audio Upload Interface | ![]() |
| Fingerprint Visualization | ![]() |
| Song Match Results | ![]() |
- Audio Fingerprinting: Generate unique audio fingerprints using spectral analysis and peak detection
- Song Identification: Match audio samples against a database of fingerprints
- YouTube Integration: Download and process audio directly from YouTube URLs
- Real-time Processing: Stream audio processing with chunked data handling
- Interactive Web Interface: User-friendly React frontend for audio recording and uploads
- Database Storage: Supabase cloud database for storing fingerprints and metadata
- RESTful API: FastAPI-based backend with CORS support
Music-Recognition-Engine/
βββ backend/ # FastAPI backend server
β βββ main.py # FastAPI application entry point
β βββ audio/
β β βββ AudioProcessing.py # Core audio fingerprinting algorithm
β β βββ testing.py # Audio processing tests
β βββ route/
β β βββ route.py # API route handlers
β βββ db/
β β βββ db.py # Database client initialization
β βββ model/
β β βββ audio.py # Data models
β βββ .env # Database configs
βββ frontend/ # React + Vite frontend
β βββ src/
β β βββ App.jsx # Main application component
β β βββ pages/
β β β βββ audioRecord.jsx # Audio recording interface
β β βββ assets/ # Static assets
β βββ package.json # Frontend dependencies
| βββ .env # backend route(optional)
βββ docker-compose.yml # PostgreSQL database configuration
- FastAPI: Modern Python web framework for building APIs
- LibROSA: Audio analysis library
- SciPy: Signal processing
- OpenCV: Image/audio processing utilities
- Pydub: Audio file conversion
- yt-dlp: YouTube audio downloading
- SQLAlchemy: ORM for database operations
- Supabase/PostgreSQL: Database for storing fingerprints
- React 19: UI library
- Vite: Build tool and dev server
- Tailwind CSS: Styling framework
- React Hot Toast: Notifications
Option 1: Docker (Recommended - Easiest)
- Docker Desktop
- Docker Compose
- Supabase account with API credentials
Option 2: Manual Setup
- Python 3.8+
- Node.js 16+
- FFmpeg (for audio processing)
- Supabase account with API credentials
git clone <repository-url>
cd Music-Recognition-EngineThe easiest way to run the entire application with automatic dependency installation:
Step 1: Create a .env file
Step 2: Update the .env file with your Supabase credentials
SUPABASE_URL=<your-supabase-url>
SUPABASE_KEY=<your-supabase-key>Step 3: Start all services with a single command
docker-compose up --buildThis will:
- β Build and start FastAPI backend (with all Python dependencies)
- β Build and start React frontend (with all Node dependencies)
- β Automatically install all required packages
- β Set up networking between services
- β Connect to Supabase (no local database needed)
Access the application:
- Frontend:
http://localhost:5173 - Backend API:
http://localhost:8000 - API Docs:
http://localhost:8000/docs
Stop all services:
docker-compose downView logs:
docker-compose logs -f backend # Backend logs
docker-compose logs -f frontend # Frontend logsNavigate to the backend directory and install Python dependencies:
cd backend
pip install -r ../requirements.txtCreate a .env file with your Supabase credentials:
SUPABASE_URL=<your-supabase-url>
SUPABASE_KEY=<your-supabase-key>Navigate to the frontend directory and install Node dependencies:
cd frontend
npm installIn one terminal, start the backend:
cd backend
python main.pyThe backend will run on http://localhost:8000
In another terminal, start the frontend:
cd frontend
npm run devThe frontend will run on http://localhost:5173
βββββββββββββββββββββββββββββββββββββββ
β Docker Compose Network β
βββββββββββββββββββββββββββββββββββββββ€
β Frontend (Node.js) β
β - Port: 5173 β
β - Auto-installs dependencies β
β - Hot reload enabled β
βββββββββββββββββββββββββββββββββββββββ€
β Backend (Python/FastAPI) β
β - Port: 8000 β
β - Auto-installs dependencies β
β - FFmpeg pre-installed β
βββββββββββββββββββββββββββββββββββββββ€
β Supabase (Cloud Database) β
β - Remote PostgreSQL instance β
β - No local setup needed β
βββββββββββββββββββββββββββββββββββββββ
# Start all services
docker-compose up --build
# Start in background
docker-compose up -d --build
# Stop all services
docker-compose down
# View logs
docker-compose logs -f
# Rebuild a specific service
docker-compose up --build backend
# Execute command in running container
docker-compose exec backend bash
docker-compose exec frontend bashGET /- Server status
POST /audio_upload- Upload audio from YouTube URL- Request body:
{"url": "youtube_url"}
- Request body:
POST /identify- Upload recorded audio
- Process uploaded audio and generate fingerprints
- Store fingerprints in database
- Match against existing fingerprints
The fingerprinting process consists of several steps:
Spectral Analysis:
- Convert audio to frequency domain using FFT
- Generate spectrogram with normalized values
- Normalize using standard deviation and mean
Peak Detection:
- Identify local maxima in the spectrogram
- Filter peaks based on loudness threshold
- Create constellation map of peaks
Hashing:
- Generate anchor points from peak pairs
- Create hashes from frequency pairs and time deltas
- Encode hashes for efficient database storage
Matching:
- Compare input fingerprint against database
- Count hash matches to identify songs
- File Conversion: Convert audio to standard WAV format
- Streaming: Process audio in chunks for memory efficiency
- FFmpeg Integration: Stream YouTube audio at specified sample rate
- Normalization: Normalize audio levels for consistent fingerprinting
Handles all audio processing and fingerprinting:
converting_to_frequency_domain()- FFT and spectrogram generationconstellation_map()- Peak detectionfingerPrinting()- Anchor point generationhashing()- Hash encodingencode_hash()- Bit-packing for efficient storage
- Audio upload and processing
- YouTube integration with streaming
- Database operations
- Fingerprint matching
Key parameters in route.py:
SAMPLE_RATE = 44100 # Hz
SAMPLE_WIDTH = 2 # Bytes
CHANNELS = 1 # Mono
CHUNK_DURATION_SEC = 5 # Seconds per chunk
BATCH = 1000 # Database batch sizeInstall FFmpeg:
- Windows:
choco install ffmpeg - macOS:
brew install ffmpeg - Linux:
apt-get install ffmpeg
Ensure PostgreSQL is running:
docker-compose psUpdate allow_origins in backend/main.py with your frontend URL
cd backend
python audio/testing.pycd frontend
npm run buildcd frontend
npm run lint- Update default PostgreSQL password in
docker-compose.yml - Restrict CORS origins in production
- Validate API inputs
- Use environment variables for sensitive data
This project is open source and available under the MIT License.
Contributions are welcome! Please feel free to submit pull requests or open issues for bugs and feature requests.


