sreepathi-ravikumar commited on
Commit
f29c874
·
verified ·
1 Parent(s): 968132a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -20
app.py CHANGED
@@ -85,28 +85,33 @@ def generate_video():
85
  lines.append('\n'.join(block_lines))
86
 
87
  # Print or use lines as slides
88
- id=0
89
- payload = {
90
- "id": id,
91
- "lines": lines
92
- }
93
-
94
- # Replace with your actual Space B URL
95
- space_b_url = "https://sreepathi-ravikumar-subprocess1.hf.space/generate"
96
-
97
- response = requests.post(space_b_url, json=payload)
98
-
99
- if response.status_code == 200:
100
- # Save received video file
101
- with open(f"/app/data/video/clip{id}.mp4", "wb") as f:
102
- f.write(response.content)
103
  else:
104
- raise Exception(f"Error from Space B: {response.text}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
 
106
- video_path = video_com(lines)
107
- #for img in image_files:
108
- #os.remove(img)
109
- return send_file(video_path, mimetype='video/mp4')
110
  except Exception as e:
111
  traceback.print_exc()
112
  return jsonify({"error": str(e)}), 500
 
85
  lines.append('\n'.join(block_lines))
86
 
87
  # Print or use lines as slides
88
+ if len(lines)==1:
89
+ video_link = "/app/data/video/clip0.mp4"
90
+ video_func(0,lines)
91
+ return send_file(video_link, mimetype='video/mp4')
 
 
 
 
 
 
 
 
 
 
 
92
  else:
93
+ for id in len(lines):
94
+ payload = {
95
+ "id": id,
96
+ "lines": lines
97
+ }
98
+
99
+ # Replace with your actual Space B URL
100
+ space_b_url = "https://sreepathi-ravikumar-subprocess1.hf.space/generate"
101
+
102
+ response = requests.post(space_b_url, json=payload)
103
+
104
+ if response.status_code == 200:
105
+ # Save received video file
106
+ with open(f"/app/data/video/clip{id}.mp4", "wb") as f:
107
+ f.write(response.content)
108
+ else:
109
+ raise Exception(f"Error from Space B: {response.text}")
110
 
111
+ video_path = video_com(lines)
112
+ #for img in image_files:
113
+ #os.remove(img)
114
+ return send_file(video_path, mimetype='video/mp4')
115
  except Exception as e:
116
  traceback.print_exc()
117
  return jsonify({"error": str(e)}), 500