From 56634e01c3c8df6d03fb8df01e5c1580e145000b Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 1 Dec 2025 14:59:12 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96agent=E6=89=93?= =?UTF-8?q?=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/xiaozhi-server/core/handle/receiveAudioHandle.py | 11 +---------- .../core/parallel/degradation_manager.py | 1 + .../core/parallel/interruption_handler.py | 1 + .../core/parallel/llm_compiler_orchestrator.py | 1 + main/xiaozhi-server/core/parallel/priority_queue.py | 1 + 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/main/xiaozhi-server/core/handle/receiveAudioHandle.py b/main/xiaozhi-server/core/handle/receiveAudioHandle.py index f8d77a5b0..51a771c72 100644 --- a/main/xiaozhi-server/core/handle/receiveAudioHandle.py +++ b/main/xiaozhi-server/core/handle/receiveAudioHandle.py @@ -210,14 +210,7 @@ async def _trigger_pseudo_streaming_prefetch(conn, audio: bytes, have_voice: boo - 用 ASR 部分结果预取 Memory - 预取 query 来自用户当前说的话,天然与最终 query 相关 - 时间线示例: - t=0ms VAD 检测到语音开始 - t=500ms buffer 累积 500ms → 发送预取 ASR → "帮我查" - ↓ - 触发 Memory 预取(query="帮我查") - t=1500ms VAD 检测到静默 → 完整 ASR → "帮我查一下今天的股票行情" - ↓ - 使用预取的 Memory(天然相关) + """ # 检查是否有 Memory 组件 if not hasattr(conn, 'memory') or conn.memory is None: @@ -491,11 +484,9 @@ async def handleAudioMessage(conn, audio): conn.vad_resume_task = asyncio.create_task(resume_vad_detection(conn)) return - # ============== Memory 预取(方案 B:伪流式 ASR)============== # 当音频 buffer 累积到 ~500ms 时,用部分 ASR 结果预取 Memory await _trigger_pseudo_streaming_prefetch(conn, audio, have_voice) - # ============== 打断处理逻辑(业界最佳实践:持续语音检测) ============== # 只有 TTS 正在播放且非手动监听模式时才检测打断 if conn.client_is_speaking and conn.client_listen_mode != "manual": # 初始化打断检测状态 diff --git a/main/xiaozhi-server/core/parallel/degradation_manager.py b/main/xiaozhi-server/core/parallel/degradation_manager.py index 6969a21f7..808178fbf 100644 --- a/main/xiaozhi-server/core/parallel/degradation_manager.py +++ b/main/xiaozhi-server/core/parallel/degradation_manager.py @@ -426,3 +426,4 @@ def is_feature_enabled(feature: str) -> bool: + diff --git a/main/xiaozhi-server/core/parallel/interruption_handler.py b/main/xiaozhi-server/core/parallel/interruption_handler.py index 4301e02b1..8240c755e 100644 --- a/main/xiaozhi-server/core/parallel/interruption_handler.py +++ b/main/xiaozhi-server/core/parallel/interruption_handler.py @@ -309,3 +309,4 @@ class InterruptionHandler: + diff --git a/main/xiaozhi-server/core/parallel/llm_compiler_orchestrator.py b/main/xiaozhi-server/core/parallel/llm_compiler_orchestrator.py index 8a692fefd..1ecebe75f 100644 --- a/main/xiaozhi-server/core/parallel/llm_compiler_orchestrator.py +++ b/main/xiaozhi-server/core/parallel/llm_compiler_orchestrator.py @@ -597,3 +597,4 @@ class LLMCompilerOrchestrator: + diff --git a/main/xiaozhi-server/core/parallel/priority_queue.py b/main/xiaozhi-server/core/parallel/priority_queue.py index c663e64f7..44e2ed32e 100644 --- a/main/xiaozhi-server/core/parallel/priority_queue.py +++ b/main/xiaozhi-server/core/parallel/priority_queue.py @@ -364,3 +364,4 @@ class Full(Exception): +