slightly neater

pull/990/head
anthony lloyd 3 years ago
parent c699878222
commit 839fab2791

@ -21,7 +21,6 @@ DEFUALT_MAX_LENGTH: int = 50 # video length variable
class TTSEngine: class TTSEngine:
"""Calls the given TTS engine to reduce code duplication and allow multiple TTS engines. """Calls the given TTS engine to reduce code duplication and allow multiple TTS engines.
Args: Args:
@ -89,7 +88,6 @@ class TTSEngine:
r" *(((.|\n){0," + str(self.tts_module.max_chars) + "})(\.|.$))", text r" *(((.|\n){0," + str(self.tts_module.max_chars) + "})(\.|.$))", text
) )
] ]
offset = 0
try: try:
silence_duration = settings.config["settings"]["tts"]["silence_duration"] silence_duration = settings.config["settings"]["tts"]["silence_duration"]
except AttributeError: except AttributeError:
@ -100,9 +98,9 @@ class TTSEngine:
idy = None idy = None
for idy, text_cut in enumerate(split_text): for idy, text_cut in enumerate(split_text):
newtext = process_text(text_cut) newtext = process_text(text_cut)
print(f"{idx}-{idy}: {newtext}\n") #print(f"{idx}-{idy}: {newtext}\n")
if not newtext or newtext.isspace(): if not newtext or newtext.isspace():
print("newtext was blank because sanitized split text resulted in none") print("newtext was blank because sanitized split text resulted in none")
continue continue
@ -153,7 +151,7 @@ class TTSEngine:
try: try:
name = ["title_no_silence.mp3", "silence.mp3", "title.txt"] name = ["title_no_silence.mp3", "silence.mp3", "title.txt"]
for i in range(0, len(name)): for i in range(0, len(name)):
os.unlink(str(rf"{self.path}/"+name[i])) os.unlink(str(rf"{self.path}/" + name[i]))
except FileNotFoundError: except FileNotFoundError:
print("file not found error") print("file not found error")
except OSError: except OSError:
@ -169,6 +167,7 @@ class TTSEngine:
except: except:
self.length = 0 self.length = 0
def process_text(text: str): def process_text(text: str):
lang = settings.config["reddit"]["thread"]["post_lang"] lang = settings.config["reddit"]["thread"]["post_lang"]
new_text = sanitize_text(text) new_text = sanitize_text(text)

Loading…
Cancel
Save