|
|
|
@ -59,16 +59,11 @@ class TTSEngine:
|
|
|
|
|
|
|
|
|
|
self.call_tts("title", process_text(self.reddit_object["thread_title"]))
|
|
|
|
|
processed_text = process_text(self.reddit_object["thread_post"])
|
|
|
|
|
if (
|
|
|
|
|
processed_text != ""
|
|
|
|
|
and settings.config["settings"]["storymode"] == True
|
|
|
|
|
):
|
|
|
|
|
if processed_text != "" and settings.config["settings"]["storymode"] == True:
|
|
|
|
|
self.call_tts("posttext", processed_text)
|
|
|
|
|
|
|
|
|
|
idx = None
|
|
|
|
|
for idx, comment in track(
|
|
|
|
|
enumerate(self.reddit_object["comments"]), "Saving..."
|
|
|
|
|
):
|
|
|
|
|
for idx, comment in track(enumerate(self.reddit_object["comments"]), "Saving..."):
|
|
|
|
|
# ! Stop creating mp3 files if the length is greater than max length.
|
|
|
|
|
if self.length > self.max_length:
|
|
|
|
|
self.length -= self.last_clip_length
|
|
|
|
@ -95,15 +90,13 @@ class TTSEngine:
|
|
|
|
|
offset = 0
|
|
|
|
|
for idy, text_cut in enumerate(split_text):
|
|
|
|
|
# print(f"{idx}-{idy}: {text_cut}\n")
|
|
|
|
|
new_text = process_text(text_cut)
|
|
|
|
|
new_text = process_text(text_cut)
|
|
|
|
|
if not new_text or new_text.isspace():
|
|
|
|
|
offset += 1
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
self.call_tts(f"{idx}-{idy - offset}.part", new_text)
|
|
|
|
|
split_files.append(
|
|
|
|
|
AudioFileClip(f"{self.path}/{idx}-{idy - offset}.part.mp3")
|
|
|
|
|
)
|
|
|
|
|
split_files.append(AudioFileClip(f"{self.path}/{idx}-{idy - offset}.part.mp3"))
|
|
|
|
|
|
|
|
|
|
CompositeAudioClip([concatenate_audioclips(split_files)]).write_audiofile(
|
|
|
|
|
f"{self.path}/{idx}.mp3", fps=44100, verbose=False, logger=None
|
|
|
|
@ -120,9 +113,7 @@ class TTSEngine:
|
|
|
|
|
# Path(f"{self.path}/{idx}-{i}.part.mp3").unlink()
|
|
|
|
|
|
|
|
|
|
def call_tts(self, filename: str, text: str):
|
|
|
|
|
self.tts_module.run(
|
|
|
|
|
text, filepath=f"{self.path}/{filename}.mp3"
|
|
|
|
|
)
|
|
|
|
|
self.tts_module.run(text, filepath=f"{self.path}/{filename}.mp3")
|
|
|
|
|
# try:
|
|
|
|
|
# self.length += MP3(f"{self.path}/{filename}.mp3").info.length
|
|
|
|
|
# except (MutagenError, HeaderNotFoundError):
|
|
|
|
|