arnabbumba077 commited on
Commit
1d5b91d
·
verified ·
1 Parent(s): 4430ef7

Upload 3 files

Browse files
Files changed (3) hide show
  1. .env +1 -0
  2. app.py +50 -0
  3. requirements.txt +6 -0
.env ADDED
@@ -0,0 +1 @@
 
 
1
+ GOOGLE_API_KEY="AIzaSyAJjp2hRJBGsei-o6kfvnZ8EeKkXl4-XuI"
app.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from dotenv import load_dotenv
3
+
4
+ load_dotenv() ## load all the environment variables
5
+ import os
6
+ from pytube import extract
7
+ import google.generativeai as genai
8
+ from youtube_transcript_api import YouTubeTranscriptApi
9
+
10
+ genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
11
+
12
+ prompt="""You are Youtube video notes maker. You will be taking the transcript text and make detailed notes of the text and provide the notes in points within 250 words. Please provide the notes given here.
13
+ """
14
+
15
+ ## Getting the transcript data from Youtube videos
16
+ def extract_transcript_details(youtube_video_url):
17
+ try:
18
+ video_id=extract.video_id(youtube_video_url)
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
+
27
+ except Exception as e:
28
+ raise e
29
+
30
+ ## Getting the summary based on Prompt from Google Gemini Pro
31
+ def generate_gemini_content(transcript_text,prompt):
32
+
33
+ model=genai.GenerativeModel("gemini-pro")
34
+ response=model.generate_content(prompt+transcript_text)
35
+ return response.text
36
+
37
+ st.title("Youtube Transcript to Detailed Notes Converter")
38
+ youtube_link=st.text_input("Enter the Youtube Video Link:")
39
+
40
+ if youtube_link:
41
+ video_id=extract.video_id(youtube_link)
42
+ st.image(f"https://img.youtube.com/vi/{video_id}/0.jpg", use_column_width=True)
43
+
44
+ if st.button("Get Detailed Notes"):
45
+ transcript_text=extract_transcript_details(youtube_link)
46
+
47
+ if transcript_text:
48
+ summary=generate_gemini_content(transcript_text, prompt)
49
+ st.markdown("## Detailed Notes:")
50
+ st.write(summary)
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ youtube_transcript_api
2
+ streamlit
3
+ google_generativeai
4
+ python-dotenv
5
+ pathlib
6
+ pytube