Pijush2023 commited on
Commit
cac7b9b
·
verified ·
1 Parent(s): 2ab087b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -22
app.py CHANGED
@@ -204,10 +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
- 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)
@@ -216,14 +216,6 @@ def handle_mode_selection(mode, chat_history, question):
216
  return chat_history, "", audio_path
217
 
218
 
219
-
220
-
221
-
222
-
223
-
224
-
225
-
226
-
227
  # Function to add a user's message to the chat history and clear the input box
228
  def add_message(history, message):
229
  if message.strip():
@@ -380,11 +372,6 @@ with gr.Blocks(theme="rawrsor1/Everforest") as demo:
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,11 +379,6 @@ with gr.Blocks(theme="rawrsor1/Everforest") as demo:
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
 
 
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
+
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)
 
216
  return chat_history, "", audio_path
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():
 
372
  inputs=[mode_selection, chatbot, question_input],
373
  outputs=[chatbot, question_input, audio_output],
374
  api_name="api_handle_response"
 
 
 
 
 
375
  )
376
 
377
  question_input.submit(
 
379
  inputs=[mode_selection, chatbot, question_input],
380
  outputs=[chatbot, question_input, audio_output],
381
  api_name="api_handle_response_on_enter"
 
 
 
 
 
382
  )
383
 
384