v1 Polish: Hindi anusvara normalizer, de-buzz filter, --dur_weight/--prior_weight & Parquet curator
Browse files49 unmodified lines50515253545549 unmodified linestext = re.sub(r"\s+", " ", text).strip()return textdef text_to_ids(self, text: str) -> torch.Tensor:"""Encodes text to a 1D tensor of token IDs in range [2, 480]."""text = self.clean_text(text)49 unmodified lines5051525354555657585960616263646566676869707149 unmodified linestext = re.sub(r"\s+", " ", text).strip()return text@staticmethoddef normalize_hindi_pronunciation(text: str) -> str:"""Resolves word-medial Hindi anusvara (ं) before stop consonants into explicithalf-nasal consonants (न्/म्/ण्/ञ्) so raw-character models pronounce words like'ईंधन' ('ईन्धन'), 'कंबल' ('कम्बल'), 'ठंड' ('ठण्ड') accurately.Leaves word-final nasalization ('मैं', 'हूं', 'गांव', 'बच्चों') untouched."""if not text:return texttext = re.sub(r"ं(?=[तथदधन])", "न्", text)text = re.sub(r"ं(?=[पफबभम])", "म्", text)text = re.sub(r"ं(?=[टठडढण])", "ण्", text)text = re.sub(r"ं(?=[चछजझञ])", "ञ्", text)return textdef text_to_ids(self, text: str) -> torch.Tensor:"""Encodes text to a 1D tensor of token IDs in range [2, 480]."""text = self.clean_text(text)
data/text_cleaner.py+16