fix(tts): gate auto reply by ENABLE_TTS; allow on-demand and manual playback
- Pipeline: skip _send_tts_audio only for non-manual when ENABLE_TTS=false; remove enable_tts early return from handle_tts_request_on_demand. - Tencent TTS: PrimaryLanguage/chunking follow user language preference only. - Expo: let manual tts_audio bypass late-segment playback gate after interrupt. - Docs: clarify ENABLE_TTS vs tts_request in api/.env.example and TTSProvider port. - Tests: add manual bypass cases; adjust pipeline language tests for en+Chinese text. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -64,6 +64,29 @@ async def test_tencent_tts_zh_uses_primary_language_1_and_zh_voice() -> None:
|
||||
assert seen["voice_type"] == 501004
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_tencent_tts_en_user_language_uses_primary_en_even_if_text_is_chinese() -> None:
|
||||
"""主语言与用户偏好一致:即使用户语言为 en 且正文为中文,也向 Tencent 提交 PrimaryLanguage=2。"""
|
||||
provider = TencentTTSProvider(
|
||||
secret_id="id",
|
||||
secret_key="key",
|
||||
voice_type=501004,
|
||||
voice_type_en=501004,
|
||||
)
|
||||
seen: dict = {}
|
||||
|
||||
def fake_sync(text: str, voice_type: int, primary_language: int) -> bytes:
|
||||
seen["primary_language"] = primary_language
|
||||
seen["voice_type"] = voice_type
|
||||
return b"OK"
|
||||
|
||||
with patch.object(provider, "_synthesize_sync", side_effect=fake_sync):
|
||||
out = await provider.synthesize("这是中文回复。", language="en")
|
||||
|
||||
assert out == b"OK"
|
||||
assert seen["primary_language"] == PRIMARY_LANGUAGE_EN
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_tencent_tts_en_uses_primary_language_2_and_en_voice() -> None:
|
||||
provider = TencentTTSProvider(
|
||||
|
||||
Reference in New Issue
Block a user