This project allows you to extract the transcript of a YouTube video and use Google's Gemini model (via the Google Generative AI library) in combination with Langchain to generate a concise summary directly in a Streamlit application.
Here’s what the application looks like in action:
-
Purpose: Provide a simple and elegant web interface to:
- Extract a video's transcript from YouTube.
- Automatically summarize that transcript using Google's Gemini model.
- Display the video itself and the resulting summary on a single page.
-
Key Technologies:
- Streamlit: Quickly build data and AI web apps in Python.
- Google Generative AI: Access to Google’s LLMs (Gemini in this case).
- YouTube Transcript API: Retrieve subtitles (transcripts) from YouTube videos.
- Langchain: A framework for orchestrating LLM usage.
- Python-dotenv: Manages environment variables securely.
-
Python 3.7+
Make sure you have Python installed on your system. -
Google API Key
- You need a Google Cloud developer account and must enable the Generative AI (PaLM) API.
- Create and obtain your
GOOGLE_API_KEYto use the Gemini model.
-
Package Installation
In the project directory, run:pip install -r requirements.txt
If you don’t have a
requirements.txtfile yet, create one containing the packages used:streamlit google-generativeai youtube_transcript_api langchain langchain_google_genai python-dotenv -
Environment Variables
Create a.envfile at the project root with the following content:GOOGLE_API_KEY=YOUR_KEY_HERE
- .env: File that stores the
GOOGLE_API_KEYenvironment variable. - requirements.txt: List of the necessary libraries to run the application.
- app.py: Main script containing the Streamlit code.
- Clone this repository (or download as a ZIP and extract):
git clone https://github.com/your-username/your-repo.git
- Navigate to the project folder:
cd your-repo - Install dependencies:
pip install -r requirements.txt
- Create the
.envfile with your API key, for example:GOOGLE_API_KEY=YOUR_API_KEY_HERE - Start the application:
streamlit run app.py
- Open your browser at the URL provided by Streamlit (usually
http://localhost:8501).
- Paste the YouTube video link: Enter the URL in the text input field.
- Wait for the transcript: The app automatically fetches the subtitles (transcript) from the video.
- Summary: The Gemini model processes the transcript and displays a summary on the same page.
- Optional: Click on "View full transcript" to see the entire video transcript.
- You can change the look and feel (colors, fonts, sizes) by editing the
<style>section withinapp.py. - To switch to a different LLM model, modify the
modelparameter when instantiatingGoogleGenerativeAI.
Contributions are welcome! Follow these steps:
- Fork this repository.
- Create a new branch for your feature or bug fix:
git checkout -b my-new-feature
- Commit your changes.
- Open a pull request (PR) for this repository.
Note: Make sure the YouTube video has subtitles (automatic or creator-provided) to successfully retrieve the transcript.
