Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -69,16 +69,16 @@ def url_to_av_summary(url):
|
|
69 |
'-vf', (
|
70 |
"drawtext=fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf:text='" + summary +
|
71 |
"':fontcolor=white:fontsize=48:box=1:[email protected]:boxborderw=5:"
|
72 |
-
"x=(w-text_w)/2:y=h-(t*(h+text_h)/
|
73 |
),
|
74 |
-
'-t', '
|
75 |
'-c:v', 'libx264', '-c:a', 'aac', '-pix_fmt', 'yuv420p', '-shortest', video_path
|
76 |
]
|
77 |
subprocess.run(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
78 |
return summary, video_path
|
79 |
|
80 |
# Timeout wrapper
|
81 |
-
def safe_summary(url, timeout_secs=
|
82 |
with concurrent.futures.ThreadPoolExecutor() as executor:
|
83 |
future = executor.submit(url_to_av_summary, url)
|
84 |
try:
|
@@ -91,8 +91,8 @@ iface = gr.Interface(
|
|
91 |
inputs=gr.Textbox(label="Article URL"),
|
92 |
outputs=[gr.Textbox(label="Summary"), gr.Video(label="Video Preview")],
|
93 |
title="🎥 Promo-Style AV Summary with Gradient Background",
|
94 |
-
description="Generates a
|
95 |
)
|
96 |
|
97 |
if __name__ == '__main__':
|
98 |
-
iface.launch()
|
|
|
69 |
'-vf', (
|
70 |
"drawtext=fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf:text='" + summary +
|
71 |
"':fontcolor=white:fontsize=48:box=1:[email protected]:boxborderw=5:"
|
72 |
+
"x=(w-text_w)/2:y=h-(t*(h+text_h)/300)"
|
73 |
),
|
74 |
+
'-t', '300', # 5 minutes max
|
75 |
'-c:v', 'libx264', '-c:a', 'aac', '-pix_fmt', 'yuv420p', '-shortest', video_path
|
76 |
]
|
77 |
subprocess.run(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
78 |
return summary, video_path
|
79 |
|
80 |
# Timeout wrapper
|
81 |
+
def safe_summary(url, timeout_secs=300):
|
82 |
with concurrent.futures.ThreadPoolExecutor() as executor:
|
83 |
future = executor.submit(url_to_av_summary, url)
|
84 |
try:
|
|
|
91 |
inputs=gr.Textbox(label="Article URL"),
|
92 |
outputs=[gr.Textbox(label="Summary"), gr.Video(label="Video Preview")],
|
93 |
title="🎥 Promo-Style AV Summary with Gradient Background",
|
94 |
+
description="Generates a video (max 5 min) with animated text over a gradient background. CPU-only, Hugging Face Spaces-ready."
|
95 |
)
|
96 |
|
97 |
if __name__ == '__main__':
|
98 |
+
iface.launch()
|