Pijush2023 commited on
Commit
3ad85f0
·
verified ·
1 Parent(s): 1522072

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -13
app.py CHANGED
@@ -365,22 +365,43 @@ 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
@@ -389,15 +410,18 @@ def bot(history, choice, tts_choice):
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)
396
 
397
- def add_message(history, message):
398
- history = history or []
399
- history.append((message, None))
400
- return history, gr.Textbox(value="", interactive=True, placeholder="Enter message or upload file...", show_label=False)
401
 
402
  # def generate_voice_response(history, tts_choice):
403
  # if not history:
 
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_pair, addresses = generate_answer(history[-1][0], choice)
372
+ # history[-1] = response_pair # Update bot response correctly
373
+
374
+ # with concurrent.futures.ThreadPoolExecutor() as executor:
375
+ # if tts_choice == "Alpha":
376
+ # audio_future = executor.submit(generate_audio_elevenlabs, response_pair[1])
377
+ # elif tts_choice == "Beta":
378
+ # audio_future = executor.submit(generate_audio_parler_tts, response_pair[1])
379
+ # elif tts_choice == "Gamma":
380
+ # audio_future = executor.submit(generate_audio_mars5, response_pair[1])
381
+
382
+ # for character in response_pair[1]:
383
+ # history[-1][1] += character
384
+ # time.sleep(0.05)
385
+ # yield history, None
386
+
387
+ # audio_path = audio_future.result()
388
+ # yield history, audio_path
389
+
390
  def bot(history, choice, tts_choice):
391
  if not history:
392
  return history
393
+ response_pair, addresses = generate_answer(history[-1][0], choice)
394
+ history[-1] = response_pair # Update bot response correctly
395
+
396
  with concurrent.futures.ThreadPoolExecutor() as executor:
397
  if tts_choice == "Alpha":
398
+ audio_future = executor.submit(generate_audio_elevenlabs, response_pair[1])
399
  elif tts_choice == "Beta":
400
+ audio_future = executor.submit(generate_audio_parler_tts, response_pair[1])
401
  elif tts_choice == "Gamma":
402
+ audio_future = executor.submit(generate_audio_mars5, response_pair[1])
403
 
404
+ for character in response_pair[1]:
 
405
  history[-1][1] += character
406
  time.sleep(0.05)
407
  yield history, None
 
410
  yield history, audio_path
411
 
412
 
413
+ def add_message(history, message):
414
+ history = history or []
415
+ history.append([message, ""]) # Ensure it is a list with two elements: message and empty response
416
+ return history, gr.Textbox(value="", interactive=True, placeholder="Enter message or upload file...", show_label=False)
417
  # def add_message(history, message):
418
  # history.append((message, None))
419
  # return history, gr.Textbox(value="", interactive=True, placeholder="Enter message or upload file...", show_label=False)
420
 
421
+ # def add_message(history, message):
422
+ # history = history or []
423
+ # history.append((message, None))
424
+ # return history, gr.Textbox(value="", interactive=True, placeholder="Enter message or upload file...", show_label=False)
425
 
426
  # def generate_voice_response(history, tts_choice):
427
  # if not history: