Fabrice-TIERCELIN commited on
Commit
38a916f
1 Parent(s): 0a1e7c4

Display/hide information

Browse files
Files changed (1) hide show
  1. demos/musicgen_app.py +26 -20
demos/musicgen_app.py CHANGED
@@ -222,8 +222,8 @@ def predict_full(model, model_path, decoder, text, melody, duration, topk, topp,
222
  top_k=topk, top_p=topp, temperature=temperature, cfg_coef=cfg_coef,
223
  gradio_progress=progress)
224
  if USE_DIFFUSION:
225
- return videos[0], wavs[0], videos[1], wavs[1]
226
- return videos[0], wavs[0], None, None
227
 
228
 
229
  def toggle_audio_src(choice):
@@ -240,17 +240,6 @@ def toggle_diffusion(choice):
240
  return [gr.update(visible = False)] * 2
241
 
242
 
243
- def toggle_hint(choice):
244
- if choice == "MultiBand_Diffusion":
245
- return [gr.update(visible=True)] * 2
246
- else:
247
- return [gr.update(visible=False)] * 2
248
-
249
-
250
- def toggle_output_hint(isVisible):
251
- return [gr.update(visible = isVisible)]
252
-
253
-
254
  def ui_full(launch_kwargs):
255
  with gr.Blocks() as interface:
256
  gr.Markdown(
@@ -307,17 +296,34 @@ def ui_full(launch_kwargs):
307
  # Adapted from https://github.com/rkfg/audiocraft/blob/long/app.py, MIT license.
308
  _ = gr.Button("Abort all", variant="stop").click(fn=interrupt, queue = False)
309
  with gr.Column():
310
- output_hint = gr.Label("To download the output, right-click and click on Save as...", label = "To download the output, right-click and click on Save as...")
311
  output = gr.Video(label="Generated Music")
312
  audio_output = gr.Audio(label="Generated Music (wav)", type='filepath', autoplay = True, show_download_button = True)
 
313
  diffusion_output = gr.Video(label="MultiBand Diffusion Decoder")
314
  audio_diffusion = gr.Audio(label="MultiBand Diffusion Decoder (wav)", type='filepath')
315
- submit.click(toggle_diffusion, decoder, [diffusion_output, audio_diffusion], queue=False,
316
- show_progress=False).then(toggle_hint, decoder, [output_hint, audio_diffusion], queue=False,
317
- show_progress=False).then(predict_full, inputs=[model, model_path, decoder, text, melody, duration, topk, topp,
318
- temperature, cfg_coef, output_hint],
319
- outputs=[output, audio_output, diffusion_output, audio_diffusion], scroll_to_output = True)
320
- radio.change(toggle_audio_src, radio, [melody], queue=False, show_progress=False)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
321
 
322
  gr.Examples(
323
  fn=predict_full,
 
222
  top_k=topk, top_p=topp, temperature=temperature, cfg_coef=cfg_coef,
223
  gradio_progress=progress)
224
  if USE_DIFFUSION:
225
+ return videos[0], wavs[0], "To download the output, right-click and click on Save as...", videos[1], wavs[1]
226
+ return videos[0], wavs[0], "To download the output, right-click and click on Save as...", None, None
227
 
228
 
229
  def toggle_audio_src(choice):
 
240
  return [gr.update(visible = False)] * 2
241
 
242
 
 
 
 
 
 
 
 
 
 
 
 
243
  def ui_full(launch_kwargs):
244
  with gr.Blocks() as interface:
245
  gr.Markdown(
 
296
  # Adapted from https://github.com/rkfg/audiocraft/blob/long/app.py, MIT license.
297
  _ = gr.Button("Abort all", variant="stop").click(fn=interrupt, queue = False)
298
  with gr.Column():
 
299
  output = gr.Video(label="Generated Music")
300
  audio_output = gr.Audio(label="Generated Music (wav)", type='filepath', autoplay = True, show_download_button = True)
301
+ output_hint = gr.Label()
302
  diffusion_output = gr.Video(label="MultiBand Diffusion Decoder")
303
  audio_diffusion = gr.Audio(label="MultiBand Diffusion Decoder (wav)", type='filepath')
304
+ submit.click(toggle_diffusion, decoder, [
305
+ diffusion_output,
306
+ audio_diffusion
307
+ ], queue=False, show_progress=False).then(predict_full, inputs = [
308
+ model,
309
+ model_path,
310
+ decoder,
311
+ text,
312
+ melody,
313
+ duration,
314
+ topk,
315
+ topp,
316
+ temperature,
317
+ cfg_coef,
318
+ output_hint
319
+ ], outputs = [
320
+ output,
321
+ audio_output,
322
+ output_hint,
323
+ diffusion_output,
324
+ audio_diffusion
325
+ ], scroll_to_output = True)
326
+ radio.change(toggle_audio_src, radio, [melody], queue = False, show_progress = False)
327
 
328
  gr.Examples(
329
  fn=predict_full,