Pijush2023 commited on
Commit
563a689
·
verified ·
1 Parent(s): b01e77f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -2
app.py CHANGED
@@ -414,6 +414,28 @@ 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
@@ -424,6 +446,10 @@ def tts_response(history, response, tts_choice):
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
@@ -438,8 +464,6 @@ def tts_response(history, response, tts_choice):
438
 
439
 
440
 
441
-
442
-
443
  # import concurrent.futures
444
  # # Existing bot function with concurrent futures for parallel processing
445
  # def bot(history, choice, tts_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
 
446
  # elif tts_choice == "Gamma":
447
  # audio_future = executor.submit(generate_audio_mars5, response)
448
 
449
+ # Initialize the response string if it's None
450
+ if history[-1][1] is None:
451
+ history[-1][1] = ""
452
+
453
  # Simulate typing effect by adding characters with delay
454
  for character in response:
455
  history[-1][1] += character
 
464
 
465
 
466
 
 
 
467
  # import concurrent.futures
468
  # # Existing bot function with concurrent futures for parallel processing
469
  # def bot(history, choice, tts_choice, retrieval_mode, model_choice):