Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -19,33 +19,23 @@ def generate_summary(url):
|
|
19 |
summary = "\n".join(results)
|
20 |
return summary
|
21 |
|
22 |
-
|
23 |
-
|
24 |
try:
|
25 |
video_id = url.split("v=")[1].split("&")[0]
|
26 |
iframe = f'<iframe width="560" height="315" src="https://www.youtube.com/embed/{video_id}" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>'
|
27 |
-
return iframe
|
28 |
except IndexError:
|
29 |
-
return "
|
30 |
-
|
31 |
-
|
32 |
-
fn=
|
33 |
-
inputs=gr.Textbox(lines=2, placeholder="Enter
|
34 |
-
outputs=gr.HTML(label="YouTube Video"),
|
35 |
-
title="YouTube Video Display",
|
36 |
-
description="Enter the
|
37 |
-
)
|
38 |
-
|
39 |
-
summary_interface = gr.Interface(
|
40 |
-
fn=generate_summary,
|
41 |
-
inputs=gr.Textbox(lines=2, placeholder="Enter your URL..."),
|
42 |
-
outputs=gr.Textbox(label="Generated Text"),
|
43 |
-
title="Chào mừng đến với hệ thống tóm tắt của Minne >.<",
|
44 |
-
description="Enter the URL to summarize and click 'Submit' to generate the summary."
|
45 |
)
|
46 |
|
47 |
-
demo = gr.TabbedInterface([summary_interface, video_interface], ["Summary Generator", "YouTube Video Info"])
|
48 |
-
|
49 |
|
50 |
demo.launch(share=True)
|
51 |
|
|
|
19 |
summary = "\n".join(results)
|
20 |
return summary
|
21 |
|
22 |
+
def generate_summary_and_video(url):
|
23 |
+
summary = generate_summary(url)
|
24 |
try:
|
25 |
video_id = url.split("v=")[1].split("&")[0]
|
26 |
iframe = f'<iframe width="560" height="315" src="https://www.youtube.com/embed/{video_id}" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>'
|
27 |
+
return f"{iframe}\n\n**Summary:**\n{summary}"
|
28 |
except IndexError:
|
29 |
+
return f"**Summary:**\n{summary}\n\nInvalid YouTube URL for video display."
|
30 |
+
|
31 |
+
demo = gr.Interface(
|
32 |
+
fn=generate_summary_and_video,
|
33 |
+
inputs=gr.Textbox(lines=2, placeholder="Enter URL..."),
|
34 |
+
outputs=gr.HTML(label="YouTube Video and Summary"),
|
35 |
+
title="YouTube Video and Summary Display",
|
36 |
+
description="Enter the URL '.'"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
)
|
38 |
|
|
|
|
|
39 |
|
40 |
demo.launch(share=True)
|
41 |
|