Pijush2023 commited on
Commit
786a34d
·
verified ·
1 Parent(s): 28374c4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -204,15 +204,18 @@ def generate_audio_elevenlabs(text):
204
  def handle_mode_selection(mode, chat_history, question):
205
  if mode == "Normal Chatbot":
206
  response = get_response(question)
207
- return add_message(chat_history, question), "", None
 
208
  elif mode == "Voice to Voice Conversation":
209
  audio_path = generate_audio_elevenlabs(question)
 
210
  return chat_history, "", audio_path
211
 
 
212
  # Function to add a user's message to the chat history and clear the input box
213
  def add_message(history, message):
214
  if message.strip():
215
- history.append((message, None)) # Add the user's message to the chat history only if it's not empty
216
  return history, "" # Clear the input box
217
 
218
  # Define function to generate a streaming response
@@ -411,4 +414,4 @@ with gr.Blocks(theme="rawrsor1/Everforest") as demo:
411
  )
412
 
413
  # Launch the Gradio interface
414
- demo.launch(show_error=True)
 
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():
218
+ history.append((message, "")) # Add the user's message to the chat history only if it's not empty
219
  return history, "" # Clear the input box
220
 
221
  # Define function to generate a streaming response
 
414
  )
415
 
416
  # Launch the Gradio interface
417
+ demo.launch(show_error=True,share=True)