Transform PDFs into engaging AI-powered podcasts using Azure services.
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
- 📄 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
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
- Python 3.9+
- Azure CLI
- Windows:
winget install --exact --id Microsoft.AzureCLIor download from Microsoft Learn
- Windows:
- FFmpeg (required for audio processing)
- Windows:
winget install Gyan.FFmpegor download from gyan.dev/ffmpeg - macOS:
brew install ffmpeg - Linux:
sudo apt-get install ffmpeg
- Windows:
- Azure subscription with services provisioned:
- Azure OpenAI (GPT-4o, text-embedding-3-large, gpt-4o-audio-preview)
- Azure Blob Storage
- Azure AI Search
-
Install dependencies:
pip install -r requirements.txt
-
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 -
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.jsonfor the complete index schema with vector search configuration. -
Verify setup:
python setup.py
-
Generate your first podcast:
python -m src.cli generate document.pdf --output podcast.mp3
python -m src.cli generate document.pdf --output podcast.mp3python -m src.cli upload document.pdfpython -m src.cli process --blob-name document.pdfThe application can be deployed as an Azure Function for serverless execution:
cd azure_function
func azure functionapp publish <your-function-app-name>- PDF Ingestion: Upload PDFs to Azure Blob Storage with Managed Identity authentication
- Text Extraction: Extract and clean text from PDFs using pdfplumber/PyPDF2
- Vector Indexing: Create searchable index with text-embedding-3-large embeddings in Azure AI Search
- Structured Script Generation: GPT-4o creates podcast scripts with clear sections (Introduction, Segments, Outro)
- Section-Based Audio Synthesis: Each script section is synthesized independently using gpt-4o-audio-preview
- Audio Combination: Sections are combined with pydub to create properly formatted MP3 with correct metadata
- Storage: Save podcast audio to Blob Storage with content-type metadata
- 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
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
- 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)
MIT