AI-Powered Real-Time Video Transcription and Summarization Service — Part 2: Setting Up the Development Environment and Integrating Whisper

⏱ 8 min read  |  ~1506 words

🔑 Key Takeaways

  • ✅ Set up a reproducible Python 3.11 environment with uvicorn and FastAPI
  • ✅ Install FFmpeg, yt‑dlp, and OpenAI Whisper for local video transcription
  • ✅ Wrap Whisper in an async FastAPI endpoint accepting video URLs
  • ✅ Use Docker or venv for isolated, repeatable development
  • ✅ Prepare the service for future Claude 4.6 or GPT‑5 summarization integration

AI‑Powered Real‑Time Video Transcription and Summarization Service — Part 2: Setting Up the Development Environment and Integrating Whisper

In Part 1 we scoped the end‑to‑end architecture (Daily video streams → FFmpeg → Whisper → Claude/ChatGPT summarizer) and drafted a high‑level data flow diagram. Now we roll up our sleeves and get the code running on our local machine.

Based on my technical understanding as a Lead Programmer Analyst, I’ll walk you through a reproducible environment setup, install the required binaries, and hook OpenAI’s Whisper model into a FastAPI service that can accept a video URL, pull the media with yt‑dlp, and return a clean transcription. The code is written in Python 3.11, uses uvicorn for async serving, and is ready to be extended with Claude 4.6 Opus or GPT‑5.4 Pro parallel agents for the summarization stage.


🗂️ 1. Why This Part Matters

Whisper is the workhorse that turns raw audio into text. In a production‑grade video‑meeting pipeline you typically:

  1. Capture the video stream (Daily.co, Zoom, Teams, etc.).
  2. Store the recording in a bucket or serve it via a temporary URL.
  3. Download the file, extract the audio track, and feed it to Whisper.
  4. Pass the raw transcript to a language model (Claude 4.6 Opus, GPT‑5.4 Pro) for summarization.

This article covers steps 1‑3, giving you a solid foundation to plug in any summarizer later.

🛠️ 2. Prerequisites

Tool Version (as of Nov 2026) Why It’s Needed
Python 3.11.9 Core language for FastAPI, Whisper, and our glue code.
Git 2.44 Version control and cloning of helper repos (e.g., AI‑Video‑Transcriber).
FFmpeg 7.0 Audio/video demuxing; Whisper expects a clean audio stream.
yt‑dlp 2026.10.15 Fast, actively maintained fork of youtube‑dl for downloading any public video URL.
uvicorn 0.30.0 ASGI server for FastAPI.
OpenAI Python SDK 1.12.0 Calls Whisper (via client.audio.transcriptions.create) and later ChatGPT/Claude APIs.

3. Step‑by‑Step Environment Setup

3.1 Create a Project Directory

mkdir ai-video-transcriber
cd ai-video-transcriber

3.2 Initialize a Git Repository (optional but recommended)

git init
git remote add origin https://github.com/your‑org/ai-video-transcriber.git

3.3 Create a Python Virtual Environment

# On macOS / Linux
python3.11 -m venv .venv
source .venv/bin/activate

# On Windows PowerShell
python -m venv .venv
.\.venv\Scripts\Activate.ps1

3.4 Upgrade pip and Install Core Packages

pip install --upgrade pip setuptools wheel
pip install fastapi[all] uvicorn python‑dotenv yt‑dlp ffmpeg‑python openai

3.5 Install System‑Level FFmpeg

Whisper internally calls ffmpeg to convert video to 16 kHz mono WAV. On macOS you can use Homebrew; on Ubuntu use apt. The binary must be discoverable on $PATH.

# macOS
brew install ffmpeg

# Ubuntu/Debian
sudo apt-get update && sudo apt-get install -y ffmpeg

Verify the installation:

ffmpeg -version | head -n 1
# Expected output: ffmpeg version 7.0 ...

3.6 Obtain an OpenAI API Key

Sign in at platform.openai.com and create a key. Store it securely in a .env file at the project root:

# .env
OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
DAILY_API_KEY=dy_yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy

3.7 Load Environment Variables in Python

We’ll use python‑dotenv to keep the code tidy.

# app/config.py
from pathlib import Path
from dotenv import load_dotenv

BASE_DIR = Path(__file__).resolve().parent
load_dotenv(BASE_DIR / ".env")

import os

OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
DAILY_API_KEY = os.getenv("DAILY_API_KEY")

4. Integrating Whisper – The Core Transcription Service

4.1 Why Call Whisper via the OpenAI API?

OpenAI now offers Whisper as a hosted endpoint (the same model that powers whisper.cpp but with auto‑scaling, GPU acceleration, and 100+ language support). This eliminates the need for a local GPU‑heavy installation while still delivering “perfect” transcriptions, as demonstrated in the recent WhisperAI.com demo (see the 2026 product sheet for unlimited 5 GB file support).

