vignesh584 commited on
Commit
67bde76
·
verified ·
1 Parent(s): d704ec8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -18
app.py CHANGED
@@ -129,14 +129,19 @@ def change_video_codec(input_file, output_file, codec='libx264', audio_codec='aa
129
 
130
  def get_talk(image_in, speech):
131
  client = Client("fffiloni/dreamtalk")
132
- result = client.predict(
133
- audio_input=handle_file(speech),
134
- image_path=handle_file(image_in),
135
- emotional_style="M030_front_neutral_level1_001.mat",
136
- api_name="/infer"
137
- )
138
- print(result)
139
- return result['video']
 
 
 
 
 
140
 
141
  #######################################################
142
  # Gradio APIs for optional image and voice generation #
@@ -212,15 +217,15 @@ def get_whisperspeech(prompt_audio_whisperspeech, audio_to_clone):
212
 
213
 
214
 
215
- def pipe (voice, image_in):
216
-
217
  try:
218
  video = get_talk(image_in, voice)
219
- except:
220
-
221
- raise gr.Error('An error occurred while loading DreamTalk: Image may not contain any face')
 
 
222
 
223
- return video
224
 
225
 
226
 
@@ -455,10 +460,12 @@ with gr.Blocks(css=css) as demo:
455
  )
456
 
457
  submit_btn.click(
458
- fn = pipe,
459
- inputs = [portrait, preprocess_audio_file],
460
- outputs = [result],
461
- show_api = False
 
 
462
  )
463
 
464
 
 
129
 
130
  def get_talk(image_in, speech):
131
  client = Client("fffiloni/dreamtalk")
132
+ try:
133
+ result = client.predict(
134
+ audio_input=handle_file(speech),
135
+ image_path=handle_file(image_in),
136
+ emotional_style="M030_front_neutral_level1_001.mat",
137
+ api_name="/infer"
138
+ )
139
+ print(result) # Debugging line
140
+ return result['video']
141
+ except Exception as e:
142
+ print(f"Error in get_talk: {e}")
143
+ raise gr.Error('An error occurred while loading DreamTalk: Image may not contain any face')
144
+
145
 
146
  #######################################################
147
  # Gradio APIs for optional image and voice generation #
 
217
 
218
 
219
 
220
+ def pipe(voice, image_in):
 
221
  try:
222
  video = get_talk(image_in, voice)
223
+ print(f"Generated video: {video}") # Debugging line
224
+ return video
225
+ except Exception as e:
226
+ print(f"Error in pipe: {e}")
227
+ raise gr.Error('An error occurred while generating the talking portrait.')
228
 
 
229
 
230
 
231
 
 
460
  )
461
 
462
  submit_btn.click(
463
+ fn=pipe,
464
+ inputs=[portrait, preprocess_audio_file],
465
+ outputs=[result],
466
+ show_api=False
467
+
468
+
469
  )
470
 
471