From 3783e710b7f563e5361ec52894f82e6ff50b11f7 Mon Sep 17 00:00:00 2001 From: Saifeddine ALOUI Date: Sun, 24 Dec 2023 02:22:15 +0100 Subject: [PATCH] upgraded --- api/__init__.py | 23 ++++++++++++++++++++++- lollms_core | 2 +- zoos/bindings_zoo | 2 +- zoos/personalities_zoo | 2 +- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/api/__init__.py b/api/__init__.py index 67e5d6f2..e790ebd3 100644 --- a/api/__init__.py +++ b/api/__init__.py @@ -47,6 +47,26 @@ if not PackageManager.check_package_installed("bs4"): import requests from bs4 import BeautifulSoup + +def convert_language_name(language_name): + # Remove leading and trailing spaces + language_name = language_name.strip() + + # Convert to lowercase + language_name = language_name.lower().replace(".","") + + # Define a dictionary mapping language names to their codes + language_codes = { + "english": "en", + "spanish": "es", + "french": "fr", + "german": "de", + # Add more language names and codes as needed + } + + # Return the corresponding language code if found, or None otherwise + return language_codes.get(language_name) + def terminate_thread(thread): if thread: if not thread.is_alive(): @@ -2062,11 +2082,12 @@ class LoLLMsAPI(LollmsApplication): from lollms.audio_gen_modules.lollms_xtts import LollmsXTTS if self.tts is None: self.tts = LollmsXTTS(self, voice_samples_path=Path(self.personality.audio_samples[0]).parent) + language = convert_language_name(self.personality.language) self.tts.set_speaker_folder(Path(self.personality.audio_samples[0]).parent) fn = self.personality.name.lower().replace(' ',"_").replace('.','') fn = f"{fn}_{message_id}.wav" url = f"audio/{fn}" - self.tts.tts_to_file(self.connections[client_id]["generated_text"], Path(self.personality.audio_samples[0]).name, f"{fn}", language="en") + self.tts.tts_to_file(self.connections[client_id]["generated_text"], Path(self.personality.audio_samples[0]).name, f"{fn}", language=language) fl = f"""