A free and open-source music recognition backend built with Node.js and TypeScript.
Instead of relying on a single provider, this project combines multiple recognition services into one unified pipeline to achieve reliable results while keeping API costs low.
Note
This backend handles the core heavy lifting of downloading, extraction, noise-reduction filtering, transcoding, and service fallback. It is perfect for integration with custom web apps, desktop components, or mobile frontends.
Tip
Looking for a ready-to-use client?
A cross-platform Flutter demo client is available at:
https://github.com/Henrycoding-design/Music-Detector-Flutter
It demonstrates how to integrate this backend into a modern application, featuring:
- 📁 Local audio file recognition
- 🎤 Audio recording and recognition
- 🔗 Media URL recognition (YouTube, Instagram, TikTok, etc.)
- 🌙 Light & Dark theme
- 📱 Cross-platform support (Android, iOS, Windows, macOS, Linux, Web)
- 🎼 Audio fingerprinting using Chromaprint (fpcalc)
- 🔍 Song identification through AcoustID
- 📚 Metadata enrichment using MusicBrainz
- 🎧 Automatic fallback to Shazam RapidAPI when open databases cannot confidently identify a track
- 🎙️ Dedicated noise-reduction and normalization pipeline for recorded/microphone audio (using ARNNDN recurrent neural network model & FFmpeg filters)
- 📦 Unified response format regardless of the recognition source
- 🚀 REST API built with Express
- 🔒 Fully typed with TypeScript
The backend includes several production-oriented reliability mechanisms:
- 🔄 Automatic YouTube session cookie validation and refresh via Heartbeat
- ❤️ Health-check endpoint designed for uptime monitors (e.g. UptimeRobot)
- 🔑 Multi-key failover for RapidAPI
- 💾 Binary auto-management across Windows and Linux
- 📈 Memory usage logging for long-running deployments
⚠️ Graceful API fallback when providers are temporarily unavailable
When deploying to serverless or cloud platforms like Render, YouTube often flags or blocks requests coming from data center IP ranges. To bypass this, the backend uses YouTube session cookies. However, these cookies expire or become invalid over time.
The /api/keep-alive heartbeat endpoint acts as a proactive mechanism to solve this. Triggered by a remote cron/uptime monitor, it systematically verifies and refreshes your session cookies before real user requests hit the backend.
Heartbeat Request Triggered
│
▼
Download small test audio (via yt-dlp)
│
▼
Is Cookie Valid?
│
┌───────┴───────┐
│ │
Yes No
│ │
│ ▼
│ Refresh Cookies
│ │
└───────┬───────┘
│
▼
Success Response
Important
Local Testing vs Deployed Render Requests: Local testing (DO NOT need cookie validation), as your domestic residential IP is usually trusted by YouTube. This feature exists strictly to ensure that requests deployed on cloud instances (like Render) remain valid and are not rejected or rate-limited by YouTube's data center blocks.
The backend provides tailored pipelines for both standard media/clean audio files and noisy microphone recordings.
URL Input (YouTube / Instagram / etc.) or Standard Audio File
│
▼
yt-dlp (extract audio) / Direct File Upload
│
▼
FFmpeg (MP3 conversion + normalization: 128kbps)
│
▼
Audio File
│
▼
Chromaprint (fpcalc)
│
▼
AcoustID
│
│
▼
MusicBrainz
├─────────────── Score ≥ 0.95 ───────────────┐
│ │
▼ ▼
Shazam API Return Result (MusicBrainz)
│
▼
Return Results (Shazam API + MusicBrainz)
If AcoustID confidence is low or no match:
│
▼
Shazam API
│
▼
Return Result (Shazam API (if any) + MusicBrainz (if any))
When audio is captured via microphone or recorded in noisy environments, raw acoustic fingerprints often fail due to background noise and low frequency hums. The recording pipeline applies targeted noise suppression before recognition:
Microphone / Recorded Audio File Upload
│
▼
FFmpeg Audio Normalization & Denoising Pipeline
├── High-pass Filter (removes rumble < 80Hz)
├── afftdn (FFT-based audio denoiser)
├── arnndn (RNN Neural Noise Reduction with models/arnndn/std.rnnn)
└── Silence Removal (trims leading silence < -50dB)
│
▼
Clean 16-bit 44.1kHz PCM WAV
│
▼
Chromaprint (fpcalc)
│
▼
AcoustID ──► MusicBrainz (Score ≥ 0.95) ──► Return Result
│
└──────► Confidence < 0.95 / No Match ──► Shazam API ──► Return Result
The backend is designed to support multiple candidate results when confidence is uncertain.
- Node.js
- TypeScript
- Express
- Axios
- Multer
- Chromaprint (fpcalc)
- AcoustID
- MusicBrainz
- Shazam API (fallback)
- FFmpeg & FFprobe
- ARNNDN (RNN-based neural noise suppression using
models/arnndn/std.rnnn)
This project is tailored to work out-of-the-box on Render.
Render Build Command:
mkdir -p bin/linux && \
curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o bin/linux/yt-dlp && \
curl -L https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linux64-gpl.tar.xz | tar -xJ --wildcards --strip-components=2 -C bin/linux/ '*/bin/ffmpeg' '*/bin/ffprobe' && \
curl -L https://github.com/acoustid/chromaprint/releases/download/v1.5.1/chromaprint-fpcalc-1.5.1-linux-x86_64.tar.gz | tar -xz --strip-components=1 -C bin/linux/ chromaprint-fpcalc-1.5.1-linux-x86_64/fpcalc && \
chmod +x bin/linux/* && \
npm install && \
npm run buildRender Start Command:
npm run startsrc/
│
├── routes/
│ ├── heartbeat.ts
│ ├── recognize.ts
│ ├── recordingRecognize.ts
│ └── urlRecognize.ts
│
├── services/
│ ├── acoustid.ts
│ ├── chromaprint.ts
│ ├── downloader.ts
│ ├── executableManager.ts
│ ├── memoryLogger.ts
│ ├── musicbrainz.ts
│ ├── normalizer.ts
│ ├── recognition.ts
│ └── shazam.ts
│
├── config.ts
└── index.ts
git clone https://github.com/Henrycoding-design/Music-Detector-Backend.git
cd Music-Detector-Backendnpm installCreate a .env file in the root directory:
ACOUSTID_API_KEY=your_key
RAPIDAPI_KEY=your_key
RAPIDAPI_KEYS=your_key1,your_key2
RAPIDAPI_HOST=shazam.p.rapidapi.com
HEARTBEAT_SECRET=your_heartbeat_secretNote
You can provide either RAPIDAPI_KEYS (comma-separated for horizontal scale and failover rotation) or a traditional singular RAPIDAPI_KEY. The system prioritizes multi-keys first and fallbacks to the singular variant.
HEARTBEAT_SECRET is used to make sure the request is coming from an authorized client, preventing random requests from accidentally triggering your yt-dlp download and cookie refreshing loop. Skip if you do not use the /api/keep-alive endpoint.
The system automatically handles production binaries via the Render build script. For local development, ensure the platform-appropriate executable files are placed in the bin/ directory:
bin/
linux/
ffmpeg
ffprobe
fpcalc
yt-dlp
windows/
ffmpeg.exe
ffprobe.exe
fpcalc.exe
yt-dlp.exe
Run the local development server (with hot-reloading via ts-node-dev):
npm run devBuild the TypeScript project into native JavaScript:
npm run buildRun the production compiled build:
npm startTriggers the heartbeat check to test and refresh deployment session cookies using a light test audio stream. This endpoint is typically targeted by external cron jobs or uptime checkers like UptimeRobot.
- Query Parameters or JSON body fields:
token: The secret key matching your configuredHEARTBEAT_SECRETenv variable.url: A reliable fallback YouTube URL used to perform the diagnostic audio chunk fetch.
Example Monitor Configuration (e.g., UptimeRobot HEAD/GET):
https://music-detector-backend.onrender.com/api/keep-alive?token=MusicFinderBackendHearbeatSecret&url=https://www.youtube.com/watch?v=1kehqCLudyg
Upload a raw audio file binary using multipart/form-data.
- Field Name:
file
Example Usage:
curl -X POST \
-F "file=@song.mp3" \
http://localhost:3000/recognizeUpload a noisy audio sample or microphone recording binary using multipart/form-data. The backend applies high-pass filtering, FFT noise suppression, RNN deep learning noise reduction (arnndn), and silence removal to produce clean PCM WAV before recognition.
- Field Name:
file - Supported Extensions:
.mp3,.wav,.flac,.m4a,.aac,.ogg(up to 10MB)
Example Usage:
curl -X POST \
-F "file=@recording.wav" \
http://localhost:3000/recordingRecognizeSend a public media link (YouTube, Instagram, TikTok, etc.) to trigger stream parsing.
- Headers:
Content-Type: application/json
Example Request:
curl -X POST http://localhost:3000/urlRecognize \
-H "Content-Type: application/json" \
-d '{
"url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
}'{
"success": true,
"result": [
{
"confidence": 0.97204643,
"recording": {
"id": "1e141b98-eed4-4312-9f72-4efc61ed24df",
"title": "Love Story",
"artist": "Taylor Swift",
"duration": 234
},
"album": "Fearless",
"releaseDate": "2008-11-11",
"isrc": "USCJY0803276",
"genres": [],
"cover": null,
"shazamUrl": null
}
]
}The backend optimization follows a confidence-based routing flow:
- High-confidence AcoustID match (≥ 0.95): Drops execution immediately and relies purely on AcoustID + MusicBrainz open-source layers (0 API cost).
- Low-confidence or no AcoustID match: Falls back cleanly to Shazam RapidAPI endpoints to handle noisy/microphone audio samples.
Warning
Do not intentionally trim or slice the original file length on ingestion for clean files. Slicing structural intervals can break continuous wave patterns that AcoustID requires to produce high confidence fingerprint matches.
- Chromaprint integration
- AcoustID integration
- MusicBrainz integration
- Shazam fallback
- Unified recognition pipeline
- yt-dlp integration
- FFmpeg preprocessing
- Multi-key failover fallback mechanism for Shazam RapidAPI
- Added Memory Logger for a one-off snapshot of current RAM usage to console
- Automated Cookie Keep-Alive validation flow
- Dedicated normalization and detection pipeline for recorded audio
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git commit -m 'Add some AmazingFeature') - Open a Pull Request
Distributed under the MIT License. See LICENSE for more information.
This project is built upon the work of excellent open-source and public services: