Spaces:
Running
on
T4
Running
on
T4
Update app.py
Browse files
app.py
CHANGED
@@ -99,16 +99,15 @@ with gr.Blocks() as demo:
|
|
99 |
]
|
100 |
)
|
101 |
|
102 |
-
# Chat transcript
|
103 |
transcript = gr.Chatbot(label="Transcript", type="messages")
|
104 |
|
105 |
-
# Lower row
|
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:
|
135 |
-
|
136 |
respond_text,
|
137 |
inputs=[text_input, transformers_chat, transcript],
|
138 |
outputs=[transformers_chat, transcript],
|
139 |
)
|
140 |
-
# Clear text input after
|
141 |
-
|
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()
|