sreepathi-ravikumar commited on
Commit
a07b9ae
·
verified ·
1 Parent(s): 70d5824

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -0
app.py CHANGED
@@ -149,6 +149,46 @@ def generate_video():
149
  traceback.print_exc()
150
  return jsonify({"error": str(e)}), 500
151
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
 
153
  if __name__ == "__main__":
154
  app.run(host="0.0.0.0", port=7860)
 
149
  traceback.print_exc()
150
  return jsonify({"error": str(e)}), 500
151
 
152
+ @app.route("/generatepower", methods=["POST"])
153
+ def generate_video_power():
154
+ try:
155
+ data = request.get_json()
156
+ userprompt = data.get("duration", '').strip()
157
+ dataset=userprompt.split("####")
158
+ promptlst=[]
159
+ langlst=[]
160
+ for i in range(len(dataset)):
161
+ prompt=extract_english_paragraphs(dataset[i])
162
+ lang=extract_native_text(dataset[i])
163
+ prompts=prompt.replace("**","")
164
+ promptlst.append(prompts)
165
+ langlst.append(lang)
166
+
167
+ image_folder = "/tmp/images"
168
+ #line=prompts.splitlines()
169
+ #asyncio.run(main(line))
170
+
171
+
172
+ # Print or use lines as slides
173
+ if True:
174
+ space_b_url = ['https://sreepathi-ravikumar-0.hf.space/generate', 'https://sreepathi-ravikumar-backendprocess2.hf.space/generate', 'https://sreepathi-ravikumar-subprocess3.hf.space/generate', 'https://sreepathi-ravikumar-subprocess4.hf.space/generate', 'https://sreepathi-ravikumar-subprocess5.hf.space/generate', 'https://sreepathi-ravikumar-subprocess6.hf.space/generate', 'https://sreepathi-ravikumar-subprocess7.hf.space/generate', 'https://sreepathi-ravikumar-subprocess8.hf.space/generate', 'https://sreepathi-ravikumar-subprocess9.hf.space/generate', 'https://sreepathi-ravikumar-subprocess10.hf.space/generate']
175
+
176
+ with ThreadPoolExecutor(max_workers=len(lines)) as executor:
177
+ for id in range(len(dataset)):
178
+ executor.submit(send_task,promptlst[id],space_b_url[id],langlst[id])
179
+
180
+ video_path = video_com(len(dataset))
181
+ #for img in image_files:
182
+ #os.remove(img)
183
+ return send_file(video_link, mimetype='video/mp4')
184
+
185
+ else:
186
+ print("learn deeper")
187
+ except Exception as e:
188
+ traceback.print_exc()
189
+ return jsonify({"error": str(e)}), 500
190
+
191
+
192
 
193
  if __name__ == "__main__":
194
  app.run(host="0.0.0.0", port=7860)