fffiloni commited on
Commit
253143e
·
verified ·
1 Parent(s): d1578ce

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -25
app.py CHANGED
@@ -203,18 +203,21 @@ def blend_vsfx(video_in, audio_result):
203
  def infer(video_in, chosen_model):
204
  image_in = extract_firstframe(video_in)
205
  caption = get_caption(image_in)
206
- if chosen_model == "MAGNet" :
207
- audio_result = get_magnet(caption)
208
- elif chosen_model == "AudioLDM-2" :
209
- audio_result = get_audioldm(caption)
210
- elif chosen_model == "AudioGen" :
211
- audio_result = get_audiogen(caption)
212
- elif chosen_model == "Tango" :
213
- audio_result = get_tango(caption)
214
- elif chosen_model == "Tango 2" :
215
- audio_result = get_tango2(caption)
216
- elif chosen_model == "Stable Audio Open" :
217
- audio_result = get_stable_audio_open(caption)
 
 
 
218
 
219
  final_res = blend_vsfx(video_in, audio_result)
220
  return gr.update(value=caption, interactive=True), gr.update(interactive=True), audio_result, final_res
@@ -222,19 +225,21 @@ def infer(video_in, chosen_model):
222
  def retry(edited_prompt, video_in, chosen_model):
223
  image_in = extract_firstframe(video_in)
224
  caption = edited_prompt
225
- if chosen_model == "MAGNet" :
226
- audio_result = get_magnet(caption)
227
- elif chosen_model == "AudioLDM-2" :
228
- audio_result = get_audioldm(caption)
229
- elif chosen_model == "AudioGen" :
230
- audio_result = get_audiogen(caption)
231
- elif chosen_model == "Tango" :
232
- audio_result = get_tango(caption)
233
- elif chosen_model == "Tango 2" :
234
- audio_result = get_tango2(caption)
235
- elif chosen_model == "Stable Audio Open" :
236
- audio_result = get_stable_audio_open(caption)
237
-
 
 
238
  final_res = blend_vsfx(video_in, audio_result)
239
  return audio_result, final_res
240
 
 
203
  def infer(video_in, chosen_model):
204
  image_in = extract_firstframe(video_in)
205
  caption = get_caption(image_in)
206
+ try:
207
+ if chosen_model == "MAGNet" :
208
+ audio_result = get_magnet(caption)
209
+ elif chosen_model == "AudioLDM-2" :
210
+ audio_result = get_audioldm(caption)
211
+ elif chosen_model == "AudioGen" :
212
+ audio_result = get_audiogen(caption)
213
+ elif chosen_model == "Tango" :
214
+ audio_result = get_tango(caption)
215
+ elif chosen_model == "Tango 2" :
216
+ audio_result = get_tango2(caption)
217
+ elif chosen_model == "Stable Audio Open" :
218
+ audio_result = get_stable_audio_open(caption)
219
+ except:
220
+ raise gr.Error(f"an error occured with {chosen_model}")
221
 
222
  final_res = blend_vsfx(video_in, audio_result)
223
  return gr.update(value=caption, interactive=True), gr.update(interactive=True), audio_result, final_res
 
225
  def retry(edited_prompt, video_in, chosen_model):
226
  image_in = extract_firstframe(video_in)
227
  caption = edited_prompt
228
+ try:
229
+ if chosen_model == "MAGNet" :
230
+ audio_result = get_magnet(caption)
231
+ elif chosen_model == "AudioLDM-2" :
232
+ audio_result = get_audioldm(caption)
233
+ elif chosen_model == "AudioGen" :
234
+ audio_result = get_audiogen(caption)
235
+ elif chosen_model == "Tango" :
236
+ audio_result = get_tango(caption)
237
+ elif chosen_model == "Tango 2" :
238
+ audio_result = get_tango2(caption)
239
+ elif chosen_model == "Stable Audio Open" :
240
+ audio_result = get_stable_audio_open(caption)
241
+ except:
242
+ raise gr.Error(f"an error occured with {chosen_model}")
243
  final_res = blend_vsfx(video_in, audio_result)
244
  return audio_result, final_res
245