From f91bea3d59bd4ef9c84401821f147cdab8afee38 Mon Sep 17 00:00:00 2001 From: electro199 Date: Fri, 9 Dec 2022 15:12:50 +0500 Subject: [PATCH] Fixed,added: 0.mp3 not found and only translate --- TTS/engine_wrapper.py | 34 ++++++++-------------------------- main.py | 4 ++-- 2 files changed, 10 insertions(+), 28 deletions(-) diff --git a/TTS/engine_wrapper.py b/TTS/engine_wrapper.py index 2a6b2a7..4cf2452 100644 --- a/TTS/engine_wrapper.py +++ b/TTS/engine_wrapper.py @@ -136,34 +136,16 @@ class TTSEngine: print("OSError") def call_tts(self, filename: str, text: str): - + self.tts_module.run(text, filepath=f"{self.path}/{filename}.mp3") + # try: + # self.length += MP3(f"{self.path}/{filename}.mp3").info.length + # except (MutagenError, HeaderNotFoundError): + # self.length += sox.file_info.duration(f"{self.path}/{filename}.mp3") try: - self.tts_module.run(text, filepath=f"{self.path}/{filename}_no_silence.mp3") - self.create_silence_mp3() - - with open(f"{self.path}/{filename}.txt", "w") as f: - f.write("file " + f"'{filename}_no_silence.mp3'" + "\n") - f.write("file " + f"'silence.mp3'" + "\n") - f.close() - os.system( - "ffmpeg -f concat -y -hide_banner -loglevel panic -safe 0 " - + "-i " - + f"{self.path}/{filename}.txt " - + "-c copy " - + f"{self.path}/{filename}.mp3" - ) clip = AudioFileClip(f"{self.path}/{filename}.mp3") - self.length += clip.duration self.last_clip_length = clip.duration + self.length += clip.duration clip.close() - try: - name = [f"{filename}_no_silence.mp3", "silence.mp3", f"{filename}.txt"] - for i in range(0, len(name)): - os.unlink(str(rf"{self.path}/" + name[i])) - except FileNotFoundError as e: - print("File not found: " + e.filename) - except OSError: - print("OSError") except: self.length = 0 @@ -180,9 +162,9 @@ class TTSEngine: ) -def process_text(text: str): +def process_text(text: str , clean : bool = True): lang = settings.config["reddit"]["thread"]["post_lang"] - new_text = sanitize_text(text) + new_text = sanitize_text(text) if clean else text if lang: print_substep("Translating Text...") translated_text = ts.google(text, to_language=lang) diff --git a/main.py b/main.py index fc5abbc..9e98c28 100755 --- a/main.py +++ b/main.py @@ -23,7 +23,7 @@ from video_creation.final_video import make_final_video from video_creation.screenshot_downloader import get_screenshots_of_reddit_posts from video_creation.voices import save_text_to_mp3 -__VERSION__ = "2.5.2" +__VERSION__ = "2.5.3" print( """ @@ -110,7 +110,7 @@ if __name__ == "__main__": except Exception as err: print_step( "Sorry, something went wrong with this test version! Try again, and feel free to report this issue at GitHub or the Discord community." + - 'stm'+ config["settings"]["storymode"] + 'stm m'+ config["settings"]["storymodemethod"] + 'ptc' + len(reddit_object["thread_post"]) + 'stm'+ config["settings"]["storymode"] + 'stm m'+ str(config["settings"]["storymodemethod"]) + 'ptc' + len(reddit_object["thread_post"]) ) raise err # todo error