Pijush2023 commited on
Commit
1522072
·
verified ·
1 Parent(s): 9a94403

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -29
app.py CHANGED
@@ -365,44 +365,22 @@ def generate_answer(message, choice):
365
  addresses = extract_addresses(response['output'])
366
  return [message, response['output']], addresses # Ensure it returns a list with two elements
367
 
368
- # def bot(history, choice, tts_choice):
369
- # if not history:
370
- # return history
371
- # response, addresses = generate_answer(history[-1][0], choice)
372
- # history[-1][1] = ""
373
-
374
- # with concurrent.futures.ThreadPoolExecutor() as executor:
375
- # if tts_choice == "Alpha":
376
- # audio_future = executor.submit(generate_audio_elevenlabs, response)
377
- # elif tts_choice == "Beta":
378
- # audio_future = executor.submit(generate_audio_parler_tts, response)
379
- # elif tts_choice == "Gamma":
380
- # audio_future = executor.submit(generate_audio_mars5, response)
381
-
382
-
383
- # for character in response:
384
- # history[-1][1] += character
385
- # time.sleep(0.05)
386
- # yield history, None
387
-
388
- # audio_path = audio_future.result()
389
- # yield history, audio_path
390
-
391
  def bot(history, choice, tts_choice):
392
  if not history:
393
  return history
394
  response, addresses = generate_answer(history[-1][0], choice)
395
- history[-1][1] = response[1] # Update bot response
396
-
397
  with concurrent.futures.ThreadPoolExecutor() as executor:
398
  if tts_choice == "Alpha":
399
- audio_future = executor.submit(generate_audio_elevenlabs, response[1])
400
  elif tts_choice == "Beta":
401
- audio_future = executor.submit(generate_audio_parler_tts, response[1])
402
  elif tts_choice == "Gamma":
403
- audio_future = executor.submit(generate_audio_mars5, response[1])
 
404
 
405
- for character in response[1]:
406
  history[-1][1] += character
407
  time.sleep(0.05)
408
  yield history, None
@@ -410,6 +388,8 @@ def bot(history, choice, tts_choice):
410
  audio_path = audio_future.result()
411
  yield history, audio_path
412
 
 
 
413
  # def add_message(history, message):
414
  # history.append((message, None))
415
  # return history, gr.Textbox(value="", interactive=True, placeholder="Enter message or upload file...", show_label=False)
 
365
  addresses = extract_addresses(response['output'])
366
  return [message, response['output']], addresses # Ensure it returns a list with two elements
367
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
368
  def bot(history, choice, tts_choice):
369
  if not history:
370
  return history
371
  response, addresses = generate_answer(history[-1][0], choice)
372
+ history[-1][1] = ""
373
+
374
  with concurrent.futures.ThreadPoolExecutor() as executor:
375
  if tts_choice == "Alpha":
376
+ audio_future = executor.submit(generate_audio_elevenlabs, response)
377
  elif tts_choice == "Beta":
378
+ audio_future = executor.submit(generate_audio_parler_tts, response)
379
  elif tts_choice == "Gamma":
380
+ audio_future = executor.submit(generate_audio_mars5, response)
381
+
382
 
383
+ for character in response:
384
  history[-1][1] += character
385
  time.sleep(0.05)
386
  yield history, None
 
388
  audio_path = audio_future.result()
389
  yield history, audio_path
390
 
391
+
392
+
393
  # def add_message(history, message):
394
  # history.append((message, None))
395
  # return history, gr.Textbox(value="", interactive=True, placeholder="Enter message or upload file...", show_label=False)