From be7b9ff4482222bcb7289255530b0c478ecc5d58 Mon Sep 17 00:00:00 2001 From: Harold Date: Wed, 17 Dec 2025 17:37:15 +0800 Subject: [PATCH] feat: filter greeting --- main/live-agent-api/api/v1/internal.py | 1 - main/xiaozhi-server/core/connection.py | 15 ++++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/main/live-agent-api/api/v1/internal.py b/main/live-agent-api/api/v1/internal.py index 8330c761b..9d386f816 100644 --- a/main/live-agent-api/api/v1/internal.py +++ b/main/live-agent-api/api/v1/internal.py @@ -101,7 +101,6 @@ async def get_agent_config( voice_id=agent.voice_id, language=language, instruction=agent.instruction, - voice_opening=agent.voice_opening, voice_closing=agent.voice_closing, enable_greeting=enable_greeting, greeting=greeting, diff --git a/main/xiaozhi-server/core/connection.py b/main/xiaozhi-server/core/connection.py index 6b6d89e46..68b696363 100644 --- a/main/xiaozhi-server/core/connection.py +++ b/main/xiaozhi-server/core/connection.py @@ -181,7 +181,9 @@ class ConnectionHandler: # agent-related configs self._instruction = None - self._voice_opening = None + self._greeting_config = { + "enable_greeting": False, + } self._voice_closing = None self._language = None @@ -511,8 +513,9 @@ class ConnectionHandler: if init_tts or init_llm: self._init_report_threads() - if self._voice_opening and self.tts: - self.logger.bind(tag=TAG).info(f"send the opening message: {self._voice_opening}") + if self.tts and self._greeting_config["enable_greeting"]: + greeting = self._greeting_config["greeting"] + self.logger.bind(tag=TAG).debug(f"send the opening message: {greeting}") opening_sentence_id = str(uuid.uuid4().hex) message_tag = MessageTag.OPENING @@ -528,7 +531,7 @@ class ConnectionHandler: sentence_id=str(uuid.uuid4().hex), sentence_type=SentenceType.MIDDLE, content_type=ContentType.TEXT, - content_detail=self._voice_opening, + content_detail=greeting, message_tag=message_tag, ) ) @@ -1016,7 +1019,9 @@ class ConnectionHandler: if "TTS" in self.config and "FishDualStreamTTS" in self.config.get("TTS", {}): self.config["TTS"]["FishDualStreamTTS"]["reference_id"] = voice_id self._instruction = private_config.get("instruction", self._instruction) - self._voice_opening = private_config.get("voice_opening", self._voice_opening) + # greeting config + self._greeting_config["enable_greeting"] = private_config.get("enable_greeting", False) + self._greeting_config["greeting"] = private_config.get("greeting", None) self._voice_closing = private_config.get("voice_closing", self._voice_closing) self._language = private_config.get("language", self._language)