Skip to content

A curated collection of practical AI projects implementing OCR systems, RAG, AI agents, and other AI use cases.

4.1 KB
Raw Blame

🎧 Music Explorer

Powered by Gemini 3 Flash, ask anything about any audio file or YouTube video

Music Explorer Demo

Overview

Music Explorer lets you analyze any audio through natural language. Upload a file or paste a YouTube URL, and ask questions: transcribe lyrics, identify instruments, detect emotion, break down track structure, or describe anything you hear. The conversation is multi-turn, so you can keep asking follow-ups without re-uploading.

Gemini 3 Flash handles the audio understanding entirely via the Gemini Files API, no local model and no GPU required.

Features

  • Multi-turn chat: ask follow-up questions about the same audio without re-uploading
  • YouTube support: paste any YouTube URL to download and analyze the audio automatically
  • Five quick-analysis presets: one click to run full description, transcription, emotion analysis, instrument identification, or track structure breakdown
  • Timestamp-aware responses: Gemini can reference specific moments in the audio
  • Microphone input: record directly in the browser for live audio analysis
  • No GPU needed: runs entirely through the Gemini API

What You Can Ask

  • "Describe this track: genre, tempo, key, instruments, and mood"
  • "Transcribe the lyrics with timestamps"
  • "What emotion does this convey? Does it shift throughout?"
  • "List every instrument and when each one enters"
  • "Break down the structure (intro, verse, chorus) with timestamps"
  • "What language is being spoken?"
  • "Summarize what's being said in this podcast clip"
  • "What chord progression is used in the chorus?"

Tech Stack

Layer Technology
Model Gemini 3 Flash (gemini-3-flash-preview) via Gemini API
Audio upload Gemini Files API
YouTube download yt-dlp + ffmpeg
UI Gradio
SDK google-genai

Prerequisites

  • Python 3.10 or higher
  • uv (recommended) or pip
  • A Gemini API key
  • ffmpeg installed on your system (required for YouTube audio extraction)

Install ffmpeg:

# macOS
brew install ffmpeg

# Ubuntu / Debian
sudo apt install ffmpeg

# Windows
winget install ffmpeg

Installation

1. Clone the Repository

git clone https://github.com/Sumanth077/Hands-On-AI-Engineering.git
cd Hands-On-AI-Engineering/audio/music_explorer

2. Set Up Environment Variables

cp .env.example .env

Add your Gemini API key:

GEMINI_API_KEY=your_gemini_api_key_here

Get your key at aistudio.google.com.

3. Install Dependencies

uv sync

Usage

uv run python app.py

Navigate to http://localhost:7860.

  1. Upload an audio file or paste a YouTube URL and click Load YouTube Audio
  2. Type a question or click a Quick Analysis preset
  3. Keep asking follow-ups: the conversation is multi-turn, no need to re-upload

How It Works

Audio file / YouTube URL
         β”‚
         β–Ό
  yt-dlp (YouTube only)    ← downloads audio as MP3
         β”‚
         β–Ό
  Gemini Files API          ← uploads audio, returns a file reference
         β”‚
         β–Ό
  Gemini 3 Flash            ← multi-turn conversation with audio context
         β”‚
         β–Ό
  Streamed response         ← transcription Β· analysis Β· timestamps Β· description

Project Structure

music_explorer/
β”œβ”€β”€ app.py            # Gradio UI and Gemini inference logic
β”œβ”€β”€ assets/
β”‚   └── demo.gif      # App demo
β”œβ”€β”€ .env.example      # API key template
β”œβ”€β”€ pyproject.toml    # Dependencies (uv)
└── README.md

Notes

  • Uploaded files are stored temporarily in the Gemini Files API for up to 48 hours
  • YouTube audio is cached locally for the session to avoid repeat downloads
  • For best results, use audio files under 20 MB

License

This project is licensed under the MIT License. See the LICENSE file for details.


Back to Top