How leonardltk/shazam-an-industrial-strength-audio-search-algorithm- works
Project Type and Purpose
• This is a standalone, batch‐oriented audio‐fingerprinting/search tool inspired by Shazam. It ingests a database of WAV files, builds and updates a lookup table (LUT) of audio “hashes,” then processes query WAVs in parallel to find matches, and finally combines and reports statistics.
Top-Level Components
• A. Configuration & Orchestration
• path.sh – environment setup (paths, thresholds)
• utils/conf.py – Shazam_conf class (thresholds for short/long audio)
• B. Database Management
• utils/Hashing.py – initial hash‐generation pipeline
• utils/Hashing_update.py – incremental add/delete of hashes
• data/database/*.scp & wav/database/*.wav – source audio lists + files
• Output: persistent LUT (e.g., serialized Python dict)
• C. Query Processing
• split (bash) – divides query SCP into $nj shards
• utils/Matching.py – per‐shard fingerprint matching against LUT
• Logs: Matching.<jid>.log
• D. Results Aggregation
• utils/Combine.py – merges per‐job match outputs
• utils/GetStats.py – computes match statistics (precision, recall)
• Final outputs: qry2db, db2qry, statistical report
Data Flow & Interactions
• Raw audio files (wav/database/*.wav) → wav.scp → Hashing.py
→ LUT written to disk
• For updates: wav_add.scp or wav_delete.scp → Hashing_update.py → LUT updated
• Query audio list (data/query_*/wav.scp) → split into shards → Matching.py (parallel jobs)
→ per‐job match logs → Combine.py → combined match list → GetStats.py → stats report
Architectural Patterns & Principles
• Pipeline / Batch processing: each stage reads files, performs computation, writes outputs
• Modular scripts: each Python tool handles one responsibility (build, update, match, combine, stats)
• Config‐driven thresholds: Shazam_conf centralizes tunable parameters
• Parallelism: queries are split and matched in parallel worker processes