fffiloni commited on
Commit
b090534
·
verified ·
1 Parent(s): 143b464

Update gradio_app.py

Browse files
Files changed (1) hide show
  1. gradio_app.py +5 -7
gradio_app.py CHANGED
@@ -53,10 +53,11 @@ def separate_speakers_core(audio_path):
53
  output_files = []
54
  for i in range(ests_speech.shape[0]):
55
  path = os.path.join(output_dir, f"speaker_{i+1}.wav")
56
- waveform = ests_speech[i].unsqueeze(0).cpu() # shape: (1, samples)
57
- torchaudio.save(path, waveform, TARGET_SR) # Saves as valid WAV
58
  output_files.append(path)
59
 
 
60
  return output_files
61
 
62
 
@@ -133,12 +134,8 @@ def separate_speakers_video(video_path):
133
 
134
  output_videos = []
135
  for i, audio_file in enumerate(output_files):
136
- # Re-encode to ensure ffmpeg/moviepy compatibility
137
- reencoded_path = os.path.join(output_dir, f"speaker_{i+1}_final.wav")
138
- convert_to_ffmpeg_friendly(audio_file, reencoded_path)
139
-
140
  speaker_video_path = os.path.join(output_dir, f"speaker_{i+1}_video.mp4")
141
- video_with_sep_audio = attach_audio_to_video(video, reencoded_path, speaker_video_path)
142
  output_videos.append(video_with_sep_audio)
143
 
144
  updates = []
@@ -152,6 +149,7 @@ def separate_speakers_video(video_path):
152
 
153
 
154
 
 
155
  # --- Gradio UI ---
156
  with gr.Blocks() as demo:
157
  gr.Markdown("# TIGER: Time-frequency Interleaved Gain Extraction and Reconstruction for Efficient Speech Separation")
 
53
  output_files = []
54
  for i in range(ests_speech.shape[0]):
55
  path = os.path.join(output_dir, f"speaker_{i+1}.wav")
56
+ waveform = ests_speech[i].cpu().unsqueeze(0) # (1, samples)
57
+ torchaudio.save(path, waveform, TARGET_SR)
58
  output_files.append(path)
59
 
60
+
61
  return output_files
62
 
63
 
 
134
 
135
  output_videos = []
136
  for i, audio_file in enumerate(output_files):
 
 
 
 
137
  speaker_video_path = os.path.join(output_dir, f"speaker_{i+1}_video.mp4")
138
+ video_with_sep_audio = attach_audio_to_video(video, audio_file, speaker_video_path)
139
  output_videos.append(video_with_sep_audio)
140
 
141
  updates = []
 
149
 
150
 
151
 
152
+
153
  # --- Gradio UI ---
154
  with gr.Blocks() as demo:
155
  gr.Markdown("# TIGER: Time-frequency Interleaved Gain Extraction and Reconstruction for Efficient Speech Separation")