Enhance pipeline execution and voice preview handling for graceful call termination
- Introduce mechanisms in the pipeline to ensure that the end call process waits for the completion of the end speech before hanging up, improving user experience during call termination. - Update the useVoicePreview hook to handle server-initiated call endings gracefully, distinguishing between normal and error disconnections. - Adjust TTS stop frame timeout settings to optimize the timing of call terminations, ensuring timely responses without unnecessary delays. - Refactor related components to support the new end call logic, enhancing overall workflow management and user interaction.
This commit is contained in:
@@ -21,6 +21,11 @@ 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
|
||||
|
||||
|
||||
def _language(value: str) -> Language | None:
|
||||
if not value:
|
||||
@@ -107,6 +112,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,
|
||||
)
|
||||
if cfg.tts_interface_type not in {"openai-tts", "dashscope-tts"}:
|
||||
raise ValueError(f"不支持的 TTS 接口类型: {cfg.tts_interface_type}")
|
||||
@@ -117,6 +123,7 @@ def create_tts(cfg: AssistantConfig):
|
||||
return OpenAITTSService(
|
||||
api_key=cfg.tts_api_key or config.TTS_API_KEY,
|
||||
base_url=cfg.tts_base_url or config.TTS_BASE_URL,
|
||||
stop_frame_timeout_s=TTS_STOP_FRAME_TIMEOUT_S,
|
||||
settings=OpenAITTSService.Settings(
|
||||
model=cfg.tts_model or config.TTS_MODEL,
|
||||
voice=voice,
|
||||
|
||||
Reference in New Issue
Block a user