parent
b8c6ae2dc1
commit
dcb42a4939
@ -0,0 +1,7 @@
|
||||
from gtts import gTTS
|
||||
|
||||
|
||||
class GTTS:
|
||||
def tts(self, req_text: str = "Google Text To Speech", filename: str = "title.mp3", random_speaker=False, censer=False):
|
||||
tts = gTTS(text=req_text, lang="en", slow=False)
|
||||
tts.save(f"{filename}")
|
@ -0,0 +1,20 @@
|
||||
from os import getenv
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from TTS.GTTS import GTTS
|
||||
from TTS.TikTok import TikTok
|
||||
|
||||
CHOICE_DIR = {
|
||||
'tiktok': TikTok,
|
||||
'gtts': GTTS
|
||||
}
|
||||
|
||||
class TTS:
|
||||
def __new__(cls):
|
||||
load_dotenv()
|
||||
CHOICE = getenv('TTsChoice').casefold()
|
||||
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)()
|
Loading…
Reference in new issue