A Streamlit-based web application that lets users ask questions about the content of a YouTube video using its English transcript. It extracts the transcript, breaks it into chunks, embeds it using HuggingFace models, and answers questions via the Perplexity LLM.
- π Enter any YouTube video URL with English captions
- π€ Ask natural language questions about the video
- π§ Powered by Perplexity LLM & HuggingFace sentence embeddings
- π Context-aware QA using FAISS vector store
- π¨ Clean UI with custom background and styled answer box
The core Streamlit app that:
- Accepts a YouTube URL and user question
- Fetches and processes transcript using
youtube-transcript-api - Splits transcript into chunks with
RecursiveCharacterTextSplitter - Generates embeddings using
sentence-transformers/all-MiniLM-L6-v2 - Stores vectors in FAISS and retrieves top
ksimilar chunks - Feeds context and question into a prompt chain using Perplexity
- Displays the generated answer in a styled output box
- Python
- Streamlit
- LangChain
- HuggingFace Sentence Transformers
- Perplexity Chat API
- FAISS
- YouTube Transcript API
-
Clone the repository
git clone https://github.com/TahaCoder563/Youtube-Transcript-Chat.git cd Youtube-Transcript-Chat -
Install dependencies
pip install -r requirements.txt
-
Set up API keys
π Get a Perplexity API Key:
- Go to https://docs.perplexity.ai
- Sign in or create an account
- Generate a new API key from the dashboard
π Get a HuggingFace API Token:
- Go to https://huggingface.co/settings/tokens
- Create a token with read access
Create a .env file in the root of the project and paste your keys:
PERPLEXITY_API_KEY="your_perplexity_api_key_here" HUGGINGFACEHUB_API_TOKEN="your_huggingface_token_here"
Replace the your_perplexity_api_key_here and your_huggingface_token_here with the respective api keys.
-
Run the app
streamlit run main.py