From 24863a9940814c577280fdedfff8a8a80e73eeef Mon Sep 17 00:00:00 2001 From: CordlessCoder Date: Mon, 6 Jun 2022 21:20:08 +0300 Subject: [PATCH] video_creation surface level refactor --- video_creation/final_video.py | 10 +++++----- video_creation/voices.py | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/video_creation/final_video.py b/video_creation/final_video.py index 8a635d6..3cbed3a 100644 --- a/video_creation/final_video.py +++ b/video_creation/final_video.py @@ -39,9 +39,9 @@ def make_final_video(number_of_clips): audio_clips = [] for i in range(0, number_of_clips): audio_clips.append(AudioFileClip(f"assets/mp3/{i}.mp3")) - audio_clips.insert(0, AudioFileClip(f"assets/mp3/title.mp3")) + audio_clips.insert(0, AudioFileClip("assets/mp3/title.mp3")) try: - audio_clips.insert(1, AudioFileClip(f"assets/mp3/posttext.mp3")) + audio_clips.insert(1, AudioFileClip("assets/mp3/posttext.mp3")) except: OSError() audio_concat = concatenate_audioclips(audio_clips) @@ -57,10 +57,10 @@ def make_final_video(number_of_clips): .resize(width=W - 100) .set_opacity(float(opacity)), ) - if os.path.exists(f"assets/mp3/posttext.mp3"): + if os.path.exists("assets/mp3/posttext.mp3"): image_clips.insert( 0, - ImageClip(f"assets/png/title.png") + ImageClip("assets/png/title.png") .set_duration(audio_clips[0].duration + audio_clips[1].duration) .set_position("center") .resize(width=W - 100) @@ -69,7 +69,7 @@ def make_final_video(number_of_clips): else: image_clips.insert( 0, - ImageClip(f"assets/png/title.png") + ImageClip("assets/png/title.png") .set_duration(audio_clips[0].duration) .set_position("center") .resize(width=W - 100) diff --git a/video_creation/voices.py b/video_creation/voices.py index 5a64f7b..3d54c40 100644 --- a/video_creation/voices.py +++ b/video_creation/voices.py @@ -19,18 +19,18 @@ def save_text_to_mp3(reddit_obj): Path("assets/mp3").mkdir(parents=True, exist_ok=True) tts = gTTS(text=reddit_obj["thread_title"], lang="en", slow=False) - tts.save(f"assets/mp3/title.mp3") - length += MP3(f"assets/mp3/title.mp3").info.length + tts.save("assets/mp3/title.mp3") + length += MP3("assets/mp3/title.mp3").info.length try: - Path(f"assets/mp3/posttext.mp3").unlink() - except OSError as e: + Path("assets/mp3/posttext.mp3").unlink() + except OSError: pass if reddit_obj["thread_post"] != "": tts = gTTS(text=reddit_obj["thread_post"], lang="en", slow=False) - tts.save(f"assets/mp3/posttext.mp3") - length += MP3(f"assets/mp3/posttext.mp3").info.length + tts.save("assets/mp3/posttext.mp3") + length += MP3("assets/mp3/posttext.mp3").info.length for idx, comment in track(enumerate(reddit_obj["comments"]), "Saving..."): # ! Stop creating mp3 files if the length is greater than 50 seconds. This can be longer, but this is just a good starting point