From c85d1c77cb9bb14f0d8d6af6cdae943188e8b2a3 Mon Sep 17 00:00:00 2001 From: iaacornus Date: Tue, 7 Jun 2022 20:39:45 +0800 Subject: [PATCH] little changes --- video_creation/final_video.py | 2 +- video_creation/voices.py | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/video_creation/final_video.py b/video_creation/final_video.py index 5758146..3ea3101 100644 --- a/video_creation/final_video.py +++ b/video_creation/final_video.py @@ -80,7 +80,7 @@ def make_final_video(number_of_clips, file_name): if file_name is None: filename = re.sub( - '[?\"%*:|<>]', '', (f"assets/{reddit.subreddit.submission.title}.mp4") + "[?\"%*:|<>]", "", (f"assets/{reddit.subreddit.submission.title}.mp4") ) final.write_videofile(filename, fps=30, audio_codec="aac", audio_bitrate="192k") diff --git a/video_creation/voices.py b/video_creation/voices.py index f8b304e..c6df660 100644 --- a/video_creation/voices.py +++ b/video_creation/voices.py @@ -1,9 +1,9 @@ +import re from pathlib import Path from gtts import gTTS from mutagen.mp3 import MP3 from rich.progress import track -import re from utils.console import print_step, print_substep @@ -40,8 +40,13 @@ def save_text_to_mp3(reddit_obj): # ! This can be longer, but this is just a good starting point if length > 50: break - comment=comment["comment_body"] - text=re.sub('((http|https)\:\/\/)?[a-zA-Z0-9\.\/\?\:@\-_=#]+\.([a-zA-Z]){2,6}([a-zA-Z0-9\.\&\/\?\:@\-_=#])*', '', comment) + comment = comment["comment_body"] + text = re.sub( + "((http|https)\:\/\/)?[a-zA-Z0-9\.\/\?\:@\-_=#]+" + + "\.([a-zA-Z]){2,6}([a-zA-Z0-9\.\&\/\?\:@\-_=#])*", + "", + comment + ) tts = gTTS(text, lang="en", slow=False) tts.save(f"assets/mp3/{idx}.mp3") length += MP3(f"assets/mp3/{idx}.mp3").info.length