A Python toolkit for working with YouTube videos: fetch captions, summarize them, run sentiment / readability analysis, and chat with a video using a local LLM and RAG.
Three providers, all driven by a video URL:
Pulls the transcript for any YouTube video (using youtube-transcript-api), translates non-English transcripts to English, and runs Silero TE for punctuation restoration and sentence segmentation on raw captions.
Feeds the segmented transcript into a fine-tuned BART model (philschmid/bart-large-cnn-samsum) chunk by chunk to produce a readable summary. The chunk size and compression ratio are configurable.
Splits the transcript with LangChain's RecursiveCharacterTextSplitter, embeds the chunks using HuggingFace's instructor-xl, indexes them in a local Chroma vector store, and answers questions about the video using a locally-loaded Vicuna 7B (TheBloke/vicuna-7B-1.1-HF) wrapped in a LangChain RetrievalQA chain.
A separate analyzer over arbitrary text that returns Flesch-Kincaid readability, emotional tone, detected calls-to-action via spaCy NER, and the top frequent words.
- Captions:
youtube-transcript-api, Silero TE (snakers4/silero-models) - Summarization: HuggingFace Transformers, BART
- RAG: LangChain, Chroma,
HuggingFaceInstructEmbeddings, Vicuna 7B - NLP analysis: NLTK, spaCy
config.py model names, paths, Chroma settings
providers/summarizer/caption.py caption fetch, translation, sentence segmentation
providers/summarizer/summary.py BART-based summarization
providers/chat/chat.py RAG: chunk, embed, Chroma, Vicuna QA
providers/sentiment/sentiment.py readability, tone, CTA, word freq
git clone https://github.com/sid6i7/youtube-toolkit
cd youtube-toolkit
pip install -r requirements.txtThen import the provider you need:
from providers.summarizer.caption import Caption
from providers.summarizer.summary import Summarizer
caption = Caption().get_caption("https://www.youtube.com/watch?v=...")
summary = Summarizer().generate_summary(caption)The chat provider loads Vicuna 7B locally, which is GPU-friendly. CPU inference works but is slow.