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8 |
+
label="URL-to-Audio",
|
9 |
+
# info="",
|
10 |
+
container=False,
|
11 |
+
)
|
12 |
+
|
13 |
+
|
14 |
+
def url_media_conf():
|
15 |
+
return gr.Textbox(
|
16 |
+
value="",
|
17 |
+
label="Enter URL",
|
18 |
+
placeholder="www.youtube.com/watch?v=g_9rPvbENUw",
|
19 |
+
visible=False,
|
20 |
+
lines=1,
|
21 |
+
)
|
22 |
+
|
23 |
+
|
24 |
+
def url_button_conf():
|
25 |
+
return gr.Button(
|
26 |
+
"Go",
|
27 |
+
variant="secondary",
|
28 |
+
visible=False,
|
29 |
+
)
|
30 |
+
|
31 |
+
|
32 |
+
def show_components_downloader(value_active):
|
33 |
+
return gr.update(
|
34 |
+
visible=value_active
|
35 |
+
), gr.update(
|
36 |
+
visible=value_active
|
37 |
+
)
|
38 |
+
|
39 |
+
|
40 |
+
def audio_conf():
|
41 |
+
return gr.File(
|
42 |
+
label="Audio file",
|
43 |
+
# file_count="multiple",
|
44 |
+
type="filepath",
|
45 |
+
container=True,
|
46 |
+
)
|
47 |
+
|
48 |
+
|
49 |
+
def stem_conf():
|
50 |
+
return gr.Radio(
|
51 |
+
choices=["vocal", "background"],
|
52 |
+
value="vocal",
|
53 |
+
label="Stem",
|
54 |
+
# info="",
|
55 |
+
)
|
56 |
+
|
57 |
+
|
58 |
+
def main_conf():
|
59 |
+
return gr.Checkbox(
|
60 |
+
False,
|
61 |
+
label="Main",
|
62 |
+
# info="",
|
63 |
+
)
|
64 |
+
|
65 |
+
|
66 |
+
def dereverb_conf():
|
67 |
+
return gr.Checkbox(
|
68 |
+
False,
|
69 |
+
label="Dereverb",
|
70 |
+
# info="",
|
71 |
+
visible=True,
|
72 |
+
)
|
73 |
+
|
74 |
+
|
75 |
+
def vocal_effects_conf():
|
76 |
+
return gr.Checkbox(
|
77 |
+
False,
|
78 |
+
label="Vocal Effects",
|
79 |
+
# info="",
|
80 |
+
visible=True,
|
81 |
+
)
|
82 |
+
|
83 |
+
|
84 |
+
def background_effects_conf():
|
85 |
+
return gr.Checkbox(
|
86 |
+
False,
|
87 |
+
label="Background Effects",
|
88 |
+
# info="",
|
89 |
+
visible=False,
|
90 |
+
)
|
91 |
+
|
92 |
+
|
93 |
+
def vocal_reverb_room_size_conf():
|
94 |
+
return gr.Number(
|
95 |
+
0.15,
|
96 |
+
label="Vocal Reverb Room Size",
|
97 |
+
minimum=0.0,
|
98 |
+
maximum=1.0,
|
99 |
+
step=0.05,
|
100 |
+
visible=True,
|
101 |
+
)
|
102 |
+
|
103 |
+
|
104 |
+
def vocal_reverb_damping_conf():
|
105 |
+
return gr.Number(
|
106 |
+
0.7,
|
107 |
+
label="Vocal Reverb Damping",
|
108 |
+
minimum=0.0,
|
109 |
+
maximum=1.0,
|
110 |
+
step=0.01,
|
111 |
+
visible=True,
|
112 |
+
)
|
113 |
+
|
114 |
+
|
115 |
+
def vocal_reverb_wet_level_conf():
|
116 |
+
return gr.Number(
|
117 |
+
0.2,
|
118 |
+
label="Vocal Reverb Wet Level",
|
119 |
+
minimum=0.0,
|
120 |
+
maximum=1.0,
|
121 |
+
step=0.05,
|
122 |
+
visible=True,
|
123 |
+
)
|
124 |
+
|
125 |
+
|
126 |
+
def vocal_reverb_dryness_level_conf():
|
127 |
+
return gr.Number(
|
128 |
+
0.8,
|
129 |
+
label="Vocal Reverb Dryness Level",
|
130 |
+
minimum=0.0,
|
131 |
+
maximum=1.0,
|
132 |
+
step=0.05,
|
133 |
+
visible=True,
|
134 |
+
)
|
135 |
+
|
136 |
+
|
137 |
+
def vocal_delay_seconds_conf():
|
138 |
+
return gr.Number(
|
139 |
+
0.,
|
140 |
+
label="Vocal Delay Seconds",
|
141 |
+
minimum=0.0,
|
142 |
+
maximum=1.0,
|
143 |
+
step=0.01,
|
144 |
+
visible=True,
|
145 |
+
)
|
146 |
+
|
147 |
+
|
148 |
+
def vocal_delay_mix_conf():
|
149 |
+
return gr.Number(
|
150 |
+
0.,
|
151 |
+
label="Vocal Delay Mix",
|
152 |
+
minimum=0.0,
|
153 |
+
maximum=1.0,
|
154 |
+
step=0.01,
|
155 |
+
visible=True,
|
156 |
+
)
|
157 |
+
|
158 |
+
|
159 |
+
def vocal_compressor_threshold_db_conf():
|
160 |
+
return gr.Number(
|
161 |
+
-15,
|
162 |
+
label="Vocal Compressor Threshold (dB)",
|
163 |
+
minimum=-60,
|
164 |
+
maximum=0,
|
165 |
+
step=1,
|
166 |
+
visible=True,
|
167 |
+
)
|
168 |
+
|
169 |
+
|
170 |
+
def vocal_compressor_ratio_conf():
|
171 |
+
return gr.Number(
|
172 |
+
4.,
|
173 |
+
label="Vocal Compressor Ratio",
|
174 |
+
minimum=0,
|
175 |
+
maximum=20,
|
176 |
+
step=0.1,
|
177 |
+
visible=True,
|
178 |
+
)
|
179 |
+
|
180 |
+
|
181 |
+
def vocal_compressor_attack_ms_conf():
|
182 |
+
return gr.Number(
|
183 |
+
1.0,
|
184 |
+
label="Vocal Compressor Attack (ms)",
|
185 |
+
minimum=0,
|
186 |
+
maximum=1000,
|
187 |
+
step=1,
|
188 |
+
visible=True,
|
189 |
+
)
|
190 |
+
|
191 |
+
|
192 |
+
def vocal_compressor_release_ms_conf():
|
193 |
+
return gr.Number(
|
194 |
+
100,
|
195 |
+
label="Vocal Compressor Release (ms)",
|
196 |
+
minimum=0,
|
197 |
+
maximum=3000,
|
198 |
+
step=1,
|
199 |
+
visible=True,
|
200 |
+
)
|
201 |
+
|
202 |
+
|
203 |
+
def vocal_gain_db_conf():
|
204 |
+
return gr.Number(
|
205 |
+
0,
|
206 |
+
label="Vocal Gain (dB)",
|
207 |
+
minimum=-40,
|
208 |
+
maximum=40,
|
209 |
+
step=1,
|
210 |
+
visible=True,
|
211 |
+
)
|
212 |
+
|
213 |
+
|
214 |
+
def background_highpass_freq_conf():
|
215 |
+
return gr.Number(
|
216 |
+
120,
|
217 |
+
label="Background Highpass Frequency (Hz)",
|
218 |
+
minimum=0,
|
219 |
+
maximum=1000,
|
220 |
+
step=1,
|
221 |
+
visible=True,
|
222 |
+
)
|
223 |
+
|
224 |
+
|
225 |
+
def background_lowpass_freq_conf():
|
226 |
+
return gr.Number(
|
227 |
+
11000,
|
228 |
+
label="Background Lowpass Frequency (Hz)",
|
229 |
+
minimum=0,
|
230 |
+
maximum=20000,
|
231 |
+
step=1,
|
232 |
+
visible=True,
|
233 |
+
)
|
234 |
+
|
235 |
+
|
236 |
+
def background_reverb_room_size_conf():
|
237 |
+
return gr.Number(
|
238 |
+
0.1,
|
239 |
+
label="Background Reverb Room Size",
|
240 |
+
minimum=0.0,
|
241 |
+
maximum=1.0,
|
242 |
+
step=0.1,
|
243 |
+
visible=True,
|
244 |
+
)
|
245 |
+
|
246 |
+
|
247 |
+
def background_reverb_damping_conf():
|
248 |
+
return gr.Number(
|
249 |
+
0.5,
|
250 |
+
label="Background Reverb Damping",
|
251 |
+
minimum=0.0,
|
252 |
+
maximum=1.0,
|
253 |
+
step=0.1,
|
254 |
+
visible=True,
|
255 |
+
)
|
256 |
+
|
257 |
+
|
258 |
+
def background_reverb_wet_level_conf():
|
259 |
+
return gr.Number(
|
260 |
+
0.25,
|
261 |
+
label="Background Reverb Wet Level",
|
262 |
+
minimum=0.0,
|
263 |
+
maximum=1.0,
|
264 |
+
step=0.05,
|
265 |
+
visible=True,
|
266 |
+
)
|
267 |
+
|
268 |
+
|
269 |
+
def background_compressor_threshold_db_conf():
|
270 |
+
return gr.Number(
|
271 |
+
-15,
|
272 |
+
label="Background Compressor Threshold (dB)",
|
273 |
+
minimum=-60,
|
274 |
+
maximum=0,
|
275 |
+
step=1,
|
276 |
+
visible=True,
|
277 |
+
)
|
278 |
+
|
279 |
+
|
280 |
+
def background_compressor_ratio_conf():
|
281 |
+
return gr.Number(
|
282 |
+
4.,
|
283 |
+
label="Background Compressor Ratio",
|
284 |
+
minimum=0,
|
285 |
+
maximum=20,
|
286 |
+
step=0.1,
|
287 |
+
visible=True,
|
288 |
+
)
|
289 |
+
|
290 |
+
|
291 |
+
def background_compressor_attack_ms_conf():
|
292 |
+
return gr.Number(
|
293 |
+
15,
|
294 |
+
label="Background Compressor Attack (ms)",
|
295 |
+
minimum=0,
|
296 |
+
maximum=1000,
|
297 |
+
step=1,
|
298 |
+
visible=True,
|
299 |
+
)
|
300 |
+
|
301 |
+
|
302 |
+
def background_compressor_release_ms_conf():
|
303 |
+
return gr.Number(
|
304 |
+
60,
|
305 |
+
label="Background Compressor Release (ms)",
|
306 |
+
minimum=0,
|
307 |
+
maximum=3000,
|
308 |
+
step=1,
|
309 |
+
visible=True,
|
310 |
+
)
|
311 |
+
|
312 |
+
|
313 |
+
def background_gain_db_conf():
|
314 |
+
return gr.Number(
|
315 |
+
0,
|
316 |
+
label="Background Gain (dB)",
|
317 |
+
minimum=-40,
|
318 |
+
maximum=40,
|
319 |
+
step=1,
|
320 |
+
visible=True,
|
321 |
+
)
|
322 |
+
|
323 |
+
|
324 |
+
def button_conf():
|
325 |
+
return gr.Button(
|
326 |
+
"Inference",
|
327 |
+
variant="primary",
|
328 |
+
)
|
329 |
+
|
330 |
+
|
331 |
+
def output_conf():
|
332 |
+
return gr.File(
|
333 |
+
label="Result",
|
334 |
+
file_count="multiple",
|
335 |
+
interactive=False,
|
336 |
+
)
|
337 |
+
|
338 |
+
|
339 |
+
def show_vocal_components(value_name):
|
340 |
+
|
341 |
+
if value_name == "vocal":
|
342 |
+
return gr.update(visible=True), gr.update(
|
343 |
+
visible=True
|
344 |
+
), gr.update(visible=True), gr.update(
|
345 |
+
visible=False
|
346 |
+
)
|
347 |
+
else:
|
348 |
+
return gr.update(visible=False), gr.update(
|
349 |
+
visible=False
|
350 |
+
), gr.update(visible=False), gr.update(
|
351 |
+
visible=True
|
352 |
+
)
|
353 |
+
|
354 |
+
|
355 |
+
def get_gui(theme):
|
356 |
+
with gr.Blocks(theme="hev832/Applio") as app:
|
357 |
+
gr.Markdown(title)
|
358 |
+
with gr.Accordion("read this", open=False):
|
359 |
+
gr.Markdown(description)
|
360 |
+
|
361 |
+
downloader_gui = downloader_conf()
|
362 |
+
with gr.Row():
|
363 |
+
with gr.Column(scale=2):
|
364 |
+
url_media_gui = url_media_conf()
|
365 |
+
with gr.Column(scale=1):
|
366 |
+
url_button_gui = url_button_conf()
|
367 |
+
|
368 |
+
downloader_gui.change(
|
369 |
+
show_components_downloader,
|
370 |
+
[downloader_gui],
|
371 |
+
[url_media_gui, url_button_gui]
|
372 |
+
)
|
373 |
+
|
374 |
+
aud = audio_conf()
|
375 |
+
|
376 |
+
url_button_gui.click(
|
377 |
+
audio_downloader,
|
378 |
+
[url_media_gui],
|
379 |
+
[aud]
|
380 |
+
)
|
381 |
+
|
382 |
+
with gr.Column():
|
383 |
+
with gr.Row():
|
384 |
+
stem_gui = stem_conf()
|
385 |
+
|
386 |
+
with gr.Column():
|
387 |
+
with gr.Row():
|
388 |
+
main_gui = main_conf()
|
389 |
+
dereverb_gui = dereverb_conf()
|
390 |
+
vocal_effects_gui = vocal_effects_conf()
|
391 |
+
background_effects_gui = background_effects_conf()
|
392 |
+
|
393 |
+
# with gr.Column():
|
394 |
+
with gr.Accordion("Vocal Effects Parameters", open=False): # with gr.Row():
|
395 |
+
# gr.Label("Vocal Effects Parameters")
|
396 |
+
with gr.Row():
|
397 |
+
vocal_reverb_room_size_gui = vocal_reverb_room_size_conf()
|
398 |
+
vocal_reverb_damping_gui = vocal_reverb_damping_conf()
|
399 |
+
vocal_reverb_dryness_gui = vocal_reverb_dryness_level_conf()
|
400 |
+
vocal_reverb_wet_level_gui = vocal_reverb_wet_level_conf()
|
401 |
+
vocal_delay_seconds_gui = vocal_delay_seconds_conf()
|
402 |
+
vocal_delay_mix_gui = vocal_delay_mix_conf()
|
403 |
+
vocal_compressor_threshold_db_gui = vocal_compressor_threshold_db_conf()
|
404 |
+
vocal_compressor_ratio_gui = vocal_compressor_ratio_conf()
|
405 |
+
vocal_compressor_attack_ms_gui = vocal_compressor_attack_ms_conf()
|
406 |
+
vocal_compressor_release_ms_gui = vocal_compressor_release_ms_conf()
|
407 |
+
vocal_gain_db_gui = vocal_gain_db_conf()
|
408 |
+
|
409 |
+
with gr.Accordion("Background Effects Parameters", open=False): # with gr.Row():
|
410 |
+
# gr.Label("Background Effects Parameters")
|
411 |
+
with gr.Row():
|
412 |
+
background_highpass_freq_gui = background_highpass_freq_conf()
|
413 |
+
background_lowpass_freq_gui = background_lowpass_freq_conf()
|
414 |
+
background_reverb_room_size_gui = background_reverb_room_size_conf()
|
415 |
+
background_reverb_damping_gui = background_reverb_damping_conf()
|
416 |
+
background_reverb_wet_level_gui = background_reverb_wet_level_conf()
|
417 |
+
background_compressor_threshold_db_gui = background_compressor_threshold_db_conf()
|
418 |
+
background_compressor_ratio_gui = background_compressor_ratio_conf()
|
419 |
+
background_compressor_attack_ms_gui = background_compressor_attack_ms_conf()
|
420 |
+
background_compressor_release_ms_gui = background_compressor_release_ms_conf()
|
421 |
+
background_gain_db_gui = background_gain_db_conf()
|
422 |
+
|
423 |
+
stem_gui.change(
|
424 |
+
show_vocal_components,
|
425 |
+
[stem_gui],
|
426 |
+
[main_gui, dereverb_gui, vocal_effects_gui, background_effects_gui],
|
427 |
+
)
|
428 |
+
|
429 |
+
button_base = button_conf()
|
430 |
+
output_base = output_conf()
|
431 |
+
|
432 |
+
button_base.click(
|
433 |
+
sound_separate,
|
434 |
+
inputs=[
|
435 |
+
aud,
|
436 |
+
stem_gui,
|
437 |
+
main_gui,
|
438 |
+
dereverb_gui,
|
439 |
+
vocal_effects_gui,
|
440 |
+
background_effects_gui,
|
441 |
+
vocal_reverb_room_size_gui, vocal_reverb_damping_gui, vocal_reverb_dryness_gui, vocal_reverb_wet_level_gui,
|
442 |
+
vocal_delay_seconds_gui, vocal_delay_mix_gui, vocal_compressor_threshold_db_gui, vocal_compressor_ratio_gui,
|
443 |
+
vocal_compressor_attack_ms_gui, vocal_compressor_release_ms_gui, vocal_gain_db_gui,
|
444 |
+
background_highpass_freq_gui, background_lowpass_freq_gui, background_reverb_room_size_gui,
|
445 |
+
background_reverb_damping_gui, background_reverb_wet_level_gui, background_compressor_threshold_db_gui,
|
446 |
+
background_compressor_ratio_gui, background_compressor_attack_ms_gui, background_compressor_release_ms_gui,
|
447 |
+
background_gain_db_gui,
|
448 |
+
],
|
449 |
+
outputs=[output_base],
|
450 |
+
)
|
451 |
+
|
452 |
+
|
453 |
+
|
454 |
+
return app
|
455 |
+
|
456 |
+
|
457 |
+
if __name__ == "__main__":
|
458 |
+
|
459 |
+
for id_model in UVR_MODELS:
|
460 |
+
download_manager(
|
461 |
+
os.path.join(MDX_DOWNLOAD_LINK, id_model), mdxnet_models_dir
|
462 |
+
)
|
463 |
+
|
464 |
+
app = get_gui(theme)
|
465 |
+
|
466 |
+
app.queue(default_concurrency_limit=40)
|
467 |
+
|
468 |
+
app.launch(
|
469 |
+
max_threads=40,
|
470 |
+
share=True,
|
471 |
+
show_error=True,
|
472 |
+
quiet=False,
|
473 |
+
debug=True,
|
474 |
+
)
|