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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import tempfile
|
| 3 |
+
import gradio as gr
|
| 4 |
+
|
| 5 |
+
from audio_separator.separator import Separator
|
| 6 |
+
|
| 7 |
+
# Model lists
|
| 8 |
+
ROFORMER_MODELS = {
|
| 9 |
+
'BS-Roformer-Viperx-1297.ckpt': 'model_bs_roformer_ep_317_sdr_12.9755.ckpt',
|
| 10 |
+
'BS-Roformer-Viperx-1296.ckpt': 'model_bs_roformer_ep_368_sdr_12.9628.ckpt',
|
| 11 |
+
'BS-Roformer-Viperx-1053.ckpt': 'model_bs_roformer_ep_937_sdr_10.5309.ckpt',
|
| 12 |
+
'BS-Roformer-De-Reverb.ckpt': 'deverb_bs_roformer_8_384dim_10depth.ckpt',
|
| 13 |
+
'Mel-Roformer-Viperx-1143.ckpt': 'model_mel_band_roformer_ep_3005_sdr_11.4360.ckpt',
|
| 14 |
+
'Mel-Roformer-Crowd-Aufr33-Viperx.ckpt': 'mel_band_roformer_crowd_aufr33_viperx_sdr_8.7144.ckpt',
|
| 15 |
+
'Mel-Roformer-Karaoke-Aufr33-Viperx.ckpt': 'mel_band_roformer_karaoke_aufr33_viperx_sdr_10.1956.ckpt',
|
| 16 |
+
'Mel-Roformer-Denoise-Aufr33': 'denoise_mel_band_roformer_aufr33_sdr_27.9959.ckpt',
|
| 17 |
+
'Mel-Roformer-Denoise-Aufr33-Aggr': 'denoise_mel_band_roformer_aufr33_aggr_sdr_27.9768.ckpt',
|
| 18 |
+
}
|
| 19 |
+
MDX23C_MODELS = [
|
| 20 |
+
'MDX23C_D1581.ckpt',
|
| 21 |
+
'MDX23C-8KFFT-InstVoc_HQ.ckpt',
|
| 22 |
+
'MDX23C-8KFFT-InstVoc_HQ_2.ckpt',
|
| 23 |
+
]
|
| 24 |
+
MDXNET_MODELS = [
|
| 25 |
+
'UVR-MDX-NET-Inst_full_292.onnx',
|
| 26 |
+
'UVR-MDX-NET_Inst_187_beta.onnx',
|
| 27 |
+
'UVR-MDX-NET_Inst_82_beta.onnx',
|
| 28 |
+
'UVR-MDX-NET_Inst_90_beta.onnx',
|
| 29 |
+
'UVR-MDX-NET_Main_340.onnx',
|
| 30 |
+
'UVR-MDX-NET_Main_390.onnx',
|
| 31 |
+
'UVR-MDX-NET_Main_406.onnx',
|
| 32 |
+
'UVR-MDX-NET_Main_427.onnx',
|
| 33 |
+
'UVR-MDX-NET_Main_438.onnx',
|
| 34 |
+
'UVR-MDX-NET-Inst_HQ_1.onnx',
|
| 35 |
+
'UVR-MDX-NET-Inst_HQ_2.onnx',
|
| 36 |
+
'UVR-MDX-NET-Inst_HQ_3.onnx',
|
| 37 |
+
'UVR-MDX-NET-Inst_HQ_4.onnx',
|
| 38 |
+
'UVR_MDXNET_Main.onnx',
|
| 39 |
+
'UVR-MDX-NET-Inst_Main.onnx',
|
| 40 |
+
'UVR_MDXNET_1_9703.onnx',
|
| 41 |
+
'UVR_MDXNET_2_9682.onnx',
|
| 42 |
+
'UVR_MDXNET_3_9662.onnx',
|
| 43 |
+
'UVR-MDX-NET-Inst_1.onnx',
|
| 44 |
+
'UVR-MDX-NET-Inst_2.onnx',
|
| 45 |
+
'UVR-MDX-NET-Inst_3.onnx',
|
| 46 |
+
'UVR_MDXNET_KARA.onnx',
|
| 47 |
+
'UVR_MDXNET_KARA_2.onnx',
|
| 48 |
+
'UVR_MDXNET_9482.onnx',
|
| 49 |
+
'UVR-MDX-NET-Voc_FT.onnx',
|
| 50 |
+
'Kim_Vocal_1.onnx',
|
| 51 |
+
'Kim_Vocal_2.onnx',
|
| 52 |
+
'Kim_Inst.onnx',
|
| 53 |
+
'Reverb_HQ_By_FoxJoy.onnx',
|
| 54 |
+
'UVR-MDX-NET_Crowd_HQ_1.onnx',
|
| 55 |
+
'kuielab_a_vocals.onnx',
|
| 56 |
+
'kuielab_a_other.onnx',
|
| 57 |
+
'kuielab_a_bass.onnx',
|
| 58 |
+
'kuielab_a_drums.onnx',
|
| 59 |
+
'kuielab_b_vocals.onnx',
|
| 60 |
+
'kuielab_b_other.onnx',
|
| 61 |
+
'kuielab_b_bass.onnx',
|
| 62 |
+
'kuielab_b_drums.onnx',
|
| 63 |
+
]
|
| 64 |
+
VR_ARCH_MODELS = [
|
| 65 |
+
'1_HP-UVR.pth',
|
| 66 |
+
'2_HP-UVR.pth',
|
| 67 |
+
'3_HP-Vocal-UVR.pth',
|
| 68 |
+
'4_HP-Vocal-UVR.pth',
|
| 69 |
+
'5_HP-Karaoke-UVR.pth',
|
| 70 |
+
'6_HP-Karaoke-UVR.pth',
|
| 71 |
+
'7_HP2-UVR.pth',
|
| 72 |
+
'8_HP2-UVR.pth',
|
| 73 |
+
'9_HP2-UVR.pth',
|
| 74 |
+
'10_SP-UVR-2B-32000-1.pth',
|
| 75 |
+
'11_SP-UVR-2B-32000-2.pth',
|
| 76 |
+
'12_SP-UVR-3B-44100.pth',
|
| 77 |
+
'13_SP-UVR-4B-44100-1.pth',
|
| 78 |
+
'14_SP-UVR-4B-44100-2.pth',
|
| 79 |
+
'15_SP-UVR-MID-44100-1.pth',
|
| 80 |
+
'16_SP-UVR-MID-44100-2.pth',
|
| 81 |
+
'17_HP-Wind_Inst-UVR.pth',
|
| 82 |
+
'UVR-DeEcho-DeReverb.pth',
|
| 83 |
+
'UVR-De-Echo-Normal.pth',
|
| 84 |
+
'UVR-De-Echo-Aggressive.pth',
|
| 85 |
+
'UVR-DeNoise.pth',
|
| 86 |
+
'UVR-DeNoise-Lite.pth',
|
| 87 |
+
'UVR-BVE-4B_SN-44100-1.pth',
|
| 88 |
+
'MGM_HIGHEND_v4.pth',
|
| 89 |
+
'MGM_LOWEND_A_v4.pth',
|
| 90 |
+
'MGM_LOWEND_B_v4.pth',
|
| 91 |
+
'MGM_MAIN_v4.pth',
|
| 92 |
+
]
|
| 93 |
+
DEMUCS_MODELS = [
|
| 94 |
+
'htdemucs_ft.yaml',
|
| 95 |
+
'htdemucs_6s.yaml',
|
| 96 |
+
'htdemucs.yaml',
|
| 97 |
+
'hdemucs_mmi.yaml',
|
| 98 |
+
]
|
| 99 |
+
|
| 100 |
+
def rename_stems(input_file, output_dir, stems, output_format):
|
| 101 |
+
"""Rename stems to the format of the input file name with __(StemX) suffix."""
|
| 102 |
+
base_name = os.path.splitext(os.path.basename(input_file))[0]
|
| 103 |
+
renamed_stems = []
|
| 104 |
+
for i, stem in enumerate(stems):
|
| 105 |
+
new_name = f"{base_name}_(Stem{i+1}).{output_format}"
|
| 106 |
+
new_path = os.path.join(output_dir, new_name)
|
| 107 |
+
os.rename(stem, new_path)
|
| 108 |
+
renamed_stems.append(new_path)
|
| 109 |
+
return renamed_stems
|
| 110 |
+
|
| 111 |
+
def roformer_separator(audio, model, seg_size, overlap, model_dir, out_dir, out_format, norm_thresh, amp_thresh):
|
| 112 |
+
"""Separate audio using Roformer model."""
|
| 113 |
+
with tempfile.TemporaryDirectory() as tmp_dir:
|
| 114 |
+
separator = Separator(
|
| 115 |
+
model_file_dir=model_dir,
|
| 116 |
+
output_dir=tmp_dir,
|
| 117 |
+
output_format=out_format,
|
| 118 |
+
normalization_threshold=norm_thresh,
|
| 119 |
+
amplification_threshold=amp_thresh,
|
| 120 |
+
mdxc_params={
|
| 121 |
+
"batch_size": 1,
|
| 122 |
+
"segment_size": seg_size,
|
| 123 |
+
"overlap": overlap,
|
| 124 |
+
}
|
| 125 |
+
)
|
| 126 |
+
|
| 127 |
+
separator.load_model(model_filename=model)
|
| 128 |
+
separation = separator.separate(audio)
|
| 129 |
+
|
| 130 |
+
stems = rename_stems(audio, out_dir, separation, out_format)
|
| 131 |
+
|
| 132 |
+
return stems[0], stems[1]
|
| 133 |
+
|
| 134 |
+
def mdx23c_separator(audio, model, seg_size, overlap, model_dir, out_dir, out_format, norm_thresh, amp_thresh):
|
| 135 |
+
"""Separate audio using MDX23C model."""
|
| 136 |
+
with tempfile.TemporaryDirectory() as tmp_dir:
|
| 137 |
+
separator = Separator(
|
| 138 |
+
model_file_dir=model_dir,
|
| 139 |
+
output_dir=tmp_dir,
|
| 140 |
+
output_format=out_format,
|
| 141 |
+
normalization_threshold=norm_thresh,
|
| 142 |
+
amplification_threshold=amp_thresh,
|
| 143 |
+
mdxc_params={
|
| 144 |
+
"batch_size": 1,
|
| 145 |
+
"segment_size": seg_size,
|
| 146 |
+
"overlap": overlap,
|
| 147 |
+
}
|
| 148 |
+
)
|
| 149 |
+
|
| 150 |
+
separator.load_model(model_filename=model)
|
| 151 |
+
separation = separator.separate(audio)
|
| 152 |
+
|
| 153 |
+
stems = rename_stems(audio, out_dir, separation, out_format)
|
| 154 |
+
|
| 155 |
+
return stems[0], stems[1]
|
| 156 |
+
|
| 157 |
+
def mdx_separator(audio, model, hop_length, seg_size, overlap, denoise, model_dir, out_dir, out_format, norm_thresh, amp_thresh):
|
| 158 |
+
"""Separate audio using MDX-NET model."""
|
| 159 |
+
with tempfile.TemporaryDirectory() as tmp_dir:
|
| 160 |
+
separator = Separator(
|
| 161 |
+
model_file_dir=model_dir,
|
| 162 |
+
output_dir=tmp_dir,
|
| 163 |
+
output_format=out_format,
|
| 164 |
+
normalization_threshold=norm_thresh,
|
| 165 |
+
amplification_threshold=amp_thresh,
|
| 166 |
+
mdx_params={
|
| 167 |
+
"batch_size": 1,
|
| 168 |
+
"hop_length": hop_length,
|
| 169 |
+
"segment_size": seg_size,
|
| 170 |
+
"overlap": overlap,
|
| 171 |
+
"enable_denoise": denoise,
|
| 172 |
+
}
|
| 173 |
+
)
|
| 174 |
+
|
| 175 |
+
separator.load_model(model_filename=model)
|
| 176 |
+
separation = separator.separate(audio)
|
| 177 |
+
|
| 178 |
+
stems = rename_stems(audio, out_dir, separation, out_format)
|
| 179 |
+
|
| 180 |
+
return stems[0], stems[1]
|
| 181 |
+
|
| 182 |
+
def vr_separator(audio, model, window_size, aggression, tta, post_process, post_process_threshold, high_end_process, model_dir, out_dir, out_format, norm_thresh, amp_thresh):
|
| 183 |
+
"""Separate audio using VR ARCH model."""
|
| 184 |
+
with tempfile.TemporaryDirectory() as tmp_dir:
|
| 185 |
+
separator = Separator(
|
| 186 |
+
model_file_dir=model_dir,
|
| 187 |
+
output_dir=tmp_dir,
|
| 188 |
+
output_format=out_format,
|
| 189 |
+
normalization_threshold=norm_thresh,
|
| 190 |
+
amplification_threshold=amp_thresh,
|
| 191 |
+
vr_params={
|
| 192 |
+
"batch_size": 1,
|
| 193 |
+
"window_size": window_size,
|
| 194 |
+
"aggression": aggression,
|
| 195 |
+
"enable_tta": tta,
|
| 196 |
+
"enable_post_process": post_process,
|
| 197 |
+
"post_process_threshold": post_process_threshold,
|
| 198 |
+
"high_end_process": high_end_process,
|
| 199 |
+
}
|
| 200 |
+
)
|
| 201 |
+
|
| 202 |
+
separator.load_model(model_filename=model)
|
| 203 |
+
separation = separator.separate(audio)
|
| 204 |
+
|
| 205 |
+
stems = rename_stems(audio, out_dir, separation, out_format)
|
| 206 |
+
|
| 207 |
+
return stems[0], stems[1]
|
| 208 |
+
|
| 209 |
+
def demucs_separator(audio, model, seg_size, shifts, overlap, segments_enabled, model_dir, out_dir, out_format, norm_thresh, amp_thresh):
|
| 210 |
+
"""Separate audio using Demucs model."""
|
| 211 |
+
with tempfile.TemporaryDirectory() as tmp_dir:
|
| 212 |
+
separator = Separator(
|
| 213 |
+
model_file_dir=model_dir,
|
| 214 |
+
output_dir=tmp_dir,
|
| 215 |
+
output_format=out_format,
|
| 216 |
+
normalization_threshold=norm_thresh,
|
| 217 |
+
amplification_threshold=amp_thresh,
|
| 218 |
+
demucs_params={
|
| 219 |
+
"segment_size": seg_size,
|
| 220 |
+
"shifts": shifts,
|
| 221 |
+
"overlap": overlap,
|
| 222 |
+
"segments_enabled": segments_enabled,
|
| 223 |
+
}
|
| 224 |
+
)
|
| 225 |
+
|
| 226 |
+
separator.load_model(model_filename=model)
|
| 227 |
+
separation = separator.separate(audio)
|
| 228 |
+
|
| 229 |
+
stems = rename_stems(audio, out_dir, separation, out_format)
|
| 230 |
+
|
| 231 |
+
return stems[0], stems[1], stems[2], stems[3]
|
| 232 |
+
|
| 233 |
+
with gr.Blocks(title="🎵 Audio Separator (by Politrees) 🎵", css="footer{display:none !important}") as app:
|
| 234 |
+
with gr.Accordion("General settings", open=False):
|
| 235 |
+
model_file_dir = gr.Textbox(value="/tmp/audio-separator-models/", label="Directory for storing model files", placeholder="/tmp/audio-separator-models/", interactive=False)
|
| 236 |
+
with gr.Row():
|
| 237 |
+
output_dir = gr.Textbox(value="", label="File output directory", placeholder="/content/output", interactive=False)
|
| 238 |
+
output_format = gr.Dropdown(value="wav", choices=["wav", "flac", "mp3"], label="Output Format")
|
| 239 |
+
with gr.Row():
|
| 240 |
+
norm_threshold = gr.Slider(value=0.9, step=0.1, minimum=0, maximum=1, label="Normalization", info="max peak amplitude to normalize input and output audio.")
|
| 241 |
+
amp_threshold = gr.Slider(value=0.6, step=0.1, minimum=0, maximum=1, label="Amplification", info="min peak amplitude to amplify input and output audio.")
|
| 242 |
+
|
| 243 |
+
with gr.Tab("Roformer"):
|
| 244 |
+
with gr.Row():
|
| 245 |
+
roformer_model = gr.Dropdown(label="Select the Model", choices=list(ROFORMER_MODELS.keys()))
|
| 246 |
+
with gr.Row():
|
| 247 |
+
roformer_seg_size = gr.Slider(minimum=32, maximum=4000, step=32, value=256, label="Segment Size", info="Larger consumes more resources, but may give better results.")
|
| 248 |
+
roformer_overlap = gr.Slider(minimum=2, maximum=4, step=1, value=4, label="Overlap", info="Amount of overlap between prediction windows.")
|
| 249 |
+
with gr.Row():
|
| 250 |
+
roformer_audio = gr.Audio(label="Input Audio", type="numpy")
|
| 251 |
+
with gr.Row():
|
| 252 |
+
roformer_button = gr.Button("Separate!", variant="primary")
|
| 253 |
+
with gr.Row():
|
| 254 |
+
roformer_stem1 = gr.Audio(label="Stem 1", type="filepath", interactive=False)
|
| 255 |
+
roformer_stem2 = gr.Audio(label="Stem 2", type="filepath", interactive=False)
|
| 256 |
+
|
| 257 |
+
with gr.Tab("MDX23C"):
|
| 258 |
+
with gr.Row():
|
| 259 |
+
mdx23c_model = gr.Dropdown(label="Select the Model", choices=MDX23C_MODELS)
|
| 260 |
+
with gr.Row():
|
| 261 |
+
mdx23c_seg_size = gr.Slider(minimum=32, maximum=4000, step=32, value=256, label="Segment Size", info="Larger consumes more resources, but may give better results.")
|
| 262 |
+
mdx23c_overlap = gr.Slider(minimum=2, maximum=50, step=1, value=8, label="Overlap", info="Amount of overlap between prediction windows.")
|
| 263 |
+
with gr.Row():
|
| 264 |
+
mdx23c_audio = gr.Audio(label="Input Audio", type="numpy")
|
| 265 |
+
with gr.Row():
|
| 266 |
+
mdx23c_button = gr.Button("Separate!", variant="primary")
|
| 267 |
+
with gr.Row():
|
| 268 |
+
mdx23c_stem1 = gr.Audio(label="Stem 1", type="filepath", interactive=False)
|
| 269 |
+
mdx23c_stem2 = gr.Audio(label="Stem 2", type="filepath", interactive=False)
|
| 270 |
+
|
| 271 |
+
with gr.Tab("MDX-NET"):
|
| 272 |
+
with gr.Row():
|
| 273 |
+
mdx_model = gr.Dropdown(label="Select the Model", choices=MDXNET_MODELS)
|
| 274 |
+
with gr.Row():
|
| 275 |
+
mdx_hop_length = gr.Slider(minimum=0.001, maximum=0.999, step=0.001, value=0.25, label="Hop Length")
|
| 276 |
+
mdx_seg_size = gr.Slider(minimum=32, maximum=4000, step=32, value=256, label="Segment Size", info="Larger consumes more resources, but may give better results.")
|
| 277 |
+
mdx_overlap = gr.Slider(minimum=0.001, maximum=0.999, step=0.001, value=0.25, label="Overlap")
|
| 278 |
+
mdx_denoise = gr.Checkbox(value=True, label="Denoise", info="Enable denoising during separation.")
|
| 279 |
+
with gr.Row():
|
| 280 |
+
mdx_audio = gr.Audio(label="Input Audio", type="numpy")
|
| 281 |
+
with gr.Row():
|
| 282 |
+
mdx_button = gr.Button("Separate!", variant="primary")
|
| 283 |
+
with gr.Row():
|
| 284 |
+
mdx_stem1 = gr.Audio(label="Stem 1", type="filepath", interactive=False)
|
| 285 |
+
mdx_stem2 = gr.Audio(label="Stem 2", type="filepath", interactive=False)
|
| 286 |
+
|
| 287 |
+
with gr.Tab("VR ARCH"):
|
| 288 |
+
with gr.Row():
|
| 289 |
+
vr_model = gr.Dropdown(label="Select the Model", choices=VR_ARCH_MODELS)
|
| 290 |
+
with gr.Row():
|
| 291 |
+
vr_window_size = gr.Dropdown(minimum=320, maximum=1024, step=32, value=512, label="Window Size")
|
| 292 |
+
vr_aggression = gr.Slider(minimum=1, maximum=50, step=1, value=5, label="Agression", info="Intensity of primary stem extraction.")
|
| 293 |
+
vr_tta = gr.Checkbox(value=True, label="TTA", info="Enable Test-Time-Augmentation; slow but improves quality.")
|
| 294 |
+
vr_post_process = gr.Checkbox(value=True, label="Post Process", info="Enable post-processing.")
|
| 295 |
+
vr_post_process_threshold = gr.Slider(minimum=0.1, maximum=0.3, step=0.1, value=0.2, label="Post Process Threshold", info="Threshold for post-processing.")
|
| 296 |
+
vr_high_end_process = gr.Checkbox(value=False, label="High End Process", info="Mirror the missing frequency range of the output.")
|
| 297 |
+
with gr.Row():
|
| 298 |
+
vr_audio = gr.Audio(label="Input Audio", type="numpy")
|
| 299 |
+
with gr.Row():
|
| 300 |
+
vr_button = gr.Button("Separate!", variant="primary")
|
| 301 |
+
with gr.Row():
|
| 302 |
+
vr_stem1 = gr.Audio(label="Stem 1", type="filepath", interactive=False)
|
| 303 |
+
vr_stem2 = gr.Audio(label="Stem 2", type="filepath", interactive=False)
|
| 304 |
+
|
| 305 |
+
with gr.Tab("Demucs"):
|
| 306 |
+
with gr.Row():
|
| 307 |
+
demucs_model = gr.Dropdown(label="Select the Model", choices=DEMUCS_MODELS)
|
| 308 |
+
with gr.Row():
|
| 309 |
+
demucs_seg_size = gr.Slider(minimum=1, maximum=100, step=1, value=50, label="Segment Size")
|
| 310 |
+
demucs_shifts = gr.Slider(minimum=0, maximum=20, step=1, value=2, label="Shifts", info="Number of predictions with random shifts, higher = slower but better quality.")
|
| 311 |
+
demucs_overlap = gr.Slider(minimum=0.001, maximum=0.999, step=0.001, value=0.25, label="Overlap")
|
| 312 |
+
demucs_segments_enabled = gr.Checkbox(value=True, label="Segment-wise processing")
|
| 313 |
+
with gr.Row():
|
| 314 |
+
demucs_audio = gr.Audio(label="Input Audio", type="numpy")
|
| 315 |
+
with gr.Row():
|
| 316 |
+
demucs_button = gr.Button("Separate!", variant="primary")
|
| 317 |
+
with gr.Row():
|
| 318 |
+
demucs_stem1 = gr.Audio(label="Stem 1", type="filepath", interactive=False)
|
| 319 |
+
demucs_stem2 = gr.Audio(label="Stem 2", type="filepath", interactive=False)
|
| 320 |
+
with gr.Row():
|
| 321 |
+
demucs_stem3 = gr.Audio(label="Stem 3", type="filepath", interactive=False)
|
| 322 |
+
demucs_stem4 = gr.Audio(label="Stem 4", type="filepath", interactive=False)
|
| 323 |
+
|
| 324 |
+
roformer_button.click(
|
| 325 |
+
roformer_separator,
|
| 326 |
+
inputs=[
|
| 327 |
+
roformer_audio,
|
| 328 |
+
roformer_model,
|
| 329 |
+
roformer_seg_size,
|
| 330 |
+
roformer_overlap,
|
| 331 |
+
model_file_dir,
|
| 332 |
+
output_dir,
|
| 333 |
+
output_format,
|
| 334 |
+
norm_threshold,
|
| 335 |
+
amp_threshold,
|
| 336 |
+
],
|
| 337 |
+
outputs=[roformer_stem1, roformer_stem2],
|
| 338 |
+
)
|
| 339 |
+
mdx23c_button.click(
|
| 340 |
+
mdx23c_separator,
|
| 341 |
+
inputs=[
|
| 342 |
+
mdx23c_audio,
|
| 343 |
+
mdx23c_model,
|
| 344 |
+
mdx23c_seg_size,
|
| 345 |
+
mdx23c_overlap,
|
| 346 |
+
model_file_dir,
|
| 347 |
+
output_dir,
|
| 348 |
+
output_format,
|
| 349 |
+
norm_threshold,
|
| 350 |
+
amp_threshold,
|
| 351 |
+
],
|
| 352 |
+
outputs=[mdx23c_stem1, mdx23c_stem2],
|
| 353 |
+
)
|
| 354 |
+
mdx_button.click(
|
| 355 |
+
mdx_separator,
|
| 356 |
+
inputs=[
|
| 357 |
+
mdx_audio,
|
| 358 |
+
mdx_model,
|
| 359 |
+
mdx_hop_length,
|
| 360 |
+
mdx_seg_size,
|
| 361 |
+
mdx_overlap,
|
| 362 |
+
mdx_denoise,
|
| 363 |
+
model_file_dir,
|
| 364 |
+
output_dir,
|
| 365 |
+
output_format,
|
| 366 |
+
norm_threshold,
|
| 367 |
+
amp_threshold,
|
| 368 |
+
],
|
| 369 |
+
outputs=[mdx_stem1, mdx_stem2],
|
| 370 |
+
)
|
| 371 |
+
vr_button.click(
|
| 372 |
+
vr_separator,
|
| 373 |
+
inputs=[
|
| 374 |
+
vr_audio,
|
| 375 |
+
vr_model,
|
| 376 |
+
vr_window_size,
|
| 377 |
+
vr_aggression,
|
| 378 |
+
vr_tta,
|
| 379 |
+
vr_post_process,
|
| 380 |
+
vr_post_process_threshold,
|
| 381 |
+
vr_high_end_process,
|
| 382 |
+
model_file_dir,
|
| 383 |
+
output_dir,
|
| 384 |
+
output_format,
|
| 385 |
+
norm_threshold,
|
| 386 |
+
amp_threshold,
|
| 387 |
+
],
|
| 388 |
+
outputs=[vr_stem1, vr_stem2],
|
| 389 |
+
)
|
| 390 |
+
demucs_button.click(
|
| 391 |
+
demucs_separator,
|
| 392 |
+
inputs=[
|
| 393 |
+
demucs_audio,
|
| 394 |
+
demucs_model,
|
| 395 |
+
demucs_seg_size,
|
| 396 |
+
demucs_shifts,
|
| 397 |
+
demucs_overlap,
|
| 398 |
+
demucs_segments_enabled,
|
| 399 |
+
model_file_dir,
|
| 400 |
+
output_dir,
|
| 401 |
+
output_format,
|
| 402 |
+
norm_threshold,
|
| 403 |
+
amp_threshold,
|
| 404 |
+
],
|
| 405 |
+
outputs=[demucs_stem1, demucs_stem2, demucs_stem3, demucs_stem4],
|
| 406 |
+
)
|
| 407 |
+
|
| 408 |
+
app.launch(share=True)
|