diff --git a/.env b/.env index 15bfb80..d4fae61 100644 --- a/.env +++ b/.env @@ -9,4 +9,4 @@ DELETE_SESSION_URL=http://101.89.151.141:3000/api/core/chat/delHistory?chatId={c DELETE_CHAT_URL=http://101.89.151.141:3000/api/core/chat/item/delete?contentId={contentId}&chatId={chatId}&appId={appId} GET_CHAT_RECORDS_URL=http://101.89.151.141:3000/api/core/chat/getPaginationRecords -VOICE_CONFIG=config/voice-xfyun.json +VOICE_CONFIG=config/voice-fastgpt-state-xfyunSuperTTS.json diff --git a/static/voice-demo/app.js b/static/voice-demo/app.js index e18caad..dc23c3a 100644 --- a/static/voice-demo/app.js +++ b/static/voice-demo/app.js @@ -20,6 +20,7 @@ const MAX_WS_LOG_LINES = 120; const MAX_GROUP_CHILDREN_RENDER = 100; const WS_LOG_GROUP_KEYS = { AUDIO_DELTA: "recv:response.audio.delta", + TEXT_DELTA: "recv:response.text.delta", AUDIO_SEND: "send:input.audio", }; @@ -205,6 +206,9 @@ function wsLogGroupLabel(groupKey) { if (groupKey === WS_LOG_GROUP_KEYS.AUDIO_DELTA) { return "response.audio.delta"; } + if (groupKey === WS_LOG_GROUP_KEYS.TEXT_DELTA) { + return "response.text.delta"; + } if (groupKey === WS_LOG_GROUP_KEYS.AUDIO_SEND) { return "input.audio binary"; } @@ -430,6 +434,22 @@ function logWsPayload(direction, payload) { ); return; } + if (direction === "recv" && payload?.type === "response.text.delta") { + const text = typeof payload.text === "string" ? payload.text : ""; + const bytes = new TextEncoder().encode(text).length; + const detail = + payload.seq != null + ? `seq=${payload.seq} ${JSON.stringify(truncateLogValue(text, 120))}` + : JSON.stringify(truncateLogValue(text, 120)); + appendWsLogGroupItem( + WS_LOG_GROUP_KEYS.TEXT_DELTA, + "recv", + "recv", + detail, + bytes, + ); + return; + } addWsLog(direction, compactWsPayload(payload)); }