Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -32,29 +32,54 @@ def generate_video():
|
|
32 |
i = 0
|
33 |
while i < len(raw_lines):
|
34 |
line = raw_lines[i].strip()
|
35 |
-
|
36 |
# Check if current line is a heading
|
37 |
-
if line.endswith('?') or line.endswith(':'):
|
38 |
block = line # Start block with heading
|
39 |
i += 1
|
40 |
|
41 |
-
#
|
42 |
paragraph_lines = []
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
46 |
i += 1
|
47 |
-
count += 1
|
48 |
|
|
|
|
|
|
|
|
|
|
|
49 |
if paragraph_lines:
|
50 |
block += '\n' + '\n'.join(paragraph_lines)
|
51 |
|
52 |
lines.append(block)
|
|
|
53 |
else:
|
54 |
-
#
|
55 |
-
|
56 |
-
|
57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
|
59 |
image_olst=[]
|
60 |
for id in range(len(lines)):
|
|
|
32 |
i = 0
|
33 |
while i < len(raw_lines):
|
34 |
line = raw_lines[i].strip()
|
35 |
+
|
36 |
# Check if current line is a heading
|
37 |
+
if line.strip().startswith("#") and (line.endswith('?') or line.endswith(':')):
|
38 |
block = line # Start block with heading
|
39 |
i += 1
|
40 |
|
41 |
+
# Accumulate body lines until next heading or 5+ lines
|
42 |
paragraph_lines = []
|
43 |
+
while i < len(raw_lines):
|
44 |
+
next_line = raw_lines[i].strip()
|
45 |
+
|
46 |
+
# Stop if next line is a heading
|
47 |
+
if next_line.strip().startswith("#") and (next_line.endswith('?') or next_line.endswith(':')):
|
48 |
+
break
|
49 |
+
|
50 |
+
paragraph_lines.append(next_line)
|
51 |
i += 1
|
|
|
52 |
|
53 |
+
# If we've gathered enough lines for a slide, break to next
|
54 |
+
if len(paragraph_lines) >= 5:
|
55 |
+
break
|
56 |
+
|
57 |
+
# Combine heading + paragraph
|
58 |
if paragraph_lines:
|
59 |
block += '\n' + '\n'.join(paragraph_lines)
|
60 |
|
61 |
lines.append(block)
|
62 |
+
|
63 |
else:
|
64 |
+
# Group normal lines (not part of any heading)
|
65 |
+
block_lines = []
|
66 |
+
count = 0
|
67 |
+
|
68 |
+
while i < len(raw_lines) and count < 5:
|
69 |
+
next_line = raw_lines[i].strip()
|
70 |
+
|
71 |
+
# If this is a heading, break to handle it separately
|
72 |
+
if next_line.strip().startswith("#") and (next_line.endswith('?') or next_line.endswith(':')):
|
73 |
+
break
|
74 |
+
|
75 |
+
block_lines.append(next_line)
|
76 |
+
i += 1
|
77 |
+
count += 1
|
78 |
+
|
79 |
+
if block_lines:
|
80 |
+
lines.append('\n'.join(block_lines))
|
81 |
+
|
82 |
+
# Print or use lines as slides
|
83 |
|
84 |
image_olst=[]
|
85 |
for id in range(len(lines)):
|