yourownvibhore commited on
Commit
fe50a6b
·
verified ·
1 Parent(s): 895ec14

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +51 -52
app.py CHANGED
@@ -1,53 +1,52 @@
1
- from dotenv import load_dotenv
2
- load_dotenv()
3
- import streamlit as st
4
- import os
5
- import google.generativeai as genai
6
- from PIL import Image
7
- import pdf2image
8
- import io
9
- import base64
10
- from youtube_transcript_api import YouTubeTranscriptApi
11
-
12
- genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
13
- # load gemini model
14
-
15
- prompt="""You are Yotube video summarizer. You will be taking the transcript text
16
- and summarizing the entire video and providing the important summary in points
17
- within 250 words. Please provide the summary of the text given here: """
18
-
19
- def get_youtube_transcript(video_url):
20
- try:
21
- video_id = video_url.split("=")[1]
22
- # video_id = video_id.split("&")[0]
23
- print(video_id)
24
- transcript = YouTubeTranscriptApi.get_transcript(video_id)
25
- transcript_text = ""
26
- for i in transcript:
27
- transcript_text += " " + i['text']
28
- return transcript_text
29
- except Exception as e:
30
- raise e
31
-
32
-
33
- def get_gemini_response(transcript_text,prompt):
34
- model=genai.GenerativeModel("gemini-pro")
35
- response=model.generate_content(prompt+transcript_text)
36
- return response.text
37
-
38
-
39
-
40
- st.title("Youtube Transcript to detailed summary")
41
- st.markdown("This app uses gemini pro to generate a detailed summary of the transcript of a youtube video")
42
- video_url = st.text_input("Enter the youtube video url")
43
-
44
- if video_url:
45
- video_id=video_url.split("=")[1]
46
- print(video_id)
47
- st.image(f"https://img.youtube.com/vi/{video_id}/0.jpg",use_column_width=True)
48
- if st.button("Generate Summary"):
49
- transcript_text = get_youtube_transcript(video_url)
50
- if transcript_text:
51
- response = get_gemini_response(transcript_text,prompt)
52
- st.markdown("## Summary:")
53
  st.write(response)
 
1
+ from dotenv import load_dotenv
2
+ load_dotenv()
3
+ import streamlit as st
4
+ import os
5
+ import google.generativeai as genai
6
+ from PIL import Image
7
+ import io
8
+ import base64
9
+ from youtube_transcript_api import YouTubeTranscriptApi
10
+
11
+ genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
12
+ # load gemini model
13
+
14
+ prompt="""You are Yotube video summarizer. You will be taking the transcript text
15
+ and summarizing the entire video and providing the important summary in points
16
+ within 250 words. Please provide the summary of the text given here: """
17
+
18
+ def get_youtube_transcript(video_url):
19
+ try:
20
+ video_id = video_url.split("=")[1]
21
+ # video_id = video_id.split("&")[0]
22
+ print(video_id)
23
+ transcript = YouTubeTranscriptApi.get_transcript(video_id)
24
+ transcript_text = ""
25
+ for i in transcript:
26
+ transcript_text += " " + i['text']
27
+ return transcript_text
28
+ except Exception as e:
29
+ raise e
30
+
31
+
32
+ def get_gemini_response(transcript_text,prompt):
33
+ model=genai.GenerativeModel("gemini-pro")
34
+ response=model.generate_content(prompt+transcript_text)
35
+ return response.text
36
+
37
+
38
+
39
+ st.title("Youtube Transcript to detailed summary")
40
+ st.markdown("This app uses gemini pro to generate a detailed summary of the transcript of a youtube video")
41
+ video_url = st.text_input("Enter the youtube video url")
42
+
43
+ if video_url:
44
+ video_id=video_url.split("=")[1]
45
+ print(video_id)
46
+ st.image(f"https://img.youtube.com/vi/{video_id}/0.jpg",use_column_width=True)
47
+ if st.button("Generate Summary"):
48
+ transcript_text = get_youtube_transcript(video_url)
49
+ if transcript_text:
50
+ response = get_gemini_response(transcript_text,prompt)
51
+ st.markdown("## Summary:")
 
52
  st.write(response)