fffiloni commited on
Commit
6b11af7
·
verified ·
1 Parent(s): 62c47fb

Update gradio_app.py

Browse files
Files changed (1) hide show
  1. gradio_app.py +16 -3
gradio_app.py CHANGED
@@ -109,17 +109,30 @@ def separate_dnr_video(video_path):
109
  return dialog_video, effect_video, music_video
110
 
111
  @spaces.GPU()
112
- def separate_speakers(audio_path):
 
113
  output_files = separate_speakers_core(audio_path)
 
 
 
 
 
 
 
 
 
 
 
114
  updates = []
115
  for i in range(MAX_SPEAKERS):
116
- if i < len(output_files):
117
- updates.append(gr.update(value=output_files[i], visible=True, label=f"Speaker {i+1}"))
118
  else:
119
  updates.append(gr.update(value=None, visible=False))
120
  return updates
121
 
122
 
 
123
  # --- Gradio UI ---
124
  with gr.Blocks() as demo:
125
  gr.Markdown("# TIGER: Time-frequency Interleaved Gain Extraction and Reconstruction for Efficient Speech Separation")
 
109
  return dialog_video, effect_video, music_video
110
 
111
  @spaces.GPU()
112
+ def separate_speakers_video(video_path):
113
+ audio_path, video = extract_audio_from_video(video_path)
114
  output_files = separate_speakers_core(audio_path)
115
+
116
+ session_id = uuid.uuid4().hex[:8]
117
+ output_dir = os.path.join("output_sep_video", session_id)
118
+ os.makedirs(output_dir, exist_ok=True)
119
+
120
+ output_videos = []
121
+ for i, audio_file in enumerate(output_files):
122
+ speaker_video_path = os.path.join(output_dir, f"speaker_{i+1}_video.mp4")
123
+ video_with_sep_audio = attach_audio_to_video(video, audio_file, speaker_video_path)
124
+ output_videos.append(video_with_sep_audio)
125
+
126
  updates = []
127
  for i in range(MAX_SPEAKERS):
128
+ if i < len(output_videos):
129
+ updates.append(gr.update(value=output_videos[i], visible=True, label=f"Speaker {i+1}"))
130
  else:
131
  updates.append(gr.update(value=None, visible=False))
132
  return updates
133
 
134
 
135
+
136
  # --- Gradio UI ---
137
  with gr.Blocks() as demo:
138
  gr.Markdown("# TIGER: Time-frequency Interleaved Gain Extraction and Reconstruction for Efficient Speech Separation")