This is a Python-based command-line tool for extracting transcripts from YouTube videos and generating structured summaries using OpenAI's GPT models. It first attempts to retrieve transcripts via the YouTube Transcript API, then falls back to audio transcription using the OpenAI Whisper API if necessary.
- Extracts YouTube transcripts using
youtube_transcript_api - Falls back to Whisper transcription via OpenAI API if transcript is unavailable
- Summarizes content using GPT-4 (or GPT-3.5 as a fallback)
- Outputs summary in structured format: summary, key points, actions, and statistics
- Prompts user to choose output format: terminal,
.md, or.txt - Secure API key handling via
.envfile - Clear logging for each step and failure mode
- Python 3.8 or higher
ffmpeg(required byyt-dlpfor audio extraction)- An OpenAI API key
-
Clone the repository:
git clone https://github.com/clorth0/gpt-video-summarizer.git cd gpt-video-summarizer -
Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate -
Install dependencies:
pip install -r requirements.txt
-
Install
ffmpegif not already installed:- macOS:
brew install ffmpeg - Ubuntu/Debian:
sudo apt install ffmpeg
- macOS:
-
Create a
.envfile in the project root:OPENAI_API_KEY=your-openai-api-key
Run the script using a YouTube video ID (not the full URL):
python transcribe.py <video_id>Example:
python transcribe.py dQw4w9WgXcQYou will be prompted to choose an output format:
Choose output format:
1. Print to terminal
2. Save as Markdown (.md)
3. Save as Plain Text (.txt)
Enter 1, 2, or 3:
Summaries include the following structure:
- One-line summary
- 3–5 key points
- 2–3 actionable steps
- Any statistics or claims mentioned
Markdown and text outputs are saved in the current working directory, named according to the video ID.
transcribe.py: Main CLI scriptgpt.py: Handles summarization logic via OpenAI APIrequirements.txt: Python dependencies.env: Stores OpenAI API key (excluded from version control)
- You must have a valid OpenAI API key with access to the GPT and Whisper APIs.
- This tool is designed for personal or research use; review OpenAI’s terms of service for usage constraints.
- Ensure that
yt-dlpandffmpegare functioning correctly in your environment.
MIT License. Contributions welcome.