Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -310,6 +310,34 @@ def generate_answer(message, choice, retrieval_mode):
|
|
310 |
|
311 |
|
312 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
313 |
def bot(history, choice, tts_choice, retrieval_mode):
|
314 |
if not history:
|
315 |
return history
|
@@ -319,6 +347,12 @@ def bot(history, choice, tts_choice, retrieval_mode):
|
|
319 |
|
320 |
history[-1][1] = ""
|
321 |
|
|
|
|
|
|
|
|
|
|
|
|
|
322 |
with concurrent.futures.ThreadPoolExecutor() as executor:
|
323 |
if tts_choice == "Alpha":
|
324 |
audio_future = executor.submit(generate_audio_elevenlabs, response)
|
@@ -326,17 +360,11 @@ def bot(history, choice, tts_choice, retrieval_mode):
|
|
326 |
audio_future = executor.submit(generate_audio_parler_tts, response)
|
327 |
elif tts_choice == "Gamma":
|
328 |
audio_future = executor.submit(generate_audio_mars5, response)
|
329 |
-
|
330 |
-
for character in response:
|
331 |
-
history[-1][1] += character
|
332 |
-
time.sleep(0.05)
|
333 |
-
yield history, None
|
334 |
-
|
335 |
audio_path = audio_future.result()
|
336 |
-
yield history, audio_path
|
337 |
|
338 |
history.append([response, None]) # Ensure the response is added in the correct format
|
339 |
-
|
340 |
|
341 |
|
342 |
|
|
|
310 |
|
311 |
|
312 |
|
313 |
+
# def bot(history, choice, tts_choice, retrieval_mode):
|
314 |
+
# if not history:
|
315 |
+
# return history
|
316 |
+
|
317 |
+
# response, addresses = generate_answer(history[-1][0], choice, retrieval_mode)
|
318 |
+
# response = f"<div style='font-size: 14px;'>{response}</div>" # Adjust the font size
|
319 |
+
|
320 |
+
# history[-1][1] = ""
|
321 |
+
|
322 |
+
# with concurrent.futures.ThreadPoolExecutor() as executor:
|
323 |
+
# if tts_choice == "Alpha":
|
324 |
+
# audio_future = executor.submit(generate_audio_elevenlabs, response)
|
325 |
+
# elif tts_choice == "Beta":
|
326 |
+
# audio_future = executor.submit(generate_audio_parler_tts, response)
|
327 |
+
# elif tts_choice == "Gamma":
|
328 |
+
# audio_future = executor.submit(generate_audio_mars5, response)
|
329 |
+
|
330 |
+
# for character in response:
|
331 |
+
# history[-1][1] += character
|
332 |
+
# time.sleep(0.05)
|
333 |
+
# yield history, None
|
334 |
+
|
335 |
+
# audio_path = audio_future.result()
|
336 |
+
# yield history, audio_path
|
337 |
+
|
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
|
|
|
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 |
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 |
|