CoolFace
Apppublic

Labhesh21/casestudy1

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
app.py62 linesDownload Raw Back to root
1import streamlit as st2from dotenv import load_dotenv3load_dotenv() #load all the env variavles4import google.generativeai as genai5import os6 7from youtube_transcript_api import YouTubeTranscriptApi8 9 10genai.configure(api_key="AIzaSyAfdQk9QbT30BfNwHfDJGZaIBVqS-781J8")11 12prompt="""You are a Youtube Video Summarizer.You will be taking the transcript text and summarize the entire video and providing the important summary in points within 250 words.Please Provide the summary of the text given here:  """13 14 15## getting the transcript data from the youtube videos16 17def extract_transcript_details(youtube_video_url):18    try:19        video_id=youtube_video_url.split("=")[1]20        print(video_id)21        transcript_text=YouTubeTranscriptApi.get_transcript(video_id)22        transcript=""23        for i in transcript_text:24            transcript+=" "+i["text"]25        return transcript26 27 28 29 30    except Exception as e:31        raise e32 33 34## getting the summary based on Prompt from Gooogle Gemini Pro35 36def generate_gemini_content(transcript_text,prompt):37 38    model=genai.GenerativeModel("gemini-pro")39    response=model.generate_content(prompt+transcript_text)40    return response.text41 42 43 44st.title("Youtube Transcript to Detailed Notes Converter")45youtube_link=st.text_input("Enter the youtube video Link:")46 47if youtube_link:48    video_id=youtube_link.split("=")[1]49    print(video_id)50    st.image(f"http://img.youtube.com/vi/{video_id}/0.jpg",use_column_width=True)51 52 53if st.button("Get Detailed Notes"):54    transcript_text=extract_transcript_details(youtube_link)55 56    if transcript_text:57        summary=generate_gemini_content(transcript_text,prompt)58        st.markdown("## Detailed Notes")59        st.write(summary)60 61 62