Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -204,9 +204,10 @@ def generate_audio_elevenlabs(text):
|
|
204 |
def handle_mode_selection(mode, chat_history, question):
|
205 |
if mode == "Normal Chatbot":
|
206 |
# Normal chatbot mode: Show the response in the chatbot output
|
207 |
-
response = get_response(question)
|
208 |
-
chat_history.append((question, response))
|
209 |
-
return chat_history, "", None
|
|
|
210 |
elif mode == "Voice to Voice Conversation":
|
211 |
# Voice to Voice mode: Generate the response using Eleven Labs and return audio without showing text
|
212 |
response = get_response(question) # Get the response text (can be omitted if not needed for debugging)
|
@@ -379,6 +380,11 @@ with gr.Blocks(theme="rawrsor1/Everforest") as demo:
|
|
379 |
inputs=[mode_selection, chatbot, question_input],
|
380 |
outputs=[chatbot, question_input, audio_output],
|
381 |
api_name="api_handle_response"
|
|
|
|
|
|
|
|
|
|
|
382 |
)
|
383 |
|
384 |
question_input.submit(
|
@@ -386,6 +392,11 @@ with gr.Blocks(theme="rawrsor1/Everforest") as demo:
|
|
386 |
inputs=[mode_selection, chatbot, question_input],
|
387 |
outputs=[chatbot, question_input, audio_output],
|
388 |
api_name="api_handle_response_on_enter"
|
|
|
|
|
|
|
|
|
|
|
389 |
)
|
390 |
|
391 |
|
|
|
204 |
def handle_mode_selection(mode, chat_history, question):
|
205 |
if mode == "Normal Chatbot":
|
206 |
# Normal chatbot mode: Show the response in the chatbot output
|
207 |
+
#response = get_response(question)
|
208 |
+
#chat_history.append((question, response))
|
209 |
+
#return chat_history, "", None
|
210 |
+
return chat_history,question, None
|
211 |
elif mode == "Voice to Voice Conversation":
|
212 |
# Voice to Voice mode: Generate the response using Eleven Labs and return audio without showing text
|
213 |
response = get_response(question) # Get the response text (can be omitted if not needed for debugging)
|
|
|
380 |
inputs=[mode_selection, chatbot, question_input],
|
381 |
outputs=[chatbot, question_input, audio_output],
|
382 |
api_name="api_handle_response"
|
383 |
+
).then(
|
384 |
+
fn=chat_with_bot,
|
385 |
+
inputs=[chatbot],
|
386 |
+
outputs=chatbot,
|
387 |
+
api_name="api_stream_response"
|
388 |
)
|
389 |
|
390 |
question_input.submit(
|
|
|
392 |
inputs=[mode_selection, chatbot, question_input],
|
393 |
outputs=[chatbot, question_input, audio_output],
|
394 |
api_name="api_handle_response_on_enter"
|
395 |
+
).then(
|
396 |
+
fn=chat_with_bot,
|
397 |
+
inputs=[chatbot],
|
398 |
+
outputs=chatbot,
|
399 |
+
api_name="api_stream_response_on_enter"
|
400 |
)
|
401 |
|
402 |
|