Steveeeeeeen HF staff commited on
Commit
8baccb8
·
verified ·
1 Parent(s): 2cdcbd0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -8
app.py CHANGED
@@ -99,16 +99,15 @@ with gr.Blocks() as demo:
99
  ]
100
  )
101
 
102
- # Chat transcript on top
103
  transcript = gr.Chatbot(label="Transcript", type="messages")
104
 
105
- # Lower row with text input and audio input side by side
106
  with gr.Row():
107
  with gr.Column(scale=1):
108
  text_input = gr.Textbox(
109
- placeholder="Type your message here...", label="Your Message"
110
  )
111
- send_button = gr.Button("Send")
112
  with gr.Column(scale=1):
113
  audio = WebRTC(
114
  rtc_configuration=rtc_configuration,
@@ -131,14 +130,14 @@ with gr.Blocks() as demo:
131
  show_progress="hidden",
132
  )
133
 
134
- # Text input: process the typed message when "Send" is clicked.
135
- send_button.click(
136
  respond_text,
137
  inputs=[text_input, transformers_chat, transcript],
138
  outputs=[transformers_chat, transcript],
139
  )
140
- # Clear text input after sending.
141
- send_button.click(lambda: "", inputs=[], outputs=[text_input])
142
 
143
  if __name__ == "__main__":
144
  demo.launch()
 
99
  ]
100
  )
101
 
102
+ # Chat transcript at the top
103
  transcript = gr.Chatbot(label="Transcript", type="messages")
104
 
105
+ # Lower row: text input and audio input side by side
106
  with gr.Row():
107
  with gr.Column(scale=1):
108
  text_input = gr.Textbox(
109
+ placeholder="Type your message here and press Enter...", label="Your Message"
110
  )
 
111
  with gr.Column(scale=1):
112
  audio = WebRTC(
113
  rtc_configuration=rtc_configuration,
 
130
  show_progress="hidden",
131
  )
132
 
133
+ # Text input: submit callback when pressing Enter.
134
+ text_input.submit(
135
  respond_text,
136
  inputs=[text_input, transformers_chat, transcript],
137
  outputs=[transformers_chat, transcript],
138
  )
139
+ # Clear text input after submission.
140
+ text_input.submit(lambda: "", inputs=[], outputs=[text_input])
141
 
142
  if __name__ == "__main__":
143
  demo.launch()