decodingdatascience commited on
Commit
a9be1fa
1 Parent(s): e02a4c0

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +69 -0
  2. requirements.txt +5 -0
app.py ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from dotenv import load_dotenv
3
+
4
+ load_dotenv() ##load all the evironment variables
5
+ import os
6
+ import google.generativeai as genai
7
+
8
+ from youtube_transcript_api import YouTubeTranscriptApi
9
+
10
+ genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
11
+
12
+ prompt="""
13
+ You are an expert AI assistant specializing in transcribing and taking detailed notes
14
+ from transcript related to Machine Learning, Deep Learning, and Artificial Intelligence.
15
+ Your task is to provide a comprehensive summary of the following transcript,
16
+ including all key points, discussions, and Q&A sessions.
17
+ Please follow these guidelines:
18
+
19
+ 1. Main Content:
20
+ - Identify and summarize the main topic(s) discussed in the transcript.
21
+ - List all key concepts, theories, and techniques mentioned.
22
+ - Provide detailed explanations for each concept, including definitions, applications, and significance in the field.
23
+ - Note any examples or case studies presented to illustrate concepts.
24
+ - Capture any formulas, algorithms, or code snippets discussed, ensuring they are accurately transcribed.
25
+ - Highlight any cutting-edge research or recent advancements mentioned.
26
+ Please provide the summary of the text given here: """
27
+
28
+
29
+ ## getting the transcript data from yt videos
30
+ def extract_transcript_details(youtube_video_url):
31
+ try:
32
+ video_id=youtube_video_url.split("=")[1]
33
+
34
+ transcript_text=YouTubeTranscriptApi.get_transcript(video_id)
35
+
36
+ transcript = ""
37
+ for i in transcript_text:
38
+ transcript += " " + i["text"]
39
+
40
+ return transcript
41
+
42
+ except Exception as e:
43
+ raise e
44
+
45
+ ## getting the summary based on Prompt from Google Gemini Pro
46
+ def generate_gemini_content(transcript_text,prompt):
47
+
48
+ model=genai.GenerativeModel("gemini-pro")
49
+ response=model.generate_content(prompt+transcript_text)
50
+ return response.text
51
+
52
+ st.title("🎥DDS YouTube Note Generator")
53
+ youtube_link = st.text_input("Enter YouTube Video Link:")
54
+
55
+ if youtube_link:
56
+ video_id = youtube_link.split("=")[1]
57
+ print(video_id)
58
+ st.image(f"http://img.youtube.com/vi/{video_id}/0.jpg", use_column_width=True)
59
+
60
+ if st.button("Get Detailed Notes"):
61
+ transcript_text=extract_transcript_details(youtube_link)
62
+
63
+ if transcript_text:
64
+ summary=generate_gemini_content(transcript_text,prompt)
65
+ st.markdown("## Detailed Notes are below:")
66
+ st.write(summary)
67
+
68
+
69
+
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ youtube_transcript_api
2
+ streamlit
3
+ google-generativeai
4
+ python-dotenv
5
+ pathlib