4.2 FastAPI Blueprint

The following file creates a single POST endpoint /transcribe that accepts a JSON payload with a video_url field. The service:

  1. Downloads the video using yt‑dlp (no file is persisted on disk beyond the temporary folder).
  2. Extracts an audio‑only WAV at 16 kHz via ffmpeg.
  3. Sends the audio stream to OpenAI’s Whisper endpoint.
  4. Returns the raw transcript JSON.
# app/main.py
import os
import uuid
import shutil
import tempfile
from pathlib import Path
from typing import Literal

import yt_dlp
import ffmpeg
import openai
from fastapi import FastAPI, HTTPException, BackgroundTasks
from pydantic import BaseModel, HttpUrl, Field

# Load config (API keys) from .env
from .config import OPENAI_API_KEY

openai.api_key = OPENAI_API_KEY

app = FastAPI(
    title="AI Video Transcriber",
    version="0.1.0",
    description="Download a video, run Whisper, and return a plain‑text transcript."
)

class TranscribeRequest(BaseModel):
    video_url: HttpUrl = Field(..., description="Public URL to the video (YouTube, Daily.co, etc.)")
    language: Literal["auto", "en", "es", "fr", "de", "zh"] = Field(
        "auto", description="ISO‑639‑1 language hint for Whisper (default: auto-detect)"
    )
    model: Literal["whisper-1", "whisper-1-large"] = Field(
        "whisper-1", description="OpenAI Whisper model identifier"
    )

class TranscribeResponse(BaseModel):
    transcription: str
    duration_seconds: float
    model_used: str

def download_video(url: str, target_dir: Path) -> Path:
    """
    Uses yt‑dlp to fetch the best‑quality video and returns the path to the file.
    """
    ydl_opts = {
        "format": "bestvideo+bestaudio/best",
        "outtmpl": str(target_dir / "%(id)s.%(ext)s"),
        "quiet": True,
        "no_warnings": True,
    }
    with yt_dlp.YoutubeDL(ydl_opts) as ydl:
        info = ydl.extract_info(url, download=True)
        filename = ydl.prepare_filename(info)
    return Path(filename)

def extract_audio(video_path: Path, out_path: Path) -> None:
    """
    Convert any video format to 16 kHz mono WAV that Whisper expects.
    """
    (
        ffmpeg
        .input(str(video_path))
        .output(str(out_path), ar=16000, ac=1, format="wav")
        .overwrite_output()
        .run(quiet=True)
    )

def cleanup_temp_dir(temp_dir: Path) -> None:
    """Remove the temporary directory recursively."""
    shutil.rmtree(temp_dir, ignore_errors=True)

@app.post("/transcribe", response_model=TranscribeResponse)
async def transcribe(request: TranscribeRequest, background_tasks: BackgroundTasks):
    # 1️⃣ Create an isolated temporary folder per request
    temp_dir = Path(tempfile.mkdtemp(prefix="transcribe_"))
    try:
        # 2️⃣ Download the video
        video_path = download_video(request.video_url, temp_dir)

        # 3️⃣ Extract audio
        audio_path = temp_dir / f"{uuid.uuid4()}.wav"
        extract_audio(video_path, audio_path)

        # 4️⃣ Call Whisper via OpenAI API (streaming disabled for simplicity)
        with open(audio_path, "rb") as audio_file:
            transcription_resp = openai.audio.transcriptions.create(
                model=request.model,
                file=audio_file,
                language=request.language if request.language != "auto" else None,
                response_format="json",
            )
        # 5️⃣ Build response
        transcript_text = transcription_resp.text
        duration = ffmpeg.probe(str(audio_path))["format"]["duration"]
        return TranscribeResponse(
            transcription=transcript_text,
            duration_seconds=float(duration),
            model_used=request.model,
        )
    except yt_dlp.utils.DownloadError as e:
        raise HTTPException(status_code=400, detail=f"Video download failed: {e}")
    except openai.OpenAIError as e:
        raise HTTPException(status_code=502, detail=f"Whisper service error: {e}")
    finally:
        # Clean up all temp files after the request finishes
        background_tasks.add_task(cleanup_temp_dir, temp_dir)

4.3 Running the Service Locally

Start the server with uvicorn (auto‑reload enabled for development):

uvicorn app.main:app --reload --host 0.0.0.0 --port 8000

Navigate to http://localhost:8000/docs – you’ll see the interactive Swagger UI generated by FastAPI. Paste a public video URL (for example, a Daily.co meeting recording) and click “Execute”. Within seconds you’ll receive a JSON payload containing the raw transcription.

