Skip to main content

RAG over audio files with provider-agnostic pipeline

Project description

AudioRAG

Provider-agnostic RAG pipeline for audio content. Download, transcribe, chunk, embed, and search audio from YouTube and other sources.

Features

  • Multi-provider support: OpenAI, Deepgram, AssemblyAI, Groq (STT); OpenAI, Voyage, Cohere (embeddings); OpenAI, Anthropic, Gemini (generation); ChromaDB, Pinecone, Weaviate, Supabase (vector stores)
  • Batch indexing: Index multiple URLs, playlists, and local directories in one command
  • Source discovery: Automatically expand playlists and recursively scan directories
  • Resumable processing: SQLite state tracking with hash-based IDs
  • Automatic chunking: Time-based segmentation with configurable duration
  • Audio splitting: Handles large files by splitting before transcription
  • Structured logging: Context-aware logging with operation timing
  • Type-safe: Python 3.12+ with full type annotations

Quick Start

import asyncio
from audiorag import AudioRAGPipeline, AudioRAGConfig

async def main():
    # Configure with your chosen providers
    config = AudioRAGConfig(
        stt_provider="openai",
        stt_model="whisper-1",
        embedding_provider="openai",
        embedding_model="text-embedding-3-small",
        vector_store_provider="chromadb",
        generation_provider="openai",
        generation_model="gpt-4o-mini",
        # API keys can also be set via environment variables
        openai_api_key="sk-...",
    )
    
    # Initialize pipeline
    pipeline = AudioRAGPipeline(config)
    
    # Index audio from YouTube
    await pipeline.index("https://youtube.com/watch?v=...")
    
    # Query the indexed content
    result = await pipeline.query("What are the main points discussed?")
    print(result.answer)
    
    # Access sources with timestamps
    for source in result.sources:
        print(f"{source.video_title} at {source.start_time}s")
        print(f"URL: {source.youtube_timestamp_url}")

asyncio.run(main())

Installation

# Install with uv (recommended)
uv add audiorag

# Or with pip
pip install audiorag

Optional Dependencies

# Audio scraping utilities (yt-dlp, pydub)
uv add audiorag[defaults]  # or: pip install audiorag[defaults]

# All providers and utilities
uv add audiorag[all]  # or: pip install audiorag[all]

# Specific providers only
uv add audiorag[openai,chromadb,scraping,cohere]

Command Line Interface

AudioRAG includes a premium CLI for easy setup, indexing, and querying.

Setup

Configure your providers and API keys interactively:

audiorag setup

This will guide you through selecting providers for STT, embeddings, vector stores, and generation, saving them to a .env file.

Indexing

Index audio from multiple sources in a single command:

# Single YouTube video
audiorag index "https://youtube.com/watch?v=..."

# YouTube playlist (auto-expanded to individual videos)
audiorag index "https://youtube.com/playlist?list=..."

# Local audio files and folders
audiorag index "./podcast.mp3" "./audio_folder/"

# Multiple URLs at once
audiorag index "https://youtube.com/watch?v=video1" "https://youtube.com/watch?v=video2"

# Mixed inputs
audiorag index "./local_audio/" "https://youtube.com/watch?v=..." "./interview.wav"

Note: Always wrap URLs and paths containing spaces in quotes.

Options:

  • --force: Re-process and re-index even if the URL has been processed before.

The CLI automatically:

  • Expands YouTube playlists/channels into individual video URLs
  • Recursively discovers audio files in directories
  • Shows progress tracking for batch operations
  • Handles errors per source without stopping the entire batch

Querying

Ask questions about your indexed audio content with a sophisticated results layout:

audiorag query "What are the main points discussed in the audio?"

Configuration

AudioRAG uses pydantic-settings with environment variable support. All settings use the AUDIORAG_ prefix.

# Example: Using OpenAI for STT, embeddings, and generation
export AUDIORAG_OPENAI_API_KEY="sk-..."
export AUDIORAG_STT_PROVIDER="openai"
export AUDIORAG_EMBEDDING_PROVIDER="openai"
export AUDIORAG_VECTOR_STORE_PROVIDER="chromadb"
export AUDIORAG_GENERATION_PROVIDER="openai"

# Example: Using different providers
export AUDIORAG_DEEPGRAM_API_KEY="..."
export AUDIORAG_STT_PROVIDER="deepgram"
export AUDIORAG_VOYAGE_API_KEY="..."
export AUDIORAG_EMBEDDING_PROVIDER="voyage"

# Processing settings
export AUDIORAG_CHUNK_DURATION_SECONDS="30"
export AUDIORAG_RETRIEVAL_TOP_K="10"
export AUDIORAG_RERANK_TOP_N="3"

See Configuration Guide for all options.

Documentation

Development

# Clone and setup
git clone <repository-url>
cd audiorag
uv sync

# Run tests
uv run pytest

# Run checks
uv run ruff check . --fix
uv run ty check

# Install pre-commit hooks
uv run prek install

Pipeline Stages

  1. Download: Fetch audio from URL (YouTube supported)
  2. Split: Divide large files into processable chunks
  3. Transcribe: Convert audio to text using STT provider
  4. Chunk: Group transcription into time-based segments
  5. Embed: Generate vector embeddings for each chunk
  6. Store: Persist embeddings in vector database

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

audiorag-0.2.0.tar.gz (43.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

audiorag-0.2.0-py3-none-any.whl (73.2 kB view details)

Uploaded Python 3

File details

Details for the file audiorag-0.2.0.tar.gz.

File metadata

  • Download URL: audiorag-0.2.0.tar.gz
  • Upload date:
  • Size: 43.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"openSUSE Tumbleweed","version":"20260207","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for audiorag-0.2.0.tar.gz
Algorithm Hash digest
SHA256 debb17b9eaca54aa1b2a7140904c613fd071c291afc1912d12c74519546179a1
MD5 f7ec88ca03e038488568147f6460121d
BLAKE2b-256 0d54da33b8a89a257bde0200b78d6f778c8b70f312f6afc482d6eaaa1c4882ca

See more details on using hashes here.

File details

Details for the file audiorag-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: audiorag-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 73.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"openSUSE Tumbleweed","version":"20260207","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for audiorag-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 baf85d24688bd9275d301ddcb0817c9cea8288341e772cb96d2ded3c2a67b7fb
MD5 42c531a47d4ba494da33dbf2d3ce18ef
BLAKE2b-256 3576255024860f7de2cba2bd0954067556fe87b81b267f1bcfac565d6fc21a82

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page