Spaces:
Runtime error
Runtime error
Update gui.py
Browse files
gui.py
CHANGED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# gui.py
|
| 2 |
+
|
| 3 |
+
import gradio as gr
|
| 4 |
+
from downloader import downloader_conf, url_media_conf, url_button_conf, show_components_downloader
|
| 5 |
+
from pipeline import sound_separate
|
| 6 |
+
|
| 7 |
+
# Constants
|
| 8 |
+
TITLE = "<center><strong><font size='7'>Audio🔹separator</font></strong></center>"
|
| 9 |
+
DESCRIPTION = "This demo uses the MDX-Net models for vocal and background sound separation."
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
def get_gui(theme):
|
| 13 |
+
with gr.Blocks(theme=theme) as app:
|
| 14 |
+
gr.Markdown(TITLE)
|
| 15 |
+
gr.Markdown(DESCRIPTION)
|
| 16 |
+
|
| 17 |
+
# Downloader UI
|
| 18 |
+
downloader_gui = downloader_conf()
|
| 19 |
+
with gr.Row():
|
| 20 |
+
with gr.Column(scale=2):
|
| 21 |
+
url_media_gui = url_media_conf()
|
| 22 |
+
with gr.Column(scale=1):
|
| 23 |
+
url_button_gui = url_button_conf()
|
| 24 |
+
|
| 25 |
+
downloader_gui.change(
|
| 26 |
+
show_components_downloader,
|
| 27 |
+
[downloader_gui],
|
| 28 |
+
[url_media_gui, url_button_gui]
|
| 29 |
+
)
|
| 30 |
+
|
| 31 |
+
# Audio file upload input
|
| 32 |
+
aud = gr.File(label="Audio file", type="filepath")
|
| 33 |
+
|
| 34 |
+
url_button_gui.click(
|
| 35 |
+
fn=audio_downloader,
|
| 36 |
+
inputs=[url_media_gui],
|
| 37 |
+
outputs=[aud]
|
| 38 |
+
)
|
| 39 |
+
|
| 40 |
+
# Stem choice
|
| 41 |
+
stem_gui = gr.Radio(choices=["vocal", "background"], value="vocal", label="Stem")
|
| 42 |
+
|
| 43 |
+
# Options for effects
|
| 44 |
+
main_gui = gr.Checkbox(False, label="Main")
|
| 45 |
+
dereverb_gui = gr.Checkbox(False, label="Dereverb", visible=True)
|
| 46 |
+
vocal_effects_gui = gr.Checkbox(False, label="Vocal Effects", visible=True)
|
| 47 |
+
background_effects_gui = gr.Checkbox(False, label="Background Effects", visible=False)
|
| 48 |
+
|
| 49 |
+
stem_gui.change(
|
| 50 |
+
lambda stem: (
|
| 51 |
+
gr.update(visible=stem == "vocal"),
|
| 52 |
+
gr.update(visible=stem == "vocal"),
|
| 53 |
+
gr.update(visible=stem == "vocal"),
|
| 54 |
+
gr.update(visible=stem == "background"),
|
| 55 |
+
),
|
| 56 |
+
[stem_gui],
|
| 57 |
+
[main_gui, dereverb_gui, vocal_effects_gui, background_effects_gui]
|
| 58 |
+
)
|
| 59 |
+
|
| 60 |
+
# Basic trigger
|
| 61 |
+
button_base = gr.Button("Inference", variant="primary")
|
| 62 |
+
output_base = gr.File(label="Result", file_count="multiple", interactive=False)
|
| 63 |
+
|
| 64 |
+
button_base.click(
|
| 65 |
+
fn=sound_separate,
|
| 66 |
+
inputs=[
|
| 67 |
+
aud, stem_gui, main_gui, dereverb_gui,
|
| 68 |
+
vocal_effects_gui, background_effects_gui
|
| 69 |
+
],
|
| 70 |
+
outputs=[output_base]
|
| 71 |
+
)
|
| 72 |
+
|
| 73 |
+
return app
|