ns-devel
commited on
Commit
·
690a126
1
Parent(s):
0f465e7
Added exception
Browse files
app.py
CHANGED
|
@@ -27,48 +27,51 @@ def download_youtube_video(video_url):
|
|
| 27 |
|
| 28 |
|
| 29 |
def main():
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
|
|
|
| 56 |
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
|
|
|
|
|
|
| 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__":
|