upgraded tts

This commit is contained in:
Saifeddine ALOUI 2024-05-20 17:41:05 +02:00
parent 880015ae82
commit bb9bb2fa92
3 changed files with 18 additions and 3 deletions

View File

@ -106,3 +106,16 @@ class LollmsOpenAITTS(LollmsTTS):
# Example usage
play_audio(speech_file_path)
def tts_file(self, text, speaker=None, file_name_or_path:Path|str=None, language="en", use_threading=False):
speech_file_path = file_name_or_path
response = self.client.audio.speech.create(
model=self.model,
voice=self.voice,
input=text,
response_format="wav"
)
response.write_to_file(speech_file_path)
return file_name_or_path

View File

@ -259,7 +259,7 @@ class LollmsXTTS(LollmsTTS):
print("Request failed with status code:", response.status_code)
return False
def tts_file(self, text, speaker, file_name_or_path, language="en"):
def tts_file(self, text, file_name_or_path, speaker=None, language="en")->str:
url = f"{self.xtts_base_url}/tts_file"
# Define the request body
@ -284,6 +284,8 @@ class LollmsXTTS(LollmsTTS):
else:
print("Request failed with status code:", response.status_code)
return file_name_or_path
def tts_audio(self, text, speaker, file_name_or_path:Path|str=None, language="en", use_threading=False):
voice=self.app.config.xtts_current_voice if speaker is None else speaker
index = find_first_available_file_index(self.output_folder, "voice_sample_",".wav")

View File

@ -62,7 +62,7 @@ class LollmsTTS:
self.voices = [] # To be filled by the child class
self.models = [] # To be filled by the child class
def tts_file(self, text, speaker, file_name_or_path, language="en"):
def tts_file(self, text, file_name_or_path, speaker=None, language="en")->str:
"""
Converts the given text to speech and saves it to a file.