venkataseetharam commited on
Commit
e2085a1
·
verified ·
1 Parent(s): 6780768

Upload 3 files

Browse files
Files changed (3) hide show
  1. .env +1 -0
  2. app.py +41 -0
  3. requirements.txt +5 -0
.env ADDED
@@ -0,0 +1 @@
 
 
1
+ GOOGLE_API_KEY="AIzaSyBXaH75cGy75Ve6aIzJKNT1T51TuDcoWxY"
app.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from dotenv import load_dotenv
3
+ load_dotenv() #load all the environment variables
4
+ import os
5
+ import google.generativeai as genai
6
+ from youtube_transcript_api import YouTubeTranscriptApi
7
+ genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
8
+
9
+ prompt="""You are a youtube video summarizer.You will be taking the transcript text and summarizing the entire video
10
+ and providing the important summary in points.Please provide the summary of the text given here"""
11
+ #getting the transcript data from the video
12
+ def extract_transcript_details(youtube_video_url):
13
+ try:
14
+ video_id=youtube_video_url.split("=")[1]
15
+ transcript_text=YouTubeTranscriptApi.get_transcript(video_id)
16
+ transcript=""
17
+ for i in transcript_text:
18
+ transcript+=" "+i["text"]
19
+ return transcript
20
+ except Exception as e:
21
+ raise e
22
+ #getting the summary from google gemini
23
+ def generate_gemini_content(transcript_text,prompt):
24
+ model=genai.GenerativeModel("gemini-pro")
25
+ response=model.generate_content(prompt+transcript_text)
26
+ return response.text
27
+
28
+ st.title("YouTube Transcript to Detailed Notes Converted")
29
+ youtube_link=st.text_input("Enter you YouTube Video URL:")
30
+
31
+ if youtube_link:
32
+ video_id=youtube_link.split("=")[1]
33
+ st.image(f"http://img.youtube.com/vi/{video_id}/0.jpg",use_column_width=True)
34
+
35
+ if st.button("Get detailed notes"):
36
+ transcript_text=extract_transcript_details(youtube_link)
37
+
38
+ if transcript_text:
39
+ summary=generate_gemini_content(transcript_text,prompt)
40
+ st.markdown("## Detailed Notes:")
41
+ st.write(summary)
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ youtube_transcript_api
2
+ streamlit
3
+ google-generativeai
4
+ python-dotenv
5
+ pathlib