ns-devel commited on
Commit
690a126
1 Parent(s): 0f465e7

Added exception

Browse files
Files changed (1) hide show
  1. app.py +44 -41
app.py CHANGED
@@ -27,48 +27,51 @@ def download_youtube_video(video_url):
27
 
28
 
29
  def main():
30
- st.title("VideoClarify")
31
- # Get video URL from user
32
- video_url = st.text_input("Enter Video URL:", key="video_url")
33
- selected_model = st.sidebar.selectbox("Select Model", ["Gemini", "OpenAI"])
34
- st.sidebar.subheader("About Tool:")
35
- st.sidebar.markdown("""
36
- VideoClarify is a tool that uses AI to summarize and answer questions about a video.
37
- """)
38
- st.sidebar.subheader("Explore These Questions:")
39
- st.sidebar.markdown("""
40
- 1. Can you summarize the key points or message of the video?
41
- 2. What is the central theme or main idea conveyed in the video?
42
- 3. What specific examples or evidence are provided in the video to support the main points?
43
- 4. Is there a specific term or jargon used in the video that I need to clarify?
44
- 5. Write a well structure article based on this video
45
- """)
46
-
47
- if len(video_url):
48
- video_url = download_youtube_video(video_url)
49
- print(video_url)
50
- st.video(video_url)
51
- # Get transcript from the video
52
- transcript = get_cached_transcript(video_url)
53
- # Provide an input box for user to ask a question
54
- question = st.text_input(
55
- label="Ask a question about the video:", key="question")
 
56
 
57
- if st.button("Get Answer"):
58
- if question:
59
- if selected_model == "Gemini":
60
- st.info("Using Gemini to answer the question.")
61
- # Use Gemini to summarize and answer the question
62
- response = gemini(transcript, question)
63
- if selected_model == "OpenAI":
64
- st.info("Using OpenAI to answer the question.")
65
- # Use OpenAI to summarize and answer the question
66
- response = get_completion(transcript, question)
67
- # Display the result to the user
68
- st.subheader("Result:")
69
- st.write(response)
70
- else:
71
- st.info("Please ask a question about the video.")
 
 
72
 
73
 
74
  if __name__ == "__main__":
 
27
 
28
 
29
  def main():
30
+ try:
31
+ st.title("VideoClarify")
32
+ # Get video URL from user
33
+ video_url = st.text_input("Enter YouTube URL:", key="video_url")
34
+ selected_model = st.sidebar.selectbox("Select Model", ["Gemini", "OpenAI"])
35
+ st.sidebar.subheader("About Tool:")
36
+ st.sidebar.markdown("""
37
+ VideoClarify is a tool that uses AI to summarize and answer questions about a video.
38
+ """)
39
+ st.sidebar.subheader("Explore These Questions:")
40
+ st.sidebar.markdown("""
41
+ 1. Can you summarize the key points or message of the video?
42
+ 2. What is the central theme or main idea conveyed in the video?
43
+ 3. What specific examples or evidence are provided in the video to support the main points?
44
+ 4. Is there a specific term or jargon used in the video that I need to clarify?
45
+ 5. Write a well structure article based on this video
46
+ """)
47
+
48
+ if len(video_url):
49
+ video_url = download_youtube_video(video_url)
50
+ print(video_url)
51
+ st.video(video_url)
52
+ # Get transcript from the video
53
+ transcript = get_cached_transcript(video_url)
54
+ # Provide an input box for user to ask a question
55
+ question = st.text_input(
56
+ label="Ask a question about the video:", key="question")
57
 
58
+ if st.button("Get Answer"):
59
+ if question:
60
+ if selected_model == "Gemini":
61
+ st.info("Using Gemini to answer the question.")
62
+ # Use Gemini to summarize and answer the question
63
+ response = gemini(transcript, question)
64
+ if selected_model == "OpenAI":
65
+ st.info("Using OpenAI to answer the question.")
66
+ # Use OpenAI to summarize and answer the question
67
+ response = get_completion(transcript, question)
68
+ # Display the result to the user
69
+ st.subheader("Result:")
70
+ st.write(response)
71
+ else:
72
+ st.info("Please ask a question about the video.")
73
+ except Exception as e:
74
+ st.write("Please refresh the page and try again.")
75
 
76
 
77
  if __name__ == "__main__":