File size: 853 Bytes
bb3a349
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from ava_tts.model import Ava


def test_split_prefers_punctuation_near_middle():
    text = "این بخش اول جمله است، و این بخش دوم جمله است."
    split = Ava._split_point(text)
    assert text[split - 1] == "،"


def test_split_falls_back_to_word_boundary():
    text = "یک متن بسیار طولانی برای آزمایش شکستن خودکار جمله"
    split = Ava._split_point(text)
    assert 0 < split < len(text)
    assert text[split].isspace()


def test_long_text_is_split_before_frontend_limit():
    ava = object.__new__(Ava)
    ava._config = {"vocab": {"a": 1}}
    ava._phonemize_normalized = lambda text: "a" * len(text)
    normalized, segments = ava.phonemize("واژه " * 120)
    assert normalized
    assert len(segments) > 1
    assert all(len(segment) <= 510 for segment in segments)