Surn commited on
Commit
d758673
1 Parent(s): 1028cad

UI Update - Add Mic Input

Browse files
Files changed (2) hide show
  1. app.py +32 -15
  2. web-ui.bat +1 -3
app.py CHANGED
@@ -38,6 +38,11 @@ def interrupt():
38
  global INTERRUPTING
39
  INTERRUPTING = True
40
 
 
 
 
 
 
41
 
42
  def make_waveform(*args, **kwargs):
43
  # Further remove some warnings.
@@ -264,6 +269,9 @@ def ui(**kwargs):
264
  css="""
265
  #col-container {max-width: 910px; margin-left: auto; margin-right: auto;}
266
  a {text-decoration-line: underline; font-weight: 600;}
 
 
 
267
  """
268
  with gr.Blocks(title="UnlimitedMusicGen", css=css) as demo:
269
  gr.Markdown(
@@ -288,18 +296,21 @@ def ui(**kwargs):
288
  with gr.Row():
289
  with gr.Column():
290
  with gr.Row():
291
- with gr.Column():
292
- text = gr.Text(label="Prompt Text", interactive=True, value="4/4 100bpm 320kbps 48khz, Industrial/Electronic Soundtrack, Dark, Intense, Sci-Fi")
293
  duration = gr.Slider(minimum=1, maximum=720, value=10, label="Duration", interactive=True)
294
- model = gr.Radio(["melody", "medium", "small", "large"], label="Model", value="melody", interactive=True)
295
- with gr.Column():
296
- melody_filepath = gr.Audio(source="upload", type="filepath", label="Melody Condition (optional)", interactive=True)
297
- prompt_index = gr.Slider(label="Melody Condition Sample Segment", minimum=-1, maximum=MAX_PROMPT_INDEX, step=1, value=0, interactive=True, info="Which 30 second segment to condition with, - 1 condition each segment independantly")
298
- harmony_only = gr.Radio(label="Harmony Only",choices=["No", "Yes"], value="No", interactive=True, info="Remove Drums?")
299
  with gr.Row():
300
- submit = gr.Button("Submit")
301
  # Adapted from https://github.com/rkfg/audiocraft/blob/long/app.py, MIT license.
302
- _ = gr.Button("Interrupt").click(fn=interrupt, queue=False)
 
 
 
 
 
 
 
303
  with gr.Accordion("Video", open=False):
304
  with gr.Row():
305
  background= gr.Image(value="./assets/background.png", source="upload", label="Background", shape=(768,512), type="filepath", interactive=True)
@@ -328,6 +339,7 @@ def ui(**kwargs):
328
  wave_file = gr.File(label=".wav file", elem_id="output_wavefile", interactive=True)
329
  seed_used = gr.Number(label='Seed used', value=-1, interactive=False)
330
 
 
331
  melody_filepath.change(load_melody_filepath, inputs=[melody_filepath, title], outputs=[title, prompt_index , model], api_name="melody_filepath_change")
332
  reuse_seed.click(fn=lambda x: x, inputs=[seed_used], outputs=[seed], queue=False, api_name="reuse_seed")
333
  submit.click(predict, inputs=[model, text,melody_filepath, duration, dimension, topk, topp, temperature, cfg_coef, background, title, settings_font, settings_font_color, seed, overlap, prompt_index, include_title, include_settings, harmony_only], outputs=[output, wave_file, seed_used], api_name="submit")
@@ -337,30 +349,35 @@ def ui(**kwargs):
337
  [
338
  "4/4 120bpm 320kbps 48khz, An 80s driving pop song with heavy drums and synth pads in the background",
339
  "./assets/bach.mp3",
340
- "melody"
 
341
  ],
342
  [
343
  "4/4 120bpm 320kbps 48khz, A cheerful country song with acoustic guitars",
344
  "./assets/bolero_ravel.mp3",
345
- "melody"
 
346
  ],
347
  [
348
  "4/4 120bpm 320kbps 48khz, 90s rock song with electric guitar and heavy drums",
349
  None,
350
- "medium"
 
351
  ],
352
  [
353
  "4/4 120bpm 320kbps 48khz, a light and cheerly EDM track, with syncopated drums, aery pads, and strong emotions",
354
  "./assets/bach.mp3",
355
- "melody"
 
356
  ],
357
  [
358
  "4/4 320kbps 48khz, lofi slow bpm electro chill with organic samples",
359
  None,
360
- "medium",
 
361
  ],
362
  ],
363
- inputs=[text, melody_filepath, model],
364
  outputs=[output]
365
  )
366
 
 
38
  global INTERRUPTING
39
  INTERRUPTING = True
40
 
41
+ def toggle_audio_src(choice):
42
+ if choice == "mic":
43
+ return gr.update(source="microphone", value=None, label="Microphone")
44
+ else:
45
+ return gr.update(source="upload", value=None, label="File")
46
 
47
  def make_waveform(*args, **kwargs):
