CLI-first audio fingerprinting experiment (Shazam-style) written in Go.

output.mp4
Given a Spotify track URL, echo-sense:
- Fetches track metadata from Spotify
- Finds a matching YouTube video
- Downloads audio via
yt-dlp(saved as.m4a) - Converts to WAV via
ffmpeg - Builds a spectrogram, extracts peaks, generates fingerprints
- Stores songs + fingerprints in Postgres (via GORM)
You can then run a local search against a downloaded track file.
This repo is actively evolving. The download + fingerprint generation path is implemented; match scoring / “print the best match” flow is still a work in progress (matching currently computes intermediate structures but does not output a final match result).
server/: Go module (the CLI lives here)server/db/: Postgres connection + GORM modelsserver/internals/recognisingAlgorithm/: spectrogram + peak picking + fingerprinting + matching logicserver/internals/spotify/: Spotify metadata + YouTube lookup + audio download pipelinesongs/: created at runtime; downloaded.m4afiles end up heretemporary_files/: created at runtime
- Go (see
server/go.modfor the configured version) - Postgres (local or remote)
yt-dlpavailable on yourPATHffmpegavailable on yourPATH
- Install dependencies
- macOS (
brew):brew install ffmpeg postgresql@16 yt-dlp
- Linux (example):
sudo apt-get install -y ffmpeg postgresqlpython3 -m pip install -U yt-dlp
- Create
server/.env
echo-sense loads environment variables from a .env file at startup (server/main.go).
Example:
# Postgres (note: current code does not use DB_PASSWORD in the DSN)
DB_HOST=localhost
DB_PORT=5432
DB_USER=postgres
DB_NAME=echo_sense
# Spotify “Client Credentials” flow
SPOTIFY_CLIENT_ID=...
SPOTIFY_CLIENT_SECRET=...Spotify credentials:
- Create an app in the Spotify Developer Dashboard.
- Copy the Client ID + Client Secret into
server/.env.
- Start Postgres
Ensure the user in DB_USER can connect without a password (the current DSN in server/db/db.go does not include DB_PASSWORD).
On startup, the app will:
- Connect to Postgres
- Create
DB_NAMEif it doesn’t exist - Auto-migrate the
songsandaudio_fingerprintstables
Run everything from server/:
cd server
go run . download "<spotify_track_url>"This creates (if missing) songs/ and downloads a file named like:
songs/<Artist> - <Title>.m4a
It also fingerprints the track and stores results in Postgres.
search looks for a file in songs/ by the base filename (without extension):
cd server
go run . search "Artist - Title"This converts the .m4a to WAV, generates fingerprints from the audio, and runs the matching pipeline against fingerprints stored in the database.
- If you see
ffmpeg error: exec: "ffmpeg": executable file not found in $PATH, installffmpegand ensure it’s on yourPATH. - If you see
exec: "yt-dlp": executable file not found in $PATH, installyt-dlpand ensure it’s on yourPATH. - If Postgres connection fails, double-check
DB_HOST,DB_PORT, and thatDB_USERcan connect to Postgres without a password (or updateserver/db/db.goto include a password in the DSN). - Spotify auth uses a cached token file
spotify_token.jsonin the working directory; don’t commit it.
- Convert audio to a normalized WAV format (
server/internals/wavService/wav.go) - Compute a spectrogram (
server/internals/recognisingAlgorithm/spectrogram.go) - Extract salient peaks (
server/internals/recognisingAlgorithm/*) - Turn peak pairs into compact fingerprints and store them (
server/internals/recognisingAlgorithm/fingerprinting.go,server/db/models/*) - For a query clip, generate fingerprints and look up candidate matches in Postgres (
server/internals/recognisingAlgorithm/matchTracks.go)