THP2903 commited on
Commit
5e1d593
·
verified ·
1 Parent(s): b249890

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -8
app.py CHANGED
@@ -22,7 +22,7 @@ def process_video_audio(video_path, audio_path):
22
  train_audio_wave[0, :] = wav[0][:261540]
23
  else:
24
  train_audio_wave[0, :len(wav[0])] = wav[0]
25
- train_audio_cnn[0, :, :, 0] = mfcc(train_audio_wave[0]).numpy()
26
 
27
  cap = cv2.VideoCapture(video_path)
28
  frame_idx = 0
@@ -43,16 +43,14 @@ def process_video_audio(video_path, audio_path):
43
  last_frame = frame
44
  frame_idx += 1
45
  cap.release()
46
-
47
-
48
  predicted_emotion = "unknown"
49
 
50
- return last_frame, predicted_emotion
51
 
52
  # Định nghĩa giao diện Gradio
53
  def gradio_interface(video, audio):
54
- frame, emotion = process_video_audio(video, audio)
55
- return gr.Image(frame, label="Processed Frame"), emotion
56
 
57
  iface = gr.Interface(
58
  fn=gradio_interface,
@@ -61,8 +59,7 @@ iface = gr.Interface(
61
  gr.Audio()
62
  ],
63
  outputs=[
64
- gr.Image(),
65
- gr.Textbox()
66
  ],
67
  live=True,
68
  title="Video and Audio Processing with Emotion Recognition"
 
22
  train_audio_wave[0, :] = wav[0][:261540]
23
  else:
24
  train_audio_wave[0, :len(wav[0])] = wav[0]
25
+ train_audio_cnn[0, :, :, 0] = mfcc(train_audio_wave[0])
26
 
27
  cap = cv2.VideoCapture(video_path)
28
  frame_idx = 0
 
43
  last_frame = frame
44
  frame_idx += 1
45
  cap.release()
 
 
46
  predicted_emotion = "unknown"
47
 
48
+ return last_frame
49
 
50
  # Định nghĩa giao diện Gradio
51
  def gradio_interface(video, audio):
52
+ frame= process_video_audio(video, audio)
53
+ return frame
54
 
55
  iface = gr.Interface(
56
  fn=gradio_interface,
 
59
  gr.Audio()
60
  ],
61
  outputs=[
62
+ gr.Image()
 
63
  ],
64
  live=True,
65
  title="Video and Audio Processing with Emotion Recognition"