From 3498ffdf098fd1ea85f3104e01b2711cd1f8763c Mon Sep 17 00:00:00 2001 From: Drugsosos <44712637+Drugsosos@users.noreply.github.com> Date: Mon, 11 Jul 2022 21:59:11 +0300 Subject: [PATCH] added crunch for sync tiktok tts --- TTS/TikTok.py | 1 + TTS/engine_wrapper.py | 4 ++-- video_creation/data/videos.json | 11 ++++++++++- video_creation/final_video.py | 1 + 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/TTS/TikTok.py b/TTS/TikTok.py index 743118c..9fa83b7 100644 --- a/TTS/TikTok.py +++ b/TTS/TikTok.py @@ -94,6 +94,7 @@ class TikTok: # TikTok Text-to-Speech Wrapper vstr = [r.json()["data"]["v_str"]][0] b64d = base64.b64decode(vstr) + with open(filepath, "wb") as out: out.write(b64d) diff --git a/TTS/engine_wrapper.py b/TTS/engine_wrapper.py index e41e55c..e8643e1 100644 --- a/TTS/engine_wrapper.py +++ b/TTS/engine_wrapper.py @@ -84,9 +84,9 @@ class TTSEngine: ) clip_length = audio_length(f'assets/temp/mp3/{filename}.mp3') - print(clip_length, '/', self.__total_length) + print(clip_length, '/', self.__total_length) # TODO remove debug - if self.__total_length + clip_length <= self.max_length: + if clip_length and self.__total_length + clip_length <= self.max_length: self.__total_length += clip_length return True return False diff --git a/video_creation/data/videos.json b/video_creation/data/videos.json index 0637a08..0a1ca06 100644 --- a/video_creation/data/videos.json +++ b/video_creation/data/videos.json @@ -1 +1,10 @@ -[] \ No newline at end of file +[ + { + "subreddit": "AskReddit", + "id": "vwgslz", + "time": "1657565829", + "background_credit": "bbswitzer", + "reddit_title": "Which singer should never have been famous", + "filename": "Which singer should never have been famous.mp4" + } +] \ No newline at end of file diff --git a/video_creation/final_video.py b/video_creation/final_video.py index 9989415..5a9a5b0 100755 --- a/video_creation/final_video.py +++ b/video_creation/final_video.py @@ -28,6 +28,7 @@ from video_creation.background import download_background, chop_background_video console = Console() W, H = 1080, 1920 # TODO move to config + max_length: int = 50 # TODO move to config