Skip to content

Mnnbnsl/Song-recognition-algorithm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

🎵 Song Recognition Algorithm (Audio Fingerprinting)

A Python implementation of a Shazam-like song recognition system based on spectrogram peak constellation maps and audio fingerprint hashing.
The system identifies a song from a short audio clip by matching time-aligned spectral fingerprints against a database.


📌 Overview

This project demonstrates how audio fingerprinting works at a low level using:

  • Digital Signal Processing (DSP)
  • Spectrogram peak detection
  • Hash-based matching with temporal alignment

Given:

  • A database of songs
  • A short query clip (e.g., 10 seconds)

The system returns:

  • The most likely matching song
  • A confidence score based on aligned hash matches

🧠 Core Idea (How It Works)

  1. Convert audio to mono and normalize
  2. Compute spectrogram (STFT)
  3. Detect prominent spectral peaks
  4. Create a constellation map
  5. Generate compact fingerprints (hashes)
  6. Match query fingerprints against database
  7. Vote using time-offset alignment

This approach is inspired by Shazam’s audio fingerprinting technique.


🧩 File Breakdown

constellation.py

Contains all DSP and fingerprinting logic.

Key Functions

  • read_wav_file()
    Reads WAV audio, converts stereo to mono, and normalizes amplitude.

  • compute_spectrogram()
    Computes magnitude spectrogram using FFT and Hann windowing.

  • detect_spectrogram_peaks()
    Detects local maxima using neighborhood filtering and thresholding.

  • generate_fingerprints()
    Generates compact hashes from anchor–target peak pairs using frequency and time deltas.


testing.py

Implements database creation and song matching.

Database Structure

{
  "Song_name": "...",
  "Fingerprint": [(hash, time_offset), ...]
}

About

Implemented shazam's song recogniton algorithm

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages