Spaces:
Running
Running
Eddycrack864
commited on
Upload app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,7 @@ from scipy.io.wavfile import read
|
|
6 |
import numpy as np
|
7 |
import gradio as gr
|
8 |
import yt_dlp
|
|
|
9 |
|
10 |
roformer_models = {
|
11 |
'BS-Roformer-Viperx-1297.ckpt': 'model_bs_roformer_ep_317_sdr_12.9755.ckpt',
|
@@ -260,6 +261,163 @@ def demucs_separator(demucs_audio, demucs_model, demucs_output_format, demucs_sh
|
|
260 |
|
261 |
return stem1_file, stem2_file, stem3_file, stem4_file
|
262 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
263 |
with gr.Blocks(theme="NoCrypt/[email protected]", title="🎵 UVR5 UI 🎵") as app:
|
264 |
gr.Markdown("<h1> 🎵 UVR5 UI 🎵 </h1>")
|
265 |
gr.Markdown("If you liked this HF Space you can give me a ❤️")
|
@@ -319,6 +477,28 @@ with gr.Blocks(theme="NoCrypt/[email protected]", title="🎵 UVR5 UI 🎵") as app:
|
|
319 |
|
320 |
roformer_download_button.click(download_audio, [roformer_link], [roformer_audio])
|
321 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
322 |
with gr.Row():
|
323 |
roformer_button = gr.Button("Separate!", variant = "primary")
|
324 |
with gr.Row():
|
@@ -397,6 +577,28 @@ with gr.Blocks(theme="NoCrypt/[email protected]", title="🎵 UVR5 UI 🎵") as app:
|
|
397 |
|
398 |
mdx23c_download_button.click(download_audio, [mdx23c_link], [mdx23c_audio])
|
399 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
400 |
with gr.Row():
|
401 |
mdx23c_button = gr.Button("Separate!", variant = "primary")
|
402 |
with gr.Row():
|
@@ -472,6 +674,28 @@ with gr.Blocks(theme="NoCrypt/[email protected]", title="🎵 UVR5 UI 🎵") as app:
|
|
472 |
|
473 |
mdxnet_download_button.click(download_audio, [mdxnet_link], [mdxnet_audio])
|
474 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
475 |
with gr.Row():
|
476 |
mdxnet_button = gr.Button("Separate!", variant = "primary")
|
477 |
with gr.Row():
|
@@ -555,6 +779,28 @@ with gr.Blocks(theme="NoCrypt/[email protected]", title="🎵 UVR5 UI 🎵") as app:
|
|
555 |
|
556 |
vrarch_download_button.click(download_audio, [vrarch_link], [vrarch_audio])
|
557 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
558 |
with gr.Row():
|
559 |
vrarch_button = gr.Button("Separate!", variant = "primary")
|
560 |
with gr.Row():
|
@@ -624,6 +870,28 @@ with gr.Blocks(theme="NoCrypt/[email protected]", title="🎵 UVR5 UI 🎵") as app:
|
|
624 |
|
625 |
demucs_download_button.click(download_audio, [demucs_link], [demucs_audio])
|
626 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
627 |
with gr.Row():
|
628 |
demucs_button = gr.Button("Separate!", variant = "primary")
|
629 |
with gr.Row():
|
@@ -672,4 +940,4 @@ with gr.Blocks(theme="NoCrypt/[email protected]", title="🎵 UVR5 UI 🎵") as app:
|
|
672 |
)
|
673 |
|
674 |
app.queue()
|
675 |
-
app.launch()
|
|
|
6 |
import numpy as np
|
7 |
import gradio as gr
|
8 |
import yt_dlp
|
9 |
+
import subprocess
|
10 |
|
11 |
roformer_models = {
|
12 |
'BS-Roformer-Viperx-1297.ckpt': 'model_bs_roformer_ep_317_sdr_12.9755.ckpt',
|
|
|
261 |
|
262 |
return stem1_file, stem2_file, stem3_file, stem4_file
|
263 |
|
264 |
+
def roformer_batch(path_input, path_output, model, output_format, overlap, segment_size):
|
265 |
+
found_files = []
|
266 |
+
logs = []
|
267 |
+
logs.clear()
|
268 |
+
|
269 |
+
extensions = (".mp3", ".wav", ".flac")
|
270 |
+
|
271 |
+
full_roformer_model = roformer_models[model]
|
272 |
+
|
273 |
+
for audio_files in os.listdir(path_input):
|
274 |
+
if audio_files.endswith(extensions):
|
275 |
+
found_files.append(audio_files)
|
276 |
+
total_files = len(found_files)
|
277 |
+
|
278 |
+
if total_files == 0:
|
279 |
+
logs.append("No valid audio files.")
|
280 |
+
yield "\n".join(logs)
|
281 |
+
else:
|
282 |
+
logs.append(f"{total_files} audio files found")
|
283 |
+
found_files.sort()
|
284 |
+
|
285 |
+
for audio_files in found_files:
|
286 |
+
file_path = os.path.join(path_input, audio_files)
|
287 |
+
prompt = ["audio-separator", file_path, "-m", f"{full_roformer_model}", f"--output_dir={path_output}", f"--output_format={output_format}", "--normalization=0.9", f"--mdxc_overlap={overlap}", f"--mdxc_segment_size={segment_size}"]
|
288 |
+
logs.append(f"Processing file: {audio_files}")
|
289 |
+
yield "\n".join(logs)
|
290 |
+
subprocess.run(prompt)
|
291 |
+
logs.append(f"File: {audio_files} processed!")
|
292 |
+
yield "\n".join(logs)
|
293 |
+
|
294 |
+
def mdx23c_batch(path_input, path_output, model, output_format, overlap, segment_size, denoise):
|
295 |
+
found_files = []
|
296 |
+
logs = []
|
297 |
+
logs.clear()
|
298 |
+
|
299 |
+
extensions = (".mp3", ".wav", ".flac")
|
300 |
+
|
301 |
+
for audio_files in os.listdir(path_input):
|
302 |
+
if audio_files.endswith(extensions):
|
303 |
+
found_files.append(audio_files)
|
304 |
+
total_files = len(found_files)
|
305 |
+
|
306 |
+
if total_files == 0:
|
307 |
+
logs.append("No valid audio files.")
|
308 |
+
yield "\n".join(logs)
|
309 |
+
else:
|
310 |
+
logs.append(f"{total_files} audio files found")
|
311 |
+
found_files.sort()
|
312 |
+
|
313 |
+
for audio_files in found_files:
|
314 |
+
file_path = os.path.join(path_input, audio_files)
|
315 |
+
prompt = ["audio-separator", file_path, "-m", f"{model}", f"--output_dir={path_output}", f"--output_format={output_format}", "--normalization=0.9", f"--mdxc_overlap={overlap}", f"--mdxc_segment_size={segment_size}"]
|
316 |
+
|
317 |
+
if denoise:
|
318 |
+
prompt.append("--mdx_enable_denoise")
|
319 |
+
|
320 |
+
logs.append(f"Processing file: {audio_files}")
|
321 |
+
yield "\n".join(logs)
|
322 |
+
subprocess.run(prompt)
|
323 |
+
logs.append(f"File: {audio_files} processed!")
|
324 |
+
yield "\n".join(logs)
|
325 |
+
|
326 |
+
def mdxnet_batch(path_input, path_output, model, output_format, overlap, segment_size, denoise):
|
327 |
+
found_files = []
|
328 |
+
logs = []
|
329 |
+
logs.clear()
|
330 |
+
|
331 |
+
extensions = (".mp3", ".wav", ".flac")
|
332 |
+
|
333 |
+
for audio_files in os.listdir(path_input):
|
334 |
+
if audio_files.endswith(extensions):
|
335 |
+
found_files.append(audio_files)
|
336 |
+
total_files = len(found_files)
|
337 |
+
|
338 |
+
if total_files == 0:
|
339 |
+
logs.append("No valid audio files.")
|
340 |
+
yield "\n".join(logs)
|
341 |
+
else:
|
342 |
+
logs.append(f"{total_files} audio files found")
|
343 |
+
found_files.sort()
|
344 |
+
|
345 |
+
for audio_files in found_files:
|
346 |
+
file_path = os.path.join(path_input, audio_files)
|
347 |
+
prompt = ["audio-separator", file_path, "-m", f"{model}", f"--output_dir={path_output}", f"--output_format={output_format}", "--normalization=0.9", f"--mdx_overlap={overlap}", f"--mdx_segment_size={segment_size}"]
|
348 |
+
|
349 |
+
if denoise:
|
350 |
+
prompt.append("--mdx_enable_denoise")
|
351 |
+
|
352 |
+
logs.append(f"Processing file: {audio_files}")
|
353 |
+
yield "\n".join(logs)
|
354 |
+
subprocess.run(prompt)
|
355 |
+
logs.append(f"File: {audio_files} processed!")
|
356 |
+
yield "\n".join(logs)
|
357 |
+
|
358 |
+
def vrarch_batch(path_input, path_output, model, output_format, window_size, agression, tta, high_end_process):
|
359 |
+
found_files = []
|
360 |
+
logs = []
|
361 |
+
logs.clear()
|
362 |
+
|
363 |
+
extensions = (".mp3", ".wav", ".flac")
|
364 |
+
|
365 |
+
for audio_files in os.listdir(path_input):
|
366 |
+
if audio_files.endswith(extensions):
|
367 |
+
found_files.append(audio_files)
|
368 |
+
total_files = len(found_files)
|
369 |
+
|
370 |
+
if total_files == 0:
|
371 |
+
logs.append("No valid audio files.")
|
372 |
+
yield "\n".join(logs)
|
373 |
+
else:
|
374 |
+
logs.append(f"{total_files} audio files found")
|
375 |
+
found_files.sort()
|
376 |
+
|
377 |
+
for audio_files in found_files:
|
378 |
+
file_path = os.path.join(path_input, audio_files)
|
379 |
+
prompt = ["audio-separator", file_path, "-m", f"{model}", f"--output_dir={path_output}", f"--output_format={output_format}", "--normalization=0.9", f"--vr_window_size={window_size}", f"--vr_aggression={agression}"]
|
380 |
+
|
381 |
+
if tta:
|
382 |
+
prompt.append("--vr_enable_tta")
|
383 |
+
if high_end_process:
|
384 |
+
prompt.append("--vr_high_end_process")
|
385 |
+
|
386 |
+
logs.append(f"Processing file: {audio_files}")
|
387 |
+
yield "\n".join(logs)
|
388 |
+
subprocess.run(prompt)
|
389 |
+
logs.append(f"File: {audio_files} processed!")
|
390 |
+
yield "\n".join(logs)
|
391 |
+
|
392 |
+
def demucs_batch(path_input, path_output, model, output_format, shifts, overlap):
|
393 |
+
found_files = []
|
394 |
+
logs = []
|
395 |
+
logs.clear()
|
396 |
+
|
397 |
+
extensions = (".mp3", ".wav", ".flac")
|
398 |
+
|
399 |
+
for audio_files in os.listdir(path_input):
|
400 |
+
if audio_files.endswith(extensions):
|
401 |
+
found_files.append(audio_files)
|
402 |
+
total_files = len(found_files)
|
403 |
+
|
404 |
+
if total_files == 0:
|
405 |
+
logs.append("No valid audio files.")
|
406 |
+
yield "\n".join(logs)
|
407 |
+
else:
|
408 |
+
logs.append(f"{total_files} audio files found")
|
409 |
+
found_files.sort()
|
410 |
+
|
411 |
+
for audio_files in found_files:
|
412 |
+
file_path = os.path.join(path_input, audio_files)
|
413 |
+
prompt = ["audio-separator", file_path, "-m", f"{model}", f"--output_dir={path_output}", f"--output_format={output_format}", "--normalization=0.9", f"--demucs_shifts={shifts}", f"--demucs_overlap={overlap}"]
|
414 |
+
|
415 |
+
logs.append(f"Processing file: {audio_files}")
|
416 |
+
yield "\n".join(logs)
|
417 |
+
subprocess.run(prompt)
|
418 |
+
logs.append(f"File: {audio_files} processed!")
|
419 |
+
yield "\n".join(logs)
|
420 |
+
|
421 |
with gr.Blocks(theme="NoCrypt/[email protected]", title="🎵 UVR5 UI 🎵") as app:
|
422 |
gr.Markdown("<h1> 🎵 UVR5 UI 🎵 </h1>")
|
423 |
gr.Markdown("If you liked this HF Space you can give me a ❤️")
|
|
|
477 |
|
478 |
roformer_download_button.click(download_audio, [roformer_link], [roformer_audio])
|
479 |
|
480 |
+
with gr.Accordion("Batch Separation", open = False):
|
481 |
+
with gr.Row():
|
482 |
+
roformer_input_path = gr.Textbox(
|
483 |
+
label = "Input Path",
|
484 |
+
placeholder = "Place the input path here",
|
485 |
+
interactive = True
|
486 |
+
)
|
487 |
+
roformer_output_path = gr.Textbox(
|
488 |
+
label = "Output Path",
|
489 |
+
placeholder = "Place the output path here",
|
490 |
+
interactive = True
|
491 |
+
)
|
492 |
+
with gr.Row():
|
493 |
+
roformer_bath_button = gr.Button("Separate!", variant = "primary")
|
494 |
+
with gr.Row():
|
495 |
+
roformer_info = gr.Textbox(
|
496 |
+
label = "Output Information",
|
497 |
+
interactive = False
|
498 |
+
)
|
499 |
+
|
500 |
+
roformer_bath_button.click(roformer_batch, [roformer_input_path, roformer_output_path, roformer_model, roformer_output_format, roformer_overlap, roformer_segment_size], [roformer_info])
|
501 |
+
|
502 |
with gr.Row():
|
503 |
roformer_button = gr.Button("Separate!", variant = "primary")
|
504 |
with gr.Row():
|
|
|
577 |
|
578 |
mdx23c_download_button.click(download_audio, [mdx23c_link], [mdx23c_audio])
|
579 |
|
580 |
+
with gr.Accordion("Batch Separation", open = False):
|
581 |
+
with gr.Row():
|
582 |
+
mdx23c_input_path = gr.Textbox(
|
583 |
+
label = "Input Path",
|
584 |
+
placeholder = "Place the input path here",
|
585 |
+
interactive = True
|
586 |
+
)
|
587 |
+
mdx23c_output_path = gr.Textbox(
|
588 |
+
label = "Output Path",
|
589 |
+
placeholder = "Place the output path here",
|
590 |
+
interactive = True
|
591 |
+
)
|
592 |
+
with gr.Row():
|
593 |
+
mdx23c_bath_button = gr.Button("Separate!", variant = "primary")
|
594 |
+
with gr.Row():
|
595 |
+
mdx23c_info = gr.Textbox(
|
596 |
+
label = "Output Information",
|
597 |
+
interactive = False
|
598 |
+
)
|
599 |
+
|
600 |
+
mdx23c_bath_button.click(mdx23c_batch, [mdx23c_input_path, mdx23c_output_path, mdx23c_model, mdx23c_output_format, mdx23c_overlap, mdx23c_segment_size, mdx23c_denoise], [mdx23c_info])
|
601 |
+
|
602 |
with gr.Row():
|
603 |
mdx23c_button = gr.Button("Separate!", variant = "primary")
|
604 |
with gr.Row():
|
|
|
674 |
|
675 |
mdxnet_download_button.click(download_audio, [mdxnet_link], [mdxnet_audio])
|
676 |
|
677 |
+
with gr.Accordion("Batch Separation", open = False):
|
678 |
+
with gr.Row():
|
679 |
+
mdxnet_input_path = gr.Textbox(
|
680 |
+
label = "Input Path",
|
681 |
+
placeholder = "Place the input path here",
|
682 |
+
interactive = True
|
683 |
+
)
|
684 |
+
mdxnet_output_path = gr.Textbox(
|
685 |
+
label = "Output Path",
|
686 |
+
placeholder = "Place the output path here",
|
687 |
+
interactive = True
|
688 |
+
)
|
689 |
+
with gr.Row():
|
690 |
+
mdxnet_bath_button = gr.Button("Separate!", variant = "primary")
|
691 |
+
with gr.Row():
|
692 |
+
mdxnet_info = gr.Textbox(
|
693 |
+
label = "Output Information",
|
694 |
+
interactive = False
|
695 |
+
)
|
696 |
+
|
697 |
+
mdxnet_bath_button.click(mdxnet_batch, [mdxnet_input_path, mdxnet_output_path, mdxnet_model, mdxnet_output_format, mdxnet_overlap, mdxnet_segment_size, mdxnet_denoise], [mdxnet_info])
|
698 |
+
|
699 |
with gr.Row():
|
700 |
mdxnet_button = gr.Button("Separate!", variant = "primary")
|
701 |
with gr.Row():
|
|
|
779 |
|
780 |
vrarch_download_button.click(download_audio, [vrarch_link], [vrarch_audio])
|
781 |
|
782 |
+
with gr.Accordion("Batch Separation", open = False):
|
783 |
+
with gr.Row():
|
784 |
+
vrarch_input_path = gr.Textbox(
|
785 |
+
label = "Input Path",
|
786 |
+
placeholder = "Place the input path here",
|
787 |
+
interactive = True
|
788 |
+
)
|
789 |
+
vrarch_output_path = gr.Textbox(
|
790 |
+
label = "Output Path",
|
791 |
+
placeholder = "Place the output path here",
|
792 |
+
interactive = True
|
793 |
+
)
|
794 |
+
with gr.Row():
|
795 |
+
vrarch_bath_button = gr.Button("Separate!", variant = "primary")
|
796 |
+
with gr.Row():
|
797 |
+
vrarch_info = gr.Textbox(
|
798 |
+
label = "Output Information",
|
799 |
+
interactive = False
|
800 |
+
)
|
801 |
+
|
802 |
+
vrarch_bath_button.click(vrarch_batch, [vrarch_input_path, vrarch_output_path, vrarch_model, vrarch_output_format, vrarch_window_size, vrarch_agression, vrarch_tta, vrarch_high_end_process], [vrarch_info])
|
803 |
+
|
804 |
with gr.Row():
|
805 |
vrarch_button = gr.Button("Separate!", variant = "primary")
|
806 |
with gr.Row():
|
|
|
870 |
|
871 |
demucs_download_button.click(download_audio, [demucs_link], [demucs_audio])
|
872 |
|
873 |
+
with gr.Accordion("Batch Separation", open = False):
|
874 |
+
with gr.Row():
|
875 |
+
demucs_input_path = gr.Textbox(
|
876 |
+
label = "Input Path",
|
877 |
+
placeholder = "Place the input path here",
|
878 |
+
interactive = True
|
879 |
+
)
|
880 |
+
demucs_output_path = gr.Textbox(
|
881 |
+
label = "Output Path",
|
882 |
+
placeholder = "Place the output path here",
|
883 |
+
interactive = True
|
884 |
+
)
|
885 |
+
with gr.Row():
|
886 |
+
demucs_bath_button = gr.Button("Separate!", variant = "primary")
|
887 |
+
with gr.Row():
|
888 |
+
demucs_info = gr.Textbox(
|
889 |
+
label = "Output Information",
|
890 |
+
interactive = False
|
891 |
+
)
|
892 |
+
|
893 |
+
demucs_bath_button.click(demucs_batch, [demucs_input_path, demucs_output_path, demucs_model, demucs_output_format, demucs_shifts, demucs_overlap], [demucs_info])
|
894 |
+
|
895 |
with gr.Row():
|
896 |
demucs_button = gr.Button("Separate!", variant = "primary")
|
897 |
with gr.Row():
|
|
|
940 |
)
|
941 |
|
942 |
app.queue()
|
943 |
+
app.launch(share=True)
|