Try to fix confirm and interrupt

This commit is contained in:
Xin Wang
2026-08-04 10:19:59 +08:00
parent caa2ff65fa
commit da828aca41
5 changed files with 96 additions and 46 deletions

View File

@@ -20,10 +20,12 @@ from services.pipecat.xfyun_super_tts import (
)
from services.pipecat.xfyun_tts import DEFAULT_XFYUN_TTS_URL, XfyunTTSService
# TTS「说完」判定的空闲时长:默认 3.0s 过长(导致工作流结束节点说完后还要等约 3s
# 才挂断,也拖慢日常轮次的交还)。设 1.0s 既能让结束语文字/音频送达,又更跟手。
# 流式 TTS 句间音频间隔通常远小于 1s,不会把一段多句回复误判为结束。
TTS_STOP_FRAME_TIMEOUT_S = 1.0
# HTTP TTS may pause between response chunks. Keep Pipecat's wider default so
# a long utterance is not marked stopped and routed onward before late chunks
# arrive. WebSocket TTS has an explicit completion event and can use the short
# idle fallback without delaying the end of a call.
HTTP_TTS_STOP_FRAME_TIMEOUT_S = 3.0
WEBSOCKET_TTS_STOP_FRAME_TIMEOUT_S = 1.0
def config_with_resource(
@@ -158,7 +160,7 @@ def create_tts(cfg: AssistantConfig):
volume=int(cfg.tts_values.get("volume") or 50),
pitch=int(cfg.tts_values.get("pitch") or 50),
push_stop_frames=True,
stop_frame_timeout_s=TTS_STOP_FRAME_TIMEOUT_S,
stop_frame_timeout_s=WEBSOCKET_TTS_STOP_FRAME_TIMEOUT_S,
)
if cfg.tts_interface_type not in {"openai-tts", "dashscope-tts"}:
raise ValueError(f"不支持的 TTS 接口类型: {cfg.tts_interface_type}")
@@ -169,7 +171,7 @@ def create_tts(cfg: AssistantConfig):
return OpenAITTSService(
api_key=_require(cfg.tts_api_key, "TTS apiKey"),
base_url=_require(cfg.tts_base_url, "TTS apiUrl"),
stop_frame_timeout_s=TTS_STOP_FRAME_TIMEOUT_S,
stop_frame_timeout_s=HTTP_TTS_STOP_FRAME_TIMEOUT_S,
settings=OpenAITTSService.Settings(
model=_require(cfg.tts_model, "TTS modelId"),
voice=voice,