This project is an attempt to recreate the core functionality of Shazam — recognizing songs based on audio fingerprints.
- Recognition Algorithm: Written in Rust to explore the language's performance and ecosystem.
- Backend: Built with Express.js for handling audio uploads, processing, and database interaction.
- Frontend: A simple interface built with React for uploading tracks and recognizing songs.
- Database: Local MySQL database stores audio fingerprints of uploaded songs.
- Audio Downloading: Uses
yt-dlpto fetch audio from YouTube based on Spotify track links.
-
Two Modes:
- Upload Mode: Add new tracks to the database.
- Users can paste a Spotify link.
- The server extracts song info (title & artist), downloads the track using yt-dlp, and processes it for fingerprinting.
- Recognition Mode: Identify a song from an audio sample.
- Supports
.wav,.mp3, and.oggfile uploads.
- Supports
- Upload Mode: Add new tracks to the database.
-
Switching Modes: The mode can be toggled with a switch on the frontend.
- The recognition algorithm is still a work in progress.
- Performance may be poor on:
- Short samples
- Low-quality recordings
- Recognition Algorithm: Rust
- Backend: Express.js (Node.js)
- Frontend: React
- Database: MySQL
-
Rust
- Install Rust using rustup: https://rustup.rs/
- Follow the instructions for your operating system
-
Node.js and npm
- Download and install from: https://nodejs.org/ (LTS version recommended)
- Verify installation:
node --version npm --version
-
MySQL
- Windows: Download MySQL Installer from the official website and follow installation prompts
- macOS: Use Homebrew:
brew install mysqlthenbrew services start mysql - Linux (Ubuntu/Debian):
sudo apt update && sudo apt install mysql-server - After installation, secure your MySQL installation:
sudo mysql_secure_installation - Create a root password when prompted
-
Log in to MySQL:
mysql -u root -p -
Create a new database:
CREATE DATABASE shazam_clone;
-
Create a user and grant privileges:
CREATE USER 'shazam_user'@'localhost' IDENTIFIED BY 'your_password'; GRANT ALL PRIVILEGES ON shazam_clone.* TO 'shazam_user'@'localhost'; FLUSH PRIVILEGES; EXIT;
- Create a Spotify Developer account at Spotify Developer Dashboard
- Create a new application
- Once created, you'll receive a Client ID and Client Secret
- Set these as environment variables (see Environment Setup below)
-
Clone the repository:
git clone https://github.com/your-username/shazam-clone.git cd shazam-clone -
Run the setup script to install dependencies:
bash setup.sh(This will install yt-dlp, ffmpeg, and other dependencies)
-
Set up environment variables:
- Create a
.envfile in the project root with:
DB_USER=shazam_user DB_PASSWORD=your_password DB_HOST=localhost DB_PORT=3306 DB_NAME=shazam_clone PORT=3000 CLIENT_PORT=3001 SPOTIFY_CLIENT_ID=your_spotify_client_id SPOTIFY_CLIENT_SECRET=your_spotify_client_secret - Create a
-
Build the Rust component:
cd recognition cargo build --release cd .. -
Install backend dependencies:
cd backend npm install cd .. -
Install frontend dependencies:
cd frontend npm install cd ..
-
Start the MySQL service if not already running
- Windows: Via Services app
- macOS:
brew services start mysql - Linux:
sudo systemctl start mysql
-
Run the Rust setup script to create database tables:
cd recognition cargo run --bin setup cd .. -
Start the backend server:
cd backend npm start -
In a new terminal, start the frontend development server:
cd frontend npm start -
Open your browser and navigate to
http://localhost:3001
-
Use the toggle switch to select either "Upload" or "Recognize" mode
-
To add songs to the database:
- Switch to "Upload" mode
- Paste a Spotify link (e.g., https://open.spotify.com/track/4cOdK2wGLETKBW3PvgPWqT)
- Click "Submit" and wait for processing
-
To recognize a song:
- Switch to "Recognize" mode
- Click "Upload Audio" and select a .wav, .mp3, or .ogg file
- Wait for the analysis results
-
Database Connection Issues:
- Verify MySQL is running
- Check your database credentials in the .env file
- Ensure the database user has proper permissions
-
Audio Processing Errors:
- Make sure ffmpeg is correctly installed and accessible in your PATH
- Check for supported audio formats (.wav, .mp3, .ogg)
-
Song Download Problems:
- Verify yt-dlp is installed correctly
- Check your internet connection
- Some songs might be unavailable on YouTube or have copyright restrictions
The application works similarly to Shazam:
- When adding songs, the system creates audio fingerprints from frequency patterns
- These fingerprints are stored in the database with song information
- During recognition, the algorithm extracts fingerprints from the sample audio
- It compares these fingerprints against the database to find the closest match
This project was mainly built for learning purposes, especially:
- Diving into Rust for performance-critical parts.
- Exploring full-stack development across React, Express, and system-level processing.
- Understanding audio fingerprinting and practical database design.
MIT
Feel free to explore, modify, or contribute!