Pijush2023 commited on
Commit
5e00576
·
verified ·
1 Parent(s): 786a34d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -203,15 +203,19 @@ def generate_audio_elevenlabs(text):
203
 
204
  def handle_mode_selection(mode, chat_history, question):
205
  if mode == "Normal Chatbot":
 
206
  response = get_response(question)
207
  chat_history.append((question, response))
208
  return chat_history, "", None
209
  elif mode == "Voice to Voice Conversation":
210
- audio_path = generate_audio_elevenlabs(question)
211
- chat_history.append((question, "[Voice Response]"))
 
 
212
  return chat_history, "", audio_path
213
 
214
 
 
215
  # Function to add a user's message to the chat history and clear the input box
216
  def add_message(history, message):
217
  if message.strip():
 
203
 
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)
213
+ audio_path = generate_audio_elevenlabs(response) # Convert the response to audio
214
+ chat_history.append((question, "[Voice Response]")) # Log that a voice response was generated (optional)
215
  return chat_history, "", audio_path
216
 
217
 
218
+
219
  # Function to add a user's message to the chat history and clear the input box
220
  def add_message(history, message):
221
  if message.strip():