Pijush2023 commited on
Commit
5962cc8
·
verified ·
1 Parent(s): 3bc821d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -5
app.py CHANGED
@@ -289,7 +289,30 @@ def generate_answer(message, choice):
289
  addresses = extract_addresses(response['output'])
290
  return response['output'], addresses
291
 
292
- def bot(history, choice, tts_choice):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
293
  if not history:
294
  return history
295
  response, addresses = generate_answer(history[-1][0], choice)
@@ -303,7 +326,6 @@ def bot(history, choice, tts_choice):
303
  elif tts_choice == "Gamma":
304
  audio_future = executor.submit(generate_audio_mars5, response)
305
 
306
-
307
  for character in response:
308
  history[-1][1] += character
309
  time.sleep(0.05)
@@ -312,8 +334,6 @@ def bot(history, choice, tts_choice):
312
  audio_path = audio_future.result()
313
  yield history, audio_path
314
 
315
-
316
-
317
  def add_message(history, message):
318
  history.append((message, None))
319
  return history, gr.Textbox(value="", interactive=True, placeholder="Enter message or upload file...", show_label=False)
@@ -704,8 +724,11 @@ with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
704
  tts_choice = gr.Radio(label="Select TTS System", choices=["Alpha", "Beta", "Gamma"], value="Alpha")
705
  retriver_button = gr.Button("Retriver")
706
  # retriver_button.click(fn=add_message, inputs=[chatbot, chat_input], outputs=[chatbot, chat_input]).then(fn=bot, inputs=[chatbot, choice, tts_choice], outputs=[chatbot],api_name="Ask_Retriever")
 
 
707
  retriver_button.click(fn=add_message, inputs=[chatbot, chat_input], outputs=[chatbot, chat_input]).then(
708
- fn=bot, inputs=[chatbot, choice, tts_choice], outputs=[chatbot], api_name="Ask_Retriever")
 
709
  #gr.Audio(interactive=False, autoplay=True)]
710
 
711
  # voice_response_button = gr.Button("Voice Response")
 
289
  addresses = extract_addresses(response['output'])
290
  return response['output'], addresses
291
 
292
+ # def bot(history, choice, tts_choice):
293
+ # if not history:
294
+ # return history
295
+ # response, addresses = generate_answer(history[-1][0], choice)
296
+ # history[-1][1] = ""
297
+
298
+ # with concurrent.futures.ThreadPoolExecutor() as executor:
299
+ # if tts_choice == "Alpha":
300
+ # audio_future = executor.submit(generate_audio_elevenlabs, response)
301
+ # elif tts_choice == "Beta":
302
+ # audio_future = executor.submit(generate_audio_parler_tts, response)
303
+ # elif tts_choice == "Gamma":
304
+ # audio_future = executor.submit(generate_audio_mars5, response)
305
+
306
+
307
+ # for character in response:
308
+ # history[-1][1] += character
309
+ # time.sleep(0.05)
310
+ # yield history, None
311
+
312
+ # audio_path = audio_future.result()
313
+ # yield history, audio_path
314
+
315
+ def bot(history, choice, tts_choice, state):
316
  if not history:
317
  return history
318
  response, addresses = generate_answer(history[-1][0], choice)
 
326
  elif tts_choice == "Gamma":
327
  audio_future = executor.submit(generate_audio_mars5, response)
328
 
 
329
  for character in response:
330
  history[-1][1] += character
331
  time.sleep(0.05)
 
334
  audio_path = audio_future.result()
335
  yield history, audio_path
336
 
 
 
337
  def add_message(history, message):
338
  history.append((message, None))
339
  return history, gr.Textbox(value="", interactive=True, placeholder="Enter message or upload file...", show_label=False)
 
724
  tts_choice = gr.Radio(label="Select TTS System", choices=["Alpha", "Beta", "Gamma"], value="Alpha")
725
  retriver_button = gr.Button("Retriver")
726
  # retriver_button.click(fn=add_message, inputs=[chatbot, chat_input], outputs=[chatbot, chat_input]).then(fn=bot, inputs=[chatbot, choice, tts_choice], outputs=[chatbot],api_name="Ask_Retriever")
727
+ # retriver_button.click(fn=add_message, inputs=[chatbot, chat_input], outputs=[chatbot, chat_input]).then(
728
+ # fn=bot, inputs=[chatbot, choice, tts_choice], outputs=[chatbot], api_name="Ask_Retriever")
729
  retriver_button.click(fn=add_message, inputs=[chatbot, chat_input], outputs=[chatbot, chat_input]).then(
730
+ fn=bot, inputs=[chatbot, choice, tts_choice, state], outputs=[chatbot], api_name="Ask_Retriever")
731
+
732
  #gr.Audio(interactive=False, autoplay=True)]
733
 
734
  # voice_response_button = gr.Button("Voice Response")