Eddycrack864
commited on
Commit
•
c276b83
1
Parent(s):
70da67e
Update app.py
Browse files
app.py
CHANGED
@@ -1,526 +1,521 @@
|
|
1 |
-
import os
|
2 |
-
import re
|
3 |
-
import random
|
4 |
-
from scipy.io.wavfile import write
|
5 |
-
import gradio as gr
|
6 |
-
|
7 |
-
roformer_models = {
|
8 |
-
'BS-Roformer-Viperx-1297.ckpt': 'model_bs_roformer_ep_317_sdr_12.9755.ckpt',
|
9 |
-
'BS-Roformer-Viperx-1296.ckpt': 'model_bs_roformer_ep_368_sdr_12.9628.ckpt',
|
10 |
-
'BS-Roformer-Viperx-1053.ckpt': 'model_bs_roformer_ep_937_sdr_10.5309.ckpt',
|
11 |
-
'Mel-Roformer-Viperx-1143.ckpt': 'model_mel_band_roformer_ep_3005_sdr_11.4360.ckpt'
|
12 |
-
}
|
13 |
-
|
14 |
-
mdx23c_models = [
|
15 |
-
'MDX23C_D1581.ckpt',
|
16 |
-
'MDX23C-8KFFT-InstVoc_HQ.ckpt',
|
17 |
-
'MDX23C-8KFFT-InstVoc_HQ_2.ckpt',
|
18 |
-
]
|
19 |
-
|
20 |
-
mdxnet_models = [
|
21 |
-
'UVR-MDX-NET-Inst_full_292.onnx',
|
22 |
-
'UVR-MDX-NET_Inst_187_beta.onnx',
|
23 |
-
'UVR-MDX-NET_Inst_82_beta.onnx',
|
24 |
-
'UVR-MDX-NET_Inst_90_beta.onnx',
|
25 |
-
'UVR-MDX-NET_Main_340.onnx',
|
26 |
-
'UVR-MDX-NET_Main_390.onnx',
|
27 |
-
'UVR-MDX-NET_Main_406.onnx',
|
28 |
-
'UVR-MDX-NET_Main_427.onnx',
|
29 |
-
'UVR-MDX-NET_Main_438.onnx',
|
30 |
-
'UVR-MDX-NET-Inst_HQ_1.onnx',
|
31 |
-
'UVR-MDX-NET-Inst_HQ_2.onnx',
|
32 |
-
'UVR-MDX-NET-Inst_HQ_3.onnx',
|
33 |
-
'UVR-MDX-NET-Inst_HQ_4.onnx',
|
34 |
-
'UVR_MDXNET_Main.onnx',
|
35 |
-
'UVR-MDX-NET-Inst_Main.onnx',
|
36 |
-
'UVR_MDXNET_1_9703.onnx',
|
37 |
-
'UVR_MDXNET_2_9682.onnx',
|
38 |
-
'UVR_MDXNET_3_9662.onnx',
|
39 |
-
'UVR-MDX-NET-Inst_1.onnx',
|
40 |
-
'UVR-MDX-NET-Inst_2.onnx',
|
41 |
-
'UVR-MDX-NET-Inst_3.onnx',
|
42 |
-
'UVR_MDXNET_KARA.onnx',
|
43 |
-
'UVR_MDXNET_KARA_2.onnx',
|
44 |
-
'UVR_MDXNET_9482.onnx',
|
45 |
-
'UVR-MDX-NET-Voc_FT.onnx',
|
46 |
-
'Kim_Vocal_1.onnx',
|
47 |
-
'Kim_Vocal_2.onnx',
|
48 |
-
'Kim_Inst.onnx',
|
49 |
-
'Reverb_HQ_By_FoxJoy.onnx',
|
50 |
-
'UVR-MDX-NET_Crowd_HQ_1.onnx',
|
51 |
-
'kuielab_a_vocals.onnx',
|
52 |
-
'kuielab_a_other.onnx',
|
53 |
-
'kuielab_a_bass.onnx',
|
54 |
-
'kuielab_a_drums.onnx',
|
55 |
-
'kuielab_b_vocals.onnx',
|
56 |
-
'kuielab_b_other.onnx',
|
57 |
-
'kuielab_b_bass.onnx',
|
58 |
-
'kuielab_b_drums.onnx',
|
59 |
-
]
|
60 |
-
|
61 |
-
vrarch_models = [
|
62 |
-
'1_HP-UVR.pth',
|
63 |
-
'2_HP-UVR.pth',
|
64 |
-
'3_HP-Vocal-UVR.pth',
|
65 |
-
'4_HP-Vocal-UVR.pth',
|
66 |
-
'5_HP-Karaoke-UVR.pth',
|
67 |
-
'6_HP-Karaoke-UVR.pth',
|
68 |
-
'7_HP2-UVR.pth',
|
69 |
-
'8_HP2-UVR.pth',
|
70 |
-
'9_HP2-UVR.pth',
|
71 |
-
'10_SP-UVR-2B-32000-1.pth',
|
72 |
-
'11_SP-UVR-2B-32000-2.pth',
|
73 |
-
'12_SP-UVR-3B-44100.pth',
|
74 |
-
'13_SP-UVR-4B-44100-1.pth',
|
75 |
-
'14_SP-UVR-4B-44100-2.pth',
|
76 |
-
'15_SP-UVR-MID-44100-1.pth',
|
77 |
-
'16_SP-UVR-MID-44100-2.pth',
|
78 |
-
'17_HP-Wind_Inst-UVR.pth',
|
79 |
-
'UVR-De-Echo-Aggressive.pth',
|
80 |
-
'UVR-De-Echo-Normal.pth',
|
81 |
-
'UVR-DeEcho-DeReverb.pth',
|
82 |
-
'UVR-DeNoise-Lite.pth',
|
83 |
-
'UVR-DeNoise.pth',
|
84 |
-
'UVR-BVE-4B_SN-44100-1.pth',
|
85 |
-
'MGM_HIGHEND_v4.pth',
|
86 |
-
'MGM_LOWEND_A_v4.pth',
|
87 |
-
'MGM_LOWEND_B_v4.pth',
|
88 |
-
'MGM_MAIN_v4.pth',
|
89 |
-
]
|
90 |
-
|
91 |
-
demucs_models = [
|
92 |
-
'htdemucs_ft.yaml',
|
93 |
-
'htdemucs.yaml',
|
94 |
-
'hdemucs_mmi.yaml',
|
95 |
-
]
|
96 |
-
|
97 |
-
output_format = [
|
98 |
-
'wav',
|
99 |
-
'flac',
|
100 |
-
'mp3',
|
101 |
-
]
|
102 |
-
|
103 |
-
mdxnet_overlap_values = [
|
104 |
-
'0.25',
|
105 |
-
'0.5',
|
106 |
-
'0.75',
|
107 |
-
'0.99',
|
108 |
-
]
|
109 |
-
|
110 |
-
vrarch_window_size_values = [
|
111 |
-
'320',
|
112 |
-
'512',
|
113 |
-
'1024',
|
114 |
-
]
|
115 |
-
|
116 |
-
def roformer_separator(roformer_audio, roformer_model, roformer_output_format, roformer_overlap):
|
117 |
-
files_list = []
|
118 |
-
files_list.clear()
|
119 |
-
directory = "./outputs"
|
120 |
-
random_id = str(random.randint(10000, 99999))
|
121 |
-
pattern = f"{random_id}"
|
122 |
-
os.makedirs("outputs", exist_ok=True)
|
123 |
-
write(f'{random_id}.wav', roformer_audio[0], roformer_audio[1])
|
124 |
-
full_roformer_model = roformer_models[roformer_model]
|
125 |
-
prompt = f"audio-separator {random_id}.wav --model_filename {full_roformer_model} --output_dir=./outputs --output_format={roformer_output_format} --normalization=0.9 --mdxc_overlap={roformer_overlap}"
|
126 |
-
os.system(prompt)
|
127 |
-
|
128 |
-
for file in os.listdir(directory):
|
129 |
-
if re.search(pattern, file):
|
130 |
-
files_list.append(os.path.join(directory, file))
|
131 |
-
|
132 |
-
stem1_file = files_list[0]
|
133 |
-
stem2_file = files_list[1]
|
134 |
-
|
135 |
-
return stem1_file, stem2_file
|
136 |
-
|
137 |
-
def mdxc_separator(mdx23c_audio, mdx23c_model, mdx23c_output_format, mdx23c_segment_size, mdx23c_overlap):
|
138 |
-
files_list = []
|
139 |
-
files_list.clear()
|
140 |
-
directory = "./outputs"
|
141 |
-
random_id = str(random.randint(10000, 99999))
|
142 |
-
pattern = f"{random_id}"
|
143 |
-
os.makedirs("outputs", exist_ok=True)
|
144 |
-
write(f'{random_id}.wav', mdx23c_audio[0], mdx23c_audio[1])
|
145 |
-
prompt = f"audio-separator {random_id}.wav --model_filename {mdx23c_model} --output_dir=./outputs --output_format={mdx23c_output_format} --normalization=0.9 --mdxc_segment_size={mdx23c_segment_size} --mdxc_overlap={mdx23c_overlap}"
|
146 |
-
os.system(prompt)
|
147 |
-
|
148 |
-
for file in os.listdir(directory):
|
149 |
-
if re.search(pattern, file):
|
150 |
-
files_list.append(os.path.join(directory, file))
|
151 |
-
|
152 |
-
stem1_file = files_list[0]
|
153 |
-
stem2_file = files_list[1]
|
154 |
-
|
155 |
-
return stem1_file, stem2_file
|
156 |
-
|
157 |
-
def mdxnet_separator(mdxnet_audio, mdxnet_model, mdxnet_output_format, mdxnet_segment_size, mdxnet_overlap, mdxnet_denoise):
|
158 |
-
files_list = []
|
159 |
-
files_list.clear()
|
160 |
-
directory = "./outputs"
|
161 |
-
random_id = str(random.randint(10000, 99999))
|
162 |
-
pattern = f"{random_id}"
|
163 |
-
os.makedirs("outputs", exist_ok=True)
|
164 |
-
write(f'{random_id}.wav', mdxnet_audio[0], mdxnet_audio[1])
|
165 |
-
prompt = f"audio-separator {random_id}.wav --model_filename {mdxnet_model} --output_dir=./outputs --output_format={mdxnet_output_format} --normalization=0.9 --mdxc_segment_size={mdxnet_segment_size} --mdxc_overlap={mdxnet_overlap}"
|
166 |
-
|
167 |
-
if mdxnet_denoise:
|
168 |
-
prompt += " --mdx_enable_denoise"
|
169 |
-
|
170 |
-
os.system(prompt)
|
171 |
-
|
172 |
-
for file in os.listdir(directory):
|
173 |
-
if re.search(pattern, file):
|
174 |
-
files_list.append(os.path.join(directory, file))
|
175 |
-
|
176 |
-
stem1_file = files_list[0]
|
177 |
-
stem2_file = files_list[1]
|
178 |
-
|
179 |
-
return stem1_file, stem2_file
|
180 |
-
|
181 |
-
def vrarch_separator(vrarch_audio, vrarch_model, vrarch_output_format, vrarch_window_size, vrarch_agression
|
182 |
-
files_list = []
|
183 |
-
files_list.clear()
|
184 |
-
directory = "./outputs"
|
185 |
-
random_id = str(random.randint(10000, 99999))
|
186 |
-
pattern = f"{random_id}"
|
187 |
-
os.makedirs("outputs", exist_ok=True)
|
188 |
-
write(f'{random_id}.wav', vrarch_audio[0], vrarch_audio[1])
|
189 |
-
prompt = f"audio-separator {random_id}.wav --model_filename {vrarch_model} --output_dir=./outputs --output_format={vrarch_output_format} --normalization=0.9 --vr_window_size={vrarch_window_size} --vr_aggression={vrarch_agression}"
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
stem1_file
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
label = "Select the
|
237 |
-
choices=
|
238 |
-
interactive = True
|
239 |
-
)
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
label = "Select the
|
283 |
-
choices =
|
284 |
-
interactive = True
|
285 |
-
)
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
label = "Select the
|
338 |
-
choices =
|
339 |
-
interactive = True
|
340 |
-
)
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
label = "Select the
|
396 |
-
choices =
|
397 |
-
interactive = True
|
398 |
-
)
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
label = "Select the
|
462 |
-
choices =
|
463 |
-
interactive = True
|
464 |
-
)
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
label = "Stem 4"
|
522 |
-
)
|
523 |
-
|
524 |
-
demucs_button.click(vrarch_separator, [demucs_audio, demucs_model, demucs_output_format, demucs_shifts, demucs_overlap], [demucs_stem1, demucs_stem2, demucs_stem3, demucs_stem4])
|
525 |
-
|
526 |
app.launch()
|
|
|
1 |
+
import os
|
2 |
+
import re
|
3 |
+
import random
|
4 |
+
from scipy.io.wavfile import write
|
5 |
+
import gradio as gr
|
6 |
+
|
7 |
+
roformer_models = {
|
8 |
+
'BS-Roformer-Viperx-1297.ckpt': 'model_bs_roformer_ep_317_sdr_12.9755.ckpt',
|
9 |
+
'BS-Roformer-Viperx-1296.ckpt': 'model_bs_roformer_ep_368_sdr_12.9628.ckpt',
|
10 |
+
'BS-Roformer-Viperx-1053.ckpt': 'model_bs_roformer_ep_937_sdr_10.5309.ckpt',
|
11 |
+
'Mel-Roformer-Viperx-1143.ckpt': 'model_mel_band_roformer_ep_3005_sdr_11.4360.ckpt'
|
12 |
+
}
|
13 |
+
|
14 |
+
mdx23c_models = [
|
15 |
+
'MDX23C_D1581.ckpt',
|
16 |
+
'MDX23C-8KFFT-InstVoc_HQ.ckpt',
|
17 |
+
'MDX23C-8KFFT-InstVoc_HQ_2.ckpt',
|
18 |
+
]
|
19 |
+
|
20 |
+
mdxnet_models = [
|
21 |
+
'UVR-MDX-NET-Inst_full_292.onnx',
|
22 |
+
'UVR-MDX-NET_Inst_187_beta.onnx',
|
23 |
+
'UVR-MDX-NET_Inst_82_beta.onnx',
|
24 |
+
'UVR-MDX-NET_Inst_90_beta.onnx',
|
25 |
+
'UVR-MDX-NET_Main_340.onnx',
|
26 |
+
'UVR-MDX-NET_Main_390.onnx',
|
27 |
+
'UVR-MDX-NET_Main_406.onnx',
|
28 |
+
'UVR-MDX-NET_Main_427.onnx',
|
29 |
+
'UVR-MDX-NET_Main_438.onnx',
|
30 |
+
'UVR-MDX-NET-Inst_HQ_1.onnx',
|
31 |
+
'UVR-MDX-NET-Inst_HQ_2.onnx',
|
32 |
+
'UVR-MDX-NET-Inst_HQ_3.onnx',
|
33 |
+
'UVR-MDX-NET-Inst_HQ_4.onnx',
|
34 |
+
'UVR_MDXNET_Main.onnx',
|
35 |
+
'UVR-MDX-NET-Inst_Main.onnx',
|
36 |
+
'UVR_MDXNET_1_9703.onnx',
|
37 |
+
'UVR_MDXNET_2_9682.onnx',
|
38 |
+
'UVR_MDXNET_3_9662.onnx',
|
39 |
+
'UVR-MDX-NET-Inst_1.onnx',
|
40 |
+
'UVR-MDX-NET-Inst_2.onnx',
|
41 |
+
'UVR-MDX-NET-Inst_3.onnx',
|
42 |
+
'UVR_MDXNET_KARA.onnx',
|
43 |
+
'UVR_MDXNET_KARA_2.onnx',
|
44 |
+
'UVR_MDXNET_9482.onnx',
|
45 |
+
'UVR-MDX-NET-Voc_FT.onnx',
|
46 |
+
'Kim_Vocal_1.onnx',
|
47 |
+
'Kim_Vocal_2.onnx',
|
48 |
+
'Kim_Inst.onnx',
|
49 |
+
'Reverb_HQ_By_FoxJoy.onnx',
|
50 |
+
'UVR-MDX-NET_Crowd_HQ_1.onnx',
|
51 |
+
'kuielab_a_vocals.onnx',
|
52 |
+
'kuielab_a_other.onnx',
|
53 |
+
'kuielab_a_bass.onnx',
|
54 |
+
'kuielab_a_drums.onnx',
|
55 |
+
'kuielab_b_vocals.onnx',
|
56 |
+
'kuielab_b_other.onnx',
|
57 |
+
'kuielab_b_bass.onnx',
|
58 |
+
'kuielab_b_drums.onnx',
|
59 |
+
]
|
60 |
+
|
61 |
+
vrarch_models = [
|
62 |
+
'1_HP-UVR.pth',
|
63 |
+
'2_HP-UVR.pth',
|
64 |
+
'3_HP-Vocal-UVR.pth',
|
65 |
+
'4_HP-Vocal-UVR.pth',
|
66 |
+
'5_HP-Karaoke-UVR.pth',
|
67 |
+
'6_HP-Karaoke-UVR.pth',
|
68 |
+
'7_HP2-UVR.pth',
|
69 |
+
'8_HP2-UVR.pth',
|
70 |
+
'9_HP2-UVR.pth',
|
71 |
+
'10_SP-UVR-2B-32000-1.pth',
|
72 |
+
'11_SP-UVR-2B-32000-2.pth',
|
73 |
+
'12_SP-UVR-3B-44100.pth',
|
74 |
+
'13_SP-UVR-4B-44100-1.pth',
|
75 |
+
'14_SP-UVR-4B-44100-2.pth',
|
76 |
+
'15_SP-UVR-MID-44100-1.pth',
|
77 |
+
'16_SP-UVR-MID-44100-2.pth',
|
78 |
+
'17_HP-Wind_Inst-UVR.pth',
|
79 |
+
'UVR-De-Echo-Aggressive.pth',
|
80 |
+
'UVR-De-Echo-Normal.pth',
|
81 |
+
'UVR-DeEcho-DeReverb.pth',
|
82 |
+
'UVR-DeNoise-Lite.pth',
|
83 |
+
'UVR-DeNoise.pth',
|
84 |
+
'UVR-BVE-4B_SN-44100-1.pth',
|
85 |
+
'MGM_HIGHEND_v4.pth',
|
86 |
+
'MGM_LOWEND_A_v4.pth',
|
87 |
+
'MGM_LOWEND_B_v4.pth',
|
88 |
+
'MGM_MAIN_v4.pth',
|
89 |
+
]
|
90 |
+
|
91 |
+
demucs_models = [
|
92 |
+
'htdemucs_ft.yaml',
|
93 |
+
'htdemucs.yaml',
|
94 |
+
'hdemucs_mmi.yaml',
|
95 |
+
]
|
96 |
+
|
97 |
+
output_format = [
|
98 |
+
'wav',
|
99 |
+
'flac',
|
100 |
+
'mp3',
|
101 |
+
]
|
102 |
+
|
103 |
+
mdxnet_overlap_values = [
|
104 |
+
'0.25',
|
105 |
+
'0.5',
|
106 |
+
'0.75',
|
107 |
+
'0.99',
|
108 |
+
]
|
109 |
+
|
110 |
+
vrarch_window_size_values = [
|
111 |
+
'320',
|
112 |
+
'512',
|
113 |
+
'1024',
|
114 |
+
]
|
115 |
+
|
116 |
+
def roformer_separator(roformer_audio, roformer_model, roformer_output_format, roformer_overlap):
|
117 |
+
files_list = []
|
118 |
+
files_list.clear()
|
119 |
+
directory = "./outputs"
|
120 |
+
random_id = str(random.randint(10000, 99999))
|
121 |
+
pattern = f"{random_id}"
|
122 |
+
os.makedirs("outputs", exist_ok=True)
|
123 |
+
write(f'{random_id}.wav', roformer_audio[0], roformer_audio[1])
|
124 |
+
full_roformer_model = roformer_models[roformer_model]
|
125 |
+
prompt = f"audio-separator {random_id}.wav --model_filename {full_roformer_model} --output_dir=./outputs --output_format={roformer_output_format} --normalization=0.9 --mdxc_overlap={roformer_overlap}"
|
126 |
+
os.system(prompt)
|
127 |
+
|
128 |
+
for file in os.listdir(directory):
|
129 |
+
if re.search(pattern, file):
|
130 |
+
files_list.append(os.path.join(directory, file))
|
131 |
+
|
132 |
+
stem1_file = files_list[0]
|
133 |
+
stem2_file = files_list[1]
|
134 |
+
|
135 |
+
return stem1_file, stem2_file
|
136 |
+
|
137 |
+
def mdxc_separator(mdx23c_audio, mdx23c_model, mdx23c_output_format, mdx23c_segment_size, mdx23c_overlap):
|
138 |
+
files_list = []
|
139 |
+
files_list.clear()
|
140 |
+
directory = "./outputs"
|
141 |
+
random_id = str(random.randint(10000, 99999))
|
142 |
+
pattern = f"{random_id}"
|
143 |
+
os.makedirs("outputs", exist_ok=True)
|
144 |
+
write(f'{random_id}.wav', mdx23c_audio[0], mdx23c_audio[1])
|
145 |
+
prompt = f"audio-separator {random_id}.wav --model_filename {mdx23c_model} --output_dir=./outputs --output_format={mdx23c_output_format} --normalization=0.9 --mdxc_segment_size={mdx23c_segment_size} --mdxc_overlap={mdx23c_overlap}"
|
146 |
+
os.system(prompt)
|
147 |
+
|
148 |
+
for file in os.listdir(directory):
|
149 |
+
if re.search(pattern, file):
|
150 |
+
files_list.append(os.path.join(directory, file))
|
151 |
+
|
152 |
+
stem1_file = files_list[0]
|
153 |
+
stem2_file = files_list[1]
|
154 |
+
|
155 |
+
return stem1_file, stem2_file
|
156 |
+
|
157 |
+
def mdxnet_separator(mdxnet_audio, mdxnet_model, mdxnet_output_format, mdxnet_segment_size, mdxnet_overlap, mdxnet_denoise):
|
158 |
+
files_list = []
|
159 |
+
files_list.clear()
|
160 |
+
directory = "./outputs"
|
161 |
+
random_id = str(random.randint(10000, 99999))
|
162 |
+
pattern = f"{random_id}"
|
163 |
+
os.makedirs("outputs", exist_ok=True)
|
164 |
+
write(f'{random_id}.wav', mdxnet_audio[0], mdxnet_audio[1])
|
165 |
+
prompt = f"audio-separator {random_id}.wav --model_filename {mdxnet_model} --output_dir=./outputs --output_format={mdxnet_output_format} --normalization=0.9 --mdxc_segment_size={mdxnet_segment_size} --mdxc_overlap={mdxnet_overlap}"
|
166 |
+
|
167 |
+
if mdxnet_denoise:
|
168 |
+
prompt += " --mdx_enable_denoise"
|
169 |
+
|
170 |
+
os.system(prompt)
|
171 |
+
|
172 |
+
for file in os.listdir(directory):
|
173 |
+
if re.search(pattern, file):
|
174 |
+
files_list.append(os.path.join(directory, file))
|
175 |
+
|
176 |
+
stem1_file = files_list[0]
|
177 |
+
stem2_file = files_list[1]
|
178 |
+
|
179 |
+
return stem1_file, stem2_file
|
180 |
+
|
181 |
+
def vrarch_separator(vrarch_audio, vrarch_model, vrarch_output_format, vrarch_window_size, vrarch_agression):
|
182 |
+
files_list = []
|
183 |
+
files_list.clear()
|
184 |
+
directory = "./outputs"
|
185 |
+
random_id = str(random.randint(10000, 99999))
|
186 |
+
pattern = f"{random_id}"
|
187 |
+
os.makedirs("outputs", exist_ok=True)
|
188 |
+
write(f'{random_id}.wav', vrarch_audio[0], vrarch_audio[1])
|
189 |
+
prompt = f"audio-separator {random_id}.wav --model_filename {vrarch_model} --output_dir=./outputs --output_format={vrarch_output_format} --normalization=0.9 --vr_window_size={vrarch_window_size} --vr_aggression={vrarch_agression}"
|
190 |
+
|
191 |
+
os.system(prompt)
|
192 |
+
|
193 |
+
for file in os.listdir(directory):
|
194 |
+
if re.search(pattern, file):
|
195 |
+
files_list.append(os.path.join(directory, file))
|
196 |
+
|
197 |
+
stem1_file = files_list[0]
|
198 |
+
stem2_file = files_list[1]
|
199 |
+
|
200 |
+
return stem1_file, stem2_file
|
201 |
+
|
202 |
+
def demucs_separator(demucs_audio, demucs_model, demucs_output_format, demucs_shifts, demucs_overlap):
|
203 |
+
files_list = []
|
204 |
+
files_list.clear()
|
205 |
+
directory = "./outputs"
|
206 |
+
random_id = str(random.randint(10000, 99999))
|
207 |
+
pattern = f"{random_id}"
|
208 |
+
os.makedirs("outputs", exist_ok=True)
|
209 |
+
write(f'{random_id}.wav', demucs_audio[0], demucs_audio[1])
|
210 |
+
prompt = f"audio-separator {random_id}.wav --model_filename {demucs_model} --output_dir=./outputs --output_format={demucs_output_format} --normalization=0.9 --demucs_shifts={demucs_shifts} --demucs_overlap={demucs_overlap}"
|
211 |
+
|
212 |
+
os.system(prompt)
|
213 |
+
|
214 |
+
for file in os.listdir(directory):
|
215 |
+
if re.search(pattern, file):
|
216 |
+
files_list.append(os.path.join(directory, file))
|
217 |
+
|
218 |
+
stem1_file = files_list[0]
|
219 |
+
stem2_file = files_list[1]
|
220 |
+
stem3_file = files_list[2]
|
221 |
+
stem4_file = files_list[3]
|
222 |
+
|
223 |
+
return stem1_file, stem2_file, stem3_file, stem4_file
|
224 |
+
|
225 |
+
with gr.Blocks(title="🎵 UVR5 UI 🎵") as app:
|
226 |
+
gr.Markdown("<h1> 🎵 UVR5 UI 🎵 </h1>")
|
227 |
+
with gr.Tabs():
|
228 |
+
with gr.TabItem("BS/Mel Roformer"):
|
229 |
+
with gr.Row():
|
230 |
+
roformer_model = gr.Dropdown(
|
231 |
+
label = "Select the Model",
|
232 |
+
choices=list(roformer_models.keys()),
|
233 |
+
interactive = True
|
234 |
+
)
|
235 |
+
roformer_output_format = gr.Dropdown(
|
236 |
+
label = "Select the Output Format",
|
237 |
+
choices = output_format,
|
238 |
+
interactive = True
|
239 |
+
)
|
240 |
+
with gr.Row():
|
241 |
+
roformer_overlap = gr.Slider(
|
242 |
+
minimum = 2,
|
243 |
+
maximum = 4,
|
244 |
+
step = 1,
|
245 |
+
label = "Overlap",
|
246 |
+
info = "Amount of overlap between prediction windows.",
|
247 |
+
value = 4,
|
248 |
+
interactive = True
|
249 |
+
)
|
250 |
+
with gr.Row():
|
251 |
+
roformer_audio = gr.Audio(
|
252 |
+
label = "Input Audio",
|
253 |
+
type = "numpy",
|
254 |
+
interactive = True
|
255 |
+
)
|
256 |
+
with gr.Row():
|
257 |
+
roformer_button = gr.Button("Separate!", variant = "primary")
|
258 |
+
with gr.Row():
|
259 |
+
roformer_stem1 = gr.Audio(
|
260 |
+
show_download_button = True,
|
261 |
+
interactive = False,
|
262 |
+
label = "Stem 1",
|
263 |
+
type = "filepath"
|
264 |
+
)
|
265 |
+
roformer_stem2 = gr.Audio(
|
266 |
+
show_download_button = True,
|
267 |
+
interactive = False,
|
268 |
+
label = "Stem 2",
|
269 |
+
type = "filepath"
|
270 |
+
)
|
271 |
+
|
272 |
+
roformer_button.click(roformer_separator, [roformer_audio, roformer_model, roformer_output_format, roformer_overlap], [roformer_stem1, roformer_stem2])
|
273 |
+
|
274 |
+
with gr.TabItem("MDX23C"):
|
275 |
+
with gr.Row():
|
276 |
+
mdx23c_model = gr.Dropdown(
|
277 |
+
label = "Select the Model",
|
278 |
+
choices = mdx23c_models,
|
279 |
+
interactive = True
|
280 |
+
)
|
281 |
+
mdx23c_output_format = gr.Dropdown(
|
282 |
+
label = "Select the Output Format",
|
283 |
+
choices = output_format,
|
284 |
+
interactive = True
|
285 |
+
)
|
286 |
+
with gr.Row():
|
287 |
+
mdx23c_segment_size = gr.Slider(
|
288 |
+
minimum = 32,
|
289 |
+
maximum = 4000,
|
290 |
+
step = 32,
|
291 |
+
label = "Segment Size",
|
292 |
+
info = "Larger consumes more resources, but may give better results.",
|
293 |
+
value = 256,
|
294 |
+
interactive = True
|
295 |
+
)
|
296 |
+
mdx23c_overlap = gr.Slider(
|
297 |
+
minimum = 2,
|
298 |
+
maximum = 50,
|
299 |
+
step = 1,
|
300 |
+
label = "Overlap",
|
301 |
+
info = "Amount of overlap between prediction windows.",
|
302 |
+
value = 8,
|
303 |
+
interactive = True
|
304 |
+
)
|
305 |
+
with gr.Row():
|
306 |
+
mdx23c_audio = gr.Audio(
|
307 |
+
label = "Input Audio",
|
308 |
+
type = "numpy",
|
309 |
+
interactive = True
|
310 |
+
)
|
311 |
+
with gr.Row():
|
312 |
+
mdx23c_button = gr.Button("Separate!", variant = "primary")
|
313 |
+
with gr.Row():
|
314 |
+
mdx23c_stem1 = gr.Audio(
|
315 |
+
show_download_button = True,
|
316 |
+
interactive = False,
|
317 |
+
label = "Stem 1",
|
318 |
+
type = "filepath"
|
319 |
+
)
|
320 |
+
mdx23c_stem2 = gr.Audio(
|
321 |
+
show_download_button = True,
|
322 |
+
interactive = False,
|
323 |
+
label = "Stem 2",
|
324 |
+
type = "filepath"
|
325 |
+
)
|
326 |
+
|
327 |
+
mdx23c_button.click(mdxc_separator, [mdx23c_audio, mdx23c_model, mdx23c_output_format, mdx23c_segment_size, mdx23c_overlap], [mdx23c_stem1, mdx23c_stem2])
|
328 |
+
|
329 |
+
with gr.TabItem("MDX-NET"):
|
330 |
+
with gr.Row():
|
331 |
+
mdxnet_model = gr.Dropdown(
|
332 |
+
label = "Select the Model",
|
333 |
+
choices = mdxnet_models,
|
334 |
+
interactive = True
|
335 |
+
)
|
336 |
+
mdxnet_output_format = gr.Dropdown(
|
337 |
+
label = "Select the Output Format",
|
338 |
+
choices = output_format,
|
339 |
+
interactive = True
|
340 |
+
)
|
341 |
+
with gr.Row():
|
342 |
+
mdxnet_segment_size = gr.Slider(
|
343 |
+
minimum = 32,
|
344 |
+
maximum = 4000,
|
345 |
+
step = 32,
|
346 |
+
label = "Segment Size",
|
347 |
+
info = "Larger consumes more resources, but may give better results.",
|
348 |
+
value = 256,
|
349 |
+
interactive = True
|
350 |
+
)
|
351 |
+
mdxnet_overlap = gr.Dropdown(
|
352 |
+
label = "Overlap",
|
353 |
+
choices = mdxnet_overlap_values,
|
354 |
+
value = mdxnet_overlap_values[0],
|
355 |
+
interactive = True
|
356 |
+
)
|
357 |
+
mdxnet_denoise = gr.Checkbox(
|
358 |
+
label = "Denoise",
|
359 |
+
info = "Enable denoising during separation.",
|
360 |
+
value = True,
|
361 |
+
interactive = True
|
362 |
+
)
|
363 |
+
with gr.Row():
|
364 |
+
mdxnet_audio = gr.Audio(
|
365 |
+
label = "Input Audio",
|
366 |
+
type = "numpy",
|
367 |
+
interactive = True
|
368 |
+
)
|
369 |
+
with gr.Row():
|
370 |
+
mdxnet_button = gr.Button("Separate", variant = "primary")
|
371 |
+
with gr.Row():
|
372 |
+
mdxnet_stem1 = gr.Audio(
|
373 |
+
show_download_button = True,
|
374 |
+
interactive = False,
|
375 |
+
label = "Stem 1",
|
376 |
+
type = "filepath"
|
377 |
+
)
|
378 |
+
mdxnet_stem2 = gr.Audio(
|
379 |
+
show_download_button = True,
|
380 |
+
interactive = False,
|
381 |
+
label = "Stem 2",
|
382 |
+
type = "filepath"
|
383 |
+
)
|
384 |
+
|
385 |
+
mdxnet_button.click(mdxnet_separator, [mdxnet_audio, mdxnet_model, mdxnet_output_format, mdxnet_segment_size, mdxnet_overlap, mdxnet_denoise], [mdxnet_stem1, mdxnet_stem2])
|
386 |
+
|
387 |
+
with gr.TabItem("VR ARCH"):
|
388 |
+
with gr.Row():
|
389 |
+
vrarch_model = gr.Dropdown(
|
390 |
+
label = "Select the Model",
|
391 |
+
choices = vrarch_models,
|
392 |
+
interactive = True
|
393 |
+
)
|
394 |
+
vrarch_output_format = gr.Dropdown(
|
395 |
+
label = "Select the Output Format",
|
396 |
+
choices = output_format,
|
397 |
+
interactive = True
|
398 |
+
)
|
399 |
+
with gr.Row():
|
400 |
+
vrarch_window_size = gr.Dropdown(
|
401 |
+
label = "Window Size",
|
402 |
+
choices = vrarch_window_size_values,
|
403 |
+
value = vrarch_window_size_values[0],
|
404 |
+
interactive = True
|
405 |
+
)
|
406 |
+
vrarch_agression = gr.Slider(
|
407 |
+
minimum = 1,
|
408 |
+
maximum = 50,
|
409 |
+
step = 1,
|
410 |
+
label = "Agression",
|
411 |
+
info = "Intensity of primary stem extraction.",
|
412 |
+
value = 5,
|
413 |
+
interactive = True
|
414 |
+
)
|
415 |
+
vrarch_tta = gr.Checkbox(
|
416 |
+
label = "TTA",
|
417 |
+
info = "Enable Test-Time-Augmentation; slow but improves quality.",
|
418 |
+
value = True,
|
419 |
+
visible = True,
|
420 |
+
interactive = True,
|
421 |
+
)
|
422 |
+
vrarch_high_end_process = gr.Checkbox(
|
423 |
+
label = "High End Process",
|
424 |
+
info = "Mirror the missing frequency range of the output.",
|
425 |
+
value = False,
|
426 |
+
visible = True,
|
427 |
+
interactive = True,
|
428 |
+
)
|
429 |
+
with gr.Row():
|
430 |
+
vrarch_audio = gr.Audio(
|
431 |
+
label = "Input Audio",
|
432 |
+
type = "numpy",
|
433 |
+
interactive = True
|
434 |
+
)
|
435 |
+
with gr.Row():
|
436 |
+
vrarch_button = gr.Button("Separate!", variant = "primary")
|
437 |
+
with gr.Row():
|
438 |
+
vrarch_stem1 = gr.Audio(
|
439 |
+
show_download_button = True,
|
440 |
+
interactive = False,
|
441 |
+
type = "filepath",
|
442 |
+
label = "Stem 1"
|
443 |
+
)
|
444 |
+
vrarch_stem2 = gr.Audio(
|
445 |
+
show_download_button = True,
|
446 |
+
interactive = False,
|
447 |
+
type = "filepath",
|
448 |
+
label = "Stem 2"
|
449 |
+
)
|
450 |
+
|
451 |
+
vrarch_button.click(vrarch_separator, [vrarch_audio, vrarch_model, vrarch_output_format, vrarch_window_size, vrarch_agression], [vrarch_stem1, vrarch_stem2])
|
452 |
+
|
453 |
+
with gr.TabItem("Demucs"):
|
454 |
+
with gr.Row():
|
455 |
+
demucs_model = gr.Dropdown(
|
456 |
+
label = "Select the Model",
|
457 |
+
choices = demucs_models,
|
458 |
+
interactive = True
|
459 |
+
)
|
460 |
+
demucs_output_format = gr.Dropdown(
|
461 |
+
label = "Select the Output Format",
|
462 |
+
choices = output_format,
|
463 |
+
interactive = True
|
464 |
+
)
|
465 |
+
with gr.Row():
|
466 |
+
demucs_shifts = gr.Slider(
|
467 |
+
minimum = 1,
|
468 |
+
maximum = 20,
|
469 |
+
step = 1,
|
470 |
+
label = "Shifts",
|
471 |
+
info = "Number of predictions with random shifts, higher = slower but better quality.",
|
472 |
+
value = 2,
|
473 |
+
interactive = True
|
474 |
+
)
|
475 |
+
demucs_overlap = gr.Slider(
|
476 |
+
minimum = 0.001,
|
477 |
+
maximum = 0.999,
|
478 |
+
step = 0.001,
|
479 |
+
label = "Overlap",
|
480 |
+
info = "Amount of overlap between prediction windows.",
|
481 |
+
value = 0.025,
|
482 |
+
interactive = True
|
483 |
+
)
|
484 |
+
with gr.Row():
|
485 |
+
demucs_audio = gr.Audio(
|
486 |
+
label = "Input Audio",
|
487 |
+
type = "numpy",
|
488 |
+
interactive = True
|
489 |
+
)
|
490 |
+
with gr.Row():
|
491 |
+
demucs_button = gr.Button("Separate!", variant = "primary")
|
492 |
+
with gr.Row():
|
493 |
+
demucs_stem1 = gr.Audio(
|
494 |
+
show_download_button = True,
|
495 |
+
interactive = False,
|
496 |
+
type = "filepath",
|
497 |
+
label = "Stem 1"
|
498 |
+
)
|
499 |
+
demucs_stem2 = gr.Audio(
|
500 |
+
show_download_button = True,
|
501 |
+
interactive = False,
|
502 |
+
type = "filepath",
|
503 |
+
label = "Stem 2"
|
504 |
+
)
|
505 |
+
with gr.Row():
|
506 |
+
demucs_stem3 = gr.Audio(
|
507 |
+
show_download_button = True,
|
508 |
+
interactive = False,
|
509 |
+
type = "filepath",
|
510 |
+
label = "Stem 3"
|
511 |
+
)
|
512 |
+
demucs_stem4 = gr.Audio(
|
513 |
+
show_download_button = True,
|
514 |
+
interactive = False,
|
515 |
+
type = "filepath",
|
516 |
+
label = "Stem 4"
|
517 |
+
)
|
518 |
+
|
519 |
+
demucs_button.click(vrarch_separator, [demucs_audio, demucs_model, demucs_output_format, demucs_shifts, demucs_overlap], [demucs_stem1, demucs_stem2, demucs_stem3, demucs_stem4])
|
520 |
+
|
|
|
|
|
|
|
|
|
|
|
521 |
app.launch()
|