From cee6533fafaf74ab57f0f27217d70af0e2b462e5 Mon Sep 17 00:00:00 2001 From: Binatrix Date: Sun, 9 Jul 2023 10:18:13 -0400 Subject: [PATCH 1/2] Update tts.py - Se ajusta que la llave de API sea proporcionada por el invocador - Se agrega listado de voces y se selecciona cual utilizar --- tts.py | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/tts.py b/tts.py index b7621b5..7d28644 100644 --- a/tts.py +++ b/tts.py @@ -1,18 +1,30 @@ -import os -from dotenv import load_dotenv import requests #Texto a voz. Esta impl utiliza ElevenLabs class TTS(): - def __init__(self): - load_dotenv() - self.key = os.getenv('ELEVENLABS_API_KEY') + voice_dict = { + "Adam": "pNInz6obpgDQGcFmaJgB", + "Antoni": "ErXwobaYiN019PkySvjV", + "Arnold": "VR6AewLTigWG4xSOukaG", + "Bella": "EXAVITQu4vr4xnSDxMaL", + "Domi": "AZnzlk1XvdvUeBnXmlld", + "Elli": "MF3mGyEYCl7XYWbV9V6O", + "Josh": "TxGEqnHWrfWFTfGW9XjX", + "Rachel": "21m00Tcm4TlvDq8ikWAM", + "Sam": "yoZ06aMxZJJ28mfd3POQ" + } + + def __init__(self, key): + self.key = key + def voices(self): + return self.voice_dict + def process(self, text): CHUNK_SIZE = 1024 #Utiliza la voz especifica de Bella #Me robe este codigo de su pagina hoh - url = "https://api.elevenlabs.io/v1/text-to-speech/EXAVITQu4vr4xnSDxMaL" + url = "https://api.elevenlabs.io/v1/text-to-speech/" + self.voice_dict[voice] headers = { "Accept": "audio/mpeg", @@ -38,4 +50,13 @@ def process(self, text): if chunk: f.write(chunk) - return file_name \ No newline at end of file + return file_name + +if __name__ == '__main__': + import os + from dotenv import load_dotenv + load_dotenv() + elevenlabs_key = os.getenv('ELEVENLABS_API_KEY') + tts = TTS(elevenlabs_key) + print(tts.voices()) + tts.process("Esta es una respuesta", "Bella") From 2e2d435062b3f1e3ab7bd7feb4d6f8b70f570679 Mon Sep 17 00:00:00 2001 From: Binatrix Date: Fri, 14 Jul 2023 18:44:20 -0400 Subject: [PATCH 2/2] Update tts.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Se agrega parĂ¡metro "voice" --- tts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tts.py b/tts.py index 7d28644..ae46242 100644 --- a/tts.py +++ b/tts.py @@ -20,7 +20,7 @@ def __init__(self, key): def voices(self): return self.voice_dict - def process(self, text): + def process(self, text, voice): CHUNK_SIZE = 1024 #Utiliza la voz especifica de Bella #Me robe este codigo de su pagina hoh