Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -54,26 +54,27 @@ def create_slides(text, duration, output_folder, max_lines=6):
|
|
54 |
logo_path = download_asset(ASSETS["logo"])
|
55 |
graphic_path = download_asset(ASSETS["illustration"])
|
56 |
|
57 |
-
query_keywords = random.choice(["blockchain", "AI", "programming", "startup"])
|
58 |
-
bg_path = download_asset(fetch_unsplash_image(query_keywords))
|
59 |
-
|
60 |
chunks = textwrap.wrap(text, width=36)
|
61 |
slides = ["\n".join(chunks[i:i+max_lines]) for i in range(0, len(chunks), max_lines)]
|
62 |
per_slide_time = duration / len(slides)
|
63 |
slide_paths = []
|
64 |
|
65 |
for i, slide_text in enumerate(slides):
|
|
|
|
|
|
|
66 |
bg = Image.open(bg_path).resize((1280, 720)).convert("RGBA")
|
67 |
enhancer = ImageEnhance.Brightness(bg)
|
68 |
bg = enhancer.enhance(0.3)
|
69 |
draw = ImageDraw.Draw(bg)
|
70 |
|
71 |
lines = slide_text.split("\n")
|
|
|
72 |
total_height = sum([font.getbbox(line)[3] - font.getbbox(line)[1] for line in lines]) + (len(lines)-1)*20
|
73 |
y = max((720 - total_height) // 2, 20)
|
74 |
for line in lines:
|
75 |
w = font.getbbox(line)[2] - font.getbbox(line)[0]
|
76 |
-
draw.text(((1280 - w) // 2, y), line
|
77 |
y += font.getbbox(line)[3] - font.getbbox(line)[1] + 20
|
78 |
|
79 |
logo = Image.open(logo_path).convert("RGBA")
|
@@ -135,7 +136,7 @@ iface = gr.Interface(
|
|
135 |
gr.Textbox(label="Summary"),
|
136 |
gr.Video(label="Generated AV Summary")
|
137 |
],
|
138 |
-
title="
|
139 |
description="Generates a 5/10 sec video summary from article URL with clean typography, visuals, logo and illustration."
|
140 |
)
|
141 |
|
|
|
54 |
logo_path = download_asset(ASSETS["logo"])
|
55 |
graphic_path = download_asset(ASSETS["illustration"])
|
56 |
|
|
|
|
|
|
|
57 |
chunks = textwrap.wrap(text, width=36)
|
58 |
slides = ["\n".join(chunks[i:i+max_lines]) for i in range(0, len(chunks), max_lines)]
|
59 |
per_slide_time = duration / len(slides)
|
60 |
slide_paths = []
|
61 |
|
62 |
for i, slide_text in enumerate(slides):
|
63 |
+
query = random.choice(slide_text.split())
|
64 |
+
bg_path = download_asset(fetch_unsplash_image(query))
|
65 |
+
|
66 |
bg = Image.open(bg_path).resize((1280, 720)).convert("RGBA")
|
67 |
enhancer = ImageEnhance.Brightness(bg)
|
68 |
bg = enhancer.enhance(0.3)
|
69 |
draw = ImageDraw.Draw(bg)
|
70 |
|
71 |
lines = slide_text.split("\n")
|
72 |
+
lines = [line.encode('utf-8', 'replace').decode('utf-8') for line in lines]
|
73 |
total_height = sum([font.getbbox(line)[3] - font.getbbox(line)[1] for line in lines]) + (len(lines)-1)*20
|
74 |
y = max((720 - total_height) // 2, 20)
|
75 |
for line in lines:
|
76 |
w = font.getbbox(line)[2] - font.getbbox(line)[0]
|
77 |
+
draw.text(((1280 - w) // 2, y), line, font=font, fill="white")
|
78 |
y += font.getbbox(line)[3] - font.getbbox(line)[1] + 20
|
79 |
|
80 |
logo = Image.open(logo_path).convert("RGBA")
|
|
|
136 |
gr.Textbox(label="Summary"),
|
137 |
gr.Video(label="Generated AV Summary")
|
138 |
],
|
139 |
+
title="🎮 AV Summary Generator (Visual Promo Style)",
|
140 |
description="Generates a 5/10 sec video summary from article URL with clean typography, visuals, logo and illustration."
|
141 |
)
|
142 |
|