|
|
@ -19,18 +19,18 @@ def save_text_to_mp3(reddit_obj):
|
|
|
|
Path("assets/mp3").mkdir(parents=True, exist_ok=True)
|
|
|
|
Path("assets/mp3").mkdir(parents=True, exist_ok=True)
|
|
|
|
|
|
|
|
|
|
|
|
tts = gTTS(text=reddit_obj["thread_title"], lang="en", slow=False)
|
|
|
|
tts = gTTS(text=reddit_obj["thread_title"], lang="en", slow=False)
|
|
|
|
tts.save(f"assets/mp3/title.mp3")
|
|
|
|
tts.save("assets/mp3/title.mp3")
|
|
|
|
length += MP3(f"assets/mp3/title.mp3").info.length
|
|
|
|
length += MP3("assets/mp3/title.mp3").info.length
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
Path(f"assets/mp3/posttext.mp3").unlink()
|
|
|
|
Path("assets/mp3/posttext.mp3").unlink()
|
|
|
|
except OSError as e:
|
|
|
|
except OSError:
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
if reddit_obj["thread_post"] != "":
|
|
|
|
if reddit_obj["thread_post"] != "":
|
|
|
|
tts = gTTS(text=reddit_obj["thread_post"], lang="en", slow=False)
|
|
|
|
tts = gTTS(text=reddit_obj["thread_post"], lang="en", slow=False)
|
|
|
|
tts.save(f"assets/mp3/posttext.mp3")
|
|
|
|
tts.save("assets/mp3/posttext.mp3")
|
|
|
|
length += MP3(f"assets/mp3/posttext.mp3").info.length
|
|
|
|
length += MP3("assets/mp3/posttext.mp3").info.length
|
|
|
|
|
|
|
|
|
|
|
|
for idx, comment in track(enumerate(reddit_obj["comments"]), "Saving..."):
|
|
|
|
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
|
|
|
|
# ! Stop creating mp3 files if the length is greater than 50 seconds. This can be longer, but this is just a good starting point
|
|
|
|