Skip to content

kyjones03/AzurePodcastGenerator

Repository files navigation

AI Podcast Generator

Transform PDFs into engaging AI-powered podcasts using Azure services.

Overview

This application takes PDF documents and converts them into natural-sounding podcast episodes with structured narratives. It uses:

  • Azure Blob Storage: Store PDFs and generated podcast audio (with Managed Identity support)
  • Azure AI Search: Index and retrieve PDF content with vector embeddings
  • Azure OpenAI: Generate podcast scripts (GPT-4o) and synthesize audio (gpt-4o-audio-preview)
  • Azure Key Vault: Secure secrets management (optional)
  • Azure Functions: Serverless deployment option

Features

  • 📄 PDF text extraction with multiple fallback methods
  • 🔍 Semantic search with vector embeddings (text-embedding-3-large)
  • ✍️ Structured script generation with sections (Intro, Segments, Outro)
  • 🎙️ Section-based audio synthesis for proper narrative flow
  • 🔐 Managed Identity authentication for enterprise security
  • 🎵 Proper MP3 metadata with accurate duration tracking
  • ☁️ Cloud-native Azure integration with DefaultAzureCredential
  • 🎨 Multiple podcast styles: conversational, educational, summary, storytelling

Project Structure

KJPodcastApp/
├── src/
│   ├── services/
│   │   ├── blob_storage.py       # Azure Blob Storage operations
│   │   ├── pdf_processor.py      # PDF text extraction
│   │   ├── search_service.py     # Azure AI Search integration
│   │   ├── script_generator.py   # Podcast script generation
│   │   └── audio_synthesizer.py  # Audio generation
│   ├── config.py                  # Configuration management
│   ├── orchestrator.py            # Pipeline orchestration
│   └── cli.py                     # Command-line interface
├── azure_function/                # Azure Function deployment
├── pdf-index.json                 # Azure AI Search index schema
├── requirements.txt
├── setup.py                       # Setup verification script
├── .env.example                   # Environment configuration template
├── README.md
└── GETTING_STARTED.md

Prerequisites

  • Python 3.9+
  • Azure CLI
    • Windows: winget install --exact --id Microsoft.AzureCLI or download from Microsoft Learn
  • FFmpeg (required for audio processing)
    • Windows: winget install Gyan.FFmpeg or download from gyan.dev/ffmpeg
    • macOS: brew install ffmpeg
    • Linux: sudo apt-get install ffmpeg
  • Azure subscription with services provisioned:
    • Azure OpenAI (GPT-4o, text-embedding-3-large, gpt-4o-audio-preview)
    • Azure Blob Storage
    • Azure AI Search

Setup

  1. Install dependencies:

    pip install -r requirements.txt
  2. Configure Azure authentication:

    Option A: Managed Identity (Recommended for Azure environments)

    cp .env.example .env
    # Edit .env and set the following:
    AZURE_KEY_VAULT_URL=https://your-key-vault.vault.azure.net/
    AZURE_STORAGE_ACCOUNT_NAME=your-storage-account
    AZURE_OPENAI_API_KEY=your-api-key
    AZURE_OPENAI_GPT4O_DEPLOYMENT=your-gpt4o-deployment
    AZURE_OPENAI_EMBEDDING_DEPLOYMENT=your-embedding-deployment
    AZURE_OPENAI_AUDIO_DEPLOYMENT=your-audio-deployment
    AZURE_SEARCH_ENDPOINT=https://your-search.search.windows.net
    AZURE_SEARCH_API_KEY=your-search-api-key
    AZURE_SEARCH_INDEX_NAME=pdf-index
    # Optional: AZURE_MANAGED_IDENTITY_CLIENT_ID=your-client-id
    # Optional: AZURE_STORAGE_CONNECTION_STRING=your-connection-string-here

    Option B: Local Development with Azure CLI

    az login
    # Then configure .env with storage account name
  3. Create Azure AI Search Index:

    The application requires a search index with vector search capabilities. You can create it using:

    Option A: Automatic (Recommended) - The index is created automatically on first run

    Option B: Manual - Use the provided schema:

    # Upload the index schema to Azure AI Search
    az search index create --service-name <search-service> \
      --name pdf-index \
      --schema @pdf-index.json

    See pdf-index.json for the complete index schema with vector search configuration.

  4. Verify setup:

    python setup.py
  5. Generate your first podcast:

    python -m src.cli generate document.pdf --output podcast.mp3

Usage

Generate Podcast from PDF

python -m src.cli generate document.pdf --output podcast.mp3

Upload PDF to Blob Storage

python -m src.cli upload document.pdf

Process Existing PDF in Blob Storage

python -m src.cli process --blob-name document.pdf

Azure Function Deployment

The application can be deployed as an Azure Function for serverless execution:

cd azure_function
func azure functionapp publish <your-function-app-name>

Architecture

Pipeline Flow

  1. PDF Ingestion: Upload PDFs to Azure Blob Storage with Managed Identity authentication
  2. Text Extraction: Extract and clean text from PDFs using pdfplumber/PyPDF2
  3. Vector Indexing: Create searchable index with text-embedding-3-large embeddings in Azure AI Search
  4. Structured Script Generation: GPT-4o creates podcast scripts with clear sections (Introduction, Segments, Outro)
  5. Section-Based Audio Synthesis: Each script section is synthesized independently using gpt-4o-audio-preview
  6. Audio Combination: Sections are combined with pydub to create properly formatted MP3 with correct metadata
  7. Storage: Save podcast audio to Blob Storage with content-type metadata

Key Technical Features

  • Managed Identity Support: Uses DefaultAzureCredential for secure, keyless authentication
  • Vector Search: Semantic search with 3072-dimensional embeddings using HNSW algorithm
  • Section-Based Synthesis: Scripts are split by logical sections (Intro/Segments/Outro) for proper narrative ordering
  • Base64-Encoded Keys: Search document keys use URL-safe base64 encoding to handle special characters
  • Proper MP3 Metadata: pydub ensures combined audio files have accurate duration and headers

Azure AI Search Index Schema

The application uses a custom index schema (pdf-index.json) with the following fields:

Field Type Description
id String URL-safe base64-encoded document key (handles special characters)
blob_name String Original PDF filename in blob storage
content String Text chunk content (searchable)
title String Document title
chunk_index Int32 Chunk sequence number for ordering
num_pages Int32 Total pages in source PDF
embedding Collection(Single) 3072-dimensional vector from text-embedding-3-large

Vector Search Configuration:

  • Algorithm: HNSW (Hierarchical Navigable Small World)
  • Metric: Cosine similarity
  • Parameters: m=4, efConstruction=400, efSearch=500
  • Optimized for fast approximate nearest neighbor search

Development

  • Python 3.9+
  • FFmpeg for audio processing
  • Azure subscription with required services provisioned
  • Azure CLI for local development authentication
  • Local development with Azure Functions Core Tools (optional)

License

MIT

About

This is a podcast generation application based in Python which leverages Azure resources such as Microsoft Foundry models, Azure Search, and Azure Blob Storage to turn your PDFs into engaging podcasts.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages