Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -352,12 +352,35 @@ 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])
|
@@ -367,12 +390,14 @@ def bot(history, choice, tts_choice):
|
|
367 |
audio_future = executor.submit(generate_audio_mars5, response_pair[1])
|
368 |
|
369 |
for character in response_pair[1]:
|
370 |
-
|
371 |
-
|
372 |
-
|
|
|
373 |
|
374 |
audio_path = audio_future.result()
|
375 |
-
|
|
|
376 |
|
377 |
|
378 |
|
|
|
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 |
with concurrent.futures.ThreadPoolExecutor() as executor:
|
385 |
if tts_choice == "Alpha":
|
386 |
audio_future = executor.submit(generate_audio_elevenlabs, response_pair[1])
|
|
|
390 |
audio_future = executor.submit(generate_audio_mars5, response_pair[1])
|
391 |
|
392 |
for character in response_pair[1]:
|
393 |
+
response_text += character
|
394 |
+
new_history = history.copy()
|
395 |
+
new_history[-1][1] = response_text
|
396 |
+
yield new_history, None
|
397 |
|
398 |
audio_path = audio_future.result()
|
399 |
+
new_history[-1][1] = response_text
|
400 |
+
yield new_history, audio_path
|
401 |
|
402 |
|
403 |
|