xJuuzouYTx commited on
Commit
5837809
1 Parent(s): 6f1ebe2

[ADD] elevenlabs tts

Browse files
Files changed (2) hide show
  1. app.py +1 -1
  2. tts/conversion.py +12 -8
app.py CHANGED
@@ -166,7 +166,7 @@ with gr.Blocks() as app:
166
  tts_model_url = gr.Textbox(placeholder="https://huggingface.co/AIVER-SE/BillieEilish/resolve/main/BillieEilish.zip", label="Url del modelo RVC", show_label=True)
167
 
168
  with gr.Row():
169
- tts_method = gr.Dropdown(choices=VOICE_METHODS, value="ElevenLabs", label="Método TTS:", visible=True)
170
  tts_model = gr.Dropdown(choices=ELEVENLABS_VOICES_NAMES, label="Modelo TTS:", visible=True, interactive=True)
171
  tts_api_key = gr.Textbox(label="ElevenLabs Api key", show_label=True, placeholder="4a4afce72349680c8e8b6fdcfaf2b65a",interactive=True)
172
 
 
166
  tts_model_url = gr.Textbox(placeholder="https://huggingface.co/AIVER-SE/BillieEilish/resolve/main/BillieEilish.zip", label="Url del modelo RVC", show_label=True)
167
 
168
  with gr.Row():
169
+ tts_method = gr.Dropdown(choices=VOICE_METHODS, value="Edge-tts", label="Método TTS:", visible=True)
170
  tts_model = gr.Dropdown(choices=ELEVENLABS_VOICES_NAMES, label="Modelo TTS:", visible=True, interactive=True)
171
  tts_api_key = gr.Textbox(label="ElevenLabs Api key", show_label=True, placeholder="4a4afce72349680c8e8b6fdcfaf2b65a",interactive=True)
172
 
tts/conversion.py CHANGED
@@ -8,6 +8,7 @@ import edge_tts
8
  from inference import Inference
9
  import asyncio
10
  from elevenlabs import voices, generate, save
 
11
 
12
  ELEVENLABS_VOICES_RAW = voices()
13
 
@@ -102,14 +103,17 @@ def tts_infer(tts_text, model_url, tts_method, tts_model, tts_api_key):
102
  print("Error: Audio will be replaced.")
103
  success = False
104
  if tts_method == 'ElevenLabs':
105
- audio = generate(
106
- text=tts_text,
107
- voice=tts_model,
108
- model="eleven_multilingual_v2",
109
- api_key=tts_api_key
110
- )
111
- save(audio=audio, filename=converted_tts_filename)
112
- success = True
 
 
 
113
 
114
  if not model_url:
115
  return 'Pon la url del modelo si quieres aplicarle otro tono.', converted_tts_filename
 
8
  from inference import Inference
9
  import asyncio
10
  from elevenlabs import voices, generate, save
11
+ from elevenlabs.api.error import UnauthenticatedRateLimitError
12
 
13
  ELEVENLABS_VOICES_RAW = voices()
14
 
 
103
  print("Error: Audio will be replaced.")
104
  success = False
105
  if tts_method == 'ElevenLabs':
106
+ try:
107
+ audio = generate(
108
+ text=tts_text,
109
+ voice=tts_model,
110
+ model="eleven_multilingual_v2",
111
+ api_key=tts_api_key
112
+ )
113
+ save(audio=audio, filename=converted_tts_filename)
114
+ success = True
115
+ except UnauthenticatedRateLimitError:
116
+ return "Necesitas configurar tu API Key para usar elevenlabs", None
117
 
118
  if not model_url:
119
  return 'Pon la url del modelo si quieres aplicarle otro tono.', converted_tts_filename