sreepathi-ravikumar commited on
Commit
e9902d8
·
verified ·
1 Parent(s): 31d1e0a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -11
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
- # 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 < 4:
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+4])
56
- lines.append(block)
57
- i += 4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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)):