From ed91e5d60732f5c92b1c3a3b5d1a819d5f0021b0 Mon Sep 17 00:00:00 2001 From: Jad Date: Sun, 23 Mar 2025 01:13:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BC=80=E5=9C=BA=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E5=9B=9E=E5=A4=8D=E5=94=A4=E9=86=92=E8=AF=8D=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/xiaozhi-server/config.yaml | 2 ++ main/xiaozhi-server/core/handle/textHandle.py | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/main/xiaozhi-server/config.yaml b/main/xiaozhi-server/config.yaml index 953b60eb..3a730b46 100644 --- a/main/xiaozhi-server/config.yaml +++ b/main/xiaozhi-server/config.yaml @@ -59,6 +59,8 @@ close_connection_no_voice_time: 120 tts_timeout: 10 # TTS播放结束提示音 tts_notify: "data/tts_notify.mp3" +# 开场是否回复唤醒词 +enable_greeting: true CMD_exit: - "退出" diff --git a/main/xiaozhi-server/core/handle/textHandle.py b/main/xiaozhi-server/core/handle/textHandle.py index c63b9a33..f1356068 100644 --- a/main/xiaozhi-server/core/handle/textHandle.py +++ b/main/xiaozhi-server/core/handle/textHandle.py @@ -3,6 +3,7 @@ import json from core.handle.abortHandle import handleAbortMessage from core.handle.helloHandle import handleHelloMessage from core.handle.receiveAudioHandle import startToChat, handleAudioMessage +from core.handle.sendAudioHandle import send_stt_message, send_tts_message from core.handle.iotHandle import handleIotDescriptors, handleIotStatus TAG = __name__ @@ -38,7 +39,13 @@ async def handleTextMessage(conn, message): conn.client_have_voice = False conn.asr_audio.clear() if "text" in msg_json: - await startToChat(conn, msg_json["text"]) + if conn.config.get("enable_greeting", True): + # 启用开场白 通过llm回复唤醒词 + await startToChat(conn, msg_json["text"]) + else: + # 不启用 直接转为聆听状态 + await send_stt_message(conn, msg_json["text"]) + await send_tts_message(conn, "stop", None) elif msg_json["type"] == "iot": if "descriptors" in msg_json: await handleIotDescriptors(conn, msg_json["descriptors"])