|
|
@ -57,12 +57,13 @@ class TTSEngine:
|
|
|
|
|
|
|
|
|
|
|
|
print_step("Saving Text to MP3 files...")
|
|
|
|
print_step("Saving Text to MP3 files...")
|
|
|
|
|
|
|
|
|
|
|
|
self.call_tts("title", self.reddit_object["thread_title"])
|
|
|
|
self.call_tts("title", process_text(self.reddit_object["thread_title"]))
|
|
|
|
|
|
|
|
processed_text = process_text(self.reddit_object["thread_post"])
|
|
|
|
if (
|
|
|
|
if (
|
|
|
|
self.reddit_object["thread_post"] != ""
|
|
|
|
processed_text != ""
|
|
|
|
and settings.config["settings"]["storymode"] == True
|
|
|
|
and settings.config["settings"]["storymode"] == True
|
|
|
|
):
|
|
|
|
):
|
|
|
|
self.call_tts("posttext", self.reddit_object["thread_post"])
|
|
|
|
self.call_tts("posttext", processed_text)
|
|
|
|
|
|
|
|
|
|
|
|
idx = None
|
|
|
|
idx = None
|
|
|
|
for idx, comment in track(
|
|
|
|
for idx, comment in track(
|
|
|
@ -78,7 +79,7 @@ class TTSEngine:
|
|
|
|
): # Split the comment if it is too long
|
|
|
|
): # Split the comment if it is too long
|
|
|
|
self.split_post(comment["comment_body"], idx) # Split the comment
|
|
|
|
self.split_post(comment["comment_body"], idx) # Split the comment
|
|
|
|
else: # If the comment is not too long, just call the tts engine
|
|
|
|
else: # If the comment is not too long, just call the tts engine
|
|
|
|
self.call_tts(f"{idx}", comment["comment_body"])
|
|
|
|
self.call_tts(f"{idx}", process_text(comment["comment_body"]))
|
|
|
|
|
|
|
|
|
|
|
|
print_substep("Saved Text to MP3 files successfully.", style="bold green")
|
|
|
|
print_substep("Saved Text to MP3 files successfully.", style="bold green")
|
|
|
|
return self.length, idx
|
|
|
|
return self.length, idx
|
|
|
@ -94,11 +95,12 @@ class TTSEngine:
|
|
|
|
offset = 0
|
|
|
|
offset = 0
|
|
|
|
for idy, text_cut in enumerate(split_text):
|
|
|
|
for idy, text_cut in enumerate(split_text):
|
|
|
|
# print(f"{idx}-{idy}: {text_cut}\n")
|
|
|
|
# print(f"{idx}-{idy}: {text_cut}\n")
|
|
|
|
if not text_cut or text_cut.isspace():
|
|
|
|
new_text = process_text(text_cut)
|
|
|
|
|
|
|
|
if not new_text or new_text.isspace():
|
|
|
|
offset += 1
|
|
|
|
offset += 1
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
|
self.call_tts(f"{idx}-{idy - offset}.part", text_cut)
|
|
|
|
self.call_tts(f"{idx}-{idy - offset}.part", new_text)
|
|
|
|
split_files.append(
|
|
|
|
split_files.append(
|
|
|
|
AudioFileClip(f"{self.path}/{idx}-{idy - offset}.part.mp3")
|
|
|
|
AudioFileClip(f"{self.path}/{idx}-{idy - offset}.part.mp3")
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -119,7 +121,7 @@ class TTSEngine:
|
|
|
|
|
|
|
|
|
|
|
|
def call_tts(self, filename: str, text: str):
|
|
|
|
def call_tts(self, filename: str, text: str):
|
|
|
|
self.tts_module.run(
|
|
|
|
self.tts_module.run(
|
|
|
|
text=process_text(text), filepath=f"{self.path}/{filename}.mp3"
|
|
|
|
text, filepath=f"{self.path}/{filename}.mp3"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
# try:
|
|
|
|
# try:
|
|
|
|
# self.length += MP3(f"{self.path}/{filename}.mp3").info.length
|
|
|
|
# self.length += MP3(f"{self.path}/{filename}.mp3").info.length
|
|
|
|