diff --git a/TTS/engine_wrapper.py b/TTS/engine_wrapper.py index bbe4e9a8f..3e69d54af 100644 --- a/TTS/engine_wrapper.py +++ b/TTS/engine_wrapper.py @@ -3,6 +3,9 @@ from typing import Tuple import re from os import getenv + +import sox +from mutagen import MutagenError from mutagen.mp3 import MP3 import translators as ts from rich.progress import track @@ -91,8 +94,10 @@ def split_post(self, text: str, idx: int) -> str: def call_tts(self, filename: str, text: str): self.tts_module.run(text=process_text(text), filepath=f"{self.path}/{filename}.mp3") - self.length += MP3(f"{self.path}/{filename}.mp3").info.length - + try: + self.length += MP3(f"{self.path}/{filename}.mp3").info.length + except MutagenError: + self.length += sox.file_info.duration(f"{self.path}/{filename}.mp3") def process_text(text: str): lang = getenv("POSTLANG", "") diff --git a/video_creation/final_video.py b/video_creation/final_video.py index d170169ab..f31d68c24 100755 --- a/video_creation/final_video.py +++ b/video_creation/final_video.py @@ -44,9 +44,7 @@ def make_final_video(number_of_clips: int, length: int, reddit_obj: dict[str]): ) # Gather all audio clips - audio_clips = [] - for i in range(0, number_of_clips): - audio_clips.append(AudioFileClip(f"assets/temp/mp3/{i}.mp3")) + audio_clips = [AudioFileClip(f"assets/mp3/{i}.mp3") for i in range(number_of_clips)] audio_clips.insert(0, AudioFileClip("assets/temp/mp3/title.mp3")) audio_concat = concatenate_audioclips(audio_clips) audio_composite = CompositeAudioClip([audio_concat])