mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-23 03:19:41 +00:00
补充注释说明,调整测试样例
This commit is contained in:
parent
a5e47f2c4e
commit
932962e8d3
2 changed files with 11 additions and 1 deletions
|
|
@ -497,6 +497,9 @@ class TTSProviderBase(ABC):
|
|||
("[", "]"),
|
||||
("[", "]"),
|
||||
)
|
||||
# 注意:“(U+201C)有双重语义:中文里是开引号(对应 ”),
|
||||
# 德语 „…“ 里是闭引号;二者冲突时计数法无法兼顾,
|
||||
# 德语句子的切分只能靠“不平衡就顺延”保守处理(最终由 flush 兜底)。
|
||||
_CLOSERS = '」』”》)"»“】〉]]'
|
||||
_QUOTE_CHARS = "".join(ch for pair in _QUOTE_PAIRS for ch in pair)
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import pytest
|
|||
from core.providers.tts.base import TTSProviderBase
|
||||
|
||||
|
||||
# 最小 stub:仅需满足抽象方法实例化要求;object.__new__ 会绕过
|
||||
# abstractmethod 检查,若基类新增抽象方法这里不会自动报错,属预期(测试不调用)
|
||||
class _TTS(TTSProviderBase):
|
||||
async def text_to_speak(self, text, output_file):
|
||||
return None
|
||||
|
|
@ -73,9 +75,14 @@ def test_guillemets_are_not_split(step):
|
|||
|
||||
@pytest.mark.parametrize("step", [1, 4])
|
||||
def test_german_low9_quotes_stay_whole(step):
|
||||
# „…“ 的闭合符 “ 是中文引号的开引号,整句在 stop flush 时输出
|
||||
# „…“ 的闭合符 “ 是中文引号的开引号:“ 总被 (“”, ””) 对计为 opener,
|
||||
# 故 „…“ 闭合后依然判不平衡,无论后续有无句末标点(实测),
|
||||
# 德语只能整句 stop flush —— 这是字符冲突下的保守预期,非缺陷
|
||||
text = "Er sagte " + _GOPEN + "Hallo!" + _GCLOSE + " und ging."
|
||||
assert _segments(text, step) == [text]
|
||||
# 闭合 + 中文句号同样整句 flush:正路径因 “ 双重语义不可达
|
||||
text2 = "Er sagte " + _GOPEN + "Hallo!" + _GCLOSE + "。Dann geht er。"
|
||||
assert _segments(text2, step) == [text2]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("step", [1, 4])
|
||||
|
|
|
|||
Loading…
Reference in a new issue