guardiancc commited on
Commit
cd6d6d8
·
verified ·
1 Parent(s): 6a32c75

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -5
app.py CHANGED
@@ -9,18 +9,33 @@ from attributtes_utils import input_pose, input_emotion, input_blink
9
 
10
 
11
  @spaces.GPU
 
12
  def process(input_vid, audio_path, pose_select, emotion_select, blink_select):
13
  model = init_model()
14
  pose = input_pose(pose_select)
15
  emotion = input_emotion(emotion_select)
16
- os.system(f"ffmpeg -y -loglevel error -i {audio_path} -vn -acodec pcm_s16le -ar 16000 -ac 1 2_output.wav")
 
 
 
 
 
 
 
 
 
 
17
  blink = input_blink(blink_select)
18
-
19
  print("input_vid: ", input_vid)
20
- result = infenrece(model, input_vid, f"2_output.wav", pose, emotion, blink)
 
 
 
 
 
 
21
  print("result: ", result)
22
-
23
- print("finished !")
24
 
25
  return result # , gr.Group.update(visible=True)
26
 
 
9
 
10
 
11
  @spaces.GPU
12
+
13
  def process(input_vid, audio_path, pose_select, emotion_select, blink_select):
14
  model = init_model()
15
  pose = input_pose(pose_select)
16
  emotion = input_emotion(emotion_select)
17
+
18
+ # Convert audio with error handling
19
+ print(audio_path, input_vid)
20
+ result = os.system(f"ffmpeg -y -loglevel error -i {audio_path} -vn -acodec pcm_s16le -ar 16000 -ac 1 2_output.wav")
21
+ if result != 0:
22
+ raise RuntimeError("Failed to execute ffmpeg command. Please check the input audio file.")
23
+
24
+ # Check if output file exists
25
+ if not os.path.exists("2_output.wav"):
26
+ raise FileNotFoundError("2_output.wav was not created. Check the ffmpeg command and input file.")
27
+
28
  blink = input_blink(blink_select)
 
29
  print("input_vid: ", input_vid)
30
+
31
+ # Perform inference
32
+ try:
33
+ result = infenrece(model, input_vid, "2_output.wav", pose, emotion, blink)
34
+ except Exception as e:
35
+ raise RuntimeError(f"Inference failed: {e}")
36
+
37
  print("result: ", result)
38
+ print("finished!")
 
39
 
40
  return result # , gr.Group.update(visible=True)
41