Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -338,21 +338,41 @@ def generate_answer(message, choice, retrieval_mode):
|
|
338 |
# history.append([response, None]) # Ensure the response is added in the correct format
|
339 |
|
340 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
341 |
def bot(history, choice, tts_choice, retrieval_mode):
|
342 |
if not history:
|
343 |
return history
|
344 |
|
345 |
response, addresses = generate_answer(history[-1][0], choice, retrieval_mode)
|
346 |
-
response = f"<div style='font-size: 14px;'>{response}</div>" # Adjust the font size
|
347 |
-
|
348 |
history[-1][1] = ""
|
349 |
|
350 |
-
# Immediately update the chatbot UI with the text response
|
351 |
-
for character in response:
|
352 |
-
history[-1][1] += character
|
353 |
-
time.sleep(0.05)
|
354 |
-
yield history, None
|
355 |
-
|
356 |
with concurrent.futures.ThreadPoolExecutor() as executor:
|
357 |
if tts_choice == "Alpha":
|
358 |
audio_future = executor.submit(generate_audio_elevenlabs, response)
|
@@ -360,11 +380,16 @@ def bot(history, choice, tts_choice, retrieval_mode):
|
|
360 |
audio_future = executor.submit(generate_audio_parler_tts, response)
|
361 |
elif tts_choice == "Gamma":
|
362 |
audio_future = executor.submit(generate_audio_mars5, response)
|
363 |
-
|
|
|
|
|
|
|
|
|
|
|
364 |
audio_path = audio_future.result()
|
|
|
365 |
|
366 |
history.append([response, None]) # Ensure the response is added in the correct format
|
367 |
-
yield history, audio_path
|
368 |
|
369 |
|
370 |
|
|
|
338 |
# history.append([response, None]) # Ensure the response is added in the correct format
|
339 |
|
340 |
|
341 |
+
# def bot(history, choice, tts_choice, retrieval_mode):
|
342 |
+
# if not history:
|
343 |
+
# return history
|
344 |
+
|
345 |
+
# response, addresses = generate_answer(history[-1][0], choice, retrieval_mode)
|
346 |
+
# response = f"<div style='font-size: 14px;'>{response}</div>" # Adjust the font size
|
347 |
+
|
348 |
+
# history[-1][1] = ""
|
349 |
+
|
350 |
+
# # Immediately update the chatbot UI with the text response
|
351 |
+
# for character in response:
|
352 |
+
# history[-1][1] += character
|
353 |
+
# time.sleep(0.05)
|
354 |
+
# yield history, None
|
355 |
+
|
356 |
+
# with concurrent.futures.ThreadPoolExecutor() as executor:
|
357 |
+
# if tts_choice == "Alpha":
|
358 |
+
# audio_future = executor.submit(generate_audio_elevenlabs, response)
|
359 |
+
# elif tts_choice == "Beta":
|
360 |
+
# audio_future = executor.submit(generate_audio_parler_tts, response)
|
361 |
+
# elif tts_choice == "Gamma":
|
362 |
+
# audio_future = executor.submit(generate_audio_mars5, response)
|
363 |
+
|
364 |
+
# audio_path = audio_future.result()
|
365 |
+
|
366 |
+
# history.append([response, None]) # Ensure the response is added in the correct format
|
367 |
+
# yield history, audio_path
|
368 |
+
|
369 |
def bot(history, choice, tts_choice, retrieval_mode):
|
370 |
if not history:
|
371 |
return history
|
372 |
|
373 |
response, addresses = generate_answer(history[-1][0], choice, retrieval_mode)
|
|
|
|
|
374 |
history[-1][1] = ""
|
375 |
|
|
|
|
|
|
|
|
|
|
|
|
|
376 |
with concurrent.futures.ThreadPoolExecutor() as executor:
|
377 |
if tts_choice == "Alpha":
|
378 |
audio_future = executor.submit(generate_audio_elevenlabs, response)
|
|
|
380 |
audio_future = executor.submit(generate_audio_parler_tts, response)
|
381 |
elif tts_choice == "Gamma":
|
382 |
audio_future = executor.submit(generate_audio_mars5, response)
|
383 |
+
|
384 |
+
for character in response:
|
385 |
+
history[-1][1] += character
|
386 |
+
time.sleep(0.05)
|
387 |
+
yield history, None
|
388 |
+
|
389 |
audio_path = audio_future.result()
|
390 |
+
yield history, audio_path
|
391 |
|
392 |
history.append([response, None]) # Ensure the response is added in the correct format
|
|
|
393 |
|
394 |
|
395 |
|