A Python application that fetches a YouTube video's transcript, splits it into meaningful chunks, stores the content in a vector database, and uses IBM Watsonx to generate a summary and answer questions about the video.
This project combines:
- YouTube transcript extraction
- transcript preprocessing and chunking
- FAISS-based semantic retrieval
- IBM Watsonx LLM summarization
- Q&A generation from video content
- a Gradio interface for easy interaction
- Extract transcript from a public YouTube URL
- Filter and normalize transcript text
- Chunk transcript content for efficient retrieval
- Create embeddings with IBM Watsonx
- Search relevant sections using FAISS similarity search
- Generate a concise video summary
- Answer user questions based on the transcript context
- Launch a simple web UI using Gradio
ytbot.py- main app containing transcript extraction, embedding, RAG pipeline, and Gradio interfaceREADME.MD- project documentation
- Python 3.11+
- pip
- IBM Cloud / IBM watsonx access
- Access to public YouTube transcripts
- Clone the repository
git clone https://github.com/AlanMelendez/AI-Powered-YouTube-Summarizer.git
cd AI-Powered-YouTube-Summarizer- Create and activate a virtual environment
On macOS/Linux:
python3 -m venv my_env
source my_env/bin/activateOn Windows:
python -m venv my_env
my_env\Scripts\activate- Install dependencies
pip install virtualenv
pip install youtube-transcript-api==1.2.1
pip install faiss-cpu==1.8.0
pip install langchain==0.2.6
pip install langchain-community==0.2.6
pip install ibm-watsonx-ai==1.0.10
pip install langchain_ibm==0.1.8
pip install gradio==4.44.1
python -m pip uninstall -y huggingface_hub
python -m pip install huggingface_hub==0.16.4
pip install --upgrade gradio fastapi starlette jinja2The application is configured in ytbot.py inside the setup_credentials() function and other model configuration blocks.
You will need to update these values for your environment:
- IBM watsonx service URL
- IBM project ID
- model ID used for generation and embeddings
Example configuration pattern:
model_id = "ibm/granite-8b-code-instruct"
credentials = Credentials(url="https://us-south.ml.cloud.ibm.com")
project_id = "your-watsonx-project-id"Make sure your IBM watsonx account has valid credentials and the required permissions before running the app.
Run the application:
python ytbot.pyThis starts the Gradio interface in your browser. Then:
- Paste a YouTube video URL
- Click the relevant action to generate a summary or ask a question
- Review the output generated from the video's transcript
The application follows this flow:
- Reads the YouTube URL
- Extracts the video ID using a regex
- Fetches the transcript using
youtube-transcript-api - Cleans and formats transcript data
- Splits the transcript into chunks
- Creates embeddings using IBM Watsonx
- Stores the chunks in a FAISS vector index
- Uses similarity search to find the most relevant content
- Sends the relevant transcript sections to an LLM for summary or Q&A generation
[
{
"text": "We're no strangers to love.",
"start": 0.0,
"duration": 3.5
},
{
"text": "You know the rules and so do I.",
"start": 3.5,
"duration": 4.0
},
{
"text": "A full commitment's what I'm thinking of.",
"start": 7.5,
"duration": 4.0
}
]- Some YouTube videos do not provide transcripts or may require manually generated captions.
- The app focuses on public videos and transcript-based analysis.
- The quality of the summary depends on the transcript quality and Watsonx model configuration.
- Add support for video metadata and chapter extraction
- Improve prompt quality for faster, more accurate summaries
- Add a requirement file for easier environment setup
- Add error handling for unsupported or private videos
- Add support for multiple languages and transcript selection
This project is intended for educational and personal use. Add a license if you plan to share or distribute it publicly.
Pull requests and improvements are welcome. If you want to extend the app, consider improving:
- transcript error handling
- multi-language support
- better citation and retrieval logic
- UI usability
- deployment setup