Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -352,37 +352,12 @@ def generate_answer(message, choice):
|
|
352 |
|
353 |
|
354 |
|
355 |
-
# def bot(history, choice, tts_choice):
|
356 |
-
# if not history:
|
357 |
-
# return history
|
358 |
-
# response_pair, addresses = generate_answer(history[-1][0], choice)
|
359 |
-
# history[-1] = response_pair # Update bot response correctly
|
360 |
-
|
361 |
-
# with concurrent.futures.ThreadPoolExecutor() as executor:
|
362 |
-
# if tts_choice == "Alpha":
|
363 |
-
# audio_future = executor.submit(generate_audio_elevenlabs, response_pair[1])
|
364 |
-
# elif tts_choice == "Beta":
|
365 |
-
# audio_future = executor.submit(generate_audio_parler_tts, response_pair[1])
|
366 |
-
# elif tts_choice == "Gamma":
|
367 |
-
# audio_future = executor.submit(generate_audio_mars5, response_pair[1])
|
368 |
-
|
369 |
-
# for character in response_pair[1]:
|
370 |
-
# history[-1][1] += character
|
371 |
-
# time.sleep(0.05)
|
372 |
-
# yield history, None
|
373 |
-
|
374 |
-
# audio_path = audio_future.result()
|
375 |
-
# yield history, audio_path
|
376 |
-
|
377 |
def bot(history, choice, tts_choice):
|
378 |
if not history:
|
379 |
return history
|
380 |
response_pair, addresses = generate_answer(history[-1][0], choice)
|
381 |
history[-1] = response_pair # Update bot response correctly
|
382 |
|
383 |
-
response_text = ""
|
384 |
-
new_history = history.copy()
|
385 |
-
|
386 |
with concurrent.futures.ThreadPoolExecutor() as executor:
|
387 |
if tts_choice == "Alpha":
|
388 |
audio_future = executor.submit(generate_audio_elevenlabs, response_pair[1])
|
@@ -392,17 +367,12 @@ def bot(history, choice, tts_choice):
|
|
392 |
audio_future = executor.submit(generate_audio_mars5, response_pair[1])
|
393 |
|
394 |
for character in response_pair[1]:
|
395 |
-
|
396 |
-
|
397 |
-
yield
|
398 |
|
399 |
audio_path = audio_future.result()
|
400 |
-
|
401 |
-
yield new_history, audio_path
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
|
407 |
def add_message(history, message):
|
408 |
history = history or []
|
|
|
352 |
|
353 |
|
354 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
355 |
def bot(history, choice, tts_choice):
|
356 |
if not history:
|
357 |
return history
|
358 |
response_pair, addresses = generate_answer(history[-1][0], choice)
|
359 |
history[-1] = response_pair # Update bot response correctly
|
360 |
|
|
|
|
|
|
|
361 |
with concurrent.futures.ThreadPoolExecutor() as executor:
|
362 |
if tts_choice == "Alpha":
|
363 |
audio_future = executor.submit(generate_audio_elevenlabs, response_pair[1])
|
|
|
367 |
audio_future = executor.submit(generate_audio_mars5, response_pair[1])
|
368 |
|
369 |
for character in response_pair[1]:
|
370 |
+
history[-1][1] += character
|
371 |
+
time.sleep(0.05)
|
372 |
+
yield history, None
|
373 |
|
374 |
audio_path = audio_future.result()
|
375 |
+
yield history, audio_path
|
|
|
|
|
|
|
|
|
|
|
376 |
|
377 |
def add_message(history, message):
|
378 |
history = history or []
|