48
  # Further remove some warnings.
 
269
  css="""
270
  #col-container {max-width: 910px; margin-left: auto; margin-right: auto;}
271
  a {text-decoration-line: underline; font-weight: 600;}
272
+ #btn-generate {background-image:linear-gradient(to right bottom, rgb(157, 255, 157), rgb(229, 255, 235));}
273
+ #btn-generate:hover {background-image:linear-gradient(to right bottom, rgb(229, 255, 229), rgb(255, 255, 255));}
274
+ #btn-generate:active {background-image:linear-gradient(to right bottom, rgb(229, 255, 235), rgb(157, 255, 157));}
275
  """
276
  with gr.Blocks(title="UnlimitedMusicGen", css=css) as demo:
277
  gr.Markdown(
 
296
  with gr.Row():
297
  with gr.Column():
298
  with gr.Row():
299
+ text = gr.Text(label="Describe your music", interactive=True, value="4/4 100bpm 320kbps 48khz, Industrial/Electronic Soundtrack, Dark, Intense, Sci-Fi")
300
+ with gr.Column():
301
  duration = gr.Slider(minimum=1, maximum=720, value=10, label="Duration", interactive=True)
302
+ model = gr.Radio(["melody", "medium", "small", "large"], label="AI Model", value="melody", interactive=True)
 
 
 
 
303
  with gr.Row():
304
+ submit = gr.Button("Generate", elem_id="btn-generate")
305
  # Adapted from https://github.com/rkfg/audiocraft/blob/long/app.py, MIT license.
306
+ _ = gr.Button("Interrupt", elem_id="btn-interrupt").click(fn=interrupt, queue=False)
307
+ with gr.Row():
308
+ with gr.Column():
309
+ melody_filepath = gr.Audio(source="upload", type="filepath", label="Melody Condition (optional)", interactive=True, elem_id="melody-input")
310
+ harmony_only = gr.Radio(label="Use Harmony Only",choices=["No", "Yes"], value="No", interactive=True, info="Remove Drums?")
311
+ with gr.Column():
312
+ radio = gr.Radio(["file", "mic"], value="file", label="Condition on a melody (optional) File or Mic")
313
+ prompt_index = gr.Slider(label="Melody Condition Sample Segment", minimum=-1, maximum=MAX_PROMPT_INDEX, step=1, value=0, interactive=True, info="Which 30 second segment to condition with, - 1 condition each segment independantly")
314
  with gr.Accordion("Video", open=False):
315
  with gr.Row():
316
  background= gr.Image(value="./assets/background.png", source="upload", label="Background", shape=(768,512), type="filepath", interactive=True)
 
339
  wave_file = gr.File(label=".wav file", elem_id="output_wavefile", interactive=True)
340
  seed_used = gr.Number(label='Seed used', value=-1, interactive=False)
341
 
342
+ radio.change(toggle_audio_src, radio, [melody_filepath], queue=False, show_progress=False)
343
  melody_filepath.change(load_melody_filepath, inputs=[melody_filepath, title], outputs=[title, prompt_index , model], api_name="melody_filepath_change")
344
  reuse_seed.click(fn=lambda x: x, inputs=[seed_used], outputs=[seed], queue=False, api_name="reuse_seed")
345
  submit.click(predict, inputs=[model, text,melody_filepath, duration, dimension, topk, topp, temperature, cfg_coef, background, title, settings_font, settings_font_color, seed, overlap, prompt_index, include_title, include_settings, harmony_only], outputs=[output, wave_file, seed_used], api_name="submit")
 
349
  [
350
  "4/4 120bpm 320kbps 48khz, An 80s driving pop song with heavy drums and synth pads in the background",
351
  "./assets/bach.mp3",
352
+ "melody",
353
+ "80s Pop Synth"
354
  ],
355
  [
356
  "4/4 120bpm 320kbps 48khz, A cheerful country song with acoustic guitars",
357
  "./assets/bolero_ravel.mp3",
358
+ "melody",
359
+ "Country Guitar"
360
  ],
361
  [
362
  "4/4 120bpm 320kbps 48khz, 90s rock song with electric guitar and heavy drums",
363
  None,
364
+ "medium",
365
+ "90s Rock Guitar"
366
  ],
367
  [
368
  "4/4 120bpm 320kbps 48khz, a light and cheerly EDM track, with syncopated drums, aery pads, and strong emotions",
369
  "./assets/bach.mp3",
370
+ "melody",
371
+ "EDM my Bach"
372
  ],
373
  [
374
  "4/4 320kbps 48khz, lofi slow bpm electro chill with organic samples",
375
  None,
376
+ "medium",
377
+ "LoFi Chill"
378
  ],
379
  ],
380
+ inputs=[text, melody_filepath, model, title],
381
  outputs=[output]
382
  )
383
 
web-ui.bat CHANGED
@@ -1,3 +1 @@
1
- py -m app
2
-
3
- pause
 
1
+ py -m app