fixes in text_len_sanitize

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

@ -23,13 +23,32 @@ class BaseApiTTS:
Split text as a list Split text as a list
""" """
# Split by comma or dot (else you can lose intonations), if there is non, split by groups of 299 chars # Split by comma or dot (else you can lose intonations), if there is non, split by groups of 299 chars
if '.' in text and all([split_text.__len__() < max_length for split_text in text.split('.')]): split_text = ''
return text.split('.')
split_text = list(
if ',' in text and all([split_text.__len__() < max_length for split_text in text.split(',')]): map(lambda x: x.strip() if x.strip()[-1] != '.' else x.strip()[:-1],
return text.split(',') filter(lambda x: True if x else False, text.split('.')))
)
return [text[i:i + max_length] for i in range(0, len(text), max_length)] if split_text and all([chunk.__len__() < max_length for chunk in split_text]):
return split_text
split_text = list(
map(lambda x: x.strip() if x.strip()[-1] != ',' else x.strip()[:-1],
filter(lambda x: True if x else False, text.split(','))
)
)
if split_text and all([chunk.__len__() < max_length for chunk in split_text]):
return split_text
return list(
map(
lambda x: x.strip() if x.strip()[-1] != '.' or x.strip()[-1] != ',' else x.strip()[:-1],
filter(
lambda x: True if x else False,
[text[i:i + max_length] for i in range(0, len(text), max_length)]
)
)
)
def write_file( def write_file(
self, self,

Loading…
Cancel
Save