Pijush2023 commited on
Commit
0b35920
·
verified ·
1 Parent(s): c1b3106

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -36
app.py CHANGED
@@ -414,28 +414,6 @@ def bot_response(history, choice, retrieval_mode, model_choice):
414
 
415
 
416
  # Function to generate TTS response
417
- # def tts_response(history, response, tts_choice):
418
- # with concurrent.futures.ThreadPoolExecutor() as executor:
419
- # # Based on the TTS choice, submit the corresponding task
420
- # if tts_choice == "Alpha":
421
- # audio_future = executor.submit(generate_audio_elevenlabs, response)
422
- # elif tts_choice == "Beta":
423
- # audio_future = executor.submit(generate_audio_parler_tts, response)
424
- # # elif tts_choice == "Gamma":
425
- # # audio_future = executor.submit(generate_audio_mars5, response)
426
-
427
- # # Simulate typing effect by adding characters with delay
428
- # for character in response:
429
- # history[-1][1] += character
430
- # time.sleep(0.05)
431
- # yield history, None
432
-
433
- # # Get the path of the generated audio
434
- # audio_path = audio_future.result()
435
-
436
- # # Return the final history and audio path
437
- # yield history, audio_path
438
-
439
  def tts_response(history, response, tts_choice):
440
  with concurrent.futures.ThreadPoolExecutor() as executor:
441
  # Based on the TTS choice, submit the corresponding task
@@ -443,10 +421,8 @@ def tts_response(history, response, tts_choice):
443
  audio_future = executor.submit(generate_audio_elevenlabs, response)
444
  elif tts_choice == "Beta":
445
  audio_future = executor.submit(generate_audio_parler_tts, response)
446
-
447
- # Initialize the response string if it's None
448
- if history[-1][1] is None:
449
- history[-1][1] = ""
450
 
451
  # Simulate typing effect by adding characters with delay
452
  for character in response:
@@ -457,12 +433,10 @@ def tts_response(history, response, tts_choice):
457
  # Get the path of the generated audio
458
  audio_path = audio_future.result()
459
 
460
- # Check if the audio path is valid before yielding it
461
- if audio_path and os.path.exists(audio_path):
462
- yield history, audio_path
463
- else:
464
- logging.error("Audio file not generated correctly")
465
- yield history, None
466
 
467
 
468
 
@@ -716,10 +690,6 @@ def add_message(history, message):
716
  history.append((message, None))
717
  return history, gr.Textbox(value="", interactive=True, show_label=False)
718
 
719
- # def add_message(history, message):
720
- # # Append a tuple with the user's message and a placeholder for the assistant's response
721
- # history.append((message, "")) # Use an empty string to ensure the format is correct
722
- # return history, gr.Textbox(value="", interactive=True, show_label=False)
723
 
724
 
725
  def print_like_dislike(x: gr.LikeData):
 
414
 
415
 
416
  # Function to generate TTS response
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
417
  def tts_response(history, response, tts_choice):
418
  with concurrent.futures.ThreadPoolExecutor() as executor:
419
  # Based on the TTS choice, submit the corresponding task
 
421
  audio_future = executor.submit(generate_audio_elevenlabs, response)
422
  elif tts_choice == "Beta":
423
  audio_future = executor.submit(generate_audio_parler_tts, response)
424
+ # elif tts_choice == "Gamma":
425
+ # audio_future = executor.submit(generate_audio_mars5, response)
 
 
426
 
427
  # Simulate typing effect by adding characters with delay
428
  for character in response:
 
433
  # Get the path of the generated audio
434
  audio_path = audio_future.result()
435
 
436
+ # Return the final history and audio path
437
+ yield history, audio_path
438
+
439
+
 
 
440
 
441
 
442
 
 
690
  history.append((message, None))
691
  return history, gr.Textbox(value="", interactive=True, show_label=False)
692
 
 
 
 
 
693
 
694
 
695
  def print_like_dislike(x: gr.LikeData):