Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -123,7 +123,7 @@ def prepare_output_dir(input_file, output_dir):
|
|
| 123 |
raise RuntimeError(f"Failed to prepare output directory {out_dir}: {e}")
|
| 124 |
return out_dir
|
| 125 |
|
| 126 |
-
def roformer_separator(audio, model_key, seg_size, override_seg_size, batch_size, overlap, pitch_shift, model_dir, out_dir, out_format, norm_thresh, amp_thresh, progress=gr.Progress(track_tqdm=True
|
| 127 |
"""Separate audio using Roformer model."""
|
| 128 |
base_name = os.path.splitext(os.path.basename(audio))[0]
|
| 129 |
print_message(audio, model_key)
|
|
@@ -147,7 +147,10 @@ def roformer_separator(audio, model_key, seg_size, override_seg_size, batch_size
|
|
| 147 |
}
|
| 148 |
)
|
| 149 |
|
|
|
|
| 150 |
separator.load_model(model_filename=model)
|
|
|
|
|
|
|
| 151 |
separation = separator.separate(audio, f"{base_name}_(Stem1)", f"{base_name}_(Stem2)")
|
| 152 |
print(f"Separation complete!\nResults: {', '.join(separation)}")
|
| 153 |
|
|
@@ -156,7 +159,7 @@ def roformer_separator(audio, model_key, seg_size, override_seg_size, batch_size
|
|
| 156 |
except Exception as e:
|
| 157 |
raise RuntimeError(f"Roformer separation failed: {e}") from e
|
| 158 |
|
| 159 |
-
def mdx23c_separator(audio, model, seg_size, override_seg_size, batch_size, overlap, pitch_shift, model_dir, out_dir, out_format, norm_thresh, amp_thresh, progress=gr.Progress(track_tqdm=True
|
| 160 |
"""Separate audio using MDX23C model."""
|
| 161 |
base_name = os.path.splitext(os.path.basename(audio))[0]
|
| 162 |
print_message(audio, model)
|
|
@@ -179,7 +182,10 @@ def mdx23c_separator(audio, model, seg_size, override_seg_size, batch_size, over
|
|
| 179 |
}
|
| 180 |
)
|
| 181 |
|
|
|
|
| 182 |
separator.load_model(model_filename=model)
|
|
|
|
|
|
|
| 183 |
separation = separator.separate(audio, f"{base_name}_(Stem1)", f"{base_name}_(Stem2)")
|
| 184 |
print(f"Separation complete!\nResults: {', '.join(separation)}")
|
| 185 |
|
|
@@ -188,7 +194,7 @@ def mdx23c_separator(audio, model, seg_size, override_seg_size, batch_size, over
|
|
| 188 |
except Exception as e:
|
| 189 |
raise RuntimeError(f"MDX23C separation failed: {e}") from e
|
| 190 |
|
| 191 |
-
def mdx_separator(audio, model, hop_length, seg_size, overlap, batch_size, denoise, model_dir, out_dir, out_format, norm_thresh, amp_thresh, progress=gr.Progress(track_tqdm=True
|
| 192 |
"""Separate audio using MDX-NET model."""
|
| 193 |
base_name = os.path.splitext(os.path.basename(audio))[0]
|
| 194 |
print_message(audio, model)
|
|
@@ -211,7 +217,10 @@ def mdx_separator(audio, model, hop_length, seg_size, overlap, batch_size, denoi
|
|
| 211 |
}
|
| 212 |
)
|
| 213 |
|
|
|
|
| 214 |
separator.load_model(model_filename=model)
|
|
|
|
|
|
|
| 215 |
separation = separator.separate(audio, f"{base_name}_(Stem1)", f"{base_name}_(Stem2)")
|
| 216 |
print(f"Separation complete!\nResults: {', '.join(separation)}")
|
| 217 |
|
|
@@ -220,7 +229,7 @@ def mdx_separator(audio, model, hop_length, seg_size, overlap, batch_size, denoi
|
|
| 220 |
except Exception as e:
|
| 221 |
raise RuntimeError(f"MDX-NET separation failed: {e}") from e
|
| 222 |
|
| 223 |
-
def vr_separator(audio, model, batch_size, window_size, aggression, tta, post_process, post_process_threshold, high_end_process, model_dir, out_dir, out_format, norm_thresh, amp_thresh, progress=gr.Progress(track_tqdm=True
|
| 224 |
"""Separate audio using VR ARCH model."""
|
| 225 |
base_name = os.path.splitext(os.path.basename(audio))[0]
|
| 226 |
print_message(audio, model)
|
|
@@ -245,7 +254,10 @@ def vr_separator(audio, model, batch_size, window_size, aggression, tta, post_pr
|
|
| 245 |
}
|
| 246 |
)
|
| 247 |
|
|
|
|
| 248 |
separator.load_model(model_filename=model)
|
|
|
|
|
|
|
| 249 |
separation = separator.separate(audio, f"{base_name}_(Stem1)", f"{base_name}_(Stem2)")
|
| 250 |
print(f"Separation complete!\nResults: {', '.join(separation)}")
|
| 251 |
|
|
@@ -254,7 +266,7 @@ def vr_separator(audio, model, batch_size, window_size, aggression, tta, post_pr
|
|
| 254 |
except Exception as e:
|
| 255 |
raise RuntimeError(f"VR ARCH separation failed: {e}") from e
|
| 256 |
|
| 257 |
-
def demucs_separator(audio, model, seg_size, shifts, overlap, segments_enabled, model_dir, out_dir, out_format, norm_thresh, amp_thresh, progress=gr.Progress(track_tqdm=True
|
| 258 |
"""Separate audio using Demucs model."""
|
| 259 |
print_message(audio, model)
|
| 260 |
try:
|
|
@@ -275,7 +287,10 @@ def demucs_separator(audio, model, seg_size, shifts, overlap, segments_enabled,
|
|
| 275 |
}
|
| 276 |
)
|
| 277 |
|
|
|
|
| 278 |
separator.load_model(model_filename=model)
|
|
|
|
|
|
|
| 279 |
separation = separator.separate(audio)
|
| 280 |
print(f"Separation complete!\nResults: {', '.join(separation)}")
|
| 281 |
|
|
|
|
| 123 |
raise RuntimeError(f"Failed to prepare output directory {out_dir}: {e}")
|
| 124 |
return out_dir
|
| 125 |
|
| 126 |
+
def roformer_separator(audio, model_key, seg_size, override_seg_size, batch_size, overlap, pitch_shift, model_dir, out_dir, out_format, norm_thresh, amp_thresh, progress=gr.Progress(track_tqdm=True)):
|
| 127 |
"""Separate audio using Roformer model."""
|
| 128 |
base_name = os.path.splitext(os.path.basename(audio))[0]
|
| 129 |
print_message(audio, model_key)
|
|
|
|
| 147 |
}
|
| 148 |
)
|
| 149 |
|
| 150 |
+
progress(0.2, desc="Model loaded...")
|
| 151 |
separator.load_model(model_filename=model)
|
| 152 |
+
|
| 153 |
+
progress(0.7, desc="Audio separated...")
|
| 154 |
separation = separator.separate(audio, f"{base_name}_(Stem1)", f"{base_name}_(Stem2)")
|
| 155 |
print(f"Separation complete!\nResults: {', '.join(separation)}")
|
| 156 |
|
|
|
|
| 159 |
except Exception as e:
|
| 160 |
raise RuntimeError(f"Roformer separation failed: {e}") from e
|
| 161 |
|
| 162 |
+
def mdx23c_separator(audio, model, seg_size, override_seg_size, batch_size, overlap, pitch_shift, model_dir, out_dir, out_format, norm_thresh, amp_thresh, progress=gr.Progress(track_tqdm=True)):
|
| 163 |
"""Separate audio using MDX23C model."""
|
| 164 |
base_name = os.path.splitext(os.path.basename(audio))[0]
|
| 165 |
print_message(audio, model)
|
|
|
|
| 182 |
}
|
| 183 |
)
|
| 184 |
|
| 185 |
+
progress(0.2, desc="Model loaded...")
|
| 186 |
separator.load_model(model_filename=model)
|
| 187 |
+
|
| 188 |
+
progress(0.7, desc="Audio separated...")
|
| 189 |
separation = separator.separate(audio, f"{base_name}_(Stem1)", f"{base_name}_(Stem2)")
|
| 190 |
print(f"Separation complete!\nResults: {', '.join(separation)}")
|
| 191 |
|
|
|
|
| 194 |
except Exception as e:
|
| 195 |
raise RuntimeError(f"MDX23C separation failed: {e}") from e
|
| 196 |
|
| 197 |
+
def mdx_separator(audio, model, hop_length, seg_size, overlap, batch_size, denoise, model_dir, out_dir, out_format, norm_thresh, amp_thresh, progress=gr.Progress(track_tqdm=True)):
|
| 198 |
"""Separate audio using MDX-NET model."""
|
| 199 |
base_name = os.path.splitext(os.path.basename(audio))[0]
|
| 200 |
print_message(audio, model)
|
|
|
|
| 217 |
}
|
| 218 |
)
|
| 219 |
|
| 220 |
+
progress(0.2, desc="Model loaded...")
|
| 221 |
separator.load_model(model_filename=model)
|
| 222 |
+
|
| 223 |
+
progress(0.7, desc="Audio separated...")
|
| 224 |
separation = separator.separate(audio, f"{base_name}_(Stem1)", f"{base_name}_(Stem2)")
|
| 225 |
print(f"Separation complete!\nResults: {', '.join(separation)}")
|
| 226 |
|
|
|
|
| 229 |
except Exception as e:
|
| 230 |
raise RuntimeError(f"MDX-NET separation failed: {e}") from e
|
| 231 |
|
| 232 |
+
def vr_separator(audio, model, batch_size, window_size, aggression, tta, post_process, post_process_threshold, high_end_process, model_dir, out_dir, out_format, norm_thresh, amp_thresh, progress=gr.Progress(track_tqdm=True)):
|
| 233 |
"""Separate audio using VR ARCH model."""
|
| 234 |
base_name = os.path.splitext(os.path.basename(audio))[0]
|
| 235 |
print_message(audio, model)
|
|
|
|
| 254 |
}
|
| 255 |
)
|
| 256 |
|
| 257 |
+
progress(0.2, desc="Model loaded...")
|
| 258 |
separator.load_model(model_filename=model)
|
| 259 |
+
|
| 260 |
+
progress(0.7, desc="Audio separated...")
|
| 261 |
separation = separator.separate(audio, f"{base_name}_(Stem1)", f"{base_name}_(Stem2)")
|
| 262 |
print(f"Separation complete!\nResults: {', '.join(separation)}")
|
| 263 |
|
|
|
|
| 266 |
except Exception as e:
|
| 267 |
raise RuntimeError(f"VR ARCH separation failed: {e}") from e
|
| 268 |
|
| 269 |
+
def demucs_separator(audio, model, seg_size, shifts, overlap, segments_enabled, model_dir, out_dir, out_format, norm_thresh, amp_thresh, progress=gr.Progress(track_tqdm=True)):
|
| 270 |
"""Separate audio using Demucs model."""
|
| 271 |
print_message(audio, model)
|
| 272 |
try:
|
|
|
|
| 287 |
}
|
| 288 |
)
|
| 289 |
|
| 290 |
+
progress(0.2, desc="Model loaded...")
|
| 291 |
separator.load_model(model_filename=model)
|
| 292 |
+
|
| 293 |
+
progress(0.7, desc="Audio separated...")
|
| 294 |
separation = separator.separate(audio)
|
| 295 |
print(f"Separation complete!\nResults: {', '.join(separation)}")
|
| 296 |
|