From 8d7f72d913651e8791724cd543087704ade48f4f Mon Sep 17 00:00:00 2001 From: whosmyqueen Date: Thu, 26 Jun 2025 17:30:28 +0800 Subject: [PATCH] =?UTF-8?q?refactor(core):=20=E4=BC=98=E5=8C=96=20MCP?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E8=B0=83=E7=94=A8=E5=93=8D=E5=BA=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 connection.py 和 intentHandler.py 中添加 speak_txt 函数调用 - 在执行 MCP 工具调用前播放 "好的, 请稍等" 语音提示 -优化了与用户的交互体验 --- main/xiaozhi-server/core/connection.py | 5 +++++ main/xiaozhi-server/core/handle/intentHandler.py | 1 + 2 files changed, 6 insertions(+) diff --git a/main/xiaozhi-server/core/connection.py b/main/xiaozhi-server/core/connection.py index 3ad945923..938733b39 100644 --- a/main/xiaozhi-server/core/connection.py +++ b/main/xiaozhi-server/core/connection.py @@ -740,6 +740,7 @@ def chat(self, query, tool_call=False): elif hasattr(self, "mcp_client") and self.mcp_client.has_tool( function_name ): + speak_txt(self, "好的, 请稍等") # 如果是小智端MCP工具调用 self.logger.bind(tag=TAG).debug( f"调用小智端MCP工具: {function_name}, 参数: {function_arguments}" @@ -1025,3 +1026,7 @@ async def _check_timeout(self): break except Exception as e: self.logger.bind(tag=TAG).error(f"超时检查任务出错: {e}") + +def speak_txt(conn, text): + conn.tts.tts_one_sentence(conn, ContentType.TEXT, content_detail=text) + conn.dialogue.put(Message(role="assistant", content=text)) \ No newline at end of file diff --git a/main/xiaozhi-server/core/handle/intentHandler.py b/main/xiaozhi-server/core/handle/intentHandler.py index de4c36c11..feff48b47 100644 --- a/main/xiaozhi-server/core/handle/intentHandler.py +++ b/main/xiaozhi-server/core/handle/intentHandler.py @@ -112,6 +112,7 @@ def process_function_call(): elif hasattr(conn, "mcp_client") and conn.mcp_client.has_tool( function_name ): + speak_txt(conn, "好的, 请稍等") # 如果是小智端MCP工具调用 conn.logger.bind(tag=TAG).debug( f"调用小智端MCP工具: {function_name}, 参数: {function_args}"