rajsecrets0 commited on
Commit
7ef0ee5
·
verified ·
1 Parent(s): 8f963f8

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +58 -0
  2. example.env +3 -0
  3. requirements (1).txt +5 -0
app.py ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from dotenv import load_dotenv
3
+
4
+ load_dotenv()
5
+ import os
6
+ import google.generativeai as genai
7
+
8
+ genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
9
+
10
+
11
+ from youtube_transcript_api import YouTubeTranscriptApi
12
+
13
+
14
+ # getting the transcript data from youtube videos
15
+ def extract_transcript_details(youtube_video_url):
16
+ try:
17
+ video_id =youtube_video_url.split("=")[1]
18
+ print(video_id)
19
+ transcript_text=YouTubeTranscriptApi.get_transcript(video_id)
20
+
21
+ transcript =""
22
+ for i in transcript_text:
23
+ transcript += " " + i["text"]
24
+
25
+ return transcript
26
+ except Exception as e:
27
+ raise e
28
+
29
+
30
+ # getting the summary from google gemini
31
+
32
+ prompt = """
33
+ you are a youtube video summariser , you take the transcript text and
34
+ summaries the entire video and providing the important summary inpoints within 250 words
35
+ the transcript text will be appended here
36
+ give the results in points and sub points :
37
+ """
38
+
39
+ def generate_gemini_content(transcript_text,prompt):
40
+ model = genai.GenerativeModel("gemini-pro")
41
+ response = model.generate_content(prompt+transcript_text)
42
+ return response.text
43
+
44
+
45
+ st.title("Youtube Video Summariser")
46
+ youtube_link = st.text_input("Enter YouTube Video Link")
47
+
48
+ if youtube_link:
49
+ video_id=youtube_link.split("=")[1]
50
+ print(video_id)
51
+ st.image(f"http://img.youtube.com/vi/{video_id}/0.jpg", use_column_width=True)
52
+ if st.button("Get Notes"):
53
+ transcript_text = extract_transcript_details(youtube_link)
54
+
55
+ if transcript_text:
56
+ summary=generate_gemini_content(transcript_text, prompt)
57
+ st.markdown("## Notes")
58
+ st.write(summary)
example.env ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ GOOGLE_API_KEY = "AIzaSy58dsdgO9H8SijNb-e2OvfLRims841"
2
+
3
+ #after putting your api key rename this file as .env
requirements (1).txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ youtube_transcript_api
2
+ streamlit
3
+ google-generativeai
4
+ python-dotenv
5
+ pathlib