polats commited on
Commit
c6a3e9f
·
1 Parent(s): 8b6384b

keep audio component visible

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -830,11 +830,12 @@ with gr.Blocks(title="LLM Inference with ZeroGPU") as demo:
830
  # 1. Update UI to "generating" state.
831
  # Crucially, we do NOT update the `chat` component here, as the backend
832
  # will provide the correctly formatted history in the first response chunk.
 
833
  yield {
834
  txt: gr.update(value="", interactive=False),
835
  submit_btn: gr.update(interactive=False),
836
  cancel_btn: gr.update(visible=True),
837
- tts_audio_output: gr.update(visible=False, value=None), # Hide audio during generation
838
  }
839
 
840
  cancelled = False
@@ -849,9 +850,9 @@ with gr.Blocks(title="LLM Inference with ZeroGPU") as demo:
849
  dbg: debug,
850
  }
851
 
852
- # Show audio output when audio is generated (final yield with TTS)
853
  if audio is not None:
854
- update_dict[tts_audio_output] = gr.update(visible=True, value=audio)
855
 
856
  yield update_dict
857
  except GeneratorExit:
@@ -890,7 +891,7 @@ with gr.Blocks(title="LLM Inference with ZeroGPU") as demo:
890
  txt: gr.update(interactive=True),
891
  submit_btn: gr.update(interactive=True),
892
  cancel_btn: gr.update(visible=False),
893
- tts_audio_output: gr.update(visible=False, value=None),
894
  }
895
 
896
  # Event for submitting text via Enter key or Submit button
@@ -931,6 +932,6 @@ with gr.Blocks(title="LLM Inference with ZeroGPU") as demo:
931
  )
932
 
933
  # Clear chat action
934
- clr.click(fn=lambda: ([], "", "", gr.update(visible=False, value=None)), outputs=[chat, txt, dbg, tts_audio_output])
935
 
936
  demo.launch(theme=CUSTOM_THEME, css=CUSTOM_CSS)
 
830
  # 1. Update UI to "generating" state.
831
  # Crucially, we do NOT update the `chat` component here, as the backend
832
  # will provide the correctly formatted history in the first response chunk.
833
+ # Keep audio visible but clear it - Gradio will show loading state
834
  yield {
835
  txt: gr.update(value="", interactive=False),
836
  submit_btn: gr.update(interactive=False),
837
  cancel_btn: gr.update(visible=True),
838
+ tts_audio_output: gr.update(value=None), # Clear audio but keep visible
839
  }
840
 
841
  cancelled = False
 
850
  dbg: debug,
851
  }
852
 
853
+ # Update audio output when audio is generated (final yield with TTS)
854
  if audio is not None:
855
+ update_dict[tts_audio_output] = gr.update(value=audio)
856
 
857
  yield update_dict
858
  except GeneratorExit:
 
891
  txt: gr.update(interactive=True),
892
  submit_btn: gr.update(interactive=True),
893
  cancel_btn: gr.update(visible=False),
894
+ tts_audio_output: gr.update(value=None), # Clear audio but keep visible
895
  }
896
 
897
  # Event for submitting text via Enter key or Submit button
 
932
  )
933
 
934
  # Clear chat action
935
+ clr.click(fn=lambda: ([], "", "", gr.update(value=None)), outputs=[chat, txt, dbg, tts_audio_output])
936
 
937
  demo.launch(theme=CUSTOM_THEME, css=CUSTOM_CSS)