From 7765c9b0186710793158fe54b9e96fee9902e87b Mon Sep 17 00:00:00 2001 From: Callum Leslie Date: Sun, 19 Jun 2022 21:55:13 +0100 Subject: [PATCH] Fix small bugs and path issues --- TTS/engine_wrapper.py | 3 +-- reddit/subreddit.py | 18 +++++++++++++----- utils/voice.py | 2 +- video_creation/data/videos.json | 10 +++++++++- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/TTS/engine_wrapper.py b/TTS/engine_wrapper.py index 4c1c2c8..5e4ddb0 100644 --- a/TTS/engine_wrapper.py +++ b/TTS/engine_wrapper.py @@ -28,7 +28,7 @@ class TTSEngine: self, tts_module, reddit_object: dict, - path: str = "assets/mp3", + path: str = "assets/temp/mp3", max_length: int = 50, ): self.tts_module = tts_module() @@ -54,7 +54,6 @@ class TTSEngine: self.reddit_object["thread_post"] != "" and getenv("STORYMODE", "").casefold() == "true" ): - self.call_tts("posttext", sanitize_text(self.reddit_object["thread_post"])) idx = None diff --git a/reddit/subreddit.py b/reddit/subreddit.py index 7c5db91..124380b 100644 --- a/reddit/subreddit.py +++ b/reddit/subreddit.py @@ -31,7 +31,9 @@ def get_subreddit_threads(): content = {} if str(getenv("REDDIT_2FA")).casefold() == "yes": - print("\nEnter your two-factor authentication code from your authenticator app.\n") + print( + "\nEnter your two-factor authentication code from your authenticator app.\n" + ) code = input("> ") print() pw = getenv("REDDIT_PASSWORD") @@ -55,14 +57,18 @@ def get_subreddit_threads(): ): # note to user. you can have multiple subreddits via reddit.subreddit("redditdev+learnpython") try: subreddit = reddit.subreddit( - re.sub(r"r\/", "", input("What subreddit would you like to pull from? ")) + re.sub( + r"r\/", "", input("What subreddit would you like to pull from? ") + ) # removes the r/ from the input ) except ValueError: subreddit = reddit.subreddit("askreddit") print_substep("Subreddit not defined. Using AskReddit.") else: - print_substep(f"Using subreddit: r/{getenv('SUBREDDIT')} from environment variable config") + print_substep( + f"Using subreddit: r/{getenv('SUBREDDIT')} from environment variable config" + ) subreddit = reddit.subreddit( getenv("SUBREDDIT") ) # Allows you to specify in .env. Done for automation purposes. @@ -83,12 +89,14 @@ def get_subreddit_threads(): print_substep(f"Thread has {upvotes} upvotes", style="bold blue") print_substep(f"Thread has a upvote ratio of {ratio}%", style="bold blue") print_substep(f"Thread has {num_comments} comments", style="bold blue") - environ["VIDEO_TITLE"] = str(textify(submission.title)) # todo use global instend of env vars + environ["VIDEO_TITLE"] = str( + textify(submission.title) + ) # todo use global instend of env vars environ["VIDEO_ID"] = str(textify(submission.id)) content["thread_url"] = f"https://reddit.com{submission.permalink}" content["thread_title"] = submission.title - # content["thread_content"] = submission.content + content["thread_post"] = submission.selftext content["comments"] = [] for top_level_comment in submission.comments: if isinstance(top_level_comment, MoreComments): diff --git a/utils/voice.py b/utils/voice.py index 7aed2ad..63e8eff 100644 --- a/utils/voice.py +++ b/utils/voice.py @@ -17,6 +17,6 @@ def sanitize_text(text): # note: not removing apostrophes regex_expr = r"\s['|’]|['|’]\s|[\^_~@!&;#:\-%“”‘\"%\*/{}\[\]\(\)\\|<>=+]" result = re.sub(regex_expr, " ", result) - result = result.replace("+", "plus").replace(" ", "+").replace("&", "and") + result = result.replace("+", "plus").replace("&", "and") # remove extra whitespace return " ".join(result.split()) diff --git a/video_creation/data/videos.json b/video_creation/data/videos.json index fe51488..8969b7b 100644 --- a/video_creation/data/videos.json +++ b/video_creation/data/videos.json @@ -1 +1,9 @@ -[] +[ + { + "id": "vfxpph", + "time": "1655671664", + "background_credit": "bbswitzer", + "reddit_title": "What unimpressive things are people idiotically proud of", + "filename": "What unimpressive things are p....mp4" + } +] \ No newline at end of file