dsh-voice-mode 0.7.7 → 0.7.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +158 -48
- package/README.md +128 -34
- package/assets/architecture.svg +1 -79
- package/assets/demo.gif +0 -0
- package/lib/client.js +645 -101
- package/lib/index.js +228 -45
- package/lib/sense-worker.mjs +2 -2
- package/lib/tts-vits-worker.cjs +1 -1
- package/package.json +3 -3
package/assets/architecture.svg
CHANGED
|
@@ -1,79 +1 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" font-family="Segoe UI, system-ui, sans-serif" font-size="14" viewBox="0 0 960 640">
|
|
2
|
-
<defs>
|
|
3
|
-
<marker id="arr" markerHeight="8" markerWidth="8" orient="auto" refX="7" refY="4">
|
|
4
|
-
<path fill="#8b949e" d="M0,0 L8,4 L0,8 z"/>
|
|
5
|
-
</marker>
|
|
6
|
-
<marker id="arrR" markerHeight="8" markerWidth="8" orient="auto" refX="7" refY="4">
|
|
7
|
-
<path fill="#f85149" d="M0,0 L8,4 L0,8 z"/>
|
|
8
|
-
</marker>
|
|
9
|
-
</defs>
|
|
10
|
-
<rect width="960" height="640" fill="#0d1117"/>
|
|
11
|
-
<text x="480" y="30" fill="#e6edf3" font-size="20" font-weight="700" text-anchor="middle">dsh-voice-mode — 语音双工数据流</text>
|
|
12
|
-
|
|
13
|
-
<!-- 左列:浏览器侧 -->
|
|
14
|
-
<rect width="200" height="56" x="30" y="70" fill="#161b22" stroke="#58a6ff" stroke-width="1.5" rx="10"/>
|
|
15
|
-
<text x="130" y="92" fill="#58a6ff" font-weight="700" text-anchor="middle">麦克风 Mic</text>
|
|
16
|
-
<text x="130" y="112" fill="#8b949e" font-size="12" text-anchor="middle">16kHz 单声道 · AEC 回声消除</text>
|
|
17
|
-
|
|
18
|
-
<rect width="200" height="70" x="30" y="165" fill="#161b22" stroke="#58a6ff" stroke-width="1.5" rx="10"/>
|
|
19
|
-
<text x="130" y="189" fill="#58a6ff" font-weight="700" text-anchor="middle">浏览器 VAD 分段</text>
|
|
20
|
-
<text x="130" y="209" fill="#8b949e" font-size="12" text-anchor="middle">静音 700ms 断句 / 按住说门控</text>
|
|
21
|
-
<text x="130" y="227" fill="#8b949e" font-size="12" text-anchor="middle">增量传输(每 0.9s 只传新增)</text>
|
|
22
|
-
|
|
23
|
-
<rect width="200" height="56" x="30" y="285" fill="#161b22" stroke="#3fb950" stroke-width="1.5" rx="10"/>
|
|
24
|
-
<text x="130" y="309" fill="#3fb950" font-weight="700" text-anchor="middle">草稿 → 自动发送</text>
|
|
25
|
-
<text x="130" y="329" fill="#8b949e" font-size="12" text-anchor="middle">autoSend / 按住说松手发送</text>
|
|
26
|
-
|
|
27
|
-
<rect width="200" height="70" x="30" y="405" fill="#161b22" stroke="#3fb950" stroke-width="1.5" rx="10"/>
|
|
28
|
-
<text x="130" y="429" fill="#3fb950" font-weight="700" text-anchor="middle">播放 + 字幕浮层</text>
|
|
29
|
-
<text x="130" y="449" fill="#8b949e" font-size="12" text-anchor="middle">SSE 音频帧(WAV/MP3)</text>
|
|
30
|
-
<text x="130" y="467" fill="#8b949e" font-size="12" text-anchor="middle">逐段顺序 · 世代链防重播</text>
|
|
31
|
-
|
|
32
|
-
<!-- 中列:host 侧 -->
|
|
33
|
-
<rect width="290" height="60" x="330" y="70" fill="#161b22" stroke="#58a6ff" stroke-width="1.5" rx="10"/>
|
|
34
|
-
<text x="475" y="94" fill="#58a6ff" font-weight="700" text-anchor="middle">zipformer2 流式识别</text>
|
|
35
|
-
<text x="475" y="114" fill="#8b949e" font-size="12" text-anchor="middle">host 本地 WASM · 启动预热 · SHA256 校验</text>
|
|
36
|
-
|
|
37
|
-
<rect width="290" height="56" x="330" y="165" fill="#161b22" stroke="#d29922" stroke-width="1.5" rx="10"/>
|
|
38
|
-
<text x="475" y="189" fill="#d29922" font-weight="700" text-anchor="middle">SenseVoice 定稿</text>
|
|
39
|
-
<text x="475" y="207" fill="#8b949e" font-size="12" text-anchor="middle">带标点 · 数字归一化</text>
|
|
40
|
-
|
|
41
|
-
<rect width="290" height="56" x="330" y="255" fill="#161b22" stroke="#a371f7" stroke-width="1.5" rx="10"/>
|
|
42
|
-
<text x="475" y="279" fill="#a371f7" font-weight="700" text-anchor="middle">llm/stream 无损 tap → 分句</text>
|
|
43
|
-
<text x="475" y="297" fill="#8b949e" font-size="12" text-anchor="middle">text-delta 过滤 · markdown 剥离</text>
|
|
44
|
-
|
|
45
|
-
<rect width="290" height="56" x="330" y="345" fill="#161b22" stroke="#a371f7" stroke-width="1.5" rx="10"/>
|
|
46
|
-
<text x="475" y="369" fill="#a371f7" font-weight="700" text-anchor="middle">TTS 队列(epoch 打断)</text>
|
|
47
|
-
<text x="475" y="387" fill="#8b949e" font-size="12" text-anchor="middle">打断即杀在途合成 · 积压作废</text>
|
|
48
|
-
|
|
49
|
-
<rect width="290" height="100" x="330" y="435" fill="#161b22" stroke="#3fb950" stroke-width="1.5" rx="10"/>
|
|
50
|
-
<text x="475" y="459" fill="#3fb950" font-weight="700" text-anchor="middle">朗读引擎 TTS</text>
|
|
51
|
-
<text x="475" y="481" fill="#8b949e" font-size="12" text-anchor="middle">Edge 云端(默认,322 音色)</text>
|
|
52
|
-
<text x="475" y="501" fill="#8b949e" font-size="12" text-anchor="middle">VITS 本地 · 纯中文(WASM)</text>
|
|
53
|
-
<text x="475" y="521" fill="#8b949e" font-size="12" text-anchor="middle">Kokoro 本地 · 中英(int8 109MB / fp32 311MB)</text>
|
|
54
|
-
|
|
55
|
-
<!-- 右列:安全面 -->
|
|
56
|
-
<rect width="240" height="200" x="690" y="70" fill="#161b22" stroke="#30363d" stroke-width="1" rx="10"/>
|
|
57
|
-
<text x="810" y="98" fill="#e6edf3" font-weight="700" text-anchor="middle">安全面(四层)</text>
|
|
58
|
-
<text x="710" y="126" fill="#8b949e" font-size="12">① 会话存在性校验</text>
|
|
59
|
-
<text x="710" y="146" fill="#8b949e" font-size="12">② 回环 + Origin 校验</text>
|
|
60
|
-
<text x="710" y="166" fill="#8b949e" font-size="12">③ 全端点限流</text>
|
|
61
|
-
<text x="710" y="186" fill="#8b949e" font-size="12">④ 模型 SHA256 + 域名白名单</text>
|
|
62
|
-
<text x="710" y="214" fill="#8b949e" font-size="12">打断:VAD 帧级检测 + 回声门控</text>
|
|
63
|
-
<text x="710" y="234" fill="#8b949e" font-size="12">模式:持续聆听 ⇄ 按住说</text>
|
|
64
|
-
<text x="710" y="254" fill="#8b949e" font-size="12">空闲:朗读计为活动</text>
|
|
65
|
-
|
|
66
|
-
<!-- 数据流连线 -->
|
|
67
|
-
<line x1="130" y1="126" x2="130" y2="163" stroke="#8b949e" stroke-width="1.5" marker-end="url(#arr)"/>
|
|
68
|
-
<line x1="230" y1="190" x2="326" y2="100" stroke="#8b949e" stroke-width="1.5" marker-end="url(#arr)"/>
|
|
69
|
-
<line x1="475" y1="130" x2="475" y2="163" stroke="#8b949e" stroke-width="1.5" marker-end="url(#arr)"/>
|
|
70
|
-
<line x1="330" y1="193" x2="232" y2="313" stroke="#8b949e" stroke-width="1.5" marker-end="url(#arr)"/>
|
|
71
|
-
<line x1="230" y1="313" x2="326" y2="283" stroke="#8b949e" stroke-width="1.5" marker-end="url(#arr)"/>
|
|
72
|
-
<line x1="475" y1="311" x2="475" y2="343" stroke="#8b949e" stroke-width="1.5" marker-end="url(#arr)"/>
|
|
73
|
-
<line x1="475" y1="401" x2="475" y2="433" stroke="#8b949e" stroke-width="1.5" marker-end="url(#arr)"/>
|
|
74
|
-
<line x1="330" y1="485" x2="232" y2="440" stroke="#8b949e" stroke-width="1.5" marker-end="url(#arr)"/>
|
|
75
|
-
|
|
76
|
-
<!-- 打断链路(红色) -->
|
|
77
|
-
<path d="M130,475 L130,600 L475,600 L475,403" fill="none" stroke="#f85149" stroke-width="1.5" marker-end="url(#arrR)"/>
|
|
78
|
-
<text x="300" y="592" fill="#f85149" font-size="12" text-anchor="middle">说话打断:本地静音 + 队列作废 + 回合取消</text>
|
|
79
|
-
</svg>
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" font-family="Segoe UI, system-ui, sans-serif" font-size="14" viewBox="0 0 960 640"><defs><marker id="arr" markerHeight="8" markerWidth="8" orient="auto" refX="7" refY="4"><path fill="#8b949e" d="M0,0 L8,4 L0,8 z"/></marker><marker id="arrR" markerHeight="8" markerWidth="8" orient="auto" refX="7" refY="4"><path fill="#f85149" d="M0,0 L8,4 L0,8 z"/></marker></defs><rect width="960" height="640" fill="#0d1117"/><text x="480" y="30" fill="#e6edf3" font-size="20" font-weight="700" text-anchor="middle">dsh-voice-mode — 语音双工数据流</text><rect width="200" height="56" x="30" y="70" fill="#161b22" stroke="#58a6ff" stroke-width="1.5" rx="10"/><text x="130" y="92" fill="#58a6ff" font-weight="700" text-anchor="middle">麦克风 Mic</text><text x="130" y="112" fill="#8b949e" font-size="12" text-anchor="middle">16kHz 单声道 · AEC 回声消除</text><rect width="200" height="70" x="30" y="165" fill="#161b22" stroke="#58a6ff" stroke-width="1.5" rx="10"/><text x="130" y="189" fill="#58a6ff" font-weight="700" text-anchor="middle">浏览器 VAD 分段</text><text x="130" y="209" fill="#8b949e" font-size="12" text-anchor="middle">静音 700ms 断句 / 按住说门控</text><text x="130" y="227" fill="#8b949e" font-size="12" text-anchor="middle">增量传输(每 0.9s 只传新增)</text><rect width="200" height="56" x="30" y="285" fill="#161b22" stroke="#3fb950" stroke-width="1.5" rx="10"/><text x="130" y="309" fill="#3fb950" font-weight="700" text-anchor="middle">草稿 → 自动发送</text><text x="130" y="329" fill="#8b949e" font-size="12" text-anchor="middle">autoSend / 按住说松手发送</text><rect width="200" height="70" x="30" y="405" fill="#161b22" stroke="#3fb950" stroke-width="1.5" rx="10"/><text x="130" y="429" fill="#3fb950" font-weight="700" text-anchor="middle">播放 + 字幕浮层</text><text x="130" y="449" fill="#8b949e" font-size="12" text-anchor="middle">SSE 音频帧(WAV/MP3)</text><text x="130" y="467" fill="#8b949e" font-size="12" text-anchor="middle">逐段顺序 · 世代链防重播</text><rect width="290" height="60" x="330" y="70" fill="#161b22" stroke="#58a6ff" stroke-width="1.5" rx="10"/><text x="475" y="94" fill="#58a6ff" font-weight="700" text-anchor="middle">zipformer2 流式识别</text><text x="475" y="114" fill="#8b949e" font-size="12" text-anchor="middle">host 本地 WASM · 启动预热 · SHA256 校验</text><rect width="290" height="56" x="330" y="165" fill="#161b22" stroke="#d29922" stroke-width="1.5" rx="10"/><text x="475" y="189" fill="#d29922" font-weight="700" text-anchor="middle">SenseVoice 定稿</text><text x="475" y="207" fill="#8b949e" font-size="12" text-anchor="middle">带标点 · 数字归一化</text><rect width="290" height="56" x="330" y="255" fill="#161b22" stroke="#a371f7" stroke-width="1.5" rx="10"/><text x="475" y="279" fill="#a371f7" font-weight="700" text-anchor="middle">llm/stream 无损 tap → 分句</text><text x="475" y="297" fill="#8b949e" font-size="12" text-anchor="middle">text-delta 过滤 · markdown 剥离</text><rect width="290" height="56" x="330" y="345" fill="#161b22" stroke="#a371f7" stroke-width="1.5" rx="10"/><text x="475" y="369" fill="#a371f7" font-weight="700" text-anchor="middle">TTS 队列(epoch 打断)</text><text x="475" y="387" fill="#8b949e" font-size="12" text-anchor="middle">打断即杀在途合成 · 积压作废</text><rect width="290" height="100" x="330" y="435" fill="#161b22" stroke="#3fb950" stroke-width="1.5" rx="10"/><text x="475" y="459" fill="#3fb950" font-weight="700" text-anchor="middle">朗读引擎 TTS</text><text x="475" y="481" fill="#8b949e" font-size="12" text-anchor="middle">Edge 云端(默认,322 音色)</text><text x="475" y="501" fill="#8b949e" font-size="12" text-anchor="middle">VITS 本地 · 纯中文(WASM)</text><text x="475" y="521" fill="#8b949e" font-size="12" text-anchor="middle">Kokoro 本地 · 中英(int8 109MB / fp32 311MB)</text><rect width="240" height="200" x="690" y="70" fill="#161b22" stroke="#30363d" stroke-width="1" rx="10"/><text x="810" y="98" fill="#e6edf3" font-weight="700" text-anchor="middle">安全面(四层)</text><text x="710" y="126" fill="#8b949e" font-size="12">① 会话存在性校验</text><text x="710" y="146" fill="#8b949e" font-size="12">② 回环 + Origin 校验</text><text x="710" y="166" fill="#8b949e" font-size="12">③ 全端点限流</text><text x="710" y="186" fill="#8b949e" font-size="12">④ 模型 SHA256 + 域名白名单</text><text x="710" y="214" fill="#8b949e" font-size="12">打断:VAD 帧级检测 + 回声门控</text><text x="710" y="234" fill="#8b949e" font-size="12">模式:持续聆听 ⇄ 按住说</text><text x="710" y="254" fill="#8b949e" font-size="12">空闲:朗读计为活动</text><line x1="130" x2="130" y1="126" y2="163" stroke="#8b949e" stroke-width="1.5" marker-end="url(#arr)"/><line x1="230" x2="326" y1="190" y2="100" stroke="#8b949e" stroke-width="1.5" marker-end="url(#arr)"/><line x1="475" x2="475" y1="130" y2="163" stroke="#8b949e" stroke-width="1.5" marker-end="url(#arr)"/><line x1="330" x2="232" y1="193" y2="313" stroke="#8b949e" stroke-width="1.5" marker-end="url(#arr)"/><line x1="230" x2="326" y1="313" y2="283" stroke="#8b949e" stroke-width="1.5" marker-end="url(#arr)"/><line x1="475" x2="475" y1="311" y2="343" stroke="#8b949e" stroke-width="1.5" marker-end="url(#arr)"/><line x1="475" x2="475" y1="401" y2="433" stroke="#8b949e" stroke-width="1.5" marker-end="url(#arr)"/><line x1="330" x2="232" y1="485" y2="440" stroke="#8b949e" stroke-width="1.5" marker-end="url(#arr)"/><path fill="none" stroke="#f85149" stroke-width="1.5" marker-end="url(#arrR)" d="M130,475 L130,600 L475,600 L475,403"/><text x="300" y="592" fill="#f85149" font-size="12" text-anchor="middle">说话打断:本地静音 + 队列作废 + 回合取消</text></svg>
|
package/assets/demo.gif
CHANGED
|
Binary file
|