You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
732 B
25 lines
732 B
from os import getenv
|
|
|
|
from dotenv import load_dotenv
|
|
|
|
from TTS.GTTS import GTTS
|
|
from TTS.POLLY import POLLY
|
|
from TTS.TikTok import TikTok
|
|
from utils.console import print_substep
|
|
|
|
CHOICE_DIR = {"tiktok": TikTok, "gtts": GTTS, "polly": POLLY}
|
|
|
|
|
|
class TTS:
|
|
def __new__(cls):
|
|
load_dotenv()
|
|
try:
|
|
CHOICE = getenv("TTsChoice").casefold()
|
|
except AttributeError:
|
|
print_substep("None defined. Defaulting to 'polly.'")
|
|
CHOICE = "polly"
|
|
valid_keys = [key.lower() for key in CHOICE_DIR.keys()]
|
|
if CHOICE not in valid_keys:
|
|
raise ValueError(f"{CHOICE} is not valid. Please use one of these {valid_keys} options")
|
|
return CHOICE_DIR.get(CHOICE)()
|