From 9ccd4d6238291dd45f92579e1406ba6405c6f961 Mon Sep 17 00:00:00 2001 From: cfy666 <3087823110@qq.com> Date: Sat, 13 Jun 2026 11:10:29 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=9B=86=E6=88=90=20VAD=20=E8=AF=AD?= =?UTF-8?q?=E9=9F=B3=E6=B4=BB=E5=8A=A8=E6=A3=80=E6=B5=8B=EF=BC=8C=E6=89=93?= =?UTF-8?q?=E9=80=9A=E6=A0=B8=E5=BF=83=E4=BA=A4=E4=BA=92=E9=93=BE=E8=B7=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 重写 useVAD Hook,接入 @ricky0123/vad-web 的 MicVAD - 支持 onSpeechStart/onSpeechEnd/onVADMisfire 回调 - useVisionSession 中串联摄像头→麦克风→WebSocket→VAD 完整流程 - App.tsx 新增 VAD 加载中和错误状态的 UI 指示 - VAD 参数对齐设计文档:positiveSpeechThreshold=0.5, minSpeechMs=250 Co-Authored-By: Claude --- frontend/src/App.css | 9 ++ frontend/src/App.tsx | 22 +++- .../src/components/EdgeProcessor/index.tsx | 105 ++++++++++++++---- frontend/src/hooks/useVisionSession.ts | 33 +++++- 4 files changed, 140 insertions(+), 29 deletions(-) diff --git a/frontend/src/App.css b/frontend/src/App.css index 6f12e3a..cc89700 100644 --- a/frontend/src/App.css +++ b/frontend/src/App.css @@ -103,6 +103,15 @@ body { animation: pulse 1.5s ease-in-out infinite; } +.vad-indicator--loading { + color: var(--color-warning); +} + +.vad-indicator--error { + color: var(--color-error); + animation: none; +} + @keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 6e8e52d..13174ec 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -13,6 +13,8 @@ function App() { currentReply, isProcessing, isSpeaking, + isVADReady, + vadError, connectionStatus, videoRef, stream, @@ -21,12 +23,18 @@ function App() { interrupt, } = useVisionSession(); + const isConnected = connectionStatus === "connected"; + return (

CamTalk

- {connectionStatus === "connected" ? "已连接" : connectionStatus === "connecting" ? "连接中..." : "未连接"} + {isConnected + ? "已连接" + : connectionStatus === "connecting" + ? "连接中..." + : "未连接"}
@@ -34,6 +42,16 @@ function App() {
{isSpeaking &&
🎤 正在聆听...
} + {isConnected && !isVADReady && !vadError && ( +
+ 正在初始化语音检测... +
+ )} + {vadError && ( +
+ ⚠️ {vadError} +
+ )}
@@ -48,7 +66,7 @@ function App() {