Skip to content

RudraNarayan94/Fourio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

61 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Fourio Preview

Description

Fourio is a command-line implementation of a music recognition system inspired by Shazam.The name Fourio is a portmanteau of "Fourier" and "Audio" named after the Fourier Transform.It analyzes song fingerprints, detects matches from local or downloaded tracks, and integrates with Spotify and YouTube for metadata and previews. It has addtional features like a REST APIs, Multiple DB support like MongoDB and SQLite.

This version of Fourio is fully written in Python, powered by:

  • ⚑ FastAPI β€” backend API framework for high-performance web services
  • 🧠 Typer β€” command-line interface (CLI) for intuitive developer experience
  • 🧩 uv β€” ultra-fast dependency manager and environment tool
  • 🎡 ffmpeg β€” audio conversion and processing utility
  • ☁️ Spotify API β€” metadata integration for tracks, albums, and playlists
  • 🎞️ YouTube API β€” for fetching song previews and additional metadata

Project Struture

fourio/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ api/             # Web API endpoints
β”‚   β”œβ”€β”€ utils/           # Logging, file handling, general utilities
β”‚   β”œβ”€β”€ db/              # Database connection and operations
β”‚   β”œβ”€β”€ models/          # Data models
β”‚   β”œβ”€β”€ services/        # Different services like Spotify, YouTube and WAV conversion
β”‚   β”œβ”€β”€ core/            # Core fingerprinting, Spectrogram and matching logic
β”‚   └── main.py          # FastAPI entry point
|── .env                 # Environment variables
β”œβ”€β”€ pyproject.toml       # uv dependencies
β”œβ”€β”€ requirements.txt     # Python dependencies  (Optional)
β”œβ”€β”€ cli_logic.py         # CLI logic        
β”œβ”€β”€ cli.py               # Typer CLI entry point
β”œβ”€β”€ .gitignore
β”œβ”€β”€ README.md
└── LICENSE

Installation

βœ” Prerequisites

πŸ”Ή Python 3.10+

πŸ”Ή FFmpeg (required for audio decoding)

Install FFmpeg:

Verify installation:

  ffmpeg -version

πŸ”Ή uv β€” ultra-fast Python environment & dependency manager

Install guide: https://github.com/astral-sh/uv


πŸš€ Steps

1. Clone the repository and create a virtual environment using uv

# Clone the repo
git clone https://github.com/RudraNarayan94/Fourio.git
cd fourio

# Create virtual environment (using uv)
uv venv

# Install dependencies
uv sync

2. (Optional) Setup using Python venv + requirements.txt

  # Clone the repo
git clone https://github.com/RudraNarayan94/Fourio.git
cd fourio

# Create virtual environment (using venv)
python -m venv venv

# Activate it
source venv/bin/activate     # macOS/Linux
# On Windows:
# venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

🎡 Environment Setup

Create a .env file inside folder.

Use the structure defined in the sample file:
πŸ‘‰ See .env.example (link)

The .env file should include keys for:

  • Spotify API access
  • Database configuration
  • Backend settings
  • YouTube API key (optional)

You can generate Spotify credentials by creating an app at the
πŸ‘‰ Spotify Developer Dashboard:
https://developer.spotify.com/dashboard/

Once created, copy your:

SPOTIFY_CLIENT_ID=your-client-id
SPOTIFY_CLIENT_SECRET=your-client-secret

These credentials allow Fourio to access track metadata, album details, and playlist information.


🧠 Usage

Run CLI

uv run python cli.py --help

alt text

🎧 Commands

Command Description
find <path_to_audio_file> Analyze audio file in any format and find matching fingerprints
download <spotify_url> Download and process a song/album/playlist from Spotify
save <path_or_dir> [--force/-f] Fingerprint and save local songs
erase Clear all stored songs and fingerprints from the database

πŸ”ŒREST api Endpoints

Endpoint Method Description
/fourio/match POST Match audio fingerprint against database and return top 10 matches
/recordings/save POST Save base64-encoded audio recording as WAV file
/songs/total GET Get total number of indexed songs in database
/songs/download POST Download and process Spotify track/album/playlist

πŸ’‘ Examples

πŸ“ŒRun Server

uv run python -m uvicorn app.main:app --reload

β–Ά Download a Spotify track

uv run python cli.py download https://open.spotify.com/track/4pqwGuGu34g8KtfN8LDGZm

πŸ”Ž Find a song match

uv run python cli.py find songs/Voila.mp3

πŸ’Ύ Save local songs

uv run python cli.py save ./local_songs/ --force

🧹 Erase all data

uv run python cli.py erase

πŸ“š Resources


πŸ§‘β€πŸ’» Author

Rudra Narayan Sahoo

πŸš€ Future Roadmap

Fourio have the potential to gradually evolve into a full-stack, Shazam-style system with a modern UI and scalable backend. Feel free to contribute or suggest features!

🎧 Frontend (React)

  • Modern UI for song matching & downloads
  • Microphone recording & PCM extraction
  • Client-side fingerprint generation
  • WebSocket for real-time matching

βš™οΈ Backend (FastAPI)

  • WEBSOCKETS Endpoints for song processing & matching
  • Redis for backend service

🧠 Fingerprinting Engine

  • Better DB Schema for fingerprints
  • Tunable fingerprint density & thresholds

☁️ Deployment

  • Docker setup
  • Optional FFmpeg/GPU acceleration

πŸ“œ License

This project is licensed under the MIT License.

About

A command-line implementation of a music recognition system inspired by Shazam

Topics

Resources

License

Stars

Watchers

Forks

Languages