Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -28,19 +28,19 @@ def extract_main_content(url):
|
|
28 |
paras = [p.get_text() for p in soup.find_all("p") if len(p.get_text()) > 60]
|
29 |
return "\n".join(paras[:20]) or None
|
30 |
|
31 |
-
#
|
32 |
-
|
33 |
-
|
34 |
logo_path = tempfile.NamedTemporaryFile(delete=False, suffix=".png").name
|
35 |
-
with open(logo_path, 'wb') as
|
36 |
-
|
37 |
return logo_path
|
38 |
|
39 |
# Create image slides from text chunks
|
40 |
def create_slides(text, duration, output_folder, max_lines=6):
|
41 |
font_path = "/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf"
|
42 |
font = ImageFont.truetype(font_path, 48)
|
43 |
-
logo_path =
|
44 |
|
45 |
chunks = textwrap.wrap(text, width=40)
|
46 |
slides = ["\n".join(chunks[i:i+max_lines]) for i in range(0, len(chunks), max_lines)]
|
@@ -114,9 +114,9 @@ iface = gr.Interface(
|
|
114 |
gr.Textbox(label="Summary"),
|
115 |
gr.Video(label="Generated AV Summary")
|
116 |
],
|
117 |
-
title="🎞️ AV Summary Generator (Multislide with Logo)",
|
118 |
-
description="Generates a 5/10 sec video summary from article URL with large text, logo, and slide animation."
|
119 |
)
|
120 |
|
121 |
if __name__ == '__main__':
|
122 |
-
iface.launch()
|
|
|
28 |
paras = [p.get_text() for p in soup.find_all("p") if len(p.get_text()) > 60]
|
29 |
return "\n".join(paras[:20]) or None
|
30 |
|
31 |
+
# Convert uploaded PNG logo to local use (as SVG substitute if needed)
|
32 |
+
def get_uploaded_logo():
|
33 |
+
from_path = "/mnt/data/CSHARP logo.png"
|
34 |
logo_path = tempfile.NamedTemporaryFile(delete=False, suffix=".png").name
|
35 |
+
with open(from_path, 'rb') as src, open(logo_path, 'wb') as dst:
|
36 |
+
dst.write(src.read())
|
37 |
return logo_path
|
38 |
|
39 |
# Create image slides from text chunks
|
40 |
def create_slides(text, duration, output_folder, max_lines=6):
|
41 |
font_path = "/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf"
|
42 |
font = ImageFont.truetype(font_path, 48)
|
43 |
+
logo_path = get_uploaded_logo()
|
44 |
|
45 |
chunks = textwrap.wrap(text, width=40)
|
46 |
slides = ["\n".join(chunks[i:i+max_lines]) for i in range(0, len(chunks), max_lines)]
|
|
|
114 |
gr.Textbox(label="Summary"),
|
115 |
gr.Video(label="Generated AV Summary")
|
116 |
],
|
117 |
+
title="🎞️ AV Summary Generator (Multislide with Uploaded Logo)",
|
118 |
+
description="Generates a 5/10 sec video summary from article URL with large text, uploaded logo, and slide animation."
|
119 |
)
|
120 |
|
121 |
if __name__ == '__main__':
|
122 |
+
iface.launch()
|