{ "cells": [ { "cell_type": "markdown", "id": "6c33ba3a", "metadata": {}, "source": [ "# PowerPoint to Narrative-Aware Voiceover Transcript Generator\n", "\n", "This notebook demonstrates the complete workflow for converting PowerPoint presentations into AI-generated voiceover transcripts using the unified transcript processor with Llama 4 Maverick through the Llama API.\n", "\n", "## Overview\n", "\n", "This unified workflow performs the following operations:\n", "\n", "1. **Content Extraction**: Pulls speaker notes and visual elements from PowerPoint slides\n", "2. **Image Conversion**: Transforms slides into high-quality images for AI analysis\n", "3. **Flexible Processing**: Choose between standard or narrative-aware processing modes\n", "4. **Transcript Generation**: Creates natural-sounding voiceover content with optional narrative continuity\n", "5. **Speech Optimization**: Converts numbers, technical terms, and abbreviations to spoken form\n", "6. **Results Export**: Saves transcripts and context information in multiple formats\n", "\n", "## Key Features\n", "\n", "- **Unified Processor**: Single class handles both standard and narrative-aware processing\n", "- **Configurable Context**: Adjustable context window for narrative continuity\n", "- **Mode Selection**: Toggle between standard and narrative processing with a simple flag\n", "- **Backward Compatibility**: Maintains compatibility with existing workflows\n", "\n", "## Prerequisites\n", "\n", "Before running this notebook, ensure you have:\n", "- Created a `.env` file with your `LLAMA_API_KEY`\n", "- Updated `config.yaml` with your presentation file path\n", "---" ] }, { "cell_type": "markdown", "id": "d8965447", "metadata": {}, "source": [ "## Setup and Configuration\n", "\n", "Import required libraries and load environment configuration." ] }, { "cell_type": "code", "execution_count": 1, "id": "21a962b2", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "SUCCESS: Environment loaded successfully!\n", "SUCCESS: Llama API key found\n" ] } ], "source": [ "# Import required libraries\n", "import pandas as pd\n", "import os\n", "from pathlib import Path\n", "from dotenv import load_dotenv\n", "import matplotlib.pyplot as plt\n", "from IPython.display import display\n", "\n", "# Load environment variables from .env file\n", "load_dotenv()\n", "\n", "# Verify setup\n", "if os.getenv('LLAMA_API_KEY'):\n", " print(\"SUCCESS: Environment loaded successfully!\")\n", " print(\"SUCCESS: Llama API key found\")\n", "else:\n", " print(\"WARNING: LLAMA_API_KEY not found in .env file\")\n", " print(\"Please check your .env file and add your API key\")" ] }, { "cell_type": "code", "execution_count": 2, "id": "71c1c8bd", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "SUCCESS: All modules imported successfully!\n", "- PPTX processor ready\n", "- Unified transcript generator ready\n", "- Configuration manager ready\n", "- Visualization generator ready\n" ] } ], "source": [ "# Import custom modules\n", "try:\n", " from src.core.pptx_processor import extract_pptx_notes, pptx_to_images_and_notes\n", " from src.processors.unified_transcript_generator import (\n", " UnifiedTranscriptProcessor,\n", " process_slides,\n", " process_slides_with_narrative\n", " )\n", " from src.config.settings import load_config, get_config\n", " from src.utils.visualization import display_slide_grid, display_slide_preview\n", "\n", "\n", " print(\"SUCCESS: All modules imported successfully!\")\n", " print(\"- PPTX processor ready\")\n", " print(\"- Unified transcript generator ready\")\n", " print(\"- Configuration manager ready\")\n", " print(\"- Visualization generator ready\")\n", "\n", "except ImportError as e:\n", " print(f\"ERROR: Import error: {e}\")\n", " print(\"Make sure you're running from the project root directory\")" ] }, { "cell_type": "code", "execution_count": 3, "id": "53781172", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "SUCCESS: Configuration loaded successfully!\n", "\n", "Current Settings:\n", "- Llama Model: Llama-4-Maverick-17B-128E-Instruct-FP8\n", "- Image DPI: 200\n", "- Image Format: png\n", "- Context Window: 5 previous slides (default)\n" ] } ], "source": [ "# Load and display configuration\n", "config = load_config()\n", "print(\"SUCCESS: Configuration loaded successfully!\")\n", "print(\"\\nCurrent Settings:\")\n", "print(f\"- Llama Model: {config['api']['llama_model']}\")\n", "print(f\"- Image DPI: {config['processing']['default_dpi']}\")\n", "print(f\"- Image Format: {config['processing']['default_format']}\")\n", "print(f\"- Context Window: 5 previous slides (default)\")" ] }, { "cell_type": "markdown", "id": "e11ef993-f0bc-4eba-82cb-e8d4b083196e", "metadata": {}, "source": [ "#### Don't forget to update the config file with your pptx file name!" ] }, { "cell_type": "code", "execution_count": 4, "id": "9386e035", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "File Configuration:\n", "- Input File: input/All About Llamas.pptx\n", "- Output Directory: output/\n", "- SUCCESS: Input file found (10.8 MB)\n", "- SUCCESS: Output directory ready\n" ] } ], "source": [ "# Configure file paths from config.yaml\n", "pptx_file = config['current_project']['pptx_file'] + config['current_project']['extension']\n", "output_dir = config['current_project']['output_dir']\n", "\n", "print(\"File Configuration:\")\n", "print(f\"- Input File: {pptx_file}\")\n", "print(f\"- Output Directory: {output_dir}\")\n", "\n", "# Verify input file exists\n", "if Path(pptx_file).exists():\n", " file_size = Path(pptx_file).stat().st_size / 1024 / 1024\n", " print(f\"- SUCCESS: Input file found ({file_size:.1f} MB)\")\n", "else:\n", " print(f\"- ERROR: Input file not found: {pptx_file}\")\n", " print(\" Please update the 'pptx_file' path in config.yaml\")\n", "\n", "# Create output directory if needed\n", "Path(output_dir).mkdir(parents=True, exist_ok=True)\n", "print(f\"- SUCCESS: Output directory ready\")" ] }, { "cell_type": "markdown", "id": "35a9e13a-4f85-488e-880b-62c7512d1248", "metadata": {}, "source": [ "## Processing Mode Configuration\n", "\n", "Choose your processing mode and configure the unified processor." ] }, { "cell_type": "code", "execution_count": 5, "id": "6fbfcb28-2f09-4497-8098-35cf3d62ebf3", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Processing Mode Configuration:\n", "- Mode: NARRATIVE CONTINUITY\n", "- Context Window: 5 previous slides\n" ] } ], "source": [ "# Configure processing mode\n", "\n", "USE_NARRATIVE = True # Set to False for standard processing, True for narrative continuity\n", "CONTEXT_WINDOW_SIZE = 5 # Number of previous slides to use as context (only used when USE_NARRATIVE=True)\n", "\n", "print(\"Processing Mode Configuration:\")\n", "if USE_NARRATIVE:\n", " print(f\"- Mode: NARRATIVE CONTINUITY\")\n", " print(f\"- Context Window: {CONTEXT_WINDOW_SIZE} previous slides\")\n", "else:\n", " print(f\"- Mode: STANDARD PROCESSING\")\n", " print(f\"- Features: Independent slide processing, faster execution\")\n", "\n", "# Initialize the unified processor\n", "processor = UnifiedTranscriptProcessor(\n", " use_narrative=USE_NARRATIVE,\n", " context_window_size=CONTEXT_WINDOW_SIZE\n", ")" ] }, { "cell_type": "markdown", "id": "ea4851e6", "metadata": {}, "source": [ "\n", "## Processing Pipeline\n", "\n", "Execute the main processing pipeline in three key steps." ] }, { "cell_type": "markdown", "id": "0f098fdf", "metadata": {}, "source": [ "### Step 1: Extract Content and Convert to Images\n", "\n", "Extract speaker notes and slide text, then convert the presentation to high-quality images for AI analysis." ] }, { "cell_type": "code", "execution_count": 6, "id": "644ee94c", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "PROCESSING: Converting PPTX to images and extracting notes...\n", "Processing: All About Llamas.pptx\n", "Extracting speaker notes...\n", "Found notes on 10 of 10 slides\n", "Notes df saved to: /Users/yucedincer/Desktop/Projects/llama-cookbook/end-to-end-use-cases/powerpoint-to-voiceover-transcript/output/All About Llamas_notes.csv\n", "Converting to PDF...\n", "Converting to PNG images at 200 DPI...\n", "\n", "Successfully processed 10 slides\n", "Images saved to: /Users/yucedincer/Desktop/Projects/llama-cookbook/end-to-end-use-cases/powerpoint-to-voiceover-transcript/output\n", "\n", "SUCCESS: Processing completed successfully!\n", "- Processed 10 slides\n", "- Images saved to: /Users/yucedincer/Desktop/Projects/llama-cookbook/end-to-end-use-cases/powerpoint-to-voiceover-transcript/output\n", "- Found notes on 10 slides\n", "- DataFrame shape: (10, 8)\n", "\n", "Sample Data (First 5 slides):\n" ] }, { "data": { "text/html": [ "
| \n", " | slide_number | \n", "slide_title | \n", "has_notes | \n", "notes_word_count | \n", "slide_text_word_count | \n", "
|---|---|---|---|---|---|
| 0 | \n", "1 | \n", "Llamas: Fascinating Animals of the Andes | \n", "True | \n", "34 | \n", "14 | \n", "
| 1 | \n", "2 | \n", "Introduction to Llamas | \n", "True | \n", "28 | \n", "25 | \n", "
| 2 | \n", "3 | \n", "Physical Characteristics | \n", "True | \n", "28 | \n", "33 | \n", "
| 3 | \n", "4 | \n", "Diet & Habitat | \n", "True | \n", "24 | \n", "23 | \n", "
| 4 | \n", "5 | \n", "Behavior & Social Structure | \n", "True | \n", "31 | \n", "30 | \n", "