Spaces:
Sleeping
Sleeping
Commit
•
d1bbbeb
1
Parent(s):
c1eb16a
Upload 2 files
Browse files- requirements.txt +5 -0
- yt_summarizer.py +47 -0
requirements.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
streamlit
|
2 |
+
PyPDF2
|
3 |
+
google.generativeai
|
4 |
+
python-dotenv
|
5 |
+
youtube_transcript_api
|
yt_summarizer.py
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from youtube_transcript_api import YouTubeTranscriptApi
|
2 |
+
import google.generativeai as genai
|
3 |
+
import os
|
4 |
+
import streamlit as st
|
5 |
+
from dotenv import load_dotenv
|
6 |
+
|
7 |
+
load_dotenv()
|
8 |
+
|
9 |
+
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
10 |
+
model = genai.GenerativeModel("gemini-pro")
|
11 |
+
prompt="""You are Yotube video summarizer. You will be taking the transcript text
|
12 |
+
and summarizing the entire video and providing the important summary in points
|
13 |
+
within 250 words. Please provide the summary of the text given here: """
|
14 |
+
|
15 |
+
def predict_result(transcript_text):
|
16 |
+
result = model.generate_content(prompt + transcript_text)
|
17 |
+
return result.text
|
18 |
+
|
19 |
+
def extract_transcript_details(youtube_video_url):
|
20 |
+
try:
|
21 |
+
video_id=youtube_video_url.split("=")[1]
|
22 |
+
|
23 |
+
transcript_text=YouTubeTranscriptApi.get_transcript(video_id)
|
24 |
+
|
25 |
+
transcript = ""
|
26 |
+
for i in transcript_text:
|
27 |
+
transcript += " " + i["text"]
|
28 |
+
|
29 |
+
return transcript
|
30 |
+
|
31 |
+
except Exception as e:
|
32 |
+
raise e
|
33 |
+
|
34 |
+
st.title("Youtube Video Transcript Summarizer")
|
35 |
+
video_url = st.text_input("Enter Youtube Video Link: ")
|
36 |
+
|
37 |
+
if video_url:
|
38 |
+
video_id = video_url.split("=")[1]
|
39 |
+
st.image(f"http://img.youtube.com/vi/{video_id}/0.jpg", use_column_width=True)
|
40 |
+
|
41 |
+
if st.button("Get Video Notes"):
|
42 |
+
transcript_text = extract_transcript_details(video_url)
|
43 |
+
|
44 |
+
if transcript_text:
|
45 |
+
summary = predict_result(transcript_text=transcript_text)
|
46 |
+
st.markdown("## Video Notes:")
|
47 |
+
st.write(summary)
|