Fix opener not trigger when tts disabled
This commit is contained in:
@@ -408,14 +408,20 @@ class DuplexPipeline:
|
||||
return None
|
||||
|
||||
prompt_hint = (self._runtime_greeting or "").strip()
|
||||
system_context = (self.conversation.system_prompt or self._runtime_system_prompt or "").strip()
|
||||
# Keep context concise to avoid overloading greeting generation.
|
||||
if len(system_context) > 1200:
|
||||
system_context = system_context[:1200]
|
||||
system_prompt = (
|
||||
"你是语音通话助手的开场白生成器。"
|
||||
"请只输出一句自然、简洁、友好的中文开场白。"
|
||||
"不要使用引号,不要使用 markdown,不要加解释。"
|
||||
)
|
||||
user_prompt = "请生成一句中文开场白(不超过25个汉字)。"
|
||||
if system_context:
|
||||
user_prompt += f"\n\n以下是该助手的系统提示词,请据此决定语气、角色和边界:\n{system_context}"
|
||||
if prompt_hint:
|
||||
user_prompt += f" 风格提示:{prompt_hint}"
|
||||
user_prompt += f"\n\n额外风格提示:{prompt_hint}"
|
||||
|
||||
try:
|
||||
generated = await self.llm_service.generate(
|
||||
@@ -532,8 +538,8 @@ class DuplexPipeline:
|
||||
if not self._outbound_task or self._outbound_task.done():
|
||||
self._outbound_task = asyncio.create_task(self._outbound_loop())
|
||||
|
||||
# Speak greeting if configured
|
||||
if tts_output_enabled:
|
||||
# Resolve greeting once per session start.
|
||||
# Always emit text opener event so text-only sessions can display it.
|
||||
greeting_to_speak = self.conversation.greeting
|
||||
if self._generated_opener_enabled():
|
||||
generated_greeting = await self._generate_runtime_greeting()
|
||||
@@ -549,6 +555,7 @@ class DuplexPipeline:
|
||||
),
|
||||
priority=20,
|
||||
)
|
||||
if tts_output_enabled:
|
||||
await self._speak(greeting_to_speak)
|
||||
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user