From cb775cba9c73cebe98afd1b4d6142ff2ba8ace03 Mon Sep 17 00:00:00 2001 From: John Toniutti Date: Mon, 26 Sep 2022 18:23:56 +0200 Subject: [PATCH] Add default argument --- TTS/TikTok.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/TTS/TikTok.py b/TTS/TikTok.py index 64372bd..6bd7f50 100644 --- a/TTS/TikTok.py +++ b/TTS/TikTok.py @@ -78,7 +78,6 @@ vocals = ( class TikTok: """TikTok Text-to-Speech Wrapper""" - max_chars: Final = 300 BASE_URL: Final = "https://api16-normal-c-useast1a.tiktokv.com/media/api/text/speech/invoke/" def __init__(self): @@ -95,8 +94,8 @@ class TikTok: if random_voice: voice = self.random_voice() else: - # if tiktok_voice is not set in the config file, then it will automatically choose one - voice = settings.config["settings"]["tts"].get("tiktok_voice") + # if tiktok_voice is not set in the config file, then use a random voice + voice = settings.config["settings"]["tts"].get("tiktok_voice", None) # get the audio from the TikTok API data = self.get_voices(voice=voice, text=text) @@ -107,7 +106,7 @@ class TikTok: raise TikTokTTSException(status_code, data["message"]) # decode data from base64 to binary - raw_voices = [data["data"]["v_str"]][0] + raw_voices = data["data"]["v_str"] decoded_voices = base64.b64decode(raw_voices) # write voices to specified filepath @@ -117,7 +116,7 @@ class TikTok: def get_voices(self, text: str, voice: Optional[str] = None) -> dict: """If voice is not passed, the API will try to use the most fitting voice""" # sanitize text - text = text.replace("+", "plus").replace(" ", "+").replace("&", "and").replace("r/", "") + text = text.replace("+", "plus").replace("&", "and").replace("r/", "") # prepare url request params = {