From 3115155d894329a4e94bb82cd18e56d3a0c96289 Mon Sep 17 00:00:00 2001 From: MeDBeD1 <82283979+MeDBeD1@users.noreply.github.com> Date: Sun, 5 Jun 2022 08:59:26 +1000 Subject: [PATCH] Added a check for selftext if selftext file exists it gets deleted and recreated if it is present in the thread --- video_creation/voices.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/video_creation/voices.py b/video_creation/voices.py index 56a2b23..c0df8b7 100644 --- a/video_creation/voices.py +++ b/video_creation/voices.py @@ -21,6 +21,11 @@ def save_text_to_mp3(reddit_obj): tts.save(f"assets/mp3/title.mp3") length += MP3(f"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")