MCPcopy Index your code
hub / github.com/elebumm/RedditVideoMakerBot / run

Method run

TTS/engine_wrapper.py:69–103  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

67 comment["comment_body"] = re.sub(r'\."\.', '".', comment["comment_body"])
68
69 def run(self) -> Tuple[int, int]:
70 Path(self.path).mkdir(parents=True, exist_ok=True)
71 print_step("Saving Text to MP3 files...")
72
73 self.add_periods()
74 self.call_tts("title", process_text(self.reddit_object["thread_title"]))
75 # processed_text = ##self.reddit_object["thread_post"] != ""
76 idx = 0
77
78 if settings.config["settings"]["storymode"]:
79 if settings.config["settings"]["storymodemethod"] == 0:
80 if len(self.reddit_object["thread_post"]) > self.tts_module.max_chars:
81 self.split_post(self.reddit_object["thread_post"], "postaudio")
82 else:
83 self.call_tts("postaudio", process_text(self.reddit_object["thread_post"]))
84 elif settings.config["settings"]["storymodemethod"] == 1:
85 for idx, text in track(enumerate(self.reddit_object["thread_post"])):
86 self.call_tts(f"postaudio-{idx}", process_text(text))
87
88 else:
89 for idx, comment in track(enumerate(self.reddit_object["comments"]), "Saving..."):
90 # ! Stop creating mp3 files if the length is greater than max length.
91 if self.length > self.max_length and idx > 1:
92 self.length -= self.last_clip_length
93 idx -= 1
94 break
95 if (
96 len(comment["comment_body"]) > self.tts_module.max_chars
97 ): # Split the comment if it is too long
98 self.split_post(comment["comment_body"], idx) # Split the comment
99 else: # If the comment is not too long, just call the tts engine
100 self.call_tts(f"{idx}", process_text(comment["comment_body"]))
101
102 print_substep("Saved Text to MP3 files successfully.", style="bold green")
103 return self.length, idx
104
105 def split_post(self, text: str, idx):
106 split_files = []

Callers 2

save_text_to_mp3Function · 0.95
call_ttsMethod · 0.45

Calls 6

add_periodsMethod · 0.95
call_ttsMethod · 0.95
split_postMethod · 0.95
print_stepFunction · 0.90
print_substepFunction · 0.90
process_textFunction · 0.85

Tested by

no test coverage detected