MCPcopy Create free account
hub / github.com/FireRedTeam/FireRedTTS / rettt

Function rettt

fireredtts/modules/text_normalizer/normalize.py:68–109  ·  view source on GitHub ↗
(sentence)

Source from the content-addressed store, hash-verified

66
67
68def rettt(sentence):
69 # handle abbreviations for all languages
70 sentence = sentence.replace("&nd", "and")
71 sentence = sentence.replace("Jan.", "january")
72 sentence = sentence.replace("Feb.", "febrary")
73 sentence = sentence.replace("Mar.", "march")
74 sentence = sentence.replace("Apr.", "april")
75 sentence = sentence.replace("May.", "may")
76 sentence = sentence.replace("Jun.", "june")
77 sentence = sentence.replace("Jul.", "july")
78 sentence = sentence.replace("Aug.", "august")
79 sentence = sentence.replace("Sept.", "september")
80 sentence = sentence.replace("Sep.", "september")
81 sentence = sentence.replace("Oct.", "october")
82 sentence = sentence.replace("Nov.", "november")
83 sentence = sentence.replace("Dec.", "december")
84 sentence = sentence.replace("Mon.", "monday")
85 sentence = sentence.replace("Tues.", "tuesday")
86 sentence = sentence.replace("Wed.", "wednesday")
87 sentence = sentence.replace("Thur.", "thursday")
88 sentence = sentence.replace("Fri.", "friday")
89 sentence = sentence.replace("Sat.", "saturday")
90 if sentence != "Sun.":
91 sentence = sentence.replace("Sun.", "sunday")
92 sentence = re.sub(r" St\. ([A-Z])", r" saint \1", sentence)
93 sentence = re.sub(r" St\.", " street", sentence)
94 sentence = re.sub(r" Rd\.", " road", sentence)
95 sentence = re.sub(r"[Aa]\.[Mm]\.", "A_M", sentence)
96 sentence = re.sub(r"[Pp]\.[Mm]\.", "P_M", sentence)
97 sentence = re.sub(r"[Bb]\.[Cc]\.", "B_C", sentence)
98 sentence = re.sub(r"[Ad]\.[Dd]\.", "A_D", sentence)
99 sentence = sentence.replace("Mr.", "mister")
100 sentence = sentence.replace("Ms.", "miss")
101 sentence = sentence.replace("Mrs.", "misses")
102 sentence = sentence.replace("Ph.D", "P_H_D")
103 sentence = sentence.replace("i.e.", "that is")
104 sentence = sentence.replace("e.g.", "for example")
105 sentence = sentence.replace("btw.", "by the way")
106 sentence = sentence.replace("btw", "by the way")
107 sentence = sentence.replace("b.t.w.", "by the way")
108 sentence = sentence.replace("@", " at ")
109 return sentence
110
111
112class TextNormalizer:

Callers 1

tnMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected