From 4bea2372dcc03880d5687221b8af823f1e8f75b3 Mon Sep 17 00:00:00 2001 From: iaacornus Date: Mon, 6 Jun 2022 18:17:12 +0800 Subject: [PATCH] from the merge request, no changes --- video_creation/voices.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/video_creation/voices.py b/video_creation/voices.py index 7e711b6..e2eeb68 100644 --- a/video_creation/voices.py +++ b/video_creation/voices.py @@ -24,6 +24,16 @@ def save_text_to_mp3(reddit_obj): tts.save("assets/mp3/title.mp3") length += MP3("assets/mp3/title.mp3").info.length + try: + Path(f"assets/mp3/posttext.mp3").unlink() + except OSError as e: + pass + + if reddit_obj["thread_post"] != "": + tts = gTTS(text=reddit_obj["thread_post"], lang="en", slow=False) + tts.save(f"assets/mp3/posttext.mp3") + length += MP3(f"assets/mp3/posttext.mp3").info.length + for idx, comment in track(enumerate(reddit_obj["comments"]), "Saving..."): # ! Stop creating mp3 files if the length is greater than 50 seconds. # ! This can be longer, but this is just a good starting point