sreepathi-ravikumar commited on
Commit
fde493c
·
verified ·
1 Parent(s): 7240b25

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -15
app.py CHANGED
@@ -18,8 +18,8 @@ def home():
18
  def generate_video():
19
  try:
20
  data = request.get_json()
21
- prompts = data.get("duration", '').strip()
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 current line is a heading
36
  if line.endswith('?') or line.endswith(';'):
37
- block = line # Start block with heading
38
  i += 1
39
 
40
- # Add next 3–5 paragraph lines (or until next heading)
41
  paragraph_lines = []
42
- count = 0
43
- while i < len(raw_lines) and not (raw_lines[i].strip().endswith('?') or raw_lines[i].strip().endswith(';')) and count < 5:
44
- paragraph_lines.append(raw_lines[i])
45
  i += 1
46
- count += 1
47
 
48
- if paragraph_lines:
49
- block += '\n' + '\n'.join(paragraph_lines)
50
-
51
- lines.append(block)
 
 
 
 
 
 
 
52
  else:
53
- # If not a heading, just group normal 5 lines
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