Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -299,73 +299,6 @@ def generate_answer(message, choice, retrieval_mode):
|
|
299 |
|
300 |
|
301 |
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
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
|
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
|
@@ -582,40 +515,7 @@ def show_map_if_details(history, choice):
|
|
582 |
|
583 |
|
584 |
|
585 |
-
|
586 |
-
# # Remove the word "Link" and any URLs from the text
|
587 |
-
# text = re.sub(r'\bLink\b', '', text) # Remove the word "Link"
|
588 |
-
# text = re.sub(r'http\S+', '', text) # Remove URLs
|
589 |
-
# return text.strip() # Remove any extra spaces
|
590 |
-
|
591 |
-
# def generate_audio_elevenlabs(text):
|
592 |
-
# XI_API_KEY = os.getenv('ELEVENLABS_API')
|
593 |
-
# VOICE_ID = 'd9MIrwLnvDeH7aZb61E9'
|
594 |
-
# tts_url = f"https://api.elevenlabs.io/v1/text-to-speech/{VOICE_ID}/stream"
|
595 |
-
# headers = {
|
596 |
-
# "Accept": "application/json",
|
597 |
-
# "xi-api-key": XI_API_KEY
|
598 |
-
# }
|
599 |
-
# data = {
|
600 |
-
# "text": preprocess_for_tts(text), # Apply preprocessing before sending to TTS
|
601 |
-
# "model_id": "eleven_multilingual_v2",
|
602 |
-
# "voice_settings": {
|
603 |
-
# "stability": 1.0,
|
604 |
-
# "similarity_boost": 0.0,
|
605 |
-
# "style": 0.60,
|
606 |
-
# "use_speaker_boost": False
|
607 |
-
# }
|
608 |
-
# }
|
609 |
-
# response = requests.post(tts_url, headers=headers, json=data, stream=True)
|
610 |
-
# if response.ok:
|
611 |
-
# with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as f:
|
612 |
-
# for chunk in response.iter_content(chunk_size=1024):
|
613 |
-
# if chunk:
|
614 |
-
# f.write(chunk)
|
615 |
-
# return f.name
|
616 |
-
# else:
|
617 |
-
# logging.error(f"Error generating audio: {response.text}")
|
618 |
-
# return None
|
619 |
|
620 |
|
621 |
|
|
|
299 |
|
300 |
|
301 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
302 |
def bot(history, choice, tts_choice, retrieval_mode):
|
303 |
if not history:
|
304 |
return history
|
|
|
515 |
|
516 |
|
517 |
|
518 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
519 |
|
520 |
|
521 |
|