diff --git a/TTS/engine_wrapper.py b/TTS/engine_wrapper.py index 1bacd86..e41e55c 100644 --- a/TTS/engine_wrapper.py +++ b/TTS/engine_wrapper.py @@ -66,7 +66,7 @@ class TTSEngine: print_substep('Saved Text to MP3 files successfully.', style='bold green') return [ comments for comments, condition in - zip(self.reddit_object['comments'], sync_tasks_primary) + zip(range(self.reddit_object['comments'].__len__()), sync_tasks_primary) if condition ] @@ -75,15 +75,19 @@ class TTSEngine: filename: str, text: str ) -> bool: - self.tts_module.run( + if not text: + return False + + self.tts_module().run( text=self.process_text(text), filepath=f'{self.path}/{filename}.mp3' ) - clip_length = audio_length(f'assets/audio/{filename}.mp3') + clip_length = audio_length(f'assets/temp/mp3/{filename}.mp3') + print(clip_length, '/', self.__total_length) if self.__total_length + clip_length <= self.max_length: - self.max_length += clip_length + self.__total_length += clip_length return True return False diff --git a/video_creation/final_video.py b/video_creation/final_video.py index f566711..9989415 100755 --- a/video_creation/final_video.py +++ b/video_creation/final_video.py @@ -28,6 +28,7 @@ from video_creation.background import download_background, chop_background_video console = Console() W, H = 1080, 1920 # TODO move to config +max_length: int = 50 # TODO move to config def name_normalize( diff --git a/video_creation/voices.py b/video_creation/voices.py index e792ec3..0098da0 100644 --- a/video_creation/voices.py +++ b/video_creation/voices.py @@ -16,7 +16,7 @@ TTSProviders = { } -async def save_text_to_mp3( +def save_text_to_mp3( reddit_obj: dict, ) -> list: """Saves text to MP3 files. @@ -37,17 +37,8 @@ async def save_text_to_mp3( if voice.casefold() in map(lambda _: _.casefold(), TTSProviders): break print('Unknown Choice') - TTS_instance = get_case_insensitive_key_value(TTSProviders, voice) - if TTS_instance == StreamlabsPolly or TTS_instance == TikTok: - from aiohttp import ClientSession - - async with ClientSession() as client: - engine_instance = TTSEngine(TTS_instance(client), reddit_obj) - results = await engine_instance.run() - else: - engine_instance = TTSEngine(TTS_instance, reddit_obj) - results = await engine_instance.run() - return results + engine_instance = TTSEngine(get_case_insensitive_key_value(TTSProviders, voice), reddit_obj) + return engine_instance.run() def get_case_insensitive_key_value(