adds elevenlabs

pull/1619/head
liamb 2 years ago
parent 68c523fb35
commit d19dfac8a3

@ -0,0 +1,46 @@
import random
from elevenlabs import generate, save
from utils import settings
class elevenlabs:
def __init__(self):
self.max_chars = 5000
self.voices = ["Adam", "Antoni", "Arnold", "Bella", "Domi", "Elli", "Josh", "Rachel", "Sam"]
def run(
self,
text: str,
filepath: str,
random_voice=False,
):
voice_name = settings.config["settings"]["tts"]["elevenlabs_voice_name"]
if voice_name == "":
voice_name = "Bella"
raise ValueError(
"set elevenlabs name value to a valid value, switching to default voice (Bella)"
)
if random_voice:
voice_name = self.randomvoice()
if settings.config["settings"]["tts"]["elevenlabs_api_key"]:
api_key = settings.config["settings"]["tts"]["elevenlabs_api_key"]
else:
api_key = None
print("set elevenlabs api key value to a valid value or quota will be limited")
audio = generate(
api_key=api_key,
text=text,
voice=voice_name,
model="eleven_monolingual_v1"
)
save(
audio=audio,
filename=f"{filepath}"
)
def randomvoice(self):
return random.choice(self.voices)

@ -20,3 +20,4 @@ spacy==3.4.1
torch==1.12.1
transformers==4.25.1
ffmpeg-python==0.2.0
elevenlabs==0.2.10

@ -42,7 +42,9 @@ background_thumbnail_font_size = { optional = true, type = "int", default = 96,
background_thumbnail_font_color = { optional = true, default = "255,255,255", example = "255,255,255", explanation = "Font color in RGB format for the thumbnail text" }
[settings.tts]
voice_choice = { optional = false, default = "tiktok", options = ["streamlabspolly", "tiktok", "googletranslate", "awspolly", "pyttsx", ], example = "tiktok", explanation = "The voice platform used for TTS generation. This can be left blank and you will be prompted to choose at runtime." }
voice_choice = { optional = false, default = "tiktok", options = ["elevenlabs", "streamlabspolly", "tiktok", "googletranslate", "awspolly", "pyttsx", ], example = "tiktok", explanation = "The voice platform used for TTS generation. This can be left blank and you will be prompted to choose at runtime." }
elevenlabs_voice_name = { optional = false, default = "Bella", example = "Bella", explanation = "The voice used for elevenlabs" }
elevenlabs_api_key = { optional = true, example = "21f13f91f54d741e2ae27d2ab1b99d59", explanation = "Elevenlabs API key" }
aws_polly_voice = { optional = false, default = "Matthew", example = "Matthew", explanation = "The voice used for AWS Polly" }
streamlabs_polly_voice = { optional = false, default = "Matthew", example = "Matthew", explanation = "The voice used for Streamlabs Polly" }
tiktok_voice = { optional = true, default = "en_us_001", example = "en_us_006", explanation = "The voice used for TikTok TTS" }

@ -7,6 +7,7 @@ from TTS.TikTok import TikTok
from TTS.aws_polly import AWSPolly
from TTS.engine_wrapper import TTSEngine
from TTS.pyttsx import pyttsx
from TTS.elevenlabs import elevenlabs
from TTS.streamlabs_polly import StreamlabsPolly
from utils import settings
from utils.console import print_table, print_step
@ -19,6 +20,7 @@ TTSProviders = {
"StreamlabsPolly": StreamlabsPolly,
"TikTok": TikTok,
"pyttsx": pyttsx,
"ElevenLabs": elevenlabs
}

Loading…
Cancel
Save