IndexTTS-2-Emotions / tests /test_multilingual.py
vasugo05's picture
Upload 244 files
fec352a verified
import re
from indextts.utils.front import TextNormalizer
from indextts.text.hindi_phonemizer import hindi_to_phoneme
def test_hindi_not_through_english_phonemizer():
txt = "मुझे बहुत खुशी हो रही है क्योंकि आज मेरा सपना पूरा हो गया।"
tn = TextNormalizer()
tn.load()
normalized = tn.normalize(txt)
# The normalized output should contain Devanagari characters (not Latin transliteration)
assert re.search(r"[\u0900-\u097F]", normalized), "Normalized Hindi should contain Devanagari script"
# It should be equal to the joined hindi_to_phoneme tokens
tokens = hindi_to_phoneme(txt)
joined = " ".join(tokens)
assert normalized == joined or joined in normalized, "Hindi must be routed to hindi_to_phoneme tokens"
def test_english_and_chinese_preserved():
tn = TextNormalizer()
tn.load()
en = "This is a test of the emergency broadcast system."
zh = "我爱你。"
norm_en = tn.normalize(en)
norm_zh = tn.normalize(zh)
# English should contain ASCII letters
assert re.search(r"[A-Za-z]", norm_en)
# Chinese should contain CJK chars
assert re.search(r"[\u4e00-\u9fff]", norm_zh)