From 7c31473d963a4b553db679482d010e2dbbd45ce6 Mon Sep 17 00:00:00 2001 From: cyteon Date: Sat, 11 May 2024 12:52:17 +0200 Subject: [PATCH] Fixing some stuff --- TTS/engine_wrapper.py | 3 ++- utils/imagenarator.py | 7 +++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/TTS/engine_wrapper.py b/TTS/engine_wrapper.py index 16056dc..8241c01 100644 --- a/TTS/engine_wrapper.py +++ b/TTS/engine_wrapper.py @@ -93,7 +93,7 @@ class TTSEngine: self.call_tts(f"postaudio-{idx}", process_text(text)) else: - os.makedirs("assets/temp/" + self.redditid + "/png") + os.makedirs("assets/temp/" + self.redditid + "/png", exist_ok=True) 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 and idx > 1: @@ -107,6 +107,7 @@ class TTSEngine: else: # If the comment is not too long, just call the tts engine self.call_tts(f"{idx}", process_text(comment["comment_body"])) + # TODO: Maybe move this somewhere better? comment_image_maker((0, 0, 0, 0), self.reddit_object, comment["comment_body"], idx, (255, 255, 255), transparent=True) print_substep("Saved Text to MP3 files successfully.", style="bold green") diff --git a/utils/imagenarator.py b/utils/imagenarator.py index 0245faa..6cd8fa2 100644 --- a/utils/imagenarator.py +++ b/utils/imagenarator.py @@ -16,6 +16,8 @@ def draw_multiple_line_text( """ Draw multiline text over given image """ + # TODO: Optimize code for comments + draw = ImageDraw.Draw(image) Fontperm = font.getsize(text) image_width, image_height = image.size @@ -25,10 +27,7 @@ def draw_multiple_line_text( line_width, line_height = font.getsize(line) if transparent: shadowcolor = "black" - for i in range( - 1, - 5 if settings.config["storymode"] else 8 # 5 was the normal value but increased to 8 for stuff like askreddit due to clipping - ): + for i in range(1, 5): draw.text( ((image_width - line_width) / 2 - i, y - i), line,