sreepathi-ravikumar commited on
Commit
7c9ccc5
·
verified ·
1 Parent(s): a8943df

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -63
app.py CHANGED
@@ -7,7 +7,7 @@ import os
7
  import asyncio
8
  from image_fetcher import main
9
  from video import create_text_image
10
- from video2 import video_com
11
 
12
  app = Flask(__name__)
13
 
@@ -19,77 +19,23 @@ def home():
19
  def generate_video():
20
  try:
21
  data = request.get_json()
22
- prompt = data.get("duration", '').strip()
23
- prompts=prompt.replace("**","")
24
- print(prompts)
25
- if prompts == '':
26
- return jsonify({"error": "prompts be must"}), 400
27
  image_folder = "/tmp/images"
28
  #line=prompts.splitlines()
29
  #asyncio.run(main(line))
30
- raw_lines = prompts.splitlines(keepends=False)
31
- lines = []
32
-
33
- i = 0
34
- while i < len(raw_lines):
35
- line = raw_lines[i].strip()
36
-
37
- # Check if current line is a heading
38
- if line.strip().startswith("#") and (line.endswith('?') or line.endswith(':')):
39
- block = line # Start block with heading
40
- i += 1
41
-
42
- # Accumulate body lines until next heading or 5+ lines
43
- paragraph_lines = []
44
- while i < len(raw_lines):
45
- next_line = raw_lines[i].strip()
46
-
47
- # Stop if next line is a heading
48
- if next_line.strip().startswith("#") and (next_line.endswith('?') or next_line.endswith(':')):
49
- break
50
-
51
- paragraph_lines.append(next_line)
52
- i += 1
53
-
54
- # If we've gathered enough lines for a slide, break to next
55
- if len(paragraph_lines) >= 5:
56
- break
57
-
58
- # Combine heading + paragraph
59
- if paragraph_lines:
60
- block += '\n' + '\n'.join(paragraph_lines)
61
-
62
- lines.append(block)
63
-
64
- else:
65
- # Group normal lines (not part of any heading)
66
- block_lines = []
67
- count = 0
68
-
69
- while i < len(raw_lines) and count < 5:
70
- next_line = raw_lines[i].strip()
71
-
72
- # If this is a heading, break to handle it separately
73
- if next_line.strip().startswith("#") and (next_line.endswith('?') or next_line.endswith(':')):
74
- break
75
-
76
- block_lines.append(next_line)
77
- i += 1
78
- count += 1
79
-
80
- if block_lines:
81
- lines.append('\n'.join(block_lines))
82
-
83
- # Print or use lines as slides
84
 
85
  image_olst=[]
86
- for id in range(len(lines)):
87
- create_text_image(lines[id],id,image_olst)
88
  image_files = sorted(glob.glob(os.path.join(image_folder, "*.png")))
89
  if not image_files:
90
  raise ValueError("No images found in folder!")
91
 
92
- video_path = video_com(lines)
93
  for img in image_files:
94
  os.remove(img)
95
 
 
7
  import asyncio
8
  from image_fetcher import main
9
  from video import create_text_image
10
+ from video2 import video_func
11
 
12
  app = Flask(__name__)
13
 
 
19
  def generate_video():
20
  try:
21
  data = request.get_json()
22
+ lines = data.get("lines", []) # This will be the list
23
+ id = data.get("id", 0) # This will be the integer
24
+
25
+ print("Received List:", lines)
26
+ print("Received Count:", id)
27
  image_folder = "/tmp/images"
28
  #line=prompts.splitlines()
29
  #asyncio.run(main(line))
30
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
 
32
  image_olst=[]
33
+ create_text_image(lines[id],id,image_olst)
 
34
  image_files = sorted(glob.glob(os.path.join(image_folder, "*.png")))
35
  if not image_files:
36
  raise ValueError("No images found in folder!")
37
 
38
+ video_path = video_func(id,lines)
39
  for img in image_files:
40
  os.remove(img)
41