๐ซ CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org
๐ฅ Video Content Q&A with CAMEL-AI
An intelligent Streamlit-based application that uses the CAMEL-AI framework to allow users to extract, understand, and query the contents of YouTube videos. It leverages CAMEL toolkits and OpenAI models for transcription, summarization, and natural language Q&A.
๐ Features
- YouTube Video Downloader: Fetches video content directly from YouTube using CAMEL's
VideoDownloaderToolkit. - Audio Transcription: Extracts and transcribes audio with
AudioAnalysisToolkit. - Summarization Agent: Uses
ChatAgentwith GPT-4o-mini to generate concise summaries of the transcript. - Question Answering: Ask any natural language questions based on the transcript โ answers are grounded in the video's content.
๐งฐ Toolkits & Architecture
This app utilizes the following CAMEL-AI components:
VideoDownloaderToolkit: For downloading YouTube videos.AudioAnalysisToolkit: For audio-to-text transcription.ChatAgent: To summarize transcripts and answer questions using OpenAI models.
๐ ๏ธ Installation
Clone the Repository:
git clone https://github.com/camel-ai/camel.git cd examples/usecases/chat_with_youtubeSet Up Virtual Environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activateInstall Dependencies:
pip install -r requirements.txtConfigure Environment Variables:
Create a
.envfile and add your OpenAI API key:OPENAI_API_KEY=your_openai_api_keyInstall ffmpeg (for audio extraction):
- macOS:
brew install ffmpeg - Ubuntu:
sudo apt install ffmpeg - Windows: Download from ffmpeg.org
- macOS:
๐ช Using Authentication Cookies with yt-dlp
YouTube may require authentication for certain videos. To allow yt-dlp to access such content, you need to provide your own cookies.txt file.
Exporting Cookies from Your Browser
Using a Browser Extension:
- Chrome: Install Get cookies.txt LOCALLY
- Firefox: Install cookies.txt
After installing the extension:
- Navigate to YouTube and log in.
- Click the extension icon and export the cookies.
- Save the file as
cookies.txtin theexamples/usecases/chat_with_youtubedirectory.
Updating the Application to Use Your Cookies
In your code, specify the path to your cookies.txt:
video_toolkit = VideoAnalysisToolkit(cookies_path="cookies.txt")
Ensure that this path points to your exported cookies.txt file.
โถ๏ธ Running the Application
Start the Streamlit server:
streamlit run app.py
Then, paste a YouTube link, and the app will download the video, transcribe it, summarize it, and let you chat with it.
๐ Project Structure
video-qa-camel/
โโโ app.py # Main Streamlit application
โโโ downloads/ # Temporary video/audio files
โโโ .env # Environment variables (not committed)
โโโ requirements.txt # Python dependencies
โโโ README.md # Project documentation
๐ก Example Usage
- Launch the app using Streamlit.
- Paste a YouTube video URL.
- Wait for the download, audio extraction, and transcription to complete.
- View the summary.
- Ask any question based on the video's content and get an AI-generated answer.
๐ Notes
- This app does not yet support chunked retrieval-based Q&A for long transcripts. For scalable Q&A over long-form content, consider integrating an external vector database (e.g., Milvus, Pinecone) with chunking and embedding.
- All answers are context-aware, based on the entire transcript, but may be truncated for long videos due to model token limits.
๐ค Contributing
Feel free to open pull requests, issues, or discussions for improvements, new features, or bug fixes.