feat: Added Unreal Speech TTS

pull/2058/head
Mohamed Moataz 2 years ago
parent 91c2b090cf
commit d2394f9c7b

@ -0,0 +1,47 @@
import random
import requests
from utils import settings
voices = ["Scarlett", "Amy", "Liv", "Dan", "Will"]
class UnrealSpeech:
def __init__(self):
self.url = "https://api.v6.unrealspeech.com/stream"
self.max_chars = 120
self.voices = voices
def run(self, text, filepath, random_voice: bool = False):
if settings.config["settings"]["tts"]["elevenlabs_api_key"]:
api_key = settings.config["settings"]["tts"]["unreal_speech_api_key"]
else:
raise ValueError(
"You didn't set an Unreal Speech API key! Please set the config variable UNREAL_SPEECH_API_KEY to a valid API key."
)
if random_voice:
voice = self.randomvoice()
else:
if not settings.config["settings"]["tts"]["unreal_speech_voice_name"]:
raise ValueError(
f"Please set the config variable UNREAL_SPEECH_VOICE_NAME to a valid voice. options are: {voices}"
)
voice = str(settings.config["settings"]["tts"]["unreal_speech_voice_name"]).capitalize()
json = {
'Text': text, # Up to 1000 characters
'VoiceId': voice, # Dan, Will, Scarlett, Liv, Amy
'Bitrate': '192k', # 320k, 256k, 192k, ...
'Speed': '-0.15', # -1.0 to 1.0
'Pitch': '1.2', # -0.5 to 1.5
'Codec': 'libmp3lame', # libmp3lame or pcm_mulaw
}
headers = {'Authorization' : f'Bearer {api_key}'}
response = requests.post(self.url, headers=headers, json=json)
with open(filepath, 'wb') as f:
f.write(response.content)
def randomvoice(self):
return random.choice(self.voices)

@ -34,7 +34,7 @@ zoom = { optional = true, default = 1, example = 1.1, explanation = "Sets the br
[settings.background] [settings.background]
background_video = { optional = true, default = "minecraft", example = "rocket-league", options = ["minecraft", "gta", "rocket-league", "motor-gta", "csgo-surf", "cluster-truck", "minecraft-2","multiversus","fall-guys","steep", ""], explanation = "Sets the background for the video based on game name" } background_video = { optional = true, default = "minecraft", example = "rocket-league", options = ["minecraft", "gta", "rocket-league", "motor-gta", "csgo-surf", "cluster-truck", "minecraft-2","multiversus","fall-guys","steep", ""], explanation = "Sets the background for the video based on game name" }
background_audio = { optional = true, default = "lofi", example = "chill-summer", options = ["lofi","lofi-2","chill-summer",""], explanation = "Sets the background audio for the video" } background_audio = { optional = true, default = "lofi", example = "chill-summer", options = ["lofi","lofi-2","chill-summer", "eerie",""], explanation = "Sets the background audio for the video" }
background_audio_volume = { optional = true, type = "float", nmin = 0, nmax = 1, default = 0.15, example = 0.05, explanation="Sets the volume of the background audio. If you don't want background audio, set it to 0.", oob_error = "The volume HAS to be between 0 and 1", input_error = "The volume HAS to be a float number between 0 and 1"} background_audio_volume = { optional = true, type = "float", nmin = 0, nmax = 1, default = 0.15, example = 0.05, explanation="Sets the volume of the background audio. If you don't want background audio, set it to 0.", oob_error = "The volume HAS to be between 0 and 1", input_error = "The volume HAS to be a float number between 0 and 1"}
enable_extra_audio = { optional = true, type = "bool", default = false, example = false, explanation="Used if you want to render another video without background audio in a separate folder", input_error = "The value HAS to be true or false"} enable_extra_audio = { optional = true, type = "bool", default = false, example = false, explanation="Used if you want to render another video without background audio in a separate folder", input_error = "The value HAS to be true or false"}
background_thumbnail = { optional = true, type = "bool", default = false, example = false, options = [true, false,], explanation = "Generate a thumbnail for the video (put a thumbnail.png file in the assets/backgrounds directory.)" } background_thumbnail = { optional = true, type = "bool", default = false, example = false, options = [true, false,], explanation = "Generate a thumbnail for the video (put a thumbnail.png file in the assets/backgrounds directory.)" }
@ -43,10 +43,12 @@ 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" } 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] [settings.tts]
voice_choice = { optional = false, default = "tiktok", options = ["elevenlabs", "streamlabspolly", "tiktok", "googletranslate", "awspolly", "pyttsx", ], example = "tiktok", explanation = "The voice platform used for TTS generation. " } voice_choice = { optional = false, default = "tiktok", options = ["elevenlabs", "streamlabspolly", "tiktok", "googletranslate", "awspolly", "pyttsx", "unrealspeech", ], example = "tiktok", explanation = "The voice platform used for TTS generation. " }
random_voice = { optional = false, default = true, example = true, options = [true, false,], explanation = "Randomizes the voice used for each comment" } random_voice = { optional = false, 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 = "Bella", example = "Bella", explanation = "The voice used for elevenlabs", options = ["Adam", "Antoni", "Arnold", "Bella", "Domi", "Elli", "Josh", "Rachel", "Sam", ] }
elevenlabs_api_key = { optional = true, example = "21f13f91f54d741e2ae27d2ab1b99d59", explanation = "Elevenlabs API key" } elevenlabs_api_key = { optional = true, example = "21f13f91f54d741e2ae27d2ab1b99d59", explanation = "Elevenlabs API key" }
unreal_speech_api_key = { optional = true, example = "21f13f91f54d741e2ae27d2ab1b99d59", explanation = "Unreal Speech API key" }
unreal_speech_voice_name = { optional = false, default = "Liv", example = "Liv", explanation = "The voice used for Unreal Speech", options = ["Scarlett", "Amy", "Liv", "Dan", "Will", ] }
aws_polly_voice = { optional = false, default = "Matthew", example = "Matthew", explanation = "The voice used for AWS Polly" } 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" } 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" } tiktok_voice = { optional = true, default = "en_us_001", example = "en_us_006", explanation = "The voice used for TikTok TTS" }

@ -10,6 +10,11 @@
"lofi-2.mp3", "lofi-2.mp3",
"stompsPlaylist" "stompsPlaylist"
], ],
"eerie":[
"https://www.youtube.com/watch?v=OozBNFEa4PM",
"eerie.mp3",
"Royalty Free Music"
],
"chill-summer":[ "chill-summer":[
"https://www.youtube.com/watch?v=EZE8JagnBI8", "https://www.youtube.com/watch?v=EZE8JagnBI8",
"chill-summer.mp3", "chill-summer.mp3",

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

Loading…
Cancel
Save