pull/963/head
Drugsosos 2 years ago
parent b4f6fe41ca
commit 01b932bf88
No known key found for this signature in database
GPG Key ID: 8E35176FE617E28D

@ -66,7 +66,7 @@ class TTSEngine:
print_substep('Saved Text to MP3 files successfully.', style='bold green') print_substep('Saved Text to MP3 files successfully.', style='bold green')
return [ return [
comments for comments, condition in 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 if condition
] ]
@ -75,15 +75,19 @@ class TTSEngine:
filename: str, filename: str,
text: str text: str
) -> bool: ) -> bool:
self.tts_module.run( if not text:
return False
self.tts_module().run(
text=self.process_text(text), text=self.process_text(text),
filepath=f'{self.path}/{filename}.mp3' 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: if self.__total_length + clip_length <= self.max_length:
self.max_length += clip_length self.__total_length += clip_length
return True return True
return False return False

@ -28,6 +28,7 @@ from video_creation.background import download_background, chop_background_video
console = Console() console = Console()
W, H = 1080, 1920 # TODO move to config W, H = 1080, 1920 # TODO move to config
max_length: int = 50 # TODO move to config
def name_normalize( def name_normalize(

@ -16,7 +16,7 @@ TTSProviders = {
} }
async def save_text_to_mp3( def save_text_to_mp3(
reddit_obj: dict, reddit_obj: dict,
) -> list: ) -> list:
"""Saves text to MP3 files. """Saves text to MP3 files.
@ -37,17 +37,8 @@ async def save_text_to_mp3(
if voice.casefold() in map(lambda _: _.casefold(), TTSProviders): if voice.casefold() in map(lambda _: _.casefold(), TTSProviders):
break break
print('Unknown Choice') print('Unknown Choice')
TTS_instance = get_case_insensitive_key_value(TTSProviders, voice) engine_instance = TTSEngine(get_case_insensitive_key_value(TTSProviders, voice), reddit_obj)
if TTS_instance == StreamlabsPolly or TTS_instance == TikTok: return engine_instance.run()
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
def get_case_insensitive_key_value( def get_case_insensitive_key_value(

Loading…
Cancel
Save