improved efficiency of empty text check

pull/1065/head
Josh Greenwood 2 years ago committed by GitHub
parent 571c782021
commit 9065f563f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -94,11 +94,12 @@ class TTSEngine:
offset = 0 offset = 0
for idy, text_cut in enumerate(split_text): for idy, text_cut in enumerate(split_text):
# print(f"{idx}-{idy}: {text_cut}\n") # print(f"{idx}-{idy}: {text_cut}\n")
if not process_text(text_cut) or process_text(text_cut.isspace()): new_text = process_text(text_cut)
if not new_text or new_text.isspace():
offset += 1 offset += 1
continue continue
self.call_tts(f"{idx}-{idy - offset}.part", text_cut) self.call_tts(f"{idx}-{idy - offset}.part", new_text)
split_files.append( split_files.append(
AudioFileClip(f"{self.path}/{idx}-{idy - offset}.part.mp3") AudioFileClip(f"{self.path}/{idx}-{idy - offset}.part.mp3")
) )
@ -119,7 +120,7 @@ class TTSEngine:
def call_tts(self, filename: str, text: str): def call_tts(self, filename: str, text: str):
self.tts_module.run( self.tts_module.run(
text=process_text(text), filepath=f"{self.path}/{filename}.mp3" text, filepath=f"{self.path}/{filename}.mp3"
) )
# try: # try:
# self.length += MP3(f"{self.path}/{filename}.mp3").info.length # self.length += MP3(f"{self.path}/{filename}.mp3").info.length

Loading…
Cancel
Save