Update app.py
Browse files
app.py
CHANGED
|
@@ -130,7 +130,7 @@ def add_message(history, message):
|
|
| 130 |
Returns the updated chatbot with an empty input textbox.
|
| 131 |
"""
|
| 132 |
history.append((message, None))
|
| 133 |
-
return history
|
| 134 |
|
| 135 |
def bot(history,message):
|
| 136 |
"""
|
|
@@ -142,7 +142,7 @@ def bot(history,message):
|
|
| 142 |
for character in response:
|
| 143 |
history[-1][1] += character
|
| 144 |
time.sleep(0.05)
|
| 145 |
-
yield history
|
| 146 |
|
| 147 |
|
| 148 |
@spaces.GPU()
|
|
@@ -213,16 +213,10 @@ with gr.Blocks(
|
|
| 213 |
elem_id="chat_input",
|
| 214 |
visible=True
|
| 215 |
)
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
submit_button = gr.Button(
|
| 219 |
-
value="Submit audio",
|
| 220 |
-
variant="primary"
|
| 221 |
-
)
|
| 222 |
-
|
| 223 |
-
chat_msg = chat_input.change(add_message, [chatbot, chat_input], [chatbot])
|
| 224 |
bot_msg = chat_msg.then(bot, [chatbot, chat_input], chatbot, api_name="bot_response")
|
| 225 |
-
|
| 226 |
|
| 227 |
submit_button.click(
|
| 228 |
fn=transcribe,
|
|
|
|
| 130 |
Returns the updated chatbot with an empty input textbox.
|
| 131 |
"""
|
| 132 |
history.append((message, None))
|
| 133 |
+
return history,
|
| 134 |
|
| 135 |
def bot(history,message):
|
| 136 |
"""
|
|
|
|
| 142 |
for character in response:
|
| 143 |
history[-1][1] += character
|
| 144 |
time.sleep(0.05)
|
| 145 |
+
yield history, gr.Textbox(value="", interactive=False)
|
| 146 |
|
| 147 |
|
| 148 |
@spaces.GPU()
|
|
|
|
| 213 |
elem_id="chat_input",
|
| 214 |
visible=True
|
| 215 |
)
|
| 216 |
+
if chat_input.value != "":
|
| 217 |
+
chat_msg = chat_input.change(add_message, [chatbot, chat_input], [chatbot])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 218 |
bot_msg = chat_msg.then(bot, [chatbot, chat_input], chatbot, api_name="bot_response")
|
| 219 |
+
bot_msg.then(lambda: gr.Textbox(interactive=False), None, [chat_input])
|
| 220 |
|
| 221 |
submit_button.click(
|
| 222 |
fn=transcribe,
|