diff --git a/TTS/elevenlabs.py b/TTS/elevenlabs.py index c1f478e..49a34b4 100644 --- a/TTS/elevenlabs.py +++ b/TTS/elevenlabs.py @@ -1,11 +1,8 @@ import random - from elevenlabs import save from elevenlabs.client import ElevenLabs - from utils import settings - class elevenlabs: def __init__(self): self.max_chars = 2500 @@ -17,9 +14,14 @@ class elevenlabs: if random_voice: voice = self.randomvoice() else: - voice = str(settings.config["settings"]["tts"]["elevenlabs_voice_name"]).capitalize() - - audio = self.client.generate(text=text, voice=voice, model="eleven_multilingual_v1") + voice_name = str(settings.config["settings"]["tts"]["elevenlabs_voice_name"]) + all_voices = self.client.voices.get_all().voices + matched = [v for v in all_voices if v.name.lower() == voice_name.lower()] + if matched: + voice = matched[0].voice_id + else: + raise ValueError(f"Voice '{voice_name}' not found in your ElevenLabs account.") + audio = self.client.generate(text=text, voice=voice, model="eleven_multilingual_v2") save(audio=audio, filename=filepath) def initialize(self): @@ -27,12 +29,11 @@ class elevenlabs: api_key = settings.config["settings"]["tts"]["elevenlabs_api_key"] else: raise ValueError( - "You didn't set an Elevenlabs API key! Please set the config variable ELEVENLABS_API_KEY to a valid API key." + "You didn't set an Elevenlabs API key!" ) - self.client = ElevenLabs(api_key=api_key) def randomvoice(self): if self.client is None: self.initialize() - return random.choice(self.client.voices.get_all().voices).name + return random.choice(self.client.voices.get_all().voices).voice_id diff --git a/utils/.config.template.toml b/utils/.config.template.toml index 9b13657..52eeb06 100644 --- a/utils/.config.template.toml +++ b/utils/.config.template.toml @@ -47,7 +47,7 @@ background_thumbnail_font_color = { optional = true, default = "255,255,255", ex [settings.tts] voice_choice = { optional = false, default = "tiktok", options = ["elevenlabs", "streamlabspolly", "tiktok", "googletranslate", "awspolly", "pyttsx", "OpenAI"], example = "tiktok", explanation = "The voice platform used for TTS generation. " } random_voice = { optional = false, type = "bool", default = true, example = true, options = [true, false,], explanation = "Randomizes the voice used for each comment" } -elevenlabs_voice_name = { optional = false, default = "Bella", example = "Bella", explanation = "The voice used for elevenlabs", options = ["Adam", "Antoni", "Arnold", "Bella", "Domi", "Elli", "Josh", "Rachel", "Sam", ] } +elevenlabs_voice_name = { optional = false, default = "Sarah - Mature, Reassuring, Confident", example = "Bella", explanation = "The voice used for elevenlabs", options = [] } 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" } diff --git a/video_creation/final_video.py b/video_creation/final_video.py index c4f3a0b..b231cda 100644 --- a/video_creation/final_video.py +++ b/video_creation/final_video.py @@ -261,7 +261,7 @@ def make_final_video( audio_concat = ffmpeg.concat(*audio_clips, a=1, v=0) ffmpeg.output( audio_concat, f"assets/temp/{reddit_id}/audio.mp3", **{"b:a": "192k"} - ).overwrite_output().run(quiet=True) + ).overwrite_output().run(quiet=False) console.log(f"[bold green] Video Will Be: {length} Seconds Long")