A powerful AI-powered YouTube video transcript analyzer that allows you to ask questions about any YouTube video content. This bot extracts transcripts from YouTube videos, processes them using Google's Gemini AI, and provides intelligent answers to your questions based on the video content.
- Multi-language Support: Automatically detects and processes transcripts in English, Hindi, and Urdu
- AI-Powered Q&A: Ask questions about video content and get intelligent answers
- Transcript Cleaning: Automatically cleans and translates transcripts to fluent English
- Vector Search: Uses FAISS vector database for efficient semantic search
- RESTful API: FastAPI-based backend for easy integration
- Chrome Extension Ready: Configured for Chrome extension integration
- Transcript Extraction: Fetches YouTube video transcripts using the YouTube Transcript API
- Language Processing: Cleans, corrects grammar, and translates non-English transcripts
- Vector Embedding: Converts processed text into vector embeddings using Google's embedding model
- Semantic Search: Uses FAISS vector database to find relevant content chunks
- AI Answering: Generates contextual answers using Google's Gemini 2.0 Flash model
- Python 3.9+
- Google API Key (for Gemini AI and embeddings)
- YouTube video with available transcripts
-
Clone the repository
git clone https://github.com/Ahtaxam/RAG.git cd RAG -
Install dependencies
pip install -r requirements.txt
-
Set up environment variables Create a
.envfile in the root directory:GOOGLE_API_KEY=your_google_api_key_here
-
Get Google API Key
- Go to Google AI Studio
- Create a new API key
- Add it to your
.envfile
python api.pyThe server will start on http://localhost:5000
- Description: Health check endpoint
- Response:
{"message": "Hello World"}
- Description: Process a YouTube video and answer questions
- Request Body:
{ "video_id": "W4tqbEmplug", "question": "What is the main topic of this video?" } - Response:
{ "success": true, "video_id": "W4tqbEmplug", "message": "Video processed successfully", "answer": "The main topic of this video is..." }
import requests
# Process a video and ask a question
response = requests.post("http://localhost:5000/process", json={
"video_id": "W4tqbEmplug",
"question": "What are the key points discussed in this video?"
})
print(response.json()["answer"])ytBot/
โโโ api.py # FastAPI server and endpoints
โโโ load_transcript.py # YouTube transcript extraction and processing
โโโ index.py # Vector database operations and Q&A logic
โโโ requirements.txt # Python dependencies
โโโ .env # Environment variables (create this)
โโโ README.md # This file
- Extracts YouTube transcripts using
youtube_transcript_api - Supports multiple languages (English, Hindi, Urdu)
- Cleans and translates transcripts using Gemini AI
- Handles errors for disabled transcripts or missing content
- Converts transcripts to vector embeddings using Google's embedding model
- Creates FAISS vector database for semantic search
- Implements Q&A functionality using Gemini 2.0 Flash
- Retrieves relevant context chunks for accurate answers
- FastAPI server with CORS support for Chrome extension integration
- RESTful endpoints for video processing and Q&A
- Error handling and response formatting
The API is configured to work with Chrome extensions:
- CORS enabled for
chrome-extension://*origins - Supports localhost development
- Handles preflight OPTIONS requests
The bot can process transcripts in:
- English (en)
- Hindi (hi)
- Urdu (ur)
All transcripts are automatically translated to English for processing.
- Requires YouTube videos to have transcripts enabled
- Depends on Google API quotas and rate limits
- Video processing time depends on transcript length
- Maximum context window for Gemini model
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is open source and available under the MIT License.
- "Transcripts are disabled": The YouTube video doesn't have transcripts available
- "No transcript found": Try a different video or check available languages
- API Key errors: Ensure your Google API key is valid and has the necessary permissions
- CORS errors: Check that your Chrome extension origin is properly configured
If you encounter issues:
- Check the console logs for detailed error messages
- Verify your API key is correctly set in the
.envfile - Ensure the YouTube video has available transcripts
- Check your internet connection and API quotas
Made with โค๏ธ using FastAPI, LangChain, and Google Gemini AI