Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -219,11 +219,12 @@ def chat_with_bot(messages, user_message):
|
|
219 |
|
220 |
|
221 |
# Function to generate audio with Eleven Labs TTS from the last bot response
|
222 |
-
def generate_audio_from_last_response(
|
223 |
-
#
|
224 |
-
if
|
225 |
-
|
226 |
-
|
|
|
227 |
return None
|
228 |
|
229 |
|
@@ -260,7 +261,7 @@ with gr.Blocks() as demo:
|
|
260 |
|
261 |
# Define interactions
|
262 |
get_response_btn.click(fn=chat_with_bot, inputs=[chatbot, question_input], outputs=chatbot)
|
263 |
-
generate_audio_btn.click(fn=generate_audio_from_last_response, inputs=
|
264 |
clean_btn.click(fn=clear_fields, inputs=[], outputs=[chatbot, question_input, audio_output])
|
265 |
|
266 |
# Launch the Gradio interface
|
|
|
219 |
|
220 |
|
221 |
# Function to generate audio with Eleven Labs TTS from the last bot response
|
222 |
+
def generate_audio_from_last_response(history):
|
223 |
+
# Get the most recent bot response from the chat history
|
224 |
+
if history and len(history) > 0:
|
225 |
+
recent_response = history[-1][1] # The second item in the tuple is the bot response text
|
226 |
+
if recent_response:
|
227 |
+
return generate_audio_elevenlabs(recent_response)
|
228 |
return None
|
229 |
|
230 |
|
|
|
261 |
|
262 |
# Define interactions
|
263 |
get_response_btn.click(fn=chat_with_bot, inputs=[chatbot, question_input], outputs=chatbot)
|
264 |
+
generate_audio_btn.click(fn=generate_audio_from_last_response, inputs=chatbot, outputs=audio_output)
|
265 |
clean_btn.click(fn=clear_fields, inputs=[], outputs=[chatbot, question_input, audio_output])
|
266 |
|
267 |
# Launch the Gradio interface
|