Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -352,11 +352,42 @@ 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 |
-
|
|
|
|
|
|
|
|
|
360 |
|
361 |
with concurrent.futures.ThreadPoolExecutor() as executor:
|
362 |
if tts_choice == "Alpha":
|
@@ -379,7 +410,6 @@ def add_message(history, message):
|
|
379 |
history.append([message, ""]) # Ensure it is a list with two elements: message and empty response
|
380 |
return history, gr.Textbox(value="", interactive=True, placeholder="Enter message or upload file...", show_label=False)
|
381 |
|
382 |
-
|
383 |
# def generate_voice_response(history, tts_choice):
|
384 |
# if not history:
|
385 |
# return None
|
|
|
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 add_message(history, message):
|
378 |
+
# history = history or []
|
379 |
+
# history.append([message, ""]) # Ensure it is a list with two elements: message and empty response
|
380 |
+
# return history, gr.Textbox(value="", interactive=True, placeholder="Enter message or upload file...", show_label=False)
|
381 |
+
|
382 |
def bot(history, choice, tts_choice):
|
383 |
if not history:
|
384 |
return history
|
385 |
response_pair, addresses = generate_answer(history[-1][0], choice)
|
386 |
+
# Ensure history has the correct format
|
387 |
+
if len(history[-1]) == 1:
|
388 |
+
history[-1].append("")
|
389 |
+
elif len(history[-1]) == 0:
|
390 |
+
history[-1] = [history[-1][0], ""]
|
391 |
|
392 |
with concurrent.futures.ThreadPoolExecutor() as executor:
|
393 |
if tts_choice == "Alpha":
|
|
|
410 |
history.append([message, ""]) # Ensure it is a list with two elements: message and empty response
|
411 |
return history, gr.Textbox(value="", interactive=True, placeholder="Enter message or upload file...", show_label=False)
|
412 |
|
|
|
413 |
# def generate_voice_response(history, tts_choice):
|
414 |
# if not history:
|
415 |
# return None
|