Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

Summarizer

A lightweight desktop app that grabs the YouTube video URL from your clipboard, pulls its subtitles, and uses GPT-3.5 Turbo to summarize the video into key points, all from a small always-available customtkinter window with a global hotkey.


Features

  • One-hotkey summarization: press Alt+S anywhere on your system to summarize the YouTube video URL currently in your clipboard.
  • Automatic language fallback: tries English first, then a manually-provided transcript, then auto-generated captions, then falls back through 10 other languages if English isn't available.
  • Follow-up enquiries: ask custom questions about the video (or about anything, even without subtitles) and chain follow-up questions off previous answers.
  • View & copy raw subtitles: inspect the original transcript text and copy it to your clipboard.
  • Dark-themed GUI built with customtkinter.

How it works

  1. You copy a YouTube link (e.g. https://www.youtube.com/watch?v=...) to your clipboard.
  2. You either click Get Subtitles in the app window, or press the global hotkey Alt+S (works even if the app is in the background, it brings itself to the front automatically).
  3. The app extracts the video ID from the URL and requests its transcript via youtube-transcript-api.
  4. If subtitles are found, the full transcript text is truncated (to stay within token limits) and sent to OpenAI's gpt-3.5-turbo model with a summarization prompt.
  5. The summary is displayed in the main text box. The full original transcript is kept in memory so you can view it later or use it as context for follow-up questions.
  6. From the Enquiry window you can ask GPT a custom question. If a transcript is loaded, it's included as context; otherwise the question is answered standalone. Each answer has its own Enquiry button so you can keep drilling deeper, using the previous answer as the new reference text.

Architecture

flowchart TD
    A[Clipboard: YouTube URL] -->|Alt+S or Get Subtitles button| B[fetch_subtitles]
    B --> C{Extract video_id}
    C --> D[get_subtitles via youtube_transcript_api]
    D -->|Manual transcript found?| E{Yes/No}
    E -->|No| F[Try auto-generated a.lang transcript]
    E -->|Yes| G[Format transcript to plain text]
    F --> G
    G --> H[truncate_text: cap token/word count]
    H --> I[summarize_text via OpenAI gpt-3.5-turbo]
    I --> J[Display summary in main text_box]
    G --> K[Store as original_subtitles - global state]

    L[Enquiry button] --> M[open_enquiry_window]
    M --> N{original_subtitles loaded?}
    N -->|Yes| O[perform_enquiry: subtitles + prompt + reference_text]
    N -->|No| P[ask_without_subtitles: prompt + reference_text]
    O --> Q[OpenAI chat.completions.create]
    P --> Q
    Q --> R[show_enquiry_response window]
    R -->|Click Enquiry again| M

    S[Show Subtitles button] --> T[show_original_subtitles window]
    T --> U[Copy to clipboard via pyperclip]
Loading

Component breakdown

Layer Responsibility Key functions
Input capture Reads the YouTube URL from the OS clipboard, listens for the global hotkey pyperclip.paste(), keyboard.add_hotkey('alt+s', ...)
Transcript retrieval Fetches manual or auto-generated captions in the requested language, with multi-language fallback get_subtitles(), YouTubeTranscriptApi
Text preprocessing Caps the transcript length so it fits within the model's context window truncate_text()
LLM summarization Sends the transcript to OpenAI and returns a structured summary summarize_text(), OpenAI client
Interactive Q&A Lets the user ask follow-up questions, with or without transcript context, chaining prior answers as new context open_enquiry_window(), perform_enquiry(), ask_without_subtitles(), show_enquiry_response()
GUI layer Dark-themed window, buttons, popups for subtitles/responses customtkinter (CTk, CTkToplevel, CTkTextbox, CTkButton)
App state In-memory globals tracking the current transcript and last answer (no persistence/database) original_subtitles, last_enquiry_response

The app is a single-process, single-file Python script with no backend server. All "architecture" lives inside one event loop (root.mainloop()), with the OpenAI API as the only external LLM dependency and the clipboard as the only "input channel" for video selection.


Requirements

  • Python 3.9+
  • An OpenAI API key with access to gpt-3.5-turbo

Python packages

pip install customtkinter youtube-transcript-api pyperclip openai keyboard

Note: On Linux, the keyboard library typically requires root privileges to capture global hotkeys (run with sudo). On macOS, you may need to grant Accessibility/Input Monitoring permissions to your terminal/IDE.


Setup

  1. Clone or download Summarizer.py.
  2. Open the file and replace the placeholder API key:
    api_key = 'your_openai_api_key'
    with your real OpenAI API key. For better security, use an environment variable instead:
    import os
    api_key = os.environ.get("OPENAI_API_KEY")
  3. Install the dependencies listed above.
  4. Run the app:
    python Summarizer.py

Usage

  1. Copy any YouTube watch URL to your clipboard.
  2. Press Alt+S, or click Get Subtitles in the app window.
  3. Read the generated summary in the main panel.
  4. Click Show Subtitles to view (and copy) the full original transcript.
  5. Click Enquiry to ask a custom question, about the video or anything else, and keep the conversation going by clicking Enquiry again from the response window.

Known limitations

  • Only works with publicly available YouTube subtitles (manual or auto-generated); videos with subtitles disabled won't summarize.
  • Long transcripts are truncated by word count rather than true token count, so very long videos may be cut short before summarization.
  • The OpenAI API key is currently hardcoded as a placeholder in the script. Move it to an environment variable before sharing or committing this code anywhere public.
  • Global hotkey support depends on OS-level permissions and may not work identically across Windows/macOS/Linux.

About

A Python application that fetches, summarizes YouTube subtitles, and allows detailed enquiries using GPT-3.5 Turbo.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages