How ieee-sb-vit-pune/agentplay works
Purpose and Entry Points
This repository is a YouTube learning/translation companion: a Chrome extension augments YouTube pages while a Python backend extracts transcripts, generates AI summaries/notes/Q&A, translates timed segments, and returns synthesized audio. Backend startup is backend/main.py; the unpacked browser-extension entry is frontend/extension/manifest.json.
Browser Extension Client
The extension runs page-facing logic through frontend/extension/content.js, coordinates YouTube navigation/state through frontend/extension/navigation.js, and exposes controls via frontend/extension/popup.js and frontend/extension/sidebar.html. It detects video context, renders transcript/translation UI, tracks playback to synchronize highlighted lines, locally caches transcript-related state, and requests backend artifacts or audio on demand.
HTTP API and Orchestration
backend/main.py is the application boundary between the extension and content-processing services. It serves endpoints for transcript and metadata retrieval, summaries/notes, audio by video/language/segment, precomputation, and POST-based video Q&A. Its primary control flow keys work by YouTube video ID, target language, and transcript segment index.
Transcript and Cache Pipeline
The backend fetches YouTube transcripts, determines whether source text needs English normalization, and retains reusable transcript/derived artifacts so repeated client requests can avoid regeneration. Full-video text supports summary, notes, and Q&A; individual timestamped segments support playback-aligned translation/audio. This storage/cache responsibility is centered in backend/main.py.
AI Translation and Content Agents
backend/crew_helper.py encapsulates CrewAI-oriented content processing used by the backend. Translation handles large transcript input in chunks and translates requested segments with a nearby context window; this preserves local meaning while permitting independently generated audio. The same backend workflow invokes AI-generated concise summaries, structured notes, and answers to video-specific queries.
Audio Delivery
For a requested (video_id, target_language, segment_number), the system resolves or creates a translated segment, synthesizes speech with Edge TTS, caches the resulting audio, and returns it to the extension. frontend/extension/content.js aligns returned audio with current YouTube playback; backend/main.py owns the server-side retrieval/generation path.
Runtime and External Boundaries
The backend is Python with dependencies declared in backend/requirements.txt; it requires root-level environment credentials for Gemini, Serper, and Mistral services. External integrations include YouTube transcript/metadata access, LLM and search-backed agent services, CrewAI orchestration, and Edge TTS. The frontend is a Chrome extension governed by frontend/extension/manifest.json, requiring browser permissions to interact with YouTube pages and inject its interface.
Main entry points: main.py HTTP API & cache owner · content.js Page UI & playback sync · manifest.json Extension manifest · crew_helper.py Summary, notes & Q&A
Components 16
Chrome Extension
- Extension manifest · Declares YouTube access and extension runtime.
frontend/extension/manifest.json - Page UI & playback sync · Renders learning UI and aligns transcript/audio to playback.
frontend/extension/content.js - YouTube navigation state · Coordinates page changes and video context.
frontend/extension/navigation.js - Extension controls
frontend/extension/popup.js - Local transcript state
frontend/extension/content.js
Python Backend
- HTTP API & cache owner · Keys reusable artifacts by video, language, and segment.
backend/main.py - Transcript & normalization · Retrieves timed text and normalizes source text to English when needed.
backend/main.py - Transcript artifact cache · Stores transcripts, translations, generated content, and audio.
backend/main.py - Summary, notes & Q&A · Generates full-video learning artifacts and query answers.
backend/crew_helper.py - Contextual translation · Chunks large transcripts and translates segments with nearby context.
backend/crew_helper.py - Segment audio generation · Resolves translated segments and synthesizes cacheable speech.
backend/main.py - Backend dependencies
backend/requirements.txt
External Services
- YouTube transcripts & metadata
- LLM and search agents · Credentials are supplied through root-level environment settings.
- CrewAI
- Edge TTS
Connections 18
- Extension manifest → Page UI & playback sync: injects
- Extension manifest → YouTube navigation state: loads
- Extension manifest → Extension controls: exposes
- YouTube navigation state → Page UI & playback sync: updates video context
- Page UI & playback sync → Local transcript state: caches state
- Page UI & playback sync → HTTP API & cache owner: requests artifacts and audio
- HTTP API & cache owner → Transcript & normalization: retrieves transcript
- Transcript & normalization → YouTube transcripts & metadata: fetches timed text
- HTTP API & cache owner → Transcript artifact cache: reads and writes
- HTTP API & cache owner → Summary, notes & Q&A: requests learning artifacts
- HTTP API & cache owner → Contextual translation: requests segment translation
- Summary, notes & Q&A → CrewAI: orchestrates
- Summary, notes & Q&A → LLM and search agents: uses
- Contextual translation → LLM and search agents: uses
- HTTP API & cache owner → Segment audio generation: serves requested segment
- Segment audio generation → Contextual translation: resolves translation
- Segment audio generation → Edge TTS: synthesizes speech
- Backend dependencies → HTTP API & cache owner: runtime dependencies