= TTSTextNormalizer()
cleaner print(cleaner.en_normalize_numbers("$350"))
print(cleaner.expand_time_english("12:05pm"))
print(cleaner("Oh my dear! this is $5 too soon... It's 1:04 am!"))
print(cleaner(["Oh my dear! this is $5 too soon...", "It's 1:04 am!"]))
Text Normalizers
TTS Cleaning & Normalization
TTSTextNormalizer
TTSTextNormalizer (language='en')
Initialize self. See help(type(self)) for accurate signature.
Punctuation
Punctuation (puncs:str=';:,.!?¡¿—…"«»“”')
*Handle punctuations in text.
Just strip punctuations from text or strip and restore them later.
Args: puncs (str): The punctuations to be processed. Defaults to _DEF_PUNCS
.
Example: >>> punc = Punctuation() >>> punc.strip(“This is. example !”) ‘This is example’
>>> text_striped, punc_map = punc.strip_to_restore("This is. example !")
>>> ' '.join(text_striped)
'This is example'
>>> text_restored = punc.restore(text_striped, punc_map)
>>> text_restored[0]
'This is. example !'*
PuncPosition
PuncPosition (value, names=None, module=None, qualname=None, type=None, start=1)
Enum for the punctuations positions
= Punctuation()
punc = "This is. This is, example!"
text print(punc.strip(text))
= punc.strip_to_restore(text)
split_text, puncs print(split_text, " ---- ", puncs)
= punc.restore(split_text, puncs)
restored_text print(restored_text)