DSP Audio Fingerprinting & Recognition System is an industrial-strength audio fingerprinting and recognition system built with Django, Elasticsearch, and PostgreSQL. It works similarly to Shazam, allowing users to identify songs by recording a short audio snippet or uploading an audio file.
This project implements the core digital signal processing (DSP) algorithms described by Avery Li-Chun Wang in his seminal 2003 paper for Shazam.
The raw audio signal is first converted to mono and downsampled (e.g., 22050 Hz). A Short-Time Fourier Transform (STFT) is applied over sliding overlapping windows to compute a Mel-scaled spectrogram, transforming the time-domain audio into a time-frequency representation.
The system analyzes the spectrogram to find "peaks"—local maxima of amplitude that represent the most prominent frequencies at any given time. By filtering out background noise and retaining only these high-energy peaks, the system generates a sparse, noise-resistant Constellation Map.
To achieve robustness against time-shifting and distortion, the system pairs peaks together. Each peak acts as an "anchor point" and is paired with several subsequent peaks within a predefined "target zone" (a specific time/frequency window).
For each pair, a hash is generated: Hash(Freq_Anchor, Freq_Target, Time_Delta). This hash is completely invariant to the absolute time the song started, making it perfect for identifying random audio snippets.
During a search query, the snippet's constellation hashes are matched against the database. The system calculates the time difference (Time_Offset = DB_Time - Query_Time) for each matching hash. If a large cluster of hashes shares the exact same Time_Offset, it indicates a strong temporal alignment, confirming a true match.
The core fingerprinting algorithm is based on:
Wang, Avery Li-Chun. "An Industrial-Strength Audio Search Algorithm." ISMIR. Vol. 2003. 2003.
Link to Paper (Columbia University)
You can easily replicate and run this system locally using Docker and Docker Compose.
- Docker & Docker Compose
- Python 3.9+ (if running locally without Docker)
-
Clone the repository
git clone <repository-url> cd <repository-directory>
-
Start the containers
docker-compose up -d --build
This will start the Django web server (Port 8000), PostgreSQL database (Port 5432), and Elasticsearch node (Port 9200).
-
Apply Database Migrations
docker-compose exec web python manage.py migrate -
Access the Application Open your browser and navigate to:
http://localhost:8000/
-
Install Dependencies Ensure you have
ffmpeginstalled on your system (required bylibrosa).pip install -r requirements.txt
-
Database Setup You need a running instance of PostgreSQL and Elasticsearch (v7.x or v8.x). Ensure your local credentials match the environment variables or configuration files.
-
Run Migrations & Start Server
python manage.py migrate python manage.py runserver
To add songs to your database, you can use the provided Django management command:
python manage.py Bulk_add_songsThis script will parse your music library, extract the audio features, generate the constellation map, create combinatorial hashes, and store them efficiently into Elasticsearch for rapid querying.