def __call__(self, text) -> List[str]: if self.g2p is None: import g2pk self.g2p = g2pk.G2p() phones = list( self.g2p( text, descriptive=self.descritive, group_vowels=self.group_vowels, to_syl=self.to_syl, )) if self.no_space: # remove space which represents word serapater phones = list(filter(lambda s: s != " ", phones)) return phones
import re from unicodedata import normalize sys.path.append("/content/src/glow-tts") from text import symbols as glowtts_symbols sys.path.remove("/content/src/glow-tts") sys.path.append("/content/src/g2pK") import g2pk sys.path.remove("/content/src/g2pK") symbols = set(glowtts_symbols) g2p = g2pk.G2p() def normalize_text(text): text = simple_replace(text) text = g2p.idioms(text) text = g2pk.english.convert_eng(text, g2p.cmu) text = g2pk.utils.annotate(text, g2p.mecab) text = g2pk.numerals.convert_num(text) text = re.sub("/[PJEB]", "", text) text = eng_cap(text) text = normalize("NFD", text) for pos, char in enumerate(text): if char not in symbols: text = text[:pos] + " " + text[pos + 1:]