Spaces:
Running
Running
Update gui.py
Browse files
gui.py
CHANGED
|
@@ -4,10 +4,11 @@ import torch
|
|
| 4 |
import logging
|
| 5 |
from yt_dlp import YoutubeDL
|
| 6 |
import gradio as gr
|
|
|
|
|
|
|
| 7 |
import numpy as np
|
| 8 |
import librosa
|
| 9 |
import soundfile as sf
|
| 10 |
-
from audio_separator.separator import Separator
|
| 11 |
from ensemble import ensemble_files
|
| 12 |
import shutil
|
| 13 |
|
|
@@ -22,8 +23,14 @@ logger = logging.getLogger(__name__)
|
|
| 22 |
ROFORMER_MODELS = {
|
| 23 |
"Vocals": {
|
| 24 |
'MelBand Roformer | Big Beta 6X by unwa': 'melband_roformer_big_beta6x.ckpt',
|
|
|
|
|
|
|
|
|
|
| 25 |
'MelBand Roformer | Vocals by Kimberley Jensen': 'vocals_mel_band_roformer.ckpt',
|
| 26 |
'MelBand Roformer Kim | FT 3 by unwa': 'mel_band_roformer_kim_ft3_unwa.ckpt',
|
|
|
|
|
|
|
|
|
|
| 27 |
'MelBand Roformer | Vocals by becruily': 'mel_band_roformer_vocals_becruily.ckpt',
|
| 28 |
'MelBand Roformer | Vocals Fullness by Aname': 'mel_band_roformer_vocal_fullness_aname.ckpt',
|
| 29 |
'BS Roformer | Vocals by Gabox': 'bs_roformer_vocals_gabox.ckpt',
|
|
@@ -81,6 +88,7 @@ ROFORMER_MODELS = {
|
|
| 81 |
'Mel-Roformer-Denoise-Aufr33': 'denoise_mel_band_roformer_aufr33_sdr_27.9959.ckpt',
|
| 82 |
'Mel-Roformer-Denoise-Aufr33-Aggr': 'denoise_mel_band_roformer_aufr33_aggr_sdr_27.9768.ckpt',
|
| 83 |
'MelBand Roformer | Denoise-Debleed by Gabox': 'mel_band_roformer_denoise_debleed_gabox.ckpt',
|
|
|
|
| 84 |
},
|
| 85 |
"Karaoke": {
|
| 86 |
'Mel-Roformer-Karaoke-Aufr33-Viperx': 'mel_band_roformer_karaoke_aufr33_viperx_sdr_10.1956.ckpt',
|
|
@@ -93,26 +101,19 @@ ROFORMER_MODELS = {
|
|
| 93 |
'BS-Roformer-Viperx-1053': 'model_bs_roformer_ep_937_sdr_10.5309.ckpt',
|
| 94 |
'Mel-Roformer-Viperx-1143': 'model_mel_band_roformer_ep_3005_sdr_11.4360.ckpt',
|
| 95 |
'Mel-Roformer-Crowd-Aufr33-Viperx': 'mel_band_roformer_crowd_aufr33_viperx_sdr_8.7144.ckpt',
|
| 96 |
-
'MelBand Roformer Kim | FT by unwa': 'mel_band_roformer_kim_ft_unwa.ckpt',
|
| 97 |
-
'MelBand Roformer Kim | FT 2 by unwa': 'mel_band_roformer_kim_ft2_unwa.ckpt',
|
| 98 |
-
'MelBand Roformer Kim | FT 2 Bleedless by unwa': 'mel_band_roformer_kim_ft2_bleedless_unwa.ckpt',
|
| 99 |
'MelBand Roformer Kim | SYHFT by SYH99999': 'MelBandRoformerSYHFT.ckpt',
|
| 100 |
'MelBand Roformer Kim | SYHFT V2 by SYH99999': 'MelBandRoformerSYHFTV2.ckpt',
|
| 101 |
'MelBand Roformer Kim | SYHFT V2.5 by SYH99999': 'MelBandRoformerSYHFTV2.5.ckpt',
|
| 102 |
'MelBand Roformer Kim | SYHFT V3 by SYH99999': 'MelBandRoformerSYHFTV3Epsilon.ckpt',
|
| 103 |
'MelBand Roformer Kim | Big SYHFT V1 by SYH99999': 'MelBandRoformerBigSYHFTV1.ckpt',
|
| 104 |
-
'MelBand Roformer Kim | Big Beta 4 FT by unwa': 'melband_roformer_big_beta4.ckpt',
|
| 105 |
-
'MelBand Roformer Kim | Big Beta 5e FT by unwa': 'melband_roformer_big_beta5e.ckpt',
|
| 106 |
-
'MelBand Roformer | Big Beta 6 by unwa': 'melband_roformer_big_beta6.ckpt',
|
| 107 |
'MelBand Roformer | Aspiration by Sucial': 'aspiration_mel_band_roformer_sdr_18.9845.ckpt',
|
| 108 |
'MelBand Roformer | Aspiration Less Aggressive by Sucial': 'aspiration_mel_band_roformer_less_aggr_sdr_18.1201.ckpt',
|
| 109 |
-
'MelBand Roformer | Bleed Suppressor V1 by unwa-97chris': 'mel_band_roformer_bleed_suppressor_v1.ckpt',
|
| 110 |
}
|
| 111 |
}
|
| 112 |
|
| 113 |
OUTPUT_FORMATS = ['wav', 'flac', 'mp3', 'ogg', 'opus', 'm4a', 'aiff', 'ac3']
|
| 114 |
|
| 115 |
-
# CSS (
|
| 116 |
CSS = """
|
| 117 |
/* Modern ve Etkileşimli Tema */
|
| 118 |
#app-container {
|
|
@@ -130,7 +131,8 @@ CSS = """
|
|
| 130 |
overflow: hidden;
|
| 131 |
}
|
| 132 |
body {
|
| 133 |
-
background:
|
|
|
|
| 134 |
margin: 0;
|
| 135 |
padding: 0;
|
| 136 |
font-family: 'Roboto', sans-serif;
|
|
@@ -479,7 +481,7 @@ def create_interface():
|
|
| 479 |
with gr.Tab("⚙️ Settings"):
|
| 480 |
with gr.Group(elem_classes="dubbing-theme"):
|
| 481 |
gr.Markdown("### General Settings")
|
| 482 |
-
model_file_dir = gr.Textbox(value="models/", label="📂 Model Cache", placeholder="Path to model directory", interactive=True)
|
| 483 |
output_dir = gr.Textbox(value="output", label="📤 Output Directory", placeholder="Where to save results", interactive=True)
|
| 484 |
output_format = gr.Dropdown(value="wav", choices=OUTPUT_FORMATS, label="🎶 Output Format", interactive=True)
|
| 485 |
norm_threshold = gr.Slider(0.1, 1, value=0.9, step=0.1, label="🔊 Normalization Threshold", interactive=True)
|
|
@@ -493,7 +495,7 @@ def create_interface():
|
|
| 493 |
with gr.Row():
|
| 494 |
roformer_audio = gr.Audio(label="🎧 Upload Audio", type="filepath", interactive=True)
|
| 495 |
url_ro = gr.Textbox(label="🔗 Or Paste URL", placeholder="YouTube or audio URL", interactive=True)
|
| 496 |
-
download_roformer = gr.Button("⬇️
|
| 497 |
roformer_exclude_stems = gr.Textbox(label="🚫 Exclude Stems", placeholder="e.g., vocals, drums (comma-separated)", interactive=True)
|
| 498 |
with gr.Row():
|
| 499 |
roformer_category = gr.Dropdown(label="📚 Category", choices=list(ROFORMER_MODELS.keys()), value="General Purpose", interactive=True)
|
|
@@ -510,30 +512,30 @@ def create_interface():
|
|
| 510 |
roformer_stem2 = gr.Audio(label="🥁 Stem 2", type="filepath", interactive=False)
|
| 511 |
|
| 512 |
# Auto Ensemble Sekmesi
|
| 513 |
-
|
| 514 |
-
|
| 515 |
-
|
| 516 |
-
|
| 517 |
-
|
| 518 |
-
|
| 519 |
-
|
| 520 |
-
|
| 521 |
-
|
| 522 |
-
|
| 523 |
-
|
| 524 |
-
|
| 525 |
-
|
| 526 |
-
|
| 527 |
-
|
| 528 |
-
|
| 529 |
-
|
| 530 |
-
|
| 531 |
-
|
| 532 |
-
|
| 533 |
|
| 534 |
gr.HTML("<div class='footer'>Powered by Audio-Separator 🌟🎶 | Made with ❤️</div>")
|
| 535 |
|
| 536 |
-
# Event Handlers
|
| 537 |
roformer_category.change(update_roformer_models, inputs=[roformer_category], outputs=[roformer_model])
|
| 538 |
download_roformer.click(fn=download_audio, inputs=[url_ro], outputs=[roformer_audio])
|
| 539 |
roformer_button.click(
|
|
@@ -541,19 +543,26 @@ def create_interface():
|
|
| 541 |
inputs=[roformer_audio, roformer_model, roformer_seg_size, roformer_override_seg_size, roformer_overlap, roformer_pitch_shift, model_file_dir, output_dir, output_format, norm_threshold, amp_threshold, batch_size, roformer_exclude_stems],
|
| 542 |
outputs=[roformer_stem1, roformer_stem2]
|
| 543 |
)
|
| 544 |
-
|
| 545 |
-
|
| 546 |
-
|
| 547 |
-
|
| 548 |
-
|
| 549 |
-
|
| 550 |
-
|
| 551 |
-
|
| 552 |
-
|
| 553 |
-
|
| 554 |
|
| 555 |
return app
|
| 556 |
|
| 557 |
if __name__ == "__main__":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 558 |
app = create_interface()
|
| 559 |
-
app.launch()
|
|
|
|
|
|
|
|
|
| 4 |
import logging
|
| 5 |
from yt_dlp import YoutubeDL
|
| 6 |
import gradio as gr
|
| 7 |
+
import argparse
|
| 8 |
+
from audio_separator.separator import Separator
|
| 9 |
import numpy as np
|
| 10 |
import librosa
|
| 11 |
import soundfile as sf
|
|
|
|
| 12 |
from ensemble import ensemble_files
|
| 13 |
import shutil
|
| 14 |
|
|
|
|
| 23 |
ROFORMER_MODELS = {
|
| 24 |
"Vocals": {
|
| 25 |
'MelBand Roformer | Big Beta 6X by unwa': 'melband_roformer_big_beta6x.ckpt',
|
| 26 |
+
'MelBand Roformer Kim | Big Beta 4 FT by unwa': 'melband_roformer_big_beta4.ckpt',
|
| 27 |
+
'MelBand Roformer Kim | Big Beta 5e FT by unwa': 'melband_roformer_big_beta5e.ckpt',
|
| 28 |
+
'MelBand Roformer | Big Beta 6 by unwa': 'melband_roformer_big_beta6.ckpt',
|
| 29 |
'MelBand Roformer | Vocals by Kimberley Jensen': 'vocals_mel_band_roformer.ckpt',
|
| 30 |
'MelBand Roformer Kim | FT 3 by unwa': 'mel_band_roformer_kim_ft3_unwa.ckpt',
|
| 31 |
+
'MelBand Roformer Kim | FT by unwa': 'mel_band_roformer_kim_ft_unwa.ckpt',
|
| 32 |
+
'MelBand Roformer Kim | FT 2 by unwa': 'mel_band_roformer_kim_ft2_unwa.ckpt',
|
| 33 |
+
'MelBand Roformer Kim | FT 2 Bleedless by unwa': 'mel_band_roformer_kim_ft2_bleedless_unwa.ckpt',
|
| 34 |
'MelBand Roformer | Vocals by becruily': 'mel_band_roformer_vocals_becruily.ckpt',
|
| 35 |
'MelBand Roformer | Vocals Fullness by Aname': 'mel_band_roformer_vocal_fullness_aname.ckpt',
|
| 36 |
'BS Roformer | Vocals by Gabox': 'bs_roformer_vocals_gabox.ckpt',
|
|
|
|
| 88 |
'Mel-Roformer-Denoise-Aufr33': 'denoise_mel_band_roformer_aufr33_sdr_27.9959.ckpt',
|
| 89 |
'Mel-Roformer-Denoise-Aufr33-Aggr': 'denoise_mel_band_roformer_aufr33_aggr_sdr_27.9768.ckpt',
|
| 90 |
'MelBand Roformer | Denoise-Debleed by Gabox': 'mel_band_roformer_denoise_debleed_gabox.ckpt',
|
| 91 |
+
'MelBand Roformer | Bleed Suppressor V1 by unwa-97chris': 'mel_band_roformer_bleed_suppressor_v1.ckpt',
|
| 92 |
},
|
| 93 |
"Karaoke": {
|
| 94 |
'Mel-Roformer-Karaoke-Aufr33-Viperx': 'mel_band_roformer_karaoke_aufr33_viperx_sdr_10.1956.ckpt',
|
|
|
|
| 101 |
'BS-Roformer-Viperx-1053': 'model_bs_roformer_ep_937_sdr_10.5309.ckpt',
|
| 102 |
'Mel-Roformer-Viperx-1143': 'model_mel_band_roformer_ep_3005_sdr_11.4360.ckpt',
|
| 103 |
'Mel-Roformer-Crowd-Aufr33-Viperx': 'mel_band_roformer_crowd_aufr33_viperx_sdr_8.7144.ckpt',
|
|
|
|
|
|
|
|
|
|
| 104 |
'MelBand Roformer Kim | SYHFT by SYH99999': 'MelBandRoformerSYHFT.ckpt',
|
| 105 |
'MelBand Roformer Kim | SYHFT V2 by SYH99999': 'MelBandRoformerSYHFTV2.ckpt',
|
| 106 |
'MelBand Roformer Kim | SYHFT V2.5 by SYH99999': 'MelBandRoformerSYHFTV2.5.ckpt',
|
| 107 |
'MelBand Roformer Kim | SYHFT V3 by SYH99999': 'MelBandRoformerSYHFTV3Epsilon.ckpt',
|
| 108 |
'MelBand Roformer Kim | Big SYHFT V1 by SYH99999': 'MelBandRoformerBigSYHFTV1.ckpt',
|
|
|
|
|
|
|
|
|
|
| 109 |
'MelBand Roformer | Aspiration by Sucial': 'aspiration_mel_band_roformer_sdr_18.9845.ckpt',
|
| 110 |
'MelBand Roformer | Aspiration Less Aggressive by Sucial': 'aspiration_mel_band_roformer_less_aggr_sdr_18.1201.ckpt',
|
|
|
|
| 111 |
}
|
| 112 |
}
|
| 113 |
|
| 114 |
OUTPUT_FORMATS = ['wav', 'flac', 'mp3', 'ogg', 'opus', 'm4a', 'aiff', 'ac3']
|
| 115 |
|
| 116 |
+
# CSS (değişmedi, aynı kalıyor)
|
| 117 |
CSS = """
|
| 118 |
/* Modern ve Etkileşimli Tema */
|
| 119 |
#app-container {
|
|
|
|
| 131 |
overflow: hidden;
|
| 132 |
}
|
| 133 |
body {
|
| 134 |
+
background: url('/content/logo.jpg') no-repeat center center fixed;
|
| 135 |
+
background-size: cover;
|
| 136 |
margin: 0;
|
| 137 |
padding: 0;
|
| 138 |
font-family: 'Roboto', sans-serif;
|
|
|
|
| 481 |
with gr.Tab("⚙️ Settings"):
|
| 482 |
with gr.Group(elem_classes="dubbing-theme"):
|
| 483 |
gr.Markdown("### General Settings")
|
| 484 |
+
model_file_dir = gr.Textbox(value="/tmp/audio-separator-models/", label="📂 Model Cache", placeholder="Path to model directory", interactive=True)
|
| 485 |
output_dir = gr.Textbox(value="output", label="📤 Output Directory", placeholder="Where to save results", interactive=True)
|
| 486 |
output_format = gr.Dropdown(value="wav", choices=OUTPUT_FORMATS, label="🎶 Output Format", interactive=True)
|
| 487 |
norm_threshold = gr.Slider(0.1, 1, value=0.9, step=0.1, label="🔊 Normalization Threshold", interactive=True)
|
|
|
|
| 495 |
with gr.Row():
|
| 496 |
roformer_audio = gr.Audio(label="🎧 Upload Audio", type="filepath", interactive=True)
|
| 497 |
url_ro = gr.Textbox(label="🔗 Or Paste URL", placeholder="YouTube or audio URL", interactive=True)
|
| 498 |
+
download_roformer = gr.Button("⬇️ download", variant="secondary")
|
| 499 |
roformer_exclude_stems = gr.Textbox(label="🚫 Exclude Stems", placeholder="e.g., vocals, drums (comma-separated)", interactive=True)
|
| 500 |
with gr.Row():
|
| 501 |
roformer_category = gr.Dropdown(label="📚 Category", choices=list(ROFORMER_MODELS.keys()), value="General Purpose", interactive=True)
|
|
|
|
| 512 |
roformer_stem2 = gr.Audio(label="🥁 Stem 2", type="filepath", interactive=False)
|
| 513 |
|
| 514 |
# Auto Ensemble Sekmesi
|
| 515 |
+
with gr.Tab("🎚️ Auto Ensemble"):
|
| 516 |
+
with gr.Group(elem_classes="dubbing-theme"):
|
| 517 |
+
gr.Markdown("### Ensemble Processing")
|
| 518 |
+
with gr.Row():
|
| 519 |
+
ensemble_audio = gr.Audio(label="🎧 Upload Audio", type="filepath", interactive=True)
|
| 520 |
+
url_ensemble = gr.Textbox(label="🔗 Or Paste URL", placeholder="YouTube or audio URL", interactive=True)
|
| 521 |
+
download_ensemble = gr.Button("⬇️ download", variant="secondary")
|
| 522 |
+
ensemble_exclude_stems = gr.Textbox(label="🚫 Exclude Stems", placeholder="e.g., vocals, drums (comma-separated)", interactive=True)
|
| 523 |
+
with gr.Row():
|
| 524 |
+
ensemble_category = gr.Dropdown(label="📚 Category", choices=list(ROFORMER_MODELS.keys()), value="Instrumentals", interactive=True)
|
| 525 |
+
ensemble_models = gr.Dropdown(label="🛠️ Models", choices=list(ROFORMER_MODELS["Instrumentals"].keys()), multiselect=True, interactive=True)
|
| 526 |
+
with gr.Row():
|
| 527 |
+
ensemble_seg_size = gr.Slider(32, 4000, value=256, step=32, label="📏 Segment Size", interactive=True)
|
| 528 |
+
ensemble_overlap = gr.Slider(2, 10, value=8, step=1, label="🔄 Overlap", interactive=True)
|
| 529 |
+
ensemble_use_tta = gr.Checkbox(value=False, label="🔍 Use TTA", interactive=True)
|
| 530 |
+
ensemble_method = gr.Dropdown(label="⚙️ Ensemble Method", choices=['avg_wave', 'median_wave', 'max_wave', 'min_wave', 'avg_fft', 'median_fft', 'max_fft', 'min_fft'], value='avg_wave', interactive=True)
|
| 531 |
+
ensemble_weights = gr.Textbox(label="⚖️ Weights", placeholder="e.g., 1.0, 1.0 (comma-separated)", interactive=True)
|
| 532 |
+
ensemble_button = gr.Button("🎛️ Run Ensemble!", variant="primary")
|
| 533 |
+
ensemble_output = gr.Audio(label="🎶 Ensemble Result", type="filepath", interactive=False)
|
| 534 |
+
ensemble_status = gr.Textbox(label="📢 Status", interactive=False)
|
| 535 |
|
| 536 |
gr.HTML("<div class='footer'>Powered by Audio-Separator 🌟🎶 | Made with ❤️</div>")
|
| 537 |
|
| 538 |
+
# Event Handlers (Aynı kalıyor)
|
| 539 |
roformer_category.change(update_roformer_models, inputs=[roformer_category], outputs=[roformer_model])
|
| 540 |
download_roformer.click(fn=download_audio, inputs=[url_ro], outputs=[roformer_audio])
|
| 541 |
roformer_button.click(
|
|
|
|
| 543 |
inputs=[roformer_audio, roformer_model, roformer_seg_size, roformer_override_seg_size, roformer_overlap, roformer_pitch_shift, model_file_dir, output_dir, output_format, norm_threshold, amp_threshold, batch_size, roformer_exclude_stems],
|
| 544 |
outputs=[roformer_stem1, roformer_stem2]
|
| 545 |
)
|
| 546 |
+
ensemble_category.change(update_ensemble_models, inputs=[ensemble_category], outputs=[ensemble_models])
|
| 547 |
+
download_ensemble.click(fn=download_audio, inputs=[url_ensemble], outputs=[ensemble_audio])
|
| 548 |
+
ensemble_button.click(
|
| 549 |
+
lambda *args: auto_ensemble_process(
|
| 550 |
+
*args[:-1],
|
| 551 |
+
weights=[float(w.strip()) for w in args[-1].split(',')] if args[-1] else None
|
| 552 |
+
),
|
| 553 |
+
inputs=[ensemble_audio, ensemble_models, ensemble_seg_size, ensemble_overlap, output_format, ensemble_use_tta, model_file_dir, output_dir, norm_threshold, amp_threshold, batch_size, ensemble_method, ensemble_exclude_stems, ensemble_weights],
|
| 554 |
+
outputs=[ensemble_output, ensemble_status]
|
| 555 |
+
)
|
| 556 |
|
| 557 |
return app
|
| 558 |
|
| 559 |
if __name__ == "__main__":
|
| 560 |
+
parser = argparse.ArgumentParser(description="Music Source Separation Web UI")
|
| 561 |
+
parser.add_argument("--port", type=int, default=7860, help="Port to run the UI on")
|
| 562 |
+
parser.add_argument("--ngrok-token", type=str, default=None, help="Ngrok token for tunneling")
|
| 563 |
+
args = parser.parse_args()
|
| 564 |
+
|
| 565 |
app = create_interface()
|
| 566 |
+
app.launch(server_name="0.0.0.0", server_port=args.port, share=True)
|
| 567 |
+
|
| 568 |
+
app.close()
|