Pijush2023 commited on
Commit
e53b56a
·
verified ·
1 Parent(s): 91833b3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -220,13 +220,14 @@ def chat_with_bot(messages, user_message):
220
 
221
  # Function to generate audio with Eleven Labs TTS from the last bot response
222
  def generate_audio_from_last_response(messages):
223
- # Get the last bot response from the conversation history
224
- if messages and messages[-1][1]: # Check if there is a bot response
225
  last_response = messages[-1][1]
226
  return generate_audio_elevenlabs(last_response)
227
  return None
228
 
229
 
 
230
  # Create the Gradio Blocks interface
231
  with gr.Blocks() as demo:
232
  chatbot = gr.Chatbot([], elem_id="RADAR", bubble_full_width=False)
 
220
 
221
  # Function to generate audio with Eleven Labs TTS from the last bot response
222
  def generate_audio_from_last_response(messages):
223
+ # Ensure the messages list is not empty and the last message has a bot response
224
+ if messages and isinstance(messages[-1], tuple) and len(messages[-1]) == 2 and messages[-1][1]:
225
  last_response = messages[-1][1]
226
  return generate_audio_elevenlabs(last_response)
227
  return None
228
 
229
 
230
+
231
  # Create the Gradio Blocks interface
232
  with gr.Blocks() as demo:
233
  chatbot = gr.Chatbot([], elem_id="RADAR", bubble_full_width=False)