sreepathi-ravikumar commited on
Commit
8c36521
·
verified ·
1 Parent(s): 37c2ae7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -20
app.py CHANGED
@@ -32,32 +32,26 @@ def generate_video():
32
  i = 0
33
  while i < len(raw_lines):
34
  line = raw_lines[i].strip()
35
-
36
- # Check if it's a heading
37
- if (line.startswith('#') or line.startswith('**') or line[0].isnumeric()) and (line.endswith('?**') or line.endswith(':**') or line.endswith('?') or line.endswith(':')):
38
- heading = line
39
  i += 1
40
 
41
- # Collect paragraph lines
42
  paragraph_lines = []
43
- while i < len(raw_lines) and not (raw_lines[i].strip().endswith('?') and raw_lines[i].strip().endswith(':')):
44
- if raw_lines[i].strip():
45
- paragraph_lines.append(raw_lines[i].strip())
46
  i += 1
 
 
 
 
47
 
48
- # Now chunk paragraph (e.g., 4 lines per slide)
49
- chunk_size = 4
50
- for idx, j in enumerate(range(0, len(paragraph_lines), chunk_size)):
51
- chunk = paragraph_lines[j:j+chunk_size]
52
- if idx == 0:
53
- # First chunk – with heading
54
- block = heading + '\n' + '\n'.join(chunk)
55
- else:
56
- # Following chunks – without heading
57
- block = '\n'.join(chunk)
58
- lines.append(block)
59
  else:
60
- # If no heading, just group 5 lines normally
61
  block = '\n'.join(raw_lines[i:i+5])
62
  lines.append(block)
63
  i += 5
 
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
+ # Add next 3–5 paragraph lines (or until next heading)
42
  paragraph_lines = []
43
+ count = 0
44
+ while i < len(raw_lines) and not (raw_lines[i].strip().endswith('?') or raw_lines[i].strip().endswith(';')) and count < 5:
45
+ paragraph_lines.append(raw_lines[i])
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
+ # If not a heading, just group normal 5 lines
55
  block = '\n'.join(raw_lines[i:i+5])
56
  lines.append(block)
57
  i += 5