Added a check for selftext

if selftext file exists it gets deleted and recreated if it is present in the thread
This commit is contained in:
MeDBeD1 authored and GitHub committed 2022-06-05 08:59:26 +10:00
1 parent 6f6b7ad3fc
commit 3115155d89
1 file changed
+5
+5
View File
@@ -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")