Fixed,added: 0.mp3 not found and only translate
This commit is contained in:
1 parent
62e5c50ba5
commit
f91bea3d59
2 files changed
+10
-28
No files matched your search
+8
-26
@@ -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)
|
||||
|
||||
@@ -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
|
||||
Reference in new issue
Block a user