owiedotch commited on
Commit
7c43d6c
1 Parent(s): aea3232

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -25
app.py CHANGED
@@ -98,30 +98,34 @@ def inference(audio_file: str, model_name: str, vocals: bool, drums: bool, bass:
98
 
99
  return output_file, separation_log
100
 
101
- # define the gradio interface
102
- iface: gr.Interface = gr.Interface(
103
- fn=inference,
104
- inputs=[
105
- gr.Audio(type="filepath"),
106
- gr.Dropdown(["htdemucs", "htdemucs_ft", "htdemucs_6s", "hdemucs_mmi", "mdx", "mdx_extra", "mdx_q", "mdx_extra_q"], label="model name", value="htdemucs_ft"), # set default value
107
- gr.Checkbox(label="vocals", value=True),
108
- gr.Checkbox(label="drums", value=True),
109
- gr.Checkbox(label="bass", value=True),
110
- gr.Checkbox(label="other", value=True),
111
- gr.Checkbox(label="save as mp3", value=False), # set default value to false
112
- gr.Slider(128, 320, step=32, label="mp3 bitrate", visible=False), # set visible to false initially
113
- ],
114
- outputs=[
115
- gr.Audio(type="filepath"),
116
- gr.Textbox(label="separation log", lines=10),
117
- ],
118
- title="demucs music source separation and mixing",
119
- description="separate vocals, drums, bass, and other instruments from your music using demucs and mix the selected stems.",
120
- )
 
 
 
 
 
 
 
 
121
 
122
- # make mp3 bitrate slider visible only when "save as mp3" is checked
123
- # iface.inputs[-2].change(fn=lambda mp3: gr.update(visible=mp3), inputs=iface.inputs[-2], outputs=iface.inputs[-1])
124
- iface.components[-2].change(fn=lambda mp3: gr.update(visible=mp3), inputs=iface.components[-2], outputs=iface.components[-1])
125
-
126
- # launch the gradio interface
127
  iface.launch()
 
98
 
99
  return output_file, separation_log
100
 
101
+ # Define the Gradio interface
102
+ with gr.Blocks() as iface:
103
+ audio_input = gr.Audio(type="filepath")
104
+ model_dropdown = gr.Dropdown(["htdemucs", "htdemucs_ft", "htdemucs_6s", "hdemucs_mmi", "mdx", "mdx_extra", "mdx_q", "mdx_extra_q"], label="Model Name", value="htdemucs_ft")
105
+ vocals_checkbox = gr.Checkbox(label="Vocals", value=True)
106
+ drums_checkbox = gr.Checkbox(label="Drums", value=True)
107
+ bass_checkbox = gr.Checkbox(label="Bass", value=True)
108
+ other_checkbox = gr.Checkbox(label="Other", value=True)
109
+ mp3_checkbox = gr.Checkbox(label="Save as MP3", value=False)
110
+ mp3_bitrate = gr.Slider(128, 320, step=32, label="MP3 Bitrate", visible=False)
111
+
112
+ output_audio = gr.Audio(type="filepath")
113
+ separation_log = gr.Textbox(label="Separation Log", lines=10)
114
+
115
+ submit_btn = gr.Button("Process")
116
+
117
+ submit_btn.click(
118
+ fn=inference,
119
+ inputs=[audio_input, model_dropdown, vocals_checkbox, drums_checkbox, bass_checkbox, other_checkbox, mp3_checkbox, mp3_bitrate],
120
+ outputs=[output_audio, separation_log]
121
+ )
122
+
123
+ # Make MP3 bitrate slider visible only when "Save as MP3" is checked
124
+ mp3_checkbox.change(
125
+ fn=lambda mp3: gr.update(visible=mp3),
126
+ inputs=mp3_checkbox,
127
+ outputs=mp3_bitrate
128
+ )
129
 
130
+ # Launch the Gradio interface
 
 
 
 
131
  iface.launch()