|
|
import streamlit as st |
|
|
from dotenv import load_dotenv |
|
|
|
|
|
load_dotenv() |
|
|
import os |
|
|
from pytube import extract |
|
|
import google.generativeai as genai |
|
|
from youtube_transcript_api import YouTubeTranscriptApi |
|
|
|
|
|
genai.configure(api_key=os.getenv("GOOGLE_API_KEY")) |
|
|
|
|
|
prompt="""You are Youtube video notes maker. You will be taking the transcript text and make detailed notes of the text and provide the notes in points within 250 words. Please provide the notes given here. |
|
|
""" |
|
|
|
|
|
|
|
|
def extract_transcript_details(youtube_video_url): |
|
|
try: |
|
|
video_id=extract.video_id(youtube_video_url) |
|
|
transcript_text=YouTubeTranscriptApi.get_transcript(video_id) |
|
|
|
|
|
transcript="" |
|
|
for i in transcript_text: |
|
|
transcript+=" " + i["text"] |
|
|
|
|
|
return transcript |
|
|
|
|
|
except Exception as e: |
|
|
raise e |
|
|
|
|
|
|
|
|
def generate_gemini_content(transcript_text,prompt): |
|
|
|
|
|
model=genai.GenerativeModel("gemini-pro") |
|
|
response=model.generate_content(prompt+transcript_text) |
|
|
return response.text |
|
|
|
|
|
st.title("Youtube Transcript to Detailed Notes Converter") |
|
|
youtube_link=st.text_input("Enter the Youtube Video Link:") |
|
|
|
|
|
if youtube_link: |
|
|
video_id=extract.video_id(youtube_link) |
|
|
st.image(f"https://img.youtube.com/vi/{video_id}/0.jpg", use_column_width=True) |
|
|
|
|
|
if st.button("Get Detailed Notes"): |
|
|
transcript_text=extract_transcript_details(youtube_link) |
|
|
|
|
|
if transcript_text: |
|
|
summary=generate_gemini_content(transcript_text, prompt) |
|
|
st.markdown("## Detailed Notes:") |
|
|
st.write(summary) |