5. Testing the Pipeline with Real‑World Data

Let’s verify the integration against the Daily demo described in the Daily blog post. The steps are:

  1. Generate a short meeting recording via Daily’s room.startRecording API.
  2. Obtain the signed URL that Daily returns after the recording finishes.
  3. POST that URL to /transcribe using curl or the Swagger UI.
curl -X POST "http://localhost:8000/transcribe" \
  -H "Content-Type: application/json" \
  -d '{"video_url":"https://files.daily.co/recordings/abc123.mp4","language":"en","model":"whisper-1"}'

The response will look like:

{
  "transcription": "Welcome everyone, today we’ll discuss the Q3 roadmap...",
  "duration_seconds": 312.45,
  "model_used": "whisper-1"
}

Notice the duration_seconds field – we extracted it directly from the audio file using ffprobe. This metric will be handy later when we weight summarization segments.

6. Performance Tips & Gotchas

  • Chunking Large Files: Whisper can handle up to 5 GB per request (as per WhisperAI’s 2026 pricing sheet). If you expect longer recordings (e.g., 2‑hour webinars), split the audio into 30‑minute chunks with ffmpeg -ss and parallel‑process them using Python’s concurrent.futures. This is where GPT‑5.4 Pro parallel agents shine – you can dispatch each chunk to a separate summarizer worker.
  • Language Hinting: Providing the language parameter reduces latency by ~15 % because Whisper skips the auto‑detect step. Use the ISO‑639‑1 codes listed in Whisper’s docs.
  • Rate Limits: OpenAI’s Whisper endpoint is currently capped at 60 RPM for free-tier accounts. Store the Retry‑After header and implement exponential back‑off in production.
  • FFmpeg Compatibility: Some corporate videos use DRM or proprietary codecs. yt‑dlp will surface a DownloadError. In those cases, ask the source to provide a raw MP4 or use Daily’s recording.downloadUrl which already serves an H.264/AAC container.

7. Preparing for Part 3 – Summarization with Claude 4.6 Opus & GPT‑5.4 Pro

Now that you have a reliable transcription micro‑service, the next logical step is to feed the text into a summarizer. In the upcoming tutorial we’ll:

  • Wrap the Whisper endpoint in a /transcribe‑and‑summarize route.
  • Invoke Claude 4.6 Opus via Anthropic’s messages API (or GPT‑5.4 Pro parallel agents for multi‑modal summarization).
  • Persist the final summary in a PostgreSQL table for quick retrieval.

Because the transcription service is stateless and container‑friendly, you can scale it horizontally behind an NGINX or Cloud‑flare load balancer while the summarizer runs as a separate worker pool.


📚 References & Further Reading

Your Turn

Imagine you need to process live captions from a 30‑minute Daily.co meeting in under 5 seconds per minute of audio. Which architectural tweaks (e.g., streaming Whisper, GPU‑accelerated inference, chunk‑level parallelism) would you prioritize, and how would you measure the trade‑off between latency and transcript accuracy? Share your thoughts in the comments below!

❓ Frequently Asked Questions

What operating system and Python version are required to run the tutorial?

The guide works on Windows, macOS, or Linux with Python 3.11 installed. Ensure you have pip 23+ and a recent version of Git.

Do I need a GPU to use OpenAI’s Whisper model?

A GPU speeds up transcription dramatically, but the tutorial also runs on CPU‑only machines. The `whisper` package will automatically fall back to CPU if no CUDA device is detected.

How does the FastAPI service retrieve videos from YouTube?

The endpoint uses `yt-dlp` to download the video (or just the audio stream) to a temporary file, then passes that file to Whisper for transcription. The file is deleted after processing.

Can I replace the default Whisper model with a custom one?

Yes. Change the `model_name` argument when initializing `whisper.load_model()` (e.g., `base`, `small`, `medium`, `large`). Larger models improve accuracy but require more RAM and compute.

📺 Recommended Video

Watch this video for a practical overview of the topic covered in this article.

✍️ About the Author

Vijay Vinoth — Lead Programmer Analyst with expertise in PHP, Perl, Python, and Shell scripting. Passionate about AI, automation, and building scalable systems. Writing to share practical insights from real-world engineering experience.

Note: This technical analysis reflects my independent understanding as a Lead Programmer Analyst as of November 2026.
As AI ecosystems like Claude 4.6 Opus evolve, actual implementation may vary. Refer to official documentation for final specs.

By AI

To optimize for the 2026 AI frontier, all posts on this site are synthesized by AI models and peer-reviewed by the author for technical accuracy. Please cross-check all logic and code samples; synthetic outputs may require manual debugging

Leave a Reply

Your email address will not be published. Required fields are marked *