Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -18,8 +18,8 @@ def home():
|
|
18 |
def generate_video():
|
19 |
try:
|
20 |
data = request.get_json()
|
21 |
-
|
22 |
-
|
23 |
if prompts == '':
|
24 |
return jsonify({"error": "prompts be must"}), 400
|
25 |
image_folder = "/tmp/images"
|
@@ -31,26 +31,32 @@ def generate_video():
|
|
31 |
i = 0
|
32 |
while i < len(raw_lines):
|
33 |
line = raw_lines[i].strip()
|
34 |
-
|
35 |
-
# Check if
|
36 |
if line.endswith('?') or line.endswith(';'):
|
37 |
-
|
38 |
i += 1
|
39 |
|
40 |
-
#
|
41 |
paragraph_lines = []
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
i += 1
|
46 |
-
count += 1
|
47 |
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
else:
|
53 |
-
# If
|
54 |
block = '\n'.join(raw_lines[i:i+5])
|
55 |
lines.append(block)
|
56 |
i += 5
|
|
|
18 |
def generate_video():
|
19 |
try:
|
20 |
data = request.get_json()
|
21 |
+
prompt = data.get("duration", '').strip()
|
22 |
+
prompts=prompt.replace("**","")
|
23 |
if prompts == '':
|
24 |
return jsonify({"error": "prompts be must"}), 400
|
25 |
image_folder = "/tmp/images"
|
|
|
31 |
i = 0
|
32 |
while i < len(raw_lines):
|
33 |
line = raw_lines[i].strip()
|
34 |
+
|
35 |
+
# Check if it's a heading
|
36 |
if line.endswith('?') or line.endswith(';'):
|
37 |
+
heading = line
|
38 |
i += 1
|
39 |
|
40 |
+
# Collect paragraph lines
|
41 |
paragraph_lines = []
|
42 |
+
while i < len(raw_lines) and not (raw_lines[i].strip().endswith('?') or raw_lines[i].strip().endswith(';')):
|
43 |
+
if raw_lines[i].strip():
|
44 |
+
paragraph_lines.append(raw_lines[i].strip())
|
45 |
i += 1
|
|
|
46 |
|
47 |
+
# Now chunk paragraph (e.g., 4 lines per slide)
|
48 |
+
chunk_size = 4
|
49 |
+
for idx, j in enumerate(range(0, len(paragraph_lines), chunk_size)):
|
50 |
+
chunk = paragraph_lines[j:j+chunk_size]
|
51 |
+
if idx == 0:
|
52 |
+
# First chunk – with heading
|
53 |
+
block = heading + '\n' + '\n'.join(chunk)
|
54 |
+
else:
|
55 |
+
# Following chunks – without heading
|
56 |
+
block = '\n'.join(chunk)
|
57 |
+
lines.append(block)
|
58 |
else:
|
59 |
+
# If no heading, just group 5 lines normally
|
60 |
block = '\n'.join(raw_lines[i:i+5])
|
61 |
lines.append(block)
|
62 |
i += 5
|