TaliDror commited on
Commit
63b6064
·
1 Parent(s): 0362643

improved UI

Browse files
Files changed (1) hide show
  1. app.py +14 -3
app.py CHANGED
@@ -535,6 +535,7 @@ def build_demo():
535
  type="filepath",
536
  label="Upload Audio",
537
  )
 
538
  audio_mic = gr.Audio(
539
  sources=["microphone"],
540
  type="filepath",
@@ -544,7 +545,7 @@ def build_demo():
544
 
545
  with gr.Column():
546
  gallery = gr.Gallery(label="Generated Images")
547
- status = gr.Markdown(visible=False)
548
 
549
  def _update_btn(upload, mic):
550
  return gr.update(interactive=(upload is not None or mic is not None))
@@ -555,13 +556,23 @@ def build_demo():
555
  def _generate(upload, mic):
556
  audio = upload if upload is not None else mic
557
  imgs, msg = generate(audio, DEFAULT_NUM_DISPLAY, DEFAULT_GUIDANCE_SCALE, DEFAULT_NUM_STEPS, DEFAULT_BASE_SEED)
558
- visible = bool(msg)
559
- return imgs, gr.update(value=msg, visible=visible)
 
 
560
 
561
  generate_btn.click(
 
 
 
 
562
  fn=_generate,
563
  inputs=[audio_upload, audio_mic],
564
  outputs=[gallery, status],
 
 
 
 
565
  )
566
 
567
  return demo
 
535
  type="filepath",
536
  label="Upload Audio",
537
  )
538
+ gr.Markdown("<div style='display:flex;align-items:center;justify-content:center;height:100%;font-size:1.2em;font-weight:bold;color:#888;'>OR</div>")
539
  audio_mic = gr.Audio(
540
  sources=["microphone"],
541
  type="filepath",
 
545
 
546
  with gr.Column():
547
  gallery = gr.Gallery(label="Generated Images")
548
+ status = gr.HTML(visible=False)
549
 
550
  def _update_btn(upload, mic):
551
  return gr.update(interactive=(upload is not None or mic is not None))
 
556
  def _generate(upload, mic):
557
  audio = upload if upload is not None else mic
558
  imgs, msg = generate(audio, DEFAULT_NUM_DISPLAY, DEFAULT_GUIDANCE_SCALE, DEFAULT_NUM_STEPS, DEFAULT_BASE_SEED)
559
+ if msg:
560
+ error_html = f'<div style="background:#fee2e2;border:1px solid #f87171;border-radius:8px;padding:12px 16px;color:#b91c1c;font-size:0.95em;">⚠️ {msg}</div>'
561
+ return imgs, gr.update(value=error_html, visible=True)
562
+ return imgs, gr.update(value="", visible=False)
563
 
564
  generate_btn.click(
565
+ fn=lambda u, m: (gr.update(value="Generating...", interactive=False, variant="secondary"), gr.update(value="", visible=False)),
566
+ inputs=[audio_upload, audio_mic],
567
+ outputs=[generate_btn, status],
568
+ ).then(
569
  fn=_generate,
570
  inputs=[audio_upload, audio_mic],
571
  outputs=[gallery, status],
572
+ ).then(
573
+ fn=lambda u, m: gr.update(value="Generate", interactive=(u is not None or m is not None), variant="primary"),
574
+ inputs=[audio_upload, audio_mic],
575
+ outputs=generate_btn,
576
  )
577
 
578
  return demo