feat: elevenlabs tts

This commit is contained in:
Alex
2024-11-02 16:43:28 +00:00
parent 0bb014c965
commit 9ca079c95a
3 changed files with 36 additions and 7 deletions

View File

@@ -5,14 +5,14 @@ from application.tts.base import BaseTTS
class GoogleTTS(BaseTTS):
def __init__(self, text):
self.text = text
def __init__(self):
pass
def text_to_speech(self):
def text_to_speech(self, text):
lang = "en"
audio_fp = io.BytesIO()
tts = gTTS(text=self.text, lang=lang, slow=False)
tts = gTTS(text=text, lang=lang, slow=False)
tts.write_to_fp(audio_fp)
audio_fp.seek(0)
audio_base64 = base64.b64encode(audio_fp.read()).decode("utf-8")