Shezem-rs
lastmod 2025-04-04created 2025-04-041 edits
A fast Rust-based audio fingerprinting system
About
- An open-source Rust implementation of a fast audio recognition and identification system inspired by Shazam
- Designed with a focus on speed, efficiency, and simplicity; indexes and searches audio files via a CLI
Key features and pros
- Fast indexing and search: quickly processes hundreds of audio files
- Simple CLI commands: intuitive usage through the index and search commands
- High-performance Rust implementation: uses system resources efficiently
- Adopts a Shazam-like audio fingerprinting approach
How it works internally
Preprocessing
- Converts stereo to mono (average of left/right channels)
- Downsamples to reduce computation: 44.1kHz → 11.025kHz
- Applies an IIR low-pass filter before downsampling to remove content above the Nyquist frequency
Spectrogram conversion
- Uses the Short-Time Fourier Transform (STFT)
- Hamming window of 1024 samples
- 50% overlap
- Splits each time window into frequency bands and keeps only the highest amplitude in each band
- Removes amplitudes below the average to keep only characteristic peaks
How fingerprint data is stored
- Peaks are organized into hashes and stored
- Stores, as tuples, the positions of surrounding peaks relative to a single anchor peak
- Structured as (anchor freq, peak freq, delta time)
- Can be converted to 32-bit or 64-bit integers
Search and alignment algorithm
- Generates fingerprints from the input sample
- Looks up candidate fingerprints in the database and sorts them in time order
- Analyzes temporal continuity based on the Longest Increasing Subsequence
- Uses a sliding window to find the densest region of matching peaks
- Computes match scores and sorts results by highest score
See also
Favorite site
Pages that link here