OpenSound commited on
Commit
d041292
1 Parent(s): 3632fdf
Files changed (1) hide show
  1. app.py +25 -0
app.py CHANGED
@@ -176,6 +176,18 @@ def process_audio(test_file):
176
  return audio1, audio2
177
 
178
 
 
 
 
 
 
 
 
 
 
 
 
 
179
  # CSS styling (optional)
180
  css = """
181
  #col-container {
@@ -198,6 +210,12 @@ with gr.Blocks(css=css, theme=gr.themes.Soft()) as demo:
198
  # Input: Upload audio file
199
  with gr.Row():
200
  gt_file_input = gr.Audio(label="Upload Audio to Separate", type="filepath", value="demo/item0_mix.wav")
 
 
 
 
 
 
201
  button = gr.Button("Generate", scale=1)
202
 
203
  # Output Component for edited audio
@@ -205,6 +223,13 @@ with gr.Blocks(css=css, theme=gr.themes.Soft()) as demo:
205
  result1 = gr.Audio(label="Separated Audio 1", type="numpy")
206
  result2 = gr.Audio(label="Separated Audio 2", type="numpy")
207
 
 
 
 
 
 
 
 
208
  # Define the trigger and input-output linking
209
  button.click(
210
  fn=process_audio,
 
176
  return audio1, audio2
177
 
178
 
179
+ # List of demo audio files
180
+ demo_audio_files = [
181
+ ("Demo Audio 1", "demo/item0_mix.wav"),
182
+ ("Demo Audio 2", "demo/item1_mix.wav"),
183
+ ("Demo Audio 3", "demo/item2_mix.wav"),
184
+ ("Demo Audio 4", "demo/item3_mix.wav"),
185
+ ("Demo Audio 5", "demo/item4_mix.wav"),
186
+ ]
187
+
188
+ def update_audio_input(choice):
189
+ return choice
190
+
191
  # CSS styling (optional)
192
  css = """
193
  #col-container {
 
210
  # Input: Upload audio file
211
  with gr.Row():
212
  gt_file_input = gr.Audio(label="Upload Audio to Separate", type="filepath", value="demo/item0_mix.wav")
213
+ # Dropdown for demo audio selection
214
+ demo_selector = gr.Dropdown(
215
+ label="Select Demo Audio",
216
+ choices=[name for name, _ in demo_audio_files],
217
+ value="Demo Audio 1"
218
+ )
219
  button = gr.Button("Generate", scale=1)
220
 
221
  # Output Component for edited audio
 
223
  result1 = gr.Audio(label="Separated Audio 1", type="numpy")
224
  result2 = gr.Audio(label="Separated Audio 2", type="numpy")
225
 
226
+ # Update the audio input with the selected demo audio file
227
+ demo_selector.change(
228
+ fn=lambda choice: next(path for name, path in demo_audio_files if name == choice),
229
+ inputs=demo_selector,
230
+ outputs=gt_file_input
231
+ )
232
+
233
  # Define the trigger and input-output linking
234
  button.click(
235
  fn=process_audio,