From 276c0679b565c291f901569d55605459c6c4c2de Mon Sep 17 00:00:00 2001 From: liamb Date: Wed, 3 May 2023 11:47:57 +1000 Subject: [PATCH] add periods fix --- TTS/engine_wrapper.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/TTS/engine_wrapper.py b/TTS/engine_wrapper.py index e6b92d8..f040bf7 100644 --- a/TTS/engine_wrapper.py +++ b/TTS/engine_wrapper.py @@ -55,9 +55,20 @@ class TTSEngine: self, ): # adds periods to the end of paragraphs (where people often forget to put them) so tts doesn't blend sentences for comment in self.reddit_object["comments"]: + # remove links + regex_urls = r"((http|https)\:\/\/)?[a-zA-Z0-9\.\/\?\:@\-_=#]+\.([a-zA-Z]){2,6}([a-zA-Z0-9\.\&\/\?\:@\-_=#])*" + comment["comment_body"] = re.sub(regex_urls, " ", comment["comment_body"]) comment["comment_body"] = comment["comment_body"].replace("\n", ". ") + comment["comment_body"] = re.sub(r'\bAI\b', 'A.I', comment["comment_body"]) + comment["comment_body"] = re.sub(r'\bAGI\b', 'A.G.I', comment["comment_body"]) if comment["comment_body"][-1] != ".": comment["comment_body"] += "." + comment["comment_body"] = comment["comment_body"].replace(". . .", ".") + comment["comment_body"] = comment["comment_body"].replace(".. . ", ".") + comment["comment_body"] = comment["comment_body"].replace(". . ", ".") + comment["comment_body"] = re.sub(r'\."\.', '".', comment["comment_body"]) + print(comment["comment_body"]) + def run(self) -> Tuple[int, int]: Path(self.path).mkdir(parents=True, exist_ok=True)