Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
feat(voice): 为桌面和手机添加本地声纹过滤
DavidShen31b0fb0a262d
diff --git a/apps/desktop/forge.config.ts b/apps/desktop/forge.config.tsindex 880d0fe112..e5538756b8 100644--- a/apps/desktop/forge.config.ts+++ b/apps/desktop/forge.config.ts@@ -249,6 +249,16 @@ function sharpPlatformPkgs(platform: string, arch: string): string[] {return pkgs;}+/**+ * sherpa-onnx-node 按 platform-arch 拆出预编译子包,Windows 子包名用 `win` 而非+ * `win32`。子包里 sherpa-onnx.node 与 onnxruntime / sherpa-onnx-c-api 动态库并排,+ * 必须整目录解包(见 packagerConfig.asar)。同上用 TARGET platform/arch。+ */+function sherpaOnnxRuntimePackages(platform: string, arch: string): string[] {+ const platformName = platform === 'win32' ? 'win' : platform;+ return ['sherpa-onnx-node', `sherpa-onnx-${platformName}-${arch}`];+}+// Locate a package's directory on disk. Some packages ship a strict `exports`// map that hides the obvious resolve targets:// - `long` blocks `./package.json` but exposes a main entry → walk up from@@ -386,6 +396,9 @@ function bundleNativeDeps(buildPath: string, targetPlatform: string, targetArch:// 必须运行时按 __dirname 找 — 所以走 NATIVE_RUNTIME_DEPS 这条路, 不让 vite// bundle。Mac/Linux 完全不带, 避免拖入 execa 这条无用依赖链。...(targetPlatform === 'win32' ? ['loudness'] : []),+ // 语音「只识别我的声音」的推理库:JS 主包 + 目标平台的预编译子包+ // (.node 与 onnxruntime 动态库同目录,整目录 asar.unpack)。+ ...sherpaOnnxRuntimePackages(targetPlatform, targetArch),];// node-addon-api 必须解析成 node-pty 实际依赖的那一版 (7.x, 有 `.targets`),// 不能让它退化到 root 可能 hoist 的 1.7.2。以 node-pty 目录为解析起点。@@ -1784,9 +1797,11 @@ const config: ForgeConfig = {// node-pty 在 macOS/Linux 上会 posix_spawn 一个无扩展名的 spawn-helper、在// Windows 上也带 winpty-agent.exe / DLL 等非 .node 二进制;这些都必须 unpack// 到 asar 外才能被 spawn / 动态加载。AutoUnpackNativesPlugin 只 unpack .node,- // 所以这里显式覆盖 loudness / node-pty 整个目录。+ // 所以这里显式覆盖 loudness / node-pty 整个目录。sherpa-onnx 平台子包同理:+ // .node 依赖同目录的 onnxruntime 动态库,只解包 .node 会加载失败。asar: {- unpack: '**/{@img/{sharp-libvips-*,sharp-win32-*},loudness,native/sqlite-vec,node-pty}/**',+ unpack:+ '**/{@img/{sharp-libvips-*,sharp-win32-*},loudness,native/sqlite-vec,node-pty,sherpa-onnx-{darwin,win,linux}-*}/**',},// 打包名(out 目录 / mac .app 包名 / Helper 目录名 / 主 plist CFBundleName)// 按区域派生:cn/global 'Cindy'(2026-07-26 显示名统一,.app 撞名双装@@ -2042,6 +2057,12 @@ const config: ForgeConfig = {// SILK/WASM 解码隔离在线程中,避免阻塞 Electron main。target: 'preload',},+ {+ entry: 'src/main/voice-input/speaker/speakerGateWorker.ts',+ config: 'vite.speaker-gate-worker.config.ts',+ // 声纹过滤的 ONNX 推理是同步 CPU 计算,隔离在线程中,避免阻塞 Electron main。+ target: 'preload',+ },{entry: 'src/main/contacts-sync/contactsSyncCodecWorker.ts',config: 'vite.contacts-sync-codec-worker.config.ts',diff --git a/apps/desktop/package.json b/apps/desktop/package.jsonindex 9517c88247..2615d2d68f 100644--- a/apps/desktop/package.json+++ b/apps/desktop/package.json@@ -175,6 +175,7 @@"remark-math": "^6.0.0","semver": "^7.8.5","sharp": "^0.35.0",+ "sherpa-onnx-node": "1.13.8","silk-wasm": "^3.7.1","smol-toml": "^1.6.1","sortablejs": "^1.15.6",diff --git a/apps/desktop/resources/THIRD-PARTY-NOTICES.txt b/apps/desktop/resources/THIRD-PARTY-NOTICES.txtindex 45725e65b1..586b3eb0a0 100644--- a/apps/desktop/resources/THIRD-PARTY-NOTICES.txt+++ b/apps/desktop/resources/THIRD-PARTY-NOTICES.txt@@ -465,6 +465,213 @@ Exact bundled library versions:Corresponding build recipes and pinned upstream source locations are available at the exact sharp-libvips tag above. The bundled libvips version is 8.18.3.+------------------------------------------------------------------------------+3D-Speaker CAM++ zh-en advanced (runtime-downloaded model) sha256:aa3cfc16963a10586a9393f5035d6d6b57e98d358b347f80c2a30bf4f00ceba2+License: Apache-2.0+Source: https://modelscope.cn/models/iic/speech_campplus_sv_zh_en_16k-common_advanced+------------------------------------------------------------------------------+Apache License+ Version 2.0, January 2004+ http://www.apache.org/licenses/++ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION++ 1. Definitions.++ "License" shall mean the terms and conditions for use, reproduction,+ and distribution as defined by Sections 1 through 9 of this document.++ "Licensor" shall mean the copyright owner or entity authorized by+ the copyright owner that is granting the License.++ "Legal Entity" shall mean the union of the acting entity and all+ other entities that control, are controlled by, or are under common+ control with that entity. For the purposes of this definition,+ "control" means (i) the power, direct or indirect, to cause the+ direction or management of such entity, whether by contract or+ otherwise, or (ii) ownership of fifty percent (50%) or more of the+ outstanding shares, or (iii) beneficial ownership of such entity.++ "You" (or "Your") shall mean an individual or Legal Entity+ exercising permissions granted by this License.++ "Source" form shall mean the preferred form for making modifications,+ including but not limited to software source code, documentation+ source, and configuration files.++ "Object" form shall mean any form resulting from mechanical+ transformation or translation of a Source form, including but+ not limited to compiled object code, generated documentation,+ and conversions to other media types.++ "Work" shall mean the work of authorship, whether in Source or+ Object form, made available under the License, as indicated by a+ copyright notice that is included in or attached to the work+ (an example is provided in the Appendix below).++ "Derivative Works" shall mean any work, whether in Source or Object+ form, that is based on (or derived from) the Work and for which the+ editorial revisions, annotations, elaborations, or other modifications+ represent, as a whole, an original work of authorship. For the purposes+ of this License, Derivative Works shall not include works that remain+ separable from, or merely link (or bind by name) to the interfaces of,+ the Work and Derivative Works thereof.++ "Contribution" shall mean any work of authorship, including+ the original version of the Work and any modifications or additions+ to that Work or Derivative Works thereof, that is intentionally+ submitted to Licensor for inclusion in the Work by the copyright owner+ or by an individual or Legal Entity authorized to submit on behalf of+ the copyright owner. For the purposes of this definition, "submitted"+ means any form of electronic, verbal, or written communication sent+ to the Licensor or its representatives, including but not limited to+ communication on electronic mailing lists, source code control systems,+ and issue tracking systems that are managed by, or on behalf of, the+ Licensor for the purpose of discussing and improving the Work, but+ excluding communication that is conspicuously marked or otherwise+ designated in writing by the copyright owner as "Not a Contribution."++ "Contributor" shall mean Licensor and any individual or Legal Entity+ on behalf of whom a Contribution has been received by Licensor and+ subsequently incorporated within the Work.++ 2. Grant of Copyright License. Subject to the terms and conditions of+ this License, each Contributor hereby grants to You a perpetual,+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable+ copyright license to reproduce, prepare Derivative Works of,+ publicly display, publicly perform, sublicense, and distribute the+ Work and such Derivative Works in Source or Object form.++ 3. Grant of Patent License. Subject to the terms and conditions of+ this License, each Contributor hereby grants to You a perpetual,+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable+ (except as stated in this section) patent license to make, have made,+ use, offer to sell, sell, import, and otherwise transfer the Work,+ where such license applies only to those patent claims licensable+ by such Contributor that are necessarily infringed by their+ Contribution(s) alone or by combination of their Contribution(s)+ with the Work to which such Contribution(s) was submitted. If You+ institute patent litigation against any entity (including a+ cross-claim or counterclaim in a lawsuit) alleging that the Work+ or a Contribution incorporated within the Work constitutes direct+ or contributory patent infringement, then any patent licenses+ granted to You under this License for that Work shall terminate+ as of the date such litigation is filed.++ 4. Redistribution. You may reproduce and distribute copies of the+ Work or Derivative Works thereof in any medium, with or without+ modifications, and in Source or Object form, provided that You+ meet the following conditions:++ (a) You must give any other recipients of the Work or+ Derivative Works a copy of this License; and++ (b) You must cause any modified files to carry prominent notices+ stating that You changed the files; and++ (c) You must retain, in the Source form of any Derivative Works+ that You distribute, all copyright, patent, trademark, and+ attribution notices from the Source form of the Work,+ excluding those notices that do not pertain to any part of+ the Derivative Works; and++ (d) If the Work includes a "NOTICE" text file as part of its+ distribution, then any Derivative Works that You distribute must+ include a readable copy of the attribution notices contained+ within such NOTICE file, excluding those notices that do not+ pertain to any part of the Derivative Works, in at least one+ of the following places: within a NOTICE text file distributed+ as part of the Derivative Works; within the Source form or+ documentation, if provided along with the Derivative Works; or,+ within a display generated by the Derivative Works, if and+ wherever such third-party notices normally appear. The contents+ of the NOTICE file are for informational purposes only and+ do not modify the License. You may add Your own attribution+ notices within Derivative Works that You distribute, alongside+ or as an addendum to the NOTICE text from the Work, provided+ that such additional attribution notices cannot be construed+ as modifying the License.++ You may add Your own copyright statement to Your modifications and+ may provide additional or different license terms and conditions+ for use, reproduction, or distribution of Your modifications, or+ for any such Derivative Works as a whole, provided Your use,+ reproduction, and distribution of the Work otherwise complies with+ the conditions stated in this License.++ 5. Submission of Contributions. Unless You explicitly state otherwise,+ any Contribution intentionally submitted for inclusion in the Work+ by You to the Licensor shall be under the terms and conditions of+ this License, without any additional terms or conditions.+ Notwithstanding the above, nothing herein shall supersede or modify+ the terms of any separate license agreement you may have executed+ with Licensor regarding such Contributions.++ 6. Trademarks. This License does not grant permission to use the trade+ names, trademarks, service marks, or product names of the Licensor,+ except as required for reasonable and customary use in describing the+ origin of the Work and reproducing the content of the NOTICE file.++ 7. Disclaimer of Warranty. Unless required by applicable law or+ agreed to in writing, Licensor provides the Work (and each+ Contributor provides its Contributions) on an "AS IS" BASIS,+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or+ implied, including, without limitation, any warranties or conditions+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A+ PARTICULAR PURPOSE. You are solely responsible for determining the+ appropriateness of using or redistributing the Work and assume any+ risks associated with Your exercise of permissions under this License.++ 8. Limitation of Liability. In no event and under no legal theory,+ whether in tort (including negligence), contract, or otherwise,+ unless required by applicable law (such as deliberate and grossly+ negligent acts) or agreed to in writing, shall any Contributor be+ liable to You for damages, including any direct, indirect, special,+ incidental, or consequential damages of any character arising as a+ result of this License or out of the use or inability to use the+ Work (including but not limited to damages for loss of goodwill,+ work stoppage, computer failure or malfunction, or any and all+ other commercial damages or losses), even if such Contributor+ has been advised of the possibility of such damages.++ 9. Accepting Warranty or Additional Liability. While redistributing+ the Work or Derivative Works thereof, You may choose to offer,+ and charge a fee for, acceptance of support, warranty, indemnity,+ or other liability obligations and/or rights consistent with this+ License. However, in accepting such obligations, You may act only+ on Your own behalf and on Your sole responsibility, not on behalf+ of any other Contributor, and only if You agree to indemnify,+ defend, and hold each Contributor harmless for any liability+ incurred by, or claims asserted against, such Contributor by reason+ of your accepting any such warranty or additional liability.++ END OF TERMS AND CONDITIONS++ APPENDIX: How to apply the Apache License to your work.++ To apply the Apache License to your work, attach the following+ boilerplate notice, with the fields enclosed by brackets "[]"+ replaced with your own identifying information. (Don't include+ the brackets!) The text should be enclosed in the appropriate+ comment syntax for the file format. We also recommend that a+ file or class name and description of purpose be included on the+ same "printed page" as the copyright notice for easier+ identification within third-party archives.++ Copyright [yyyy] [name of copyright owner]++ Licensed under the Apache License, Version 2.0 (the "License");+ you may not use this file except in compliance with the License.+ You may obtain a copy of the License at++ http://www.apache.org/licenses/LICENSE-2.0++ Unless required by applicable law or agreed to in writing, software+ distributed under the License is distributed on an "AS IS" BASIS,+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ See the License for the specific language governing permissions and+ limitations under the License.+------------------------------------------------------------------------------Android SDK Platform-Tools (bundled binaries) 32.0.0License: LicenseRef-Android-Platform-Tools-Notice@@ -3641,6 +3848,31 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS INTHE SOFTWARE.+------------------------------------------------------------------------------+ONNX Runtime (native inference library) bundled with sherpa-onnx-node 1.13.8+License: MIT+Source: https://github.com/microsoft/onnxruntime+------------------------------------------------------------------------------+Copyright (c) Microsoft Corporation++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in+all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+THE SOFTWARE.+------------------------------------------------------------------------------OpenAI Codex CLI (runtime-downloaded binary) 0.159.2License: Apache-2.0@@ -4191,6 +4423,31 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS INTHE SOFTWARE.+------------------------------------------------------------------------------+Silero VAD (runtime-downloaded model) sha256:9e2449e1087496d8d4caba907f23e0bd3f78d91fa552479bb9c23ac09cbb1fd6+License: MIT+Source: https://github.com/snakers4/silero-vad+------------------------------------------------------------------------------+Copyright (c) 2020-present Silero Team++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in+all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+THE SOFTWARE.+------------------------------------------------------------------------------SQLite (compiled into better-sqlite3) see better-sqlite3 package version aboveLicense: LicenseRef-Public-Domain@@ -4465,7 +4722,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.==============================================================================-SECTION 2: npm packages (923 packages)+SECTION 2: npm packages (929 packages)==============================================================================- @antfu/[email protected] — MIT — https://github.com/antfu/install-pkg@@ -5290,6 +5547,12 @@ SECTION 2: npm packages (923 packages)- [email protected] — MIT — https://github.com/sindresorhus/shebang-regex- [email protected] — MIT — https://github.com/sindresorhus/shell-env- [email protected] — MIT — https://github.com/sindresorhus/shell-path+- [email protected] — Apache-2.0 — https://github.com/csukuangfj/sherpa-onnx+- [email protected] — Apache-2.0 — https://github.com/csukuangfj/sherpa-onnx+- [email protected] — Apache-2.0 — https://github.com/csukuangfj/sherpa-onnx+- [email protected] — Apache-2.0 — https://github.com/csukuangfj/sherpa-onnx+- [email protected] — Apache-2.0 — https://github.com/csukuangfj/sherpa-onnx+- [email protected] — Apache-2.0 — https://github.com/csukuangfj/sherpa-onnx- [email protected] — MIT — https://github.com/ljharb/side-channel- [email protected] — MIT — https://github.com/ljharb/side-channel-list- [email protected] — MIT — https://github.com/ljharb/side-channel-map@@ -42793,3 +43056,9 @@ Packages without a standalone license file (license per package.json):- npm:[email protected] (MIT)- npm:[email protected] (MIT)- npm:[email protected] (ISC)+- npm:[email protected] (Apache-2.0)+- npm:[email protected] (Apache-2.0)+- npm:[email protected] (Apache-2.0)+- npm:[email protected] (Apache-2.0)+- npm:[email protected] (Apache-2.0)+- npm:[email protected] (Apache-2.0)diff --git a/apps/desktop/src/main/voice-input/VoiceInputDataStore.ts b/apps/desktop/src/main/voice-input/VoiceInputDataStore.tsindex e842c49625..6aaee390f5 100644--- a/apps/desktop/src/main/voice-input/VoiceInputDataStore.ts+++ b/apps/desktop/src/main/voice-input/VoiceInputDataStore.ts@@ -8,6 +8,7 @@ import {coalesceDictionaryLearningActions,deleteTerms,dictionaryTermKey,+ isSpeakerGateStrictness,materializeDictionary,recordLearningEvent,renameTerm,@@ -111,7 +112,7 @@ export class VoiceInputDataStore {// 在下一次物化时被静默丢掉。词典变更一律走下面的语义化入口。const nextSettings = normalizeVoiceInputSettings({...current.settings,- ...translateComposerLongPressPatch(stripDictionaryFields(patch)),+ ...translateSpeakerFilterStrictnessPatch(translateComposerLongPressPatch(stripDictionaryFields(patch))),}, process.platform);this.replaceState({...current,@@ -954,13 +955,14 @@ function cloneSettings(settings: VoiceInputSettings): VoiceInputSettings {* 落盘只记录 override。运行时快照里的 `composerLongPressEnabled` / `dictionarySyncEnabled`* 是默认值 + override 合成的有效值;写进文件会把当时的默认钉死,未自定义的用户就跟不上* 后续改默认 —— 尤其是「恢复默认」后残留的旧有效值,将来默认一变就会被- * `legacyDictionarySyncOverride()` 重新解释成显式 override。两个字段都只持久化- * 各自的 `*Override`。+ * `legacyDictionarySyncOverride()` 重新解释成显式 override。这几个字段(含声纹过滤+ * 灵敏度 `speakerFilterStrictness`)都只持久化各自的 `*Override`。*/function projectVoiceInputDataForPersist(state: StoredVoiceInputData): unknown {const settings: Record<string, unknown> = { ...state.settings };delete settings.composerLongPressEnabled;delete settings.dictionarySyncEnabled;+ delete settings.speakerFilterStrictness;return { ...state, settings };}@@ -1042,6 +1044,20 @@ function stripDictionaryFields(patch: unknown): Record<string, unknown> {return next;}+/** 声纹过滤灵敏度:同样只记 override,renderer 传有效值字段;`null` = 恢复默认。 */+function translateSpeakerFilterStrictnessPatch(patch: Record<string, unknown>): Record<string, unknown> {+ if (!('speakerFilterStrictness' in patch)) return patch;+ const next = { ...patch };+ const value = next.speakerFilterStrictness;+ delete next.speakerFilterStrictness;+ if (isSpeakerGateStrictness(value)) {+ next.speakerFilterStrictnessOverride = value;+ } else if (value === null) {+ next.speakerFilterStrictnessOverride = null;+ }+ return next;+}+/*** 长按输入框开关:UI 传有效值,持久化只认 override(规则同上面的同步开关)。* 每次显式拨动都记成 override;`null` = 恢复默认,删掉 override 跟随版本默认值。diff --git a/apps/desktop/src/main/voice-input/__tests__/speakerFilterSetting.test.ts b/apps/desktop/src/main/voice-input/__tests__/speakerFilterSetting.test.tsnew file mode 100644index 0000000000..476f713a1c--- /dev/null+++ b/apps/desktop/src/main/voice-input/__tests__/speakerFilterSetting.test.ts@@ -0,0 +1,114 @@+/**+ * 「识别我的声音」设置的落盘契约:开关是普通布尔值;灵敏度只记录用户 override,+ * 不把默认档位固化进用户配置(docs/dev-rules/configuration-and-overrides.md §2)。+ */++import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';+import fs from 'node:fs';+import os from 'node:os';+import path from 'node:path';++let tempDir = '';++vi.mock('electron', () => ({+ app: { getPath: () => tempDir },+ ipcMain: { handle: vi.fn(), on: vi.fn() },+ BrowserWindow: { getAllWindows: () => [] },+}));+vi.mock('../../logger.js', () => ({+ createLogger: () => ({ info: () => {}, warn: () => {}, error: () => {}, debug: () => {} }),+}));+vi.mock('../../appSessionState.js', () => ({+ getActiveAppSession: () => ({ dataOwnerId: 'owner-1' }),+ ownerScopedUserDataPath: (...parts: string[]) => path.join(tempDir, 'owners', 'owner-1', ...parts),+}));+vi.mock('../../utils/ipcValidate.js', () => ({+ throwIpcError: (code: string, message: string) => {+ throw new Error(`[${code}] ${message}`);+ },+}));++const { voiceDictionarySyncStore } = await import('../VoiceDictionarySyncStore.js');+const { voiceInputDataStore } = await import('../VoiceInputDataStore.js');++const DATA_FILE = 'voice-input-data.v1.json';++function dataFilePath(): string {+ return path.join(tempDir, 'owners', 'owner-1', DATA_FILE);+}++function writeSettingsFile(settings: Record<string, unknown>): void {+ fs.mkdirSync(path.dirname(dataFilePath()), { recursive: true });+ fs.writeFileSync(dataFilePath(), JSON.stringify({ version: 1, settings, history: [] }), 'utf-8');+}++function readPersistedSettings(): Record<string, unknown> {+ return JSON.parse(fs.readFileSync(dataFilePath(), 'utf-8')).settings;+}++/** 两个 store 都按 ownerId 缓存内存状态,每个用例都要从磁盘重新读。 */+function resetStoreCaches(): void {+ (voiceDictionarySyncStore as unknown as { data: unknown; dataOwnerId: unknown }).data = null;+ (voiceDictionarySyncStore as unknown as { data: unknown; dataOwnerId: unknown }).dataOwnerId = null;+ (voiceDictionarySyncStore as unknown as { pendingRecovery: unknown }).pendingRecovery = null;+ (voiceInputDataStore as unknown as { state: unknown; stateOwnerId: unknown }).state = null;+ (voiceInputDataStore as unknown as { state: unknown; stateOwnerId: unknown }).stateOwnerId = null;+}++beforeEach(() => {+ tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'cindy-speaker-filter-setting-'));+ resetStoreCaches();+});++afterEach(() => {+ fs.rmSync(tempDir, { recursive: true, force: true });+});++describe('识别我的声音 —— 开关与灵敏度', () => {+ it('默认关闭、标准档;无关设置保存不会写入灵敏度', () => {+ writeSettingsFile({ dictionaryEntries: [] });+ const settings = voiceInputDataStore.getSettings();+ expect(settings.speakerFilterEnabled).toBe(false);+ expect(settings.speakerFilterStrictness).toBe('standard');++ voiceInputDataStore.updateSettings({ language: 'zh-CN' });+ expect(readPersistedSettings().speakerFilterStrictnessOverride).toBeUndefined();+ expect(readPersistedSettings().speakerFilterStrictness).toBeUndefined();+ });++ it('打开开关后重载保持', () => {+ writeSettingsFile({ dictionaryEntries: [] });+ voiceInputDataStore.updateSettings({ speakerFilterEnabled: true });+ expect(readPersistedSettings().speakerFilterEnabled).toBe(true);+ resetStoreCaches();+ expect(voiceInputDataStore.getSettings().speakerFilterEnabled).toBe(true);+ });++ it('选择灵敏度只记 override,重载后保持', () => {+ writeSettingsFile({ dictionaryEntries: [] });+ const next = voiceInputDataStore.updateSettings({ speakerFilterStrictness: 'strict' });+ expect(next.speakerFilterStrictness).toBe('strict');+ expect(readPersistedSettings().speakerFilterStrictnessOverride).toBe('strict');+ expect(readPersistedSettings().speakerFilterStrictness).toBeUndefined();++ resetStoreCaches();+ expect(voiceInputDataStore.getSettings().speakerFilterStrictness).toBe('strict');+ });++ it('传 null 恢复默认:删除 override,重新跟随版本默认档位', () => {+ writeSettingsFile({ dictionaryEntries: [] });+ voiceInputDataStore.updateSettings({ speakerFilterStrictness: 'relaxed' });+ const next = voiceInputDataStore.updateSettings({ speakerFilterStrictness: null });+ expect(next.speakerFilterStrictness).toBe('standard');+ expect(readPersistedSettings().speakerFilterStrictnessOverride).toBeUndefined();+ });++ it('非法档位被忽略,残留的有效值不会被当成用户选择', () => {+ writeSettingsFile({ dictionaryEntries: [], speakerFilterStrictness: 'strict' });+ expect(voiceInputDataStore.getSettings().speakerFilterStrictness).toBe('standard');++ voiceInputDataStore.updateSettings({ speakerFilterStrictness: 'extreme' } as never);+ expect(voiceInputDataStore.getSettings().speakerFilterStrictness).toBe('standard');+ expect(readPersistedSettings().speakerFilterStrictnessOverride).toBeUndefined();+ });+});diff --git a/apps/desktop/src/main/voice-input/index.ts b/apps/desktop/src/main/voice-input/index.tsindex b774b5b932..b89f9c8aa2 100644--- a/apps/desktop/src/main/voice-input/index.ts+++ b/apps/desktop/src/main/voice-input/index.ts@@ -155,6 +155,7 @@ import {type VoiceInputConnectionTestResult,} from '../../shared/voiceInputConnectionTest.js';import { runSerializedVoiceInputConnectionTest } from './voiceInputConnectionTest.js';+import { getSpeakerFilterService, registerVoiceSpeakerFilterIpc } from './speaker/index.js';const log = createLogger('voice-input');let customAsrCredentialRevision = 0;@@ -1876,6 +1877,7 @@ export async function transcribeVoiceInputAudioFile(*/export function registerVoiceInputIpc(): void {registerVoiceInputDataStoreIpc();+ registerVoiceSpeakerFilterIpc();if (!appRestoreRegistered) {appRestoreRegistered = true;app.once('before-quit', () => {@@ -2342,9 +2344,12 @@ export function registerVoiceInputIpc(): void {if (runId) emit({ type: 'timeline', runId, event: timelineEvent });});+ // "Recognize my voice": undefined unless enabled, enrolled and the models are on disk.+ const audioGate = getSpeakerFilterService().createGate(voiceInputDataStore.getSettings());const controller = new VoiceInputController({asr: provider,refiner,+ audioGate,pauseRefinementEnabled: true,recoveryErrorMessage: voiceContext ? getVoiceInputRateLimitMessage : undefined,logger,@@ -2430,6 +2435,7 @@ export function registerVoiceInputIpc(): void {refiner: refiner ? effectiveRefinerProfile?.model : undefined,refinerProvider: refiner ? effectiveRefinerProfile?.id : undefined,refinerChain: refiner ? readyRefinerProfiles.map((profile) => profile.id) : undefined,+ speakerFilter: Boolean(audioGate),refinementEnabled: Boolean(refiner),refinementRequested: shouldRefine,refinementContext: refiner ? summarizeRefinementContext(refinementContext) : undefined,diff --git a/apps/desktop/src/main/voice-input/speaker/__tests__/speakerEngineHost.test.ts b/apps/desktop/src/main/voice-input/speaker/__tests__/speakerEngineHost.test.tsnew file mode 100644index 0000000000..31b39258a2--- /dev/null+++ b/apps/desktop/src/main/voice-input/speaker/__tests__/speakerEngineHost.test.ts@@ -0,0 +1,49 @@+import { EventEmitter } from 'node:events';+import { afterEach, describe, expect, it, vi } from 'vitest';++const workers: FakeWorker[] = [];+class FakeWorker extends EventEmitter {+ sent: Array<{ id: number; op: string }> = [];+ terminate = vi.fn(async () => 0);+ unref = vi.fn();+ postMessage = vi.fn((request: { id: number; op: string }) => { this.sent.push(request); });+ constructor() { super(); workers.push(this); }+ reply() { this.emit('message', { id: this.sent.at(-1)!.id, ok: true }); }+}+vi.mock('node:worker_threads', () => ({ Worker: FakeWorker }));+const { SpeakerEngineHost } = await import('../speakerEngineHost');++afterEach(() => { vi.useRealTimers(); workers.length = 0; });++describe('speaker worker request lifecycle', () => {+ it('times out a stalled model load and allows a fresh worker to retry', async () => {+ vi.useFakeTimers();+ const host = new SpeakerEngineHost(() => ({ vadModel: 'vad', embeddingModel: 'embedding' }), 'worker', 100);+ const pending = host.warm();+ const failure = expect(pending).rejects.toThrow('request_timeout');+ await vi.advanceTimersByTimeAsync(100);+ await failure;+ expect(workers[0].terminate).toHaveBeenCalledOnce();+ const retry = host.warm();+ expect(workers).toHaveLength(2);+ workers[1].reply();+ await retry;+ host.shutdown();+ expect(vi.getTimerCount()).toBe(0);+ });++ it('times out enrollment inference after a successful model load', async () => {+ vi.useFakeTimers();+ const host = new SpeakerEngineHost(() => ({ vadModel: 'vad', embeddingModel: 'embedding' }), 'worker', 100);+ const ready = host.warm();+ workers[0].reply();+ await ready;+ const pending = host.createEnrollmentEngine().embed(new Float32Array(160));+ const failure = expect(pending).rejects.toThrow('request_timeout');+ await vi.advanceTimersByTimeAsync(100);+ await failure;+ expect(workers[0].terminate).toHaveBeenCalledOnce();+ host.shutdown();+ expect(vi.getTimerCount()).toBe(0);+ });+});diff --git a/apps/desktop/src/main/voice-input/speaker/__tests__/speakerFilterService.test.ts b/apps/desktop/src/main/voice-input/speaker/__tests__/speakerFilterService.test.tsnew file mode 100644index 0000000000..3e645869da--- /dev/null+++ b/apps/desktop/src/main/voice-input/speaker/__tests__/speakerFilterService.test.ts@@ -0,0 +1,133 @@+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';+import fs from 'node:fs';+import os from 'node:os';+import path from 'node:path';++import { speakerModelAsset, speakerModelLocalName, SpeakerGate } from '@cindy/voice-input-core';++let tempDir = '';+let owner = 'owner-1';+let generation = 1;++vi.mock('electron', () => ({+ app: { getPath: () => tempDir, once: vi.fn() },+ ipcMain: { handle: vi.fn() },+ BrowserWindow: { getAllWindows: () => [] },+ safeStorage: {+ isEncryptionAvailable: () => true,+ encryptString: (plain: string) => Buffer.from(plain, 'utf-8'),+ decryptString: (cipher: Buffer) => cipher.toString('utf-8'),+ },+}));+vi.mock('../../../logger.js', () => ({+ createLogger: () => ({ info: () => {}, warn: () => {}, error: () => {}, debug: () => {} }),+}));+vi.mock('../../../appSessionState.js', () => ({+ ownerScopedUserDataPath: (...parts: string[]) => path.join(tempDir, 'owners', owner, ...parts),+ activeOwnerScopeKey: () => `${owner}:${generation}`,+ getActiveAppSession: () => ({ dataOwnerId: owner }),+ isAppSessionBoundaryPending: () => false,+}));+vi.mock('../../../clientEndpointsService.js', () => ({+ getClientEndpoint: () => 'https://cdn.example.com',+}));+vi.mock('../../../security/trustedAppRenderer.js', () => ({+ assertTrustedAppRendererEvent: () => {},+ isTrustedAppRendererWindow: () => true,+}));++const { getSpeakerFilterService, parseEnrollmentClips } = await import('../index');+const { SpeakerProfileStore } = await import('../speakerProfileStore');+const { SpeakerEngineHost } = await import('../speakerEngineHost');++beforeEach(() => {+ owner = 'owner-1';+ generation = 1;+ tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'cindy-speaker-service-'));+});++afterEach(() => {+ vi.restoreAllMocks();+ getSpeakerFilterService().shutdown();+ fs.rmSync(tempDir, { recursive: true, force: true });+});++function installModels(): void {+ const dir = path.join(tempDir, 'voice-models');+ fs.mkdirSync(dir, { recursive: true });+ for (const role of ['vad', 'embedding'] as const) {+ const asset = speakerModelAsset(role);+ // Only the size is checked; a sparse file of the right length is enough.+ const fd = fs.openSync(path.join(dir, speakerModelLocalName(asset)), 'w');+ fs.ftruncateSync(fd, asset.bytes);+ fs.closeSync(fd);+ }+}++function enroll(): void {+ new SpeakerProfileStore(() => path.join(tempDir, 'owners', 'owner-1', 'voice-speaker-profile.json'), {+ isAvailable: () => true,+ encrypt: (plain) => Buffer.from(plain, 'utf-8'),+ decrypt: (cipher) => cipher.toString('utf-8'),+ }).write(Float32Array.from([1, 0, 0]));+}++const on = { speakerFilterEnabled: true, speakerFilterStrictness: 'standard' } as const;++describe('speaker filter service', () => {+ it.each(['switch', 'delete'] as const)('discards enrollment after %s while inference is pending', async (action) => {+ installModels();+ let release!: () => void;+ const waiting = new Promise<void>((resolve) => { release = resolve; });+ vi.spyOn(SpeakerEngineHost.prototype, 'createEnrollmentEngine').mockReturnValue({+ extractSpeech: async () => { await waiting; return new Float32Array(48_000); },+ embed: async () => Float32Array.of(1, 0),+ });+ const service = getSpeakerFilterService();+ const pending = service.enroll([new ArrayBuffer(2), new ArrayBuffer(2), new ArrayBuffer(2)]);+ if (action === 'switch') { owner = 'owner-2'; generation += 1; }+ else service.deleteProfile();+ release();+ expect(await pending).toMatchObject({ ok: false });+ expect(service.getStatus().enrolled).toBe(false);+ expect(fs.existsSync(path.join(tempDir, 'owners', owner, 'voice-speaker-profile.json'))).toBe(false);+ });++ it.runIf(getSpeakerFilterService().supported)('builds a gate only when on, downloaded and enrolled', () => {+ const service = getSpeakerFilterService();+ expect(service.createGate(on)).toBeUndefined();++ installModels();+ expect(service.createGate(on)).toBeUndefined();++ enroll();+ expect(service.createGate({ ...on, speakerFilterEnabled: false })).toBeUndefined();+ expect(service.getStatus()).toMatchObject({ supported: true, modelState: 'ready', enrolled: true });+ });++ it.runIf(getSpeakerFilterService().supported)('returns a gate once every condition holds', () => {+ installModels();+ enroll();+ // The worker is started lazily; warming it fails harmlessly in tests.+ expect(getSpeakerFilterService().createGate(on)).toBeInstanceOf(SpeakerGate);+ });+});++describe('parseEnrollmentClips', () => {+ const clip = (bytes: number) => new Uint8Array(bytes);++ it('accepts exactly three non-empty PCM16 clips', () => {+ const clips = parseEnrollmentClips({ clips: [clip(320), clip(640), new ArrayBuffer(960)] });+ expect(clips?.map((buffer) => buffer.byteLength)).toEqual([320, 640, 960]);+ });++ it('rejects malformed payloads', () => {+ expect(parseEnrollmentClips(null)).toBeNull();+ expect(parseEnrollmentClips({ clips: [clip(320), clip(320)] })).toBeNull();+ expect(parseEnrollmentClips({ clips: [clip(320), clip(320), 'nope'] })).toBeNull();+ expect(parseEnrollmentClips({ clips: [clip(320), clip(320), clip(0)] })).toBeNull();+ expect(parseEnrollmentClips({ clips: [clip(320), clip(320), clip(321)] })).toBeNull();+ // Longer than the 20-second limit.+ expect(parseEnrollmentClips({ clips: [clip(320), clip(320), clip(20 * 16_000 * 2 + 2)] })).toBeNull();+ });+});diff --git a/apps/desktop/src/main/voice-input/speaker/__tests__/speakerModelStore.test.ts b/apps/desktop/src/main/voice-input/speaker/__tests__/speakerModelStore.test.tsnew file mode 100644index 0000000000..aa4f8fd428--- /dev/null+++ b/apps/desktop/src/main/voice-input/speaker/__tests__/speakerModelStore.test.ts@@ -0,0 +1,123 @@+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';+import fs from 'node:fs';+import os from 'node:os';+import path from 'node:path';++// Tiny stand-ins for the real 28 MB models; the store only cares about size and name.+vi.mock('@cindy/voice-input-core', async (importOriginal) => {+ const actual = await importOriginal<typeof import('@cindy/voice-input-core')>();+ const assets = [+ { role: 'vad', fileName: 'vad.onnx', sha256: 'a'.repeat(64), bytes: 8 },+ { role: 'embedding', fileName: 'embed.onnx', sha256: 'b'.repeat(64), bytes: 16 },+ ] as const;+ return {+ ...actual,+ SPEAKER_MODEL_ASSETS: assets,+ SPEAKER_MODEL_TOTAL_BYTES: 24,+ speakerModelAsset: (role: string) => assets.find((asset) => asset.role === role),+ };+});++const { SpeakerModelStore } = await import('../speakerModelStore');+const { DownloadError } = await import('../../../downloader');++let dir = '';++beforeEach(() => {+ dir = fs.mkdtempSync(path.join(os.tmpdir(), 'cindy-speaker-models-'));+});++afterEach(() => {+ fs.rmSync(dir, { recursive: true, force: true });+});++type DownloadCall = { url: string; targetPath: string; expectedSize?: number; sha256?: string };++function fakeDownload(calls: DownloadCall[], fail?: (call: DownloadCall) => Error | undefined) {+ return vi.fn(async (options: DownloadCall & { onProgress?: (event: { loaded: number }) => void }) => {+ calls.push(options);+ const error = fail?.(options);+ if (error) throw error;+ options.onProgress?.({ loaded: options.expectedSize ?? 0 });+ fs.writeFileSync(options.targetPath, Buffer.alloc(options.expectedSize ?? 0));+ return { path: options.targetPath, size: options.expectedSize ?? 0, sha256: options.sha256 ?? '', fromCache: false };+ });+}++function createStore(download: ReturnType<typeof fakeDownload>, cdn = 'https://cdn.example.com/') {+ return new SpeakerModelStore({+ dir: () => dir,+ cdnBaseUrl: () => cdn,+ download: download as never,+ });+}++describe('SpeakerModelStore', () => {+ it('reports missing until every model is on disk, then ready', async () => {+ const calls: DownloadCall[] = [];+ const store = createStore(fakeDownload(calls));+ expect(store.getModelPaths()).toBeNull();+ expect(store.getState().modelState).toBe('missing');++ await store.ensureDownloaded();++ expect(calls.map((call) => call.url)).toEqual([+ `https://cdn.example.com/voice-models/${'a'.repeat(64)}.onnx`,+ `https://cdn.example.com/voice-models/${'b'.repeat(64)}.onnx`,+ ]);+ expect(calls.every((call) => call.sha256 && call.expectedSize)).toBe(true);+ expect(store.getState()).toMatchObject({ modelState: 'ready', downloadedBytes: 24, totalBytes: 24 });+ expect(store.getModelPaths()).toEqual({+ vadModel: path.join(dir, `${'a'.repeat(16)}-vad.onnx`),+ embeddingModel: path.join(dir, `${'b'.repeat(16)}-embed.onnx`),+ });+ });++ it('joins a running download instead of starting another', async () => {+ const calls: DownloadCall[] = [];+ const store = createStore(fakeDownload(calls));+ await Promise.all([store.ensureDownloaded(), store.ensureDownloaded()]);+ expect(calls).toHaveLength(2);+ });++ it('skips models already present and removes files of older versions', async () => {+ fs.writeFileSync(path.join(dir, `${'a'.repeat(16)}-vad.onnx`), Buffer.alloc(8));+ fs.writeFileSync(path.join(dir, 'old-model.onnx'), 'stale');+ const calls: DownloadCall[] = [];+ await createStore(fakeDownload(calls)).ensureDownloaded();+ expect(calls).toHaveLength(1);+ expect(fs.existsSync(path.join(dir, 'old-model.onnx'))).toBe(false);+ });++ it('classifies a checksum failure and allows a retry', async () => {+ const calls: DownloadCall[] = [];+ let failOnce = true;+ const store = createStore(+ fakeDownload(calls, () => {+ if (!failOnce) return undefined;+ failOnce = false;+ return new DownloadError('CHECKSUM', 'mismatch');+ }),+ );+ await expect(store.ensureDownloaded()).rejects.toThrow('mismatch');+ expect(store.getState()).toMatchObject({ modelState: 'failed', downloadError: 'checksum' });++ await store.ensureDownloaded();+ expect(store.getState().modelState).toBe('ready');+ });++ it('treats a user cancel as missing, not failed', async () => {+ const store = createStore(fakeDownload([], () => new DownloadError('ABORTED', 'aborted')));+ await expect(store.ensureDownloaded()).rejects.toThrow();+ expect(store.getState()).toMatchObject({ modelState: 'missing' });+ expect(store.getState().downloadError).toBeUndefined();+ });++ it('refuses a CDN base that is not https', async () => {+ const calls: DownloadCall[] = [];+ const store = createStore(fakeDownload(calls), '');+ await expect(store.ensureDownloaded()).rejects.toThrow();+ expect(calls).toHaveLength(0);+ expect(store.getState()).toMatchObject({ modelState: 'failed', downloadError: 'unavailable' });+ });+});diff --git a/apps/desktop/src/main/voice-input/speaker/__tests__/speakerProfileStore.test.ts b/apps/desktop/src/main/voice-input/speaker/__tests__/speakerProfileStore.test.tsnew file mode 100644index 0000000000..44b55b4403--- /dev/null+++ b/apps/desktop/src/main/voice-input/speaker/__tests__/speakerProfileStore.test.ts@@ -0,0 +1,97 @@+import { afterEach, beforeEach, describe, expect, it } from 'vitest';+import fs from 'node:fs';+import os from 'node:os';+import path from 'node:path';++import { speakerModelAsset } from '@cindy/voice-input-core';++import {+ SpeakerProfileStorageUnavailableError,+ SpeakerProfileStore,+ type SpeakerProfileCipher,+} from '../speakerProfileStore';++let dir = '';++beforeEach(() => {+ dir = fs.mkdtempSync(path.join(os.tmpdir(), 'cindy-speaker-profile-'));+});++afterEach(() => {+ fs.rmSync(dir, { recursive: true, force: true });+});++/** Reversible stand-in for safeStorage that is visibly not plaintext. */+function fakeCipher(available = true): SpeakerProfileCipher {+ return {+ isAvailable: () => available,+ encrypt: (plain) => Buffer.from(Buffer.from(plain, 'utf-8').map((byte) => byte ^ 0x5a)),+ decrypt: (cipher) => Buffer.from(cipher.map((byte) => byte ^ 0x5a)).toString('utf-8'),+ };+}++describe('SpeakerProfileStore', () => {+ it('round-trips the voiceprint through the cipher and never writes it in plain text', () => {+ const file = path.join(dir, 'owners', 'a', 'voice-speaker-profile.json');+ const store = new SpeakerProfileStore(() => file, fakeCipher());+ store.write(Float32Array.from([0.25, -0.5, 0.125]), 1_700_000_000_000);++ const raw = fs.readFileSync(file, 'utf-8');+ expect(raw).not.toContain('0.25');+ expect(raw).not.toContain('embedding');++ const fresh = new SpeakerProfileStore(() => file, fakeCipher());+ const profile = fresh.read();+ expect(Array.from(profile?.embedding ?? [])).toEqual([0.25, -0.5, 0.125]);+ expect(profile?.createdAt).toBe(1_700_000_000_000);+ });++ it('keeps each account separate', () => {+ let owner = 'a';+ const store = new SpeakerProfileStore(() => path.join(dir, owner, 'profile.json'), fakeCipher());+ store.write(Float32Array.from([1, 0]));+ owner = 'b';+ expect(store.read()).toBeNull();+ });++ it('reads a voiceprint from another embedding model as not enrolled', () => {+ const file = path.join(dir, 'profile.json');+ const cipher = fakeCipher();+ const payload = { embedding: [1, 0], createdAt: 1, modelSha256: 'f'.repeat(64) };+ fs.writeFileSync(file, JSON.stringify({ version: 1, data: cipher.encrypt(JSON.stringify(payload)).toString('base64') }));+ expect(speakerModelAsset('embedding').sha256).not.toBe('f'.repeat(64));+ expect(new SpeakerProfileStore(() => file, cipher).read()).toBeNull();+ });++ it('treats corrupt or undecryptable files as not enrolled', () => {+ const file = path.join(dir, 'profile.json');+ fs.writeFileSync(file, '{not json');+ expect(new SpeakerProfileStore(() => file, fakeCipher()).read()).toBeNull();++ fs.writeFileSync(file, JSON.stringify({ version: 1, data: 'AAAA' }));+ const throwing: SpeakerProfileCipher = {+ ...fakeCipher(),+ decrypt: () => {+ throw new Error('keychain locked');+ },+ };+ expect(new SpeakerProfileStore(() => file, throwing).read()).toBeNull();+ });++ it('refuses to write without OS encryption and leaves no file behind', () => {+ const file = path.join(dir, 'profile.json');+ const store = new SpeakerProfileStore(() => file, fakeCipher(false));+ expect(() => store.write(Float32Array.from([1]))).toThrow(SpeakerProfileStorageUnavailableError);+ expect(fs.existsSync(file)).toBe(false);+ });++ it('deletes the voiceprint file and its cached copy', () => {+ const file = path.join(dir, 'profile.json');+ const store = new SpeakerProfileStore(() => file, fakeCipher());+ store.write(Float32Array.from([1, 0]));+ expect(store.read()).not.toBeNull();+ store.delete();+ expect(fs.existsSync(file)).toBe(false);+ expect(store.read()).toBeNull();+ });+});diff --git a/apps/desktop/src/main/voice-input/speaker/index.ts b/apps/desktop/src/main/voice-input/speaker/index.tsnew file mode 100644index 0000000000..722ca0c4e4--- /dev/null+++ b/apps/desktop/src/main/voice-input/speaker/index.ts@@ -0,0 +1,277 @@+import { app, BrowserWindow, ipcMain, safeStorage } from 'electron';+import path from 'node:path';++import {+ buildSpeakerEnrollment,+ pcm16ToFloat,+ SPEAKER_GATE_SAMPLE_RATE,+ SPEAKER_GATE_STRICTNESS_THRESHOLDS,+ SpeakerGate,+ type SpeakerGateStrictness,+} from '@cindy/voice-input-core';++import { createLogger } from '../../logger.js';+import { activeOwnerScopeKey, getActiveAppSession, isAppSessionBoundaryPending, ownerScopedUserDataPath } from '../../appSessionState.js';+import { getClientEndpoint } from '../../clientEndpointsService.js';+import { assertTrustedAppRendererEvent, isTrustedAppRendererWindow } from '../../security/trustedAppRenderer.js';+import { throwIpcError } from '../../utils/ipcValidate.js';+import {+ VOICE_SPEAKER_ENROLLMENT_CLIP_COUNT,+ VOICE_SPEAKER_ENROLLMENT_MAX_CLIP_SEC,+ VOICE_SPEAKER_FILTER_CHANNELS,+ type VoiceSpeakerEnrollResult,+ type VoiceSpeakerFilterStatus,+} from '../../../shared/voiceSpeakerFilter';+import { SpeakerEngineHost } from './speakerEngineHost.js';+import { SpeakerModelStore } from './speakerModelStore.js';+import { SpeakerProfileStorageUnavailableError, SpeakerProfileStore } from './speakerProfileStore.js';++const log = createLogger('voice-speaker');++/** Platforms sherpa-onnx-node ships a prebuilt addon for and Cindy packages. */+const SUPPORTED_PLATFORMS = new Set(['darwin-arm64', 'darwin-x64', 'win32-x64', 'linux-x64', 'linux-arm64']);+const PROFILE_FILE_NAME = 'voice-speaker-profile.json';+const MODEL_DIR_NAME = 'voice-models';++export type SpeakerGateSettings = {+ speakerFilterEnabled: boolean;+ speakerFilterStrictness: SpeakerGateStrictness;+};++/**+ * "Recognize my voice" for desktop dictation: downloads the models on demand,+ * keeps this account's voiceprint, and builds the gate for a dictation run.+ * Every failure here leaves dictation working exactly as without the filter.+ */+class SpeakerFilterService {+ readonly supported = SUPPORTED_PLATFORMS.has(`${process.platform}-${process.arch}`);+ private readonly models = new SpeakerModelStore({+ // Models carry no personal data and are shared by every account on this device.+ dir: () => path.join(app.getPath('userData'), MODEL_DIR_NAME),+ cdnBaseUrl: () => {+ try {+ return getClientEndpoint('cdnBaseUrl');+ } catch {+ return '';+ }+ },+ onChange: () => this.broadcastStatus(),+ logger: log,+ });+ private readonly profiles = new SpeakerProfileStore(+ () => ownerScopedUserDataPath(PROFILE_FILE_NAME),+ {+ isAvailable: () => safeStorage.isEncryptionAvailable(),+ encrypt: (plain) => safeStorage.encryptString(plain),+ decrypt: (cipher) => safeStorage.decryptString(cipher),+ },+ );+ private readonly engine = new SpeakerEngineHost(() => this.models.getModelPaths());+ private enrolling = false;+ private profileRevision = 0;++ getStatus(): VoiceSpeakerFilterStatus {+ if (!this.supported) {+ return { supported: false, modelState: 'missing', downloadedBytes: 0, totalBytes: 0, enrolled: false };+ }+ const profile = this.profiles.read();+ return {+ supported: true,+ ...this.models.getState(),+ enrolled: Boolean(profile),+ ...(profile?.createdAt ? { enrolledAt: profile.createdAt } : {}),+ };+ }++ /**+ * The gate for one dictation run, or undefined when the filter is off or+ * not ready. Warms the worker so the first chunk is not held by model load.+ */+ createGate(settings: SpeakerGateSettings): SpeakerGate | undefined {+ if (!settings.speakerFilterEnabled || !this.supported) return undefined;+ if (!this.models.getModelPaths()) return undefined;+ const profile = this.profiles.read();+ if (!profile) return undefined;+ void this.engine.warm().catch((error) => {+ log.warn('speaker engine warm failed', { error: errorMessage(error) });+ });+ const thresholds = SPEAKER_GATE_STRICTNESS_THRESHOLDS[settings.speakerFilterStrictness];+ let accepted = 0;+ let rejected = 0;+ return new SpeakerGate({+ engine: this.engine.createGateEngine(),+ enrolledEmbedding: profile.embedding,+ threshold: thresholds.threshold,+ continueThreshold: thresholds.continueThreshold,+ onDecision: (decision) => {+ // Counts and scores only; never audio or the voiceprint itself.+ if (decision.accepted) accepted += 1;+ else rejected += 1;+ log.debug('speaker gate decision', {+ accepted: decision.accepted,+ score: Math.round(decision.score * 100) / 100,+ speechMs: Math.round(((decision.endSample - decision.startSample) / SPEAKER_GATE_SAMPLE_RATE) * 1000),+ computeMs: Math.round(decision.computeMs),+ acceptedSoFar: accepted,+ rejectedSoFar: rejected,+ });+ },+ onPassthrough: (reason) => {+ log.warn('speaker gate passthrough', { reason });+ },+ });+ }++ downloadModels(): void {+ if (!this.supported) return;+ void this.models.ensureDownloaded().catch(() => {+ // State and a classified error are already recorded and broadcast.+ });+ }++ cancelDownload(): void {+ this.models.cancelDownload();+ }++ async enroll(clips: ArrayBuffer[]): Promise<VoiceSpeakerEnrollResult> {+ if (!getActiveAppSession().dataOwnerId || isAppSessionBoundaryPending()) return { ok: false, reason: 'failed' };+ if (!this.supported || !this.models.getModelPaths()) return { ok: false, reason: 'models_missing' };+ if (this.enrolling) return { ok: false, reason: 'failed' };+ const owner = activeOwnerScopeKey();+ const revision = ++this.profileRevision;+ this.enrolling = true;+ try {+ const result = await buildSpeakerEnrollment(+ this.engine.createEnrollmentEngine(),+ clips.map((clip) => pcm16ToFloat(clip)),+ );+ if (isAppSessionBoundaryPending() || owner !== activeOwnerScopeKey() || revision !== this.profileRevision) {+ return { ok: false, reason: 'failed' };+ }+ if (!result.ok) {+ log.info('speaker enrollment rejected', {+ reason: result.reason,+ clipIndex: result.clipIndex,+ speechSec: result.speechSec === undefined ? undefined : Math.round(result.speechSec * 10) / 10,+ selfScore: result.selfScore === undefined ? undefined : Math.round(result.selfScore * 100) / 100,+ });+ return { ok: false, reason: result.reason, clipIndex: result.clipIndex };+ }+ this.profiles.write(result.embedding);+ log.info('speaker enrolled', {+ speechSec: Math.round(result.speechSec * 10) / 10,+ selfScore: Math.round(result.selfScore * 100) / 100,+ });+ const status = this.getStatus();+ this.broadcastStatus(status);+ return { ok: true, status };+ } catch (error) {+ if (error instanceof SpeakerProfileStorageUnavailableError) {+ return { ok: false, reason: 'storage_unavailable' };+ }+ log.warn('speaker enrollment failed', { error: errorMessage(error) });+ return { ok: false, reason: 'failed' };+ } finally {+ this.enrolling = false;+ }+ }++ deleteProfile(): VoiceSpeakerFilterStatus {+ this.profileRevision += 1;+ this.profiles.delete();+ log.info('speaker profile deleted');+ const status = this.getStatus();+ this.broadcastStatus(status);+ return status;+ }++ shutdown(): void {+ this.models.cancelDownload();+ this.engine.shutdown('quit');+ }++ broadcastStatus(status = this.getStatus()): void {+ BrowserWindow.getAllWindows().forEach((window) => {+ if (!isTrustedAppRendererWindow(window)) return;+ window.webContents.send(VOICE_SPEAKER_FILTER_CHANNELS.statusChanged, status);+ });+ }+}++let service: SpeakerFilterService | null = null;++export function getSpeakerFilterService(): SpeakerFilterService {+ service ??= new SpeakerFilterService();+ return service;+}++let ipcRegistered = false;++export function registerVoiceSpeakerFilterIpc(): void {+ if (ipcRegistered) return;+ ipcRegistered = true;+ const channels = VOICE_SPEAKER_FILTER_CHANNELS;++ ipcMain.handle(channels.getStatus, (event): VoiceSpeakerFilterStatus => {+ assertTrustedAppRendererEvent(event);+ return getSpeakerFilterService().getStatus();+ });+ ipcMain.handle(channels.downloadModels, (event): VoiceSpeakerFilterStatus => {+ assertTrustedAppRendererEvent(event);+ const speaker = getSpeakerFilterService();+ speaker.downloadModels();+ return speaker.getStatus();+ });+ ipcMain.handle(channels.cancelDownload, (event): VoiceSpeakerFilterStatus => {+ assertTrustedAppRendererEvent(event);+ const speaker = getSpeakerFilterService();+ speaker.cancelDownload();+ return speaker.getStatus();+ });+ ipcMain.handle(channels.enroll, async (event, payload: unknown): Promise<VoiceSpeakerEnrollResult> => {+ assertTrustedAppRendererEvent(event);+ const clips = parseEnrollmentClips(payload);+ if (!clips) return { ok: false, reason: 'failed' };+ return getSpeakerFilterService().enroll(clips);+ });+ ipcMain.handle(channels.deleteProfile, (event): VoiceSpeakerFilterStatus => {+ assertTrustedAppRendererEvent(event);+ try {+ return getSpeakerFilterService().deleteProfile();+ } catch {+ return throwIpcError('INTERNAL', 'Unable to delete voiceprint');+ }+ });++ app.once('before-quit', () => service?.shutdown());+}++const MAX_CLIP_BYTES = VOICE_SPEAKER_ENROLLMENT_MAX_CLIP_SEC * SPEAKER_GATE_SAMPLE_RATE * 2;++/** Exactly the expected number of PCM16 clips, each within the size limit. */+export function parseEnrollmentClips(payload: unknown): ArrayBuffer[] | null {+ if (!payload || typeof payload !== 'object') return null;+ const clips = (payload as { clips?: unknown }).clips;+ if (!Array.isArray(clips) || clips.length !== VOICE_SPEAKER_ENROLLMENT_CLIP_COUNT) return null;+ const out: ArrayBuffer[] = [];+ for (const clip of clips) {+ const bytes = toArrayBuffer(clip);+ if (!bytes || bytes.byteLength === 0 || bytes.byteLength > MAX_CLIP_BYTES || bytes.byteLength % 2 !== 0) {+ return null;+ }+ out.push(bytes);+ }+ return out;+}++function toArrayBuffer(value: unknown): ArrayBuffer | null {+ if (value instanceof ArrayBuffer) return value;+ if (ArrayBuffer.isView(value)) {+ return value.buffer.slice(value.byteOffset, value.byteOffset + value.byteLength) as ArrayBuffer;+ }+ return null;+}++function errorMessage(error: unknown): string {+ return error instanceof Error ? error.message : String(error);+}diff --git a/apps/desktop/src/main/voice-input/speaker/speakerEngineHost.ts b/apps/desktop/src/main/voice-input/speaker/speakerEngineHost.tsnew file mode 100644index 0000000000..1dcc71714d--- /dev/null+++ b/apps/desktop/src/main/voice-input/speaker/speakerEngineHost.ts@@ -0,0 +1,189 @@+import path from 'node:path';+// eslint-disable-next-line no-restricted-imports -- speaker-gate inference is CPU-isolated and never touches the database.+import { Worker } from 'node:worker_threads';++import {+ SPEAKER_GATE_VAD_FRAME,+ type SpeakerEnrollmentEngine,+ type SpeakerGateEngine,+} from '@cindy/voice-input-core';++import type { SpeakerWorkerRequest, SpeakerWorkerResponse } from './speakerWorkerProtocol';++type ModelPaths = { vadModel: string; embeddingModel: string };++type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;+type RequestBody = DistributiveOmit<SpeakerWorkerRequest, 'id'>;+type OkResponse = Extract<SpeakerWorkerResponse, { ok: true }>;++type Pending = {+ resolve: (response: OkResponse) => void;+ reject: (error: Error) => void;+ timer: ReturnType<typeof setTimeout>;+};++/** A worker idle this long is stopped; the next dictation starts it again. */+const IDLE_SHUTDOWN_MS = 10 * 60_000;++/**+ * Owns the speaker-gate worker thread. The worker is started on first use,+ * loads the models once, and exits after a quiet period. A crashed worker+ * rejects everything in flight (the gate then fails open) and is restarted on+ * the next call.+ */+export class SpeakerEngineHost {+ private worker: Worker | null = null;+ private loadedModels: ModelPaths | null = null;+ private readyPromise: Promise<void> | null = null;+ private nextId = 1;+ private nextSession = 1;+ private readonly pending = new Map<number, Pending>();+ private idleTimer: ReturnType<typeof setTimeout> | null = null;++ constructor(+ private readonly resolveModels: () => ModelPaths | null,+ private readonly workerPath = path.join(__dirname, 'speakerGateWorker.js'),+ private readonly requestTimeoutMs = 15_000,+ ) {}++ /** Starts the worker and loads models ahead of the first chunk. */+ warm(): Promise<void> {+ return this.ensureReady();+ }++ createGateEngine(): SpeakerGateEngine {+ const session = `run-${this.nextSession++}`;+ return {+ resetVad: async () => {+ await this.call({ op: 'vad-reset', session });+ },+ detectSpeech: async (samples) => {+ const usable = samples.length - (samples.length % SPEAKER_GATE_VAD_FRAME);+ const response = await this.call({ op: 'vad', session, samples: samples.slice(0, usable) });+ return Array.from(response.flags ?? [], (flag) => flag === 1);+ },+ embed: async (samples) => (await this.call({ op: 'embed', samples: samples.slice() })).embedding ?? null,+ };+ }++ createEnrollmentEngine(): SpeakerEnrollmentEngine {+ return {+ extractSpeech: async (samples) =>+ (await this.call({ op: 'speech', samples: samples.slice() })).samples ?? new Float32Array(0),+ embed: async (samples) => (await this.call({ op: 'embed', samples: samples.slice() })).embedding ?? null,+ };+ }++ /** Stops the worker (models deleted, app quitting). */+ shutdown(reason = 'shutdown'): void {+ this.clearIdleTimer();+ const worker = this.worker;+ this.worker = null;+ this.loadedModels = null;+ this.readyPromise = null;+ this.rejectAll(new Error(`speaker engine ${reason}`));+ void worker?.terminate();+ }++ private async call(body: RequestBody): Promise<OkResponse> {+ await this.ensureReady();+ return this.send(body);+ }++ private ensureReady(): Promise<void> {+ const models = this.resolveModels();+ if (!models) return Promise.reject(new Error('speaker models are not installed'));+ if (+ this.readyPromise &&+ this.loadedModels?.vadModel === models.vadModel &&+ this.loadedModels.embeddingModel === models.embeddingModel+ ) {+ return this.readyPromise;+ }+ if (this.worker) this.shutdown('models_changed');+ this.loadedModels = models;+ const ready = this.send({ op: 'init', ...models }).then(() => undefined);+ this.readyPromise = ready;+ // A failed load must not stick: the next call tries a fresh worker.+ ready.catch(() => {+ if (this.readyPromise === ready) this.shutdown('init_failed');+ });+ return ready;+ }++ private send(body: RequestBody): Promise<OkResponse> {+ let worker: Worker;+ try {+ worker = this.ensureWorker();+ } catch (error) {+ // A worker that cannot even start must reject like any other failure,+ // so the gate fails open instead of breaking dictation start.+ return Promise.reject(error instanceof Error ? error : new Error(String(error)));+ }+ const id = this.nextId++;+ this.clearIdleTimer();+ return new Promise<OkResponse>((resolve, reject) => {+ const timer = setTimeout(() => {+ if (this.worker === worker) this.shutdown('request_timeout');+ }, this.requestTimeoutMs);+ timer.unref?.();+ this.pending.set(id, { resolve, reject, timer });+ const request = { ...body, id } as SpeakerWorkerRequest;+ const transfer = 'samples' in request ? [request.samples.buffer as ArrayBuffer] : [];+ try {+ worker.postMessage(request, transfer);+ } catch {+ this.shutdown('send_failed');+ }+ });+ }++ private ensureWorker(): Worker {+ if (this.worker) return this.worker;+ const worker = new Worker(this.workerPath);+ worker.on('message', (response: SpeakerWorkerResponse) => {+ if (this.worker !== worker) return;+ const pending = this.pending.get(response.id);+ if (!pending) return;+ clearTimeout(pending.timer);+ this.pending.delete(response.id);+ if (response.ok) pending.resolve(response);+ else pending.reject(new Error(response.error));+ if (this.pending.size === 0) this.scheduleIdleShutdown();+ });+ const onGone = (error: Error): void => {+ if (this.worker !== worker) return;+ this.worker = null;+ this.loadedModels = null;+ this.readyPromise = null;+ this.clearIdleTimer();+ this.rejectAll(error);+ };+ worker.on('error', onGone);+ worker.on('exit', (code) => onGone(new Error(`speaker worker exited (${code})`)));+ // An idle worker must not keep the app alive on quit.+ worker.unref();+ this.worker = worker;+ return worker;+ }++ private rejectAll(error: Error): void {+ const pending = [...this.pending.values()];+ this.pending.clear();+ for (const entry of pending) {+ clearTimeout(entry.timer);+ entry.reject(error);+ }+ }++ private scheduleIdleShutdown(): void {+ this.clearIdleTimer();+ this.idleTimer = setTimeout(() => this.shutdown('idle'), IDLE_SHUTDOWN_MS);+ this.idleTimer.unref?.();+ }++ private clearIdleTimer(): void {+ if (this.idleTimer) clearTimeout(this.idleTimer);+ this.idleTimer = null;+ }+}diff --git a/apps/desktop/src/main/voice-input/speaker/speakerGateWorker.ts b/apps/desktop/src/main/voice-input/speaker/speakerGateWorker.tsnew file mode 100644index 0000000000..31ff46613c--- /dev/null+++ b/apps/desktop/src/main/voice-input/speaker/speakerGateWorker.ts@@ -0,0 +1,193 @@+// eslint-disable-next-line no-restricted-imports -- dedicated non-DB worker entry for speaker-gate inference.+import { parentPort } from 'node:worker_threads';+import { createRequire } from 'node:module';++import type { SpeakerWorkerRequest, SpeakerWorkerResponse } from './speakerWorkerProtocol';++/*+ * Speaker-gate inference thread. sherpa-onnx runs ONNX models synchronously,+ * so it lives here instead of on Electron main. Requests are handled strictly+ * one at a time in arrival order; the host relies on that ordering.+ */++const SAMPLE_RATE = 16_000;+const VAD_FRAME = 512;+// Gate runs keep their own VAD state. Old runs are evicted instead of freed+// explicitly, so a run that ended without cleanup cannot leak.+const MAX_VAD_SESSIONS = 4;++type SherpaVad = {+ acceptWaveform(samples: Float32Array): void;+ isDetected(): boolean;+ isEmpty(): boolean;+ front(enableExternalBuffer?: boolean): { start: number; samples: Float32Array };+ pop(): void;+ flush(): void;+ reset(): void;+};++type SherpaStream = {+ acceptWaveform(input: { sampleRate: number; samples: Float32Array }): void;+ inputFinished(): void;+};++type SherpaExtractor = {+ createStream(): SherpaStream;+ isReady(stream: SherpaStream): boolean;+ compute(stream: SherpaStream, enableExternalBuffer?: boolean): Float32Array;+};++type SherpaModule = {+ Vad: new (config: unknown, bufferSizeInSeconds: number) => SherpaVad;+ SpeakerEmbeddingExtractor: new (config: unknown) => SherpaExtractor;+};++const port = parentPort;+if (!port) throw new Error('Speaker gate worker must run in a worker thread.');++let sherpa: SherpaModule | null = null;+let vadModelPath = '';+let extractor: SherpaExtractor | null = null;+const vadSessions = new Map<string, SherpaVad>();++function loadSherpa(): SherpaModule {+ if (!sherpa) {+ // Native addon: shipped unpacked next to the app, never bundled.+ sherpa = createRequire(__filename)('sherpa-onnx-node') as SherpaModule;+ }+ return sherpa;+}++function createVad(): SherpaVad {+ return new (loadSherpa().Vad)(+ {+ sileroVad: {+ model: vadModelPath,+ threshold: 0.5,+ minSpeechDuration: 0.25,+ minSilenceDuration: 0.25,+ maxSpeechDuration: 20,+ windowSize: VAD_FRAME,+ },+ sampleRate: SAMPLE_RATE,+ debug: 0,+ numThreads: 1,+ },+ 30,+ );+}++function requireExtractor(): SherpaExtractor {+ if (!extractor) throw new Error('speaker models are not loaded');+ return extractor;+}++function sessionVad(session: string): SherpaVad {+ let vad = vadSessions.get(session);+ if (vad) {+ // Keep recently used sessions at the end for eviction order.+ vadSessions.delete(session);+ } else {+ vad = createVad();+ }+ vadSessions.set(session, vad);+ while (vadSessions.size > MAX_VAD_SESSIONS) {+ const oldest = vadSessions.keys().next().value;+ if (oldest === undefined) break;+ vadSessions.delete(oldest);+ }+ return vad;+}++function drain(vad: SherpaVad, into?: Float32Array[]): void {+ while (!vad.isEmpty()) {+ if (into) into.push(Float32Array.from(vad.front(false).samples));+ vad.pop();+ }+}++function embed(samples: Float32Array): Float32Array | null {+ const engine = requireExtractor();+ const stream = engine.createStream();+ stream.acceptWaveform({ sampleRate: SAMPLE_RATE, samples });+ stream.inputFinished();+ if (!engine.isReady(stream)) return null;+ return Float32Array.from(engine.compute(stream, false));+}++function extractSpeech(samples: Float32Array): Float32Array {+ const vad = createVad();+ const parts: Float32Array[] = [];+ for (let i = 0; i < samples.length; i += VAD_FRAME) {+ vad.acceptWaveform(samples.subarray(i, Math.min(i + VAD_FRAME, samples.length)));+ drain(vad, parts);+ }+ vad.flush();+ drain(vad, parts);+ const out = new Float32Array(parts.reduce((sum, part) => sum + part.length, 0));+ let offset = 0;+ for (const part of parts) {+ out.set(part, offset);+ offset += part.length;+ }+ return out;+}++function handle(request: SpeakerWorkerRequest): SpeakerWorkerResponse {+ switch (request.op) {+ case 'init': {+ const module = loadSherpa();+ vadModelPath = request.vadModel;+ vadSessions.clear();+ extractor = new module.SpeakerEmbeddingExtractor({+ model: request.embeddingModel,+ numThreads: 1,+ debug: 0,+ provider: 'cpu',+ });+ return { id: request.id, ok: true };+ }+ case 'vad-reset': {+ if (!vadModelPath) throw new Error('speaker models are not loaded');+ sessionVad(request.session).reset();+ return { id: request.id, ok: true };+ }+ case 'vad': {+ if (!vadModelPath) throw new Error('speaker models are not loaded');+ const vad = sessionVad(request.session);+ const frames = Math.floor(request.samples.length / VAD_FRAME);+ const flags = new Uint8Array(frames);+ for (let i = 0; i < frames; i += 1) {+ vad.acceptWaveform(request.samples.subarray(i * VAD_FRAME, (i + 1) * VAD_FRAME));+ flags[i] = vad.isDetected() ? 1 : 0;+ // Only the per-frame flag is used; finished segments would pile up.+ drain(vad);+ }+ return { id: request.id, ok: true, flags };+ }+ case 'embed':+ return { id: request.id, ok: true, embedding: embed(request.samples) };+ case 'speech':+ return { id: request.id, ok: true, samples: extractSpeech(request.samples) };+ }+}++port.on('message', (request: SpeakerWorkerRequest) => {+ let response: SpeakerWorkerResponse;+ try {+ response = handle(request);+ } catch (error) {+ response = {+ id: request.id,+ ok: false,+ error: error instanceof Error ? error.message : String(error),+ };+ }+ const transfer: ArrayBuffer[] = [];+ if (response.ok) {+ for (const value of [response.flags, response.embedding, response.samples]) {+ if (value) transfer.push(value.buffer as ArrayBuffer);+ }+ }+ port.postMessage(response, transfer);+});diff --git a/apps/desktop/src/main/voice-input/speaker/speakerModelStore.ts b/apps/desktop/src/main/voice-input/speaker/speakerModelStore.tsnew file mode 100644index 0000000000..be27672b0c--- /dev/null+++ b/apps/desktop/src/main/voice-input/speaker/speakerModelStore.ts@@ -0,0 +1,190 @@+import fs from 'node:fs';+import path from 'node:path';++import {+ SPEAKER_MODEL_ASSETS,+ SPEAKER_MODEL_TOTAL_BYTES,+ speakerModelAsset,+ speakerModelCdnPath,+ speakerModelLocalName,+ type SpeakerModelAsset,+} from '@cindy/voice-input-core';++import { DownloadError, createDownloader, type DownloadOptions, type DownloadResult } from '../../downloader';+import type { VoiceSpeakerFilterStatus } from '../../../shared/voiceSpeakerFilter';++export type SpeakerModelPaths = { vadModel: string; embeddingModel: string };++type ModelState = Pick<VoiceSpeakerFilterStatus, 'modelState' | 'downloadedBytes' | 'totalBytes' | 'downloadError'>;++type SpeakerModelStoreOptions = {+ /** Directory owned by this store; models are shared by every account. */+ dir: () => string;+ cdnBaseUrl: () => string;+ download?: (options: DownloadOptions) => Promise<DownloadResult>;+ onChange?: () => void;+ logger?: { info(message: string, meta?: unknown): void; warn(message: string, meta?: unknown): void };+};++/**+ * Downloads the speaker-gate models on demand and reports where they are.+ *+ * Files are fetched from the region CDN by content hash and only become+ * visible after the downloader verified SHA-256, so a present file of the+ * expected size is trusted. One download runs at a time; asking again while+ * it runs joins it.+ */+export class SpeakerModelStore {+ private readonly download: (options: DownloadOptions) => Promise<DownloadResult>;+ private inflight: Promise<void> | null = null;+ private abort: AbortController | null = null;+ private progress = new Map<string, number>();+ private lastError: VoiceSpeakerFilterStatus['downloadError'];++ constructor(private readonly options: SpeakerModelStoreOptions) {+ this.download = options.download ?? createDownloader();+ }++ /** Model files ready to load, or null while any is missing. */+ getModelPaths(): SpeakerModelPaths | null {+ if (!SPEAKER_MODEL_ASSETS.every((asset) => this.isInstalled(asset))) return null;+ return {+ vadModel: this.localPath(speakerModelAsset('vad')),+ embeddingModel: this.localPath(speakerModelAsset('embedding')),+ };+ }++ getState(): ModelState {+ if (this.inflight) {+ let downloaded = 0;+ for (const asset of SPEAKER_MODEL_ASSETS) {+ downloaded += this.isInstalled(asset) ? asset.bytes : Math.min(asset.bytes, this.progress.get(asset.sha256) ?? 0);+ }+ return { modelState: 'downloading', downloadedBytes: downloaded, totalBytes: SPEAKER_MODEL_TOTAL_BYTES };+ }+ if (this.getModelPaths()) {+ return { modelState: 'ready', downloadedBytes: SPEAKER_MODEL_TOTAL_BYTES, totalBytes: SPEAKER_MODEL_TOTAL_BYTES };+ }+ return {+ modelState: this.lastError ? 'failed' : 'missing',+ downloadedBytes: 0,+ totalBytes: SPEAKER_MODEL_TOTAL_BYTES,+ ...(this.lastError ? { downloadError: this.lastError } : {}),+ };+ }++ /** Starts (or joins) the download. Resolves when every model is in place. */+ ensureDownloaded(): Promise<void> {+ if (this.getModelPaths()) return Promise.resolve();+ if (this.inflight) return this.inflight;+ const controller = new AbortController();+ this.abort = controller;+ this.lastError = undefined;+ this.progress = new Map();+ const run = this.downloadAll(controller.signal).finally(() => {+ if (this.inflight === run) {+ this.inflight = null;+ this.abort = null;+ }+ this.options.onChange?.();+ });+ this.inflight = run;+ this.options.onChange?.();+ return run;+ }++ cancelDownload(): void {+ this.abort?.abort();+ }++ private async downloadAll(signal: AbortSignal): Promise<void> {+ const base = this.options.cdnBaseUrl().replace(/\/+$/, '');+ if (!/^https:\/\//i.test(base)) {+ this.lastError = 'unavailable';+ throw new Error('speaker model CDN is not configured');+ }+ const dir = this.options.dir();+ try {+ fs.mkdirSync(dir, { recursive: true });+ for (const asset of SPEAKER_MODEL_ASSETS) {+ if (this.isInstalled(asset)) continue;+ let lastNotified = 0;+ await this.download({+ url: `${base}/${speakerModelCdnPath(asset)}`,+ targetPath: this.localPath(asset),+ sha256: asset.sha256,+ expectedSize: asset.bytes,+ maxBytes: asset.bytes,+ // CDN edges may redirect; content is pinned by SHA-256 either way.+ isUrlAllowed: (url) => /^https:\/\//i.test(url),+ signal,+ onProgress: (event) => {+ this.progress.set(asset.sha256, event.loaded);+ // Throttle pushes to the renderer; the final state is sent on completion.+ const now = Date.now();+ if (now - lastNotified >= 250) {+ lastNotified = now;+ this.options.onChange?.();+ }+ },+ });+ this.options.logger?.info('speaker model downloaded', { file: asset.fileName, bytes: asset.bytes });+ }+ this.removeStaleFiles(dir);+ } catch (error) {+ this.lastError = classifyDownloadError(error);+ this.options.logger?.warn('speaker model download failed', {+ kind: this.lastError ?? 'cancelled',+ code: error instanceof DownloadError ? error.code : undefined,+ });+ throw error;+ }+ }++ private localPath(asset: SpeakerModelAsset): string {+ return path.join(this.options.dir(), speakerModelLocalName(asset));+ }++ private isInstalled(asset: SpeakerModelAsset): boolean {+ try {+ const stat = fs.statSync(this.localPath(asset));+ return stat.isFile() && stat.size === asset.bytes;+ } catch {+ return false;+ }+ }++ /** Drops files from older model versions; keeps partial downloads. */+ private removeStaleFiles(dir: string): void {+ const keep = new Set(SPEAKER_MODEL_ASSETS.map(speakerModelLocalName));+ for (const name of fs.readdirSync(dir)) {+ if (keep.has(name) || !name.endsWith('.onnx')) continue;+ try {+ fs.rmSync(path.join(dir, name), { force: true });+ } catch {+ // A file still open elsewhere is retried on the next download.+ }+ }+ }+}++function classifyDownloadError(error: unknown): VoiceSpeakerFilterStatus['downloadError'] {+ if (!(error instanceof DownloadError)) return 'network';+ switch (error.code) {+ case 'ABORTED':+ // User cancelled: back to "missing", no error to show.+ return undefined;+ case 'DISK':+ case 'EXISTS':+ return 'disk';+ case 'CHECKSUM':+ case 'SIZE':+ return 'checksum';+ case 'HTTP_4XX':+ case 'URL_POLICY':+ case 'INVALID_ARG':+ return 'unavailable';+ default:+ return 'network';+ }+}diff --git a/apps/desktop/src/main/voice-input/speaker/speakerProfileStore.ts b/apps/desktop/src/main/voice-input/speaker/speakerProfileStore.tsnew file mode 100644index 0000000000..03623d9180--- /dev/null+++ b/apps/desktop/src/main/voice-input/speaker/speakerProfileStore.ts@@ -0,0 +1,126 @@+import fs from 'node:fs';+import path from 'node:path';++import { speakerModelAsset } from '@cindy/voice-input-core';++export type SpeakerProfileCipher = {+ isAvailable(): boolean;+ encrypt(plain: string): Buffer;+ decrypt(cipher: Buffer): string;+};++export type SpeakerProfile = {+ embedding: Float32Array;+ createdAt: number;+};++type StoredFile = {+ version: 1;+ /** safeStorage ciphertext of {@link StoredPayload}, base64. */+ data: string;+};++type StoredPayload = {+ embedding: number[];+ createdAt: number;+ /** Embedding model that produced the voiceprint; another model cannot compare it. */+ modelSha256: string;+};++const MAX_FILE_BYTES = 64 * 1024;+const MAX_EMBEDDING_DIM = 4096;++/**+ * The enrolled voiceprint of this device's user, one per account.+ *+ * It is biometric data: it stays on this device (never synced or uploaded),+ * is encrypted with the OS keychain through safeStorage, and is dropped as+ * soon as the user deletes it. A voiceprint from another embedding model+ * reads as "not enrolled" so the user records again.+ */+export class SpeakerProfileStore {+ private cache: { file: string; profile: SpeakerProfile } | null = null;++ constructor(+ private readonly filePath: () => string,+ private readonly cipher: SpeakerProfileCipher,+ ) {}++ read(): SpeakerProfile | null {+ const file = this.filePath();+ if (this.cache?.file === file) return this.cache.profile;+ const profile = this.load(file);+ // A failed read (e.g. keychain still locked) is retried next time.+ this.cache = profile ? { file, profile } : null;+ return profile;+ }++ /** Throws when the OS keychain is unavailable; nothing is written then. */+ write(embedding: Float32Array, createdAt = Date.now()): SpeakerProfile {+ if (!this.cipher.isAvailable()) throw new SpeakerProfileStorageUnavailableError();+ const payload: StoredPayload = {+ embedding: Array.from(embedding),+ createdAt,+ modelSha256: speakerModelAsset('embedding').sha256,+ };+ const stored: StoredFile = {+ version: 1,+ data: this.cipher.encrypt(JSON.stringify(payload)).toString('base64'),+ };+ const file = this.filePath();+ fs.mkdirSync(path.dirname(file), { recursive: true });+ const tmp = `${file}.${process.pid}.tmp`;+ fs.writeFileSync(tmp, JSON.stringify(stored), { mode: 0o600 });+ fs.renameSync(tmp, file);+ const profile = { embedding: Float32Array.from(embedding), createdAt };+ this.cache = { file, profile };+ return profile;+ }++ delete(): void {+ const file = this.filePath();+ fs.rmSync(file, { force: true });+ this.cache = null;+ }++ private load(file: string): SpeakerProfile | null {+ let raw: string;+ try {+ const stat = fs.statSync(file);+ if (!stat.isFile() || stat.size > MAX_FILE_BYTES) return null;+ raw = fs.readFileSync(file, 'utf-8');+ } catch {+ return null;+ }+ try {+ const stored = JSON.parse(raw) as Partial<StoredFile>;+ if (stored.version !== 1 || typeof stored.data !== 'string') return null;+ const payload = JSON.parse(this.cipher.decrypt(Buffer.from(stored.data, 'base64'))) as Partial<StoredPayload>;+ if (payload.modelSha256 !== speakerModelAsset('embedding').sha256) return null;+ const embedding = payload.embedding;+ if (+ !Array.isArray(embedding) ||+ embedding.length === 0 ||+ embedding.length > MAX_EMBEDDING_DIM ||+ !embedding.every((value) => typeof value === 'number' && Number.isFinite(value))+ ) {+ return null;+ }+ return {+ embedding: Float32Array.from(embedding),+ createdAt: typeof payload.createdAt === 'number' ? payload.createdAt : 0,+ };+ } catch {+ // Unreadable (keychain locked, other profile's key, corrupt): treat as+ // not enrolled. The gate stays off; the user can record again.+ return null;+ }+ }+}++export class SpeakerProfileStorageUnavailableError extends Error {+ constructor() {+ super('secure storage is unavailable');+ this.name = 'SpeakerProfileStorageUnavailableError';+ }+}diff --git a/apps/desktop/src/main/voice-input/speaker/speakerWorkerProtocol.ts b/apps/desktop/src/main/voice-input/speaker/speakerWorkerProtocol.tsnew file mode 100644index 0000000000..fedf30ad51--- /dev/null+++ b/apps/desktop/src/main/voice-input/speaker/speakerWorkerProtocol.ts@@ -0,0 +1,17 @@+/** Messages between Electron main and the speaker-gate worker thread. */+export type SpeakerWorkerRequest =+ | { id: number; op: 'init'; vadModel: string; embeddingModel: string }+ | { id: number; op: 'vad-reset'; session: string }+ | { id: number; op: 'vad'; session: string; samples: Float32Array }+ | { id: number; op: 'embed'; samples: Float32Array }+ | { id: number; op: 'speech'; samples: Float32Array };++export type SpeakerWorkerResponse =+ | {+ id: number;+ ok: true;+ flags?: Uint8Array;+ embedding?: Float32Array | null;+ samples?: Float32Array;+ }+ | { id: number; ok: false; error: string };diff --git a/apps/desktop/src/preload/preload.ts b/apps/desktop/src/preload/preload.tsindex f8616a0ba6..7ce0727f9c 100644--- a/apps/desktop/src/preload/preload.ts+++ b/apps/desktop/src/preload/preload.ts@@ -29,6 +29,11 @@ import { DESKTOP_LOCAL, type RemoteDesktopApi } from '../shared/remoteDesktop';import { DEVICE_LINK_PUSH } from '../shared/deviceLinkIpc';import { PROVIDER_SHARE_IPC, type ProviderShareCommand } from '../shared/providerShare';import { PROVIDER_GROUP_IPC, type ProviderGroupCommand } from '../shared/providerGroup';+import {+ VOICE_SPEAKER_FILTER_CHANNELS,+ type VoiceSpeakerEnrollResult,+ type VoiceSpeakerFilterStatus,+} from '../shared/voiceSpeakerFilter';import type { MobileCodexRateLimitsResult, MobileCodexRateLimitResetResult } from '@cindy/maker-shared/device-link-contract';import type { AppearanceSettings } from '../shared/appearanceSettings';import type { DialogueWorkspaceSettingsState } from '../shared/dialogueWorkspaceSettings';@@ -664,6 +669,7 @@ const fanOutVoiceInputDictionaryLearningEvidence = createIpcFanOut('voice-input:dictionary-learning-evidence',);const fanOutVoiceInputDataChanged = createIpcFanOut('voice-input:data-changed');+const fanOutVoiceSpeakerStatusChanged = createIpcFanOut(VOICE_SPEAKER_FILTER_CHANNELS.statusChanged);// 挂起/锁屏 → renderer 释放 fast activation 的保活麦克风(见 shared/voiceInputPowerIpc)。const fanOutVoiceInputPowerStateChange = createIpcFanOut(VOICE_INPUT_POWER_STATE_CHANNEL);// 应用级快捷键 override 变化广播 (设置页改绑 / reset 后 main 推全量 overrides,@@ -1724,6 +1730,19 @@ contextBridge.exposeInMainWorld('electronAPI', {throwVoiceInputSyncError(result);},onDataChanged: fanOutVoiceInputDataChanged,+ speakerFilter: {+ getStatus: (): Promise<VoiceSpeakerFilterStatus> =>+ ipcRenderer.invoke(VOICE_SPEAKER_FILTER_CHANNELS.getStatus),+ downloadModels: (): Promise<VoiceSpeakerFilterStatus> =>+ ipcRenderer.invoke(VOICE_SPEAKER_FILTER_CHANNELS.downloadModels),+ cancelDownload: (): Promise<VoiceSpeakerFilterStatus> =>+ ipcRenderer.invoke(VOICE_SPEAKER_FILTER_CHANNELS.cancelDownload),+ enroll: (clips: ArrayBuffer[]): Promise<VoiceSpeakerEnrollResult> =>+ ipcRenderer.invoke(VOICE_SPEAKER_FILTER_CHANNELS.enroll, { clips }),+ deleteProfile: (): Promise<VoiceSpeakerFilterStatus> =>+ ipcRenderer.invoke(VOICE_SPEAKER_FILTER_CHANNELS.deleteProfile),+ onStatusChanged: fanOutVoiceSpeakerStatusChanged,+ },// options.suspend 表示「录制期挂起」这个意图。main 侧会丢掉与存盘不一致的同步请求// (过时的广播回声),而挂起传的 null 恰恰故意与存盘不同,必须能区分开。setGlobalShortcut: (diff --git a/apps/desktop/src/renderer/components/settings/VoiceInputSection.settings-search.ts b/apps/desktop/src/renderer/components/settings/VoiceInputSection.settings-search.tsindex 80f6be26da..a5dd138b6f 100644--- a/apps/desktop/src/renderer/components/settings/VoiceInputSection.settings-search.ts+++ b/apps/desktop/src/renderer/components/settings/VoiceInputSection.settings-search.ts@@ -17,6 +17,7 @@ export default {{ id: 'settings.voiceInput.sections.usageData', fallbackTargetId: 'settings-panel-voice-input', tab: 'voice-input', targetId: 'settings-search-voice-usage-data', titleKey: 'settings.voiceInput.sections.usageData', sectionKey: 'settings.tabs.voiceInput' },{ id: 'settings.voiceInput.fastActivation.label', fallbackTargetId: 'settings-panel-voice-input', tab: 'voice-input', targetId: 'settings-search-settings-voiceInput-fastActivation-label', titleKey: 'settings.voiceInput.fastActivation.label', sectionKey: 'settings.tabs.voiceInput', descriptionKey: 'settings.voiceInput.fastActivation.hint' },{ id: 'settings.voiceInput.composerLongPress.label', fallbackTargetId: 'settings-panel-voice-input', tab: 'voice-input', targetId: 'settings-search-settings-voiceInput-composerLongPress-label', titleKey: 'settings.voiceInput.composerLongPress.label', sectionKey: 'settings.tabs.voiceInput', descriptionKey: 'settings.voiceInput.composerLongPress.hint' },+ { id: 'settings.voiceInput.speakerFilter.label', fallbackTargetId: 'settings-panel-voice-input', tab: 'voice-input', targetId: 'settings-search-settings-voiceInput-speakerFilter-label', titleKey: 'settings.voiceInput.speakerFilter.label', sectionKey: 'settings.tabs.voiceInput', descriptionKey: 'settings.voiceInput.speakerFilter.hint' },{ id: 'settings.voiceInput.shortcut.label', fallbackTargetId: 'settings-panel-voice-input', tab: 'voice-input', targetId: 'settings-search-settings-voiceInput-shortcut-label', titleKey: 'settings.voiceInput.shortcut.label', sectionKey: 'settings.tabs.voiceInput', descriptionKey: 'settings.voiceInput.shortcut.hint' },],diff --git a/apps/desktop/src/renderer/components/settings/VoiceInputSection.tsx b/apps/desktop/src/renderer/components/settings/VoiceInputSection.tsxindex bc24fb94b8..7dc3698de0 100644--- a/apps/desktop/src/renderer/components/settings/VoiceInputSection.tsx+++ b/apps/desktop/src/renderer/components/settings/VoiceInputSection.tsx@@ -2,6 +2,7 @@ import { Button } from '@/components/ui/button';import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type KeyboardEvent as ReactKeyboardEvent, type ReactNode } from 'react';import { useSettingsSearchNavigation } from './SettingsSearchNavigation';import { DefaultOverrideControls } from './DefaultOverrideControls';+import { VoiceSpeakerFilterCard } from './VoiceSpeakerFilterCard';import { useTranslation } from 'react-i18next';import { useSearchParams } from 'react-router-dom';import * as Dialog from '@radix-ui/react-dialog';@@ -1049,6 +1050,9 @@ export function VoiceInputSection() {setAutoDictionaryEnabled,setDictionarySyncEnabled,resetDictionarySyncEnabled,+ setSpeakerFilterEnabled,+ setSpeakerFilterStrictness,+ resetSpeakerFilterStrictness,addDictionaryEntry: addDictionarySettingEntry,importDictionaryEntries: importDictionarySettingEntries,editDictionaryEntry: editDictionarySettingEntry,@@ -2747,6 +2751,16 @@ export function VoiceInputSection() {</div></VoiceInputCard>+ <VoiceSpeakerFilterCard+ enabled={settings.speakerFilterEnabled}+ strictness={settings.speakerFilterStrictness}+ strictnessCustomized={settings.speakerFilterStrictnessOverride != null}+ microphoneDeviceId={settings.microphoneDeviceId}+ onEnabledChange={setSpeakerFilterEnabled}+ onStrictnessChange={setSpeakerFilterStrictness}+ onStrictnessReset={resetSpeakerFilterStrictness}+ />+<VoiceInputCardid="settings-search-voice-usage-data"title={t('settings.voiceInput.sections.usageData')}diff --git a/apps/desktop/src/renderer/components/settings/VoiceSpeakerEnrollmentDialog.tsx b/apps/desktop/src/renderer/components/settings/VoiceSpeakerEnrollmentDialog.tsxnew file mode 100644index 0000000000..521c1ef19c--- /dev/null+++ b/apps/desktop/src/renderer/components/settings/VoiceSpeakerEnrollmentDialog.tsx@@ -0,0 +1,337 @@+import { useCallback, useEffect, useRef, useState, type CSSProperties } from 'react';+import { useTranslation } from 'react-i18next';+import * as Dialog from '@radix-ui/react-dialog';+import { Check, Mic } from 'lucide-react';++import { Button } from '@/components/ui/button';+import { createLogger } from '@/lib/logger';+import { toast } from '@/lib/toast';+import { cn } from '@/lib/utils';+import { requestRendererMicrophonePermission } from '@/voice-input/startGuards';+import {+ recordSpeakerEnrollmentClip,+ SpeakerEnrollmentAbortedError,+ SpeakerEnrollmentNoAudioError,+} from '@/voice-input/speakerEnrollmentRecorder';+import {+ VOICE_SPEAKER_ENROLLMENT_CLIP_COUNT,+ VOICE_SPEAKER_ENROLLMENT_TARGET_CLIP_SEC,+ type VoiceSpeakerEnrollResult,+ type VoiceSpeakerFilterStatus,+} from '../../../shared/voiceSpeakerFilter';++const log = createLogger('VoiceSpeakerEnrollmentDialog');+const CLIP_INDEXES = Array.from({ length: VOICE_SPEAKER_ENROLLMENT_CLIP_COUNT }, (_, index) => index);++type EnrollErrorKey = Extract<VoiceSpeakerEnrollResult, { ok: false }>['reason'] | 'microphone' | 'noAudio';++type EnrollError = { key: EnrollErrorKey; clipIndex?: number };++interface VoiceSpeakerEnrollmentDialogProps {+ open: boolean;+ onOpenChange: (open: boolean) => void;+ /** The microphone chosen for dictation; enrollment must record from it. */+ microphoneDeviceId: string | null;+ onEnrolled: (status: VoiceSpeakerFilterStatus) => void;+}++/**+ * Reads three short passages aloud to build the voiceprint. Each clip records+ * a fixed time and stops by itself; any clip can be re-recorded, and main+ * points at the clip to redo when one does not match the others.+ */+export function VoiceSpeakerEnrollmentDialog({+ open,+ onOpenChange,+ microphoneDeviceId,+ onEnrolled,+}: VoiceSpeakerEnrollmentDialogProps) {+ const { t } = useTranslation();+ const [clips, setClips] = useState<Array<ArrayBuffer | null>>(() => CLIP_INDEXES.map(() => null));+ const [current, setCurrent] = useState(0);+ const [recording, setRecording] = useState(false);+ const [progress, setProgress] = useState(0);+ const [level, setLevel] = useState(0);+ const [submitting, setSubmitting] = useState(false);+ const [error, setError] = useState<EnrollError | null>(null);+ const abortRef = useRef<AbortController | null>(null);+ const recordButtonRef = useRef<HTMLButtonElement>(null);+ const submitButtonRef = useRef<HTMLButtonElement>(null);+ const returnFocusRef = useRef<HTMLElement | null>(null);+ const clipsRef = useRef(clips);+ clipsRef.current = clips;++ const reset = useCallback(() => {+ abortRef.current?.abort();+ abortRef.current = null;+ setClips(CLIP_INDEXES.map(() => null));+ setCurrent(0);+ setRecording(false);+ setProgress(0);+ setLevel(0);+ setSubmitting(false);+ setError(null);+ }, []);++ useEffect(() => {+ if (!open) reset();+ }, [open, reset]);++ // Never leave the microphone open behind an unmounted dialog.+ useEffect(() => () => abortRef.current?.abort(), []);++ // Recording disables the buttons and drops focus; hand it back to the next step.+ const wasBusy = useRef(false);+ useEffect(() => {+ const busy = recording || submitting;+ if (wasBusy.current && !busy && open) {+ const done = clipsRef.current.every((clip) => clip !== null);+ (done ? submitButtonRef : recordButtonRef).current?.focus();+ }+ wasBusy.current = busy;+ }, [open, recording, submitting]);++ const record = useCallback(async () => {+ if (abortRef.current || recording || submitting) return;+ setError(null);+ const controller = new AbortController();+ abortRef.current = controller;+ const index = current;+ setRecording(true);+ setProgress(0);+ setLevel(0);+ try {+ const permission = await requestRendererMicrophonePermission();+ if (controller.signal.aborted) return;+ if (!permission.ok) {+ setError({ key: 'microphone' });+ return;+ }+ const clip = await recordSpeakerEnrollmentClip({+ deviceId: microphoneDeviceId ?? undefined,+ durationMs: VOICE_SPEAKER_ENROLLMENT_TARGET_CLIP_SEC * 1000,+ onLevel: setLevel,+ onProgress: setProgress,+ signal: controller.signal,+ });+ if (controller.signal.aborted) return;+ const next = [...clipsRef.current];+ next[index] = clip;+ setClips(next);+ const nextEmpty = CLIP_INDEXES.find((candidate) => !next[candidate]);+ if (nextEmpty !== undefined) setCurrent(nextEmpty);+ } catch (recordError) {+ if (controller.signal.aborted || recordError instanceof SpeakerEnrollmentAbortedError) return;+ log.warn('enrollment recording failed:', recordError instanceof Error ? recordError.message : String(recordError));+ setError({ key: recordError instanceof SpeakerEnrollmentNoAudioError ? 'noAudio' : 'microphone' });+ } finally {+ if (abortRef.current === controller && !controller.signal.aborted) {+ abortRef.current = null;+ setRecording(false);+ setLevel(0);+ }+ }+ }, [current, microphoneDeviceId, recording, submitting]);++ const submit = useCallback(async () => {+ const ready = clips.every((clip): clip is ArrayBuffer => clip !== null);+ if (!ready || submitting || recording) return;+ setSubmitting(true);+ setError(null);+ try {+ const result = await window.electronAPI.voiceInput.speakerFilter.enroll(clips as ArrayBuffer[]);+ if (result.ok) {+ onEnrolled(result.status);+ toast.success(t('settings.voiceInput.speakerFilter.enroll.done'));+ onOpenChange(false);+ return;+ }+ setError({ key: result.reason, clipIndex: result.clipIndex });+ if (result.clipIndex !== undefined) {+ const redo = result.clipIndex;+ setClips((previous) => previous.map((clip, index) => (index === redo ? null : clip)));+ setCurrent(redo);+ }+ } catch (enrollError) {+ log.warn('enrollment failed:', enrollError instanceof Error ? enrollError.message : String(enrollError));+ setError({ key: 'failed' });+ } finally {+ setSubmitting(false);+ }+ }, [clips, onEnrolled, onOpenChange, recording, submitting, t]);++ const allRecorded = clips.every((clip) => clip !== null);+ const errorText = error+ ? t(`settings.voiceInput.speakerFilter.enroll.errors.${error.key}`, {+ index: (error.clipIndex ?? 0) + 1,+ })+ : null;++ return (+ <Dialog.Root+ open={open}+ onOpenChange={(next) => {+ // Saving cannot be interrupted; closing mid-recording just discards it.+ if (!next && submitting) return;+ if (!next) abortRef.current?.abort();+ onOpenChange(next);+ }}+ >+ <Dialog.Portal>+ <Dialog.Overlay+ className="modal-scrim fixed inset-0 z-50"+ style={{ WebkitAppRegion: 'no-drag' } as CSSProperties}+ />+ <Dialog.Content+ onPointerDownOutside={(event) => event.preventDefault()}+ // Land on the primary action, not on the first passage chip.+ onOpenAutoFocus={(event) => {+ event.preventDefault();+ returnFocusRef.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;+ recordButtonRef.current?.focus();+ }}+ onCloseAutoFocus={(event) => {+ event.preventDefault();+ if (returnFocusRef.current?.isConnected) returnFocusRef.current.focus();+ }}+ className={cn(+ 'modal-panel fixed left-1/2 top-1/2 z-50 w-[min(460px,calc(100vw-32px))] -translate-x-1/2 -translate-y-1/2',+ 'flex flex-col gap-4 p-5 outline-none',+ )}+ style={{ WebkitAppRegion: 'no-drag' } as CSSProperties}+ >+ <div className="flex flex-col gap-1.5">+ <Dialog.Title className="text-18 font-semibold leading-[1.35] text-[var(--settings-section-title)]">+ {t('settings.voiceInput.speakerFilter.enroll.title')}+ </Dialog.Title>+ <Dialog.Description className="text-13 leading-[1.5] text-[var(--settings-section-sublabel)]">+ {t('settings.voiceInput.speakerFilter.enroll.description', {+ clips: VOICE_SPEAKER_ENROLLMENT_CLIP_COUNT,+ seconds: VOICE_SPEAKER_ENROLLMENT_TARGET_CLIP_SEC,+ })}+ </Dialog.Description>+ </div>++ <div+ role="group"+ aria-label={t('settings.voiceInput.speakerFilter.enroll.stepsAriaLabel')}+ className="flex items-center gap-2"+ >+ {CLIP_INDEXES.map((index) => {+ const recorded = clips[index] !== null;+ const selected = index === current;+ return (+ <button+ key={index}+ type="button"+ aria-current={selected ? 'step' : undefined}+ disabled={recording || submitting}+ onClick={() => {+ setCurrent(index);+ setError(null);+ }}+ className={cn(+ 'flex h-7 items-center gap-1.5 rounded-full border px-3 text-12 font-medium transition-colors',+ 'disabled:cursor-default disabled:opacity-60',+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring-soft)]',+ selected+ ? 'border-[var(--settings-section-title)] text-[var(--settings-section-title)]'+ : 'border-[var(--settings-theme-card-border)] text-[var(--settings-section-sublabel)] hover:bg-[var(--settings-btn-secondary-hover-bg)]',+ )}+ >+ {recorded ? <Check size={12} aria-hidden /> : null}+ {t('settings.voiceInput.speakerFilter.enroll.step', {+ current: index + 1,+ total: VOICE_SPEAKER_ENROLLMENT_CLIP_COUNT,+ })}+ </button>+ );+ })}+ </div>++ <p+ className={cn(+ 'rounded-xl border border-[var(--settings-input-border)] bg-[var(--settings-input-bg)] px-4 py-3',+ 'text-15 leading-[1.6] text-[var(--settings-section-title)]',+ )}+ >+ {t(`settings.voiceInput.speakerFilter.enroll.passages.p${current + 1}`)}+ </p>++ <div className="flex min-h-8 items-center gap-3">+ <Button+ ref={recordButtonRef}+ variant="secondary"+ size="md"+ type="button"+ disabled={recording || submitting}+ onClick={() => {+ void record();+ }}+ >+ <Mic size={14} />+ {t(+ clips[current]+ ? 'settings.voiceInput.speakerFilter.enroll.rerecord'+ : 'settings.voiceInput.speakerFilter.enroll.record',+ )}+ </Button>+ <p+ aria-live="polite"+ className="min-w-0 text-12 leading-[1.4] text-[var(--settings-section-sublabel)]"+ >+ {recording+ ? t('settings.voiceInput.speakerFilter.enroll.recording', {+ seconds: Math.max(+ 0,+ Math.ceil(VOICE_SPEAKER_ENROLLMENT_TARGET_CLIP_SEC * (1 - progress)),+ ),+ })+ : clips[current]+ ? t('settings.voiceInput.speakerFilter.enroll.recorded')+ : null}+ </p>+ {recording ? (+ <div+ aria-hidden+ className="ml-auto h-1 w-20 shrink-0 overflow-hidden rounded-full bg-[var(--settings-theme-card-border)]"+ >+ <div+ className="h-full rounded-full bg-[var(--settings-section-title)] transition-[width] duration-75"+ style={{ width: `${Math.round(Math.min(1, level * 3) * 100)}%` }}+ />+ </div>+ ) : null}+ </div>++ {errorText ? (+ <p role="alert" className="text-12 leading-[1.4] text-[var(--error-fg)]">+ {errorText}+ </p>+ ) : null}++ <div className="flex justify-end gap-2">+ <Dialog.Close asChild>+ <Button variant="secondary" size="lg" type="button" disabled={submitting}>+ {t('settings.voiceInput.speakerFilter.enroll.cancel')}+ </Button>+ </Dialog.Close>+ <Button+ ref={submitButtonRef}+ variant="cta"+ size="lg"+ type="button"+ loading={submitting}+ disabled={!allRecorded || recording}+ onClick={() => {+ void submit();+ }}+ >+ {t('settings.voiceInput.speakerFilter.enroll.submit')}+ </Button>+ </div>+ </Dialog.Content>+ </Dialog.Portal>+ </Dialog.Root>+ );+}diff --git a/apps/desktop/src/renderer/components/settings/VoiceSpeakerFilterCard.tsx b/apps/desktop/src/renderer/components/settings/VoiceSpeakerFilterCard.tsxnew file mode 100644index 0000000000..5a2fc13f59--- /dev/null+++ b/apps/desktop/src/renderer/components/settings/VoiceSpeakerFilterCard.tsx@@ -0,0 +1,310 @@+import { useState } from 'react';+import { useTranslation } from 'react-i18next';+import { Loader2 } from 'lucide-react';+import {+ SPEAKER_GATE_STRICTNESS_VALUES,+ SPEAKER_MODEL_TOTAL_BYTES,+ type SpeakerGateStrictness,+} from '@cindy/voice-input-core';++import { Button } from '@/components/ui/button';+import { useConfirmDialog } from '@/components/ui/confirm-dialog-provider';+import { SegmentedControl } from '@/components/ui/segmented-control';+import { Switch } from '@/components/ui/switch';+import { useVoiceSpeakerFilterStatus } from '@/hooks/useVoiceSpeakerFilterStatus';+import { createLogger } from '@/lib/logger';+import { toast } from '@/lib/toast';+import { cn } from '@/lib/utils';+import { DefaultOverrideControls } from './DefaultOverrideControls';+import { VoiceSpeakerEnrollmentDialog } from './VoiceSpeakerEnrollmentDialog';+import type { VoiceSpeakerFilterStatus } from '../../../shared/voiceSpeakerFilter';++const log = createLogger('VoiceSpeakerFilterCard');++interface VoiceSpeakerFilterCardProps {+ enabled: boolean;+ strictness: SpeakerGateStrictness;+ strictnessCustomized: boolean;+ microphoneDeviceId: string | null;+ onEnabledChange: (enabled: boolean) => void;+ onStrictnessChange: (strictness: SpeakerGateStrictness) => void;+ onStrictnessReset: () => Promise<boolean>;+}++/**+ * "Recognize my voice": the switch, the one-time model download, the voiceprint+ * and the strictness. The filter only takes effect when it is on, the models+ * are downloaded and a voiceprint is enrolled; the card says what is missing.+ */+export function VoiceSpeakerFilterCard({+ enabled,+ strictness,+ strictnessCustomized,+ microphoneDeviceId,+ onEnabledChange,+ onStrictnessChange,+ onStrictnessReset,+}: VoiceSpeakerFilterCardProps) {+ const { t, i18n } = useTranslation();+ const { confirm } = useConfirmDialog();+ const { status, setStatus } = useVoiceSpeakerFilterStatus();+ const [enrolling, setEnrolling] = useState(false);+ const supported = status?.supported !== false;++ const runStatusAction = (action: () => Promise<VoiceSpeakerFilterStatus>): void => {+ void action()+ .then(setStatus)+ .catch((error) => {+ log.warn('speaker filter action failed:', error instanceof Error ? error.message : String(error));+ toast.error(t('settings.voiceInput.speakerFilter.actionFailed'));+ });+ };++ const downloadModels = (): void => runStatusAction(() => window.electronAPI.voiceInput.speakerFilter.downloadModels());++ const toggle = (next: boolean): void => {+ onEnabledChange(next);+ // The models are fetched the first time the user turns the filter on.+ if (next && status && (status.modelState === 'missing' || status.modelState === 'failed')) {+ downloadModels();+ }+ };++ const deleteProfile = async (): Promise<void> => {+ const confirmed = await confirm({+ presentation: 'standard',+ title: t('settings.voiceInput.speakerFilter.profile.deleteConfirm.title'),+ description: t('settings.voiceInput.speakerFilter.profile.deleteConfirm.description'),+ confirmText: t('settings.voiceInput.speakerFilter.profile.deleteConfirm.confirm'),+ cancelText: t('settings.voiceInput.speakerFilter.profile.deleteConfirm.cancel'),+ confirmVariant: 'destructive',+ });+ if (!confirmed) return;+ void window.electronAPI.voiceInput.speakerFilter+ .deleteProfile()+ .then((next) => {+ setStatus(next);+ toast.success(t('settings.voiceInput.speakerFilter.profile.deleted'));+ })+ .catch((error) => {+ log.warn('speaker profile delete failed:', error instanceof Error ? error.message : String(error));+ toast.error(t('settings.voiceInput.speakerFilter.actionFailed'));+ });+ };++ const showDetails = supported && status !== null && (enabled || status.enrolled);+ const modelsReady = status?.modelState === 'ready';++ return (+ <section+ className={cn(+ 'flex flex-col gap-4 rounded-xl p-4',+ 'bg-[var(--settings-theme-card-bg)]',+ 'border border-[var(--settings-theme-card-border)]',+ )}+ >+ <h3+ className="text-13 font-medium text-[var(--settings-section-sublabel)]"+ style={{ letterSpacing: '0.12px' }}+ >+ {t('settings.voiceInput.sections.speakerFilter')}+ </h3>++ <div className="flex items-center justify-between gap-5">+ <div className="flex min-w-0 flex-col gap-1">+ <p+ id="settings-search-settings-voiceInput-speakerFilter-label"+ className="text-13 font-medium text-[var(--settings-section-title)]"+ style={{ letterSpacing: '0.12px' }}+ >+ {t('settings.voiceInput.speakerFilter.label')}+ </p>+ <p className="text-12 leading-[1.4] text-[var(--settings-section-sublabel)] opacity-70">+ {supported+ ? t('settings.voiceInput.speakerFilter.hint')+ : t('settings.voiceInput.speakerFilter.unsupported')}+ </p>+ </div>+ <Switch+ checked={enabled && supported}+ disabled={!supported || status === null}+ onCheckedChange={toggle}+ aria-label={t('settings.voiceInput.speakerFilter.ariaLabel')}+ />+ </div>++ {showDetails && status ? (+ // Every row gets the same hairline the other voice-input rows use.+ <div+ className={cn(+ 'flex flex-col gap-4 border-t border-[var(--settings-theme-card-border)] pt-4',+ '[&>*+*]:border-t [&>*+*]:border-[var(--settings-theme-card-border)] [&>*+*]:pt-4',+ )}+ >+ {!modelsReady ? <ModelRow status={status} onDownload={downloadModels} /> : null}++ {modelsReady ? (+ <div className="flex items-center justify-between gap-5">+ <div className="flex min-w-0 flex-col gap-1">+ <p className="text-13 font-medium text-[var(--settings-section-title)]">+ {t(+ status.enrolled+ ? 'settings.voiceInput.speakerFilter.profile.enrolled'+ : 'settings.voiceInput.speakerFilter.profile.missing',+ )}+ </p>+ <p className="text-12 leading-[1.4] text-[var(--settings-section-sublabel)] opacity-70">+ {status.enrolled && status.enrolledAt+ ? t('settings.voiceInput.speakerFilter.profile.enrolledAt', {+ date: new Date(status.enrolledAt).toLocaleDateString(i18n.language),+ })+ : t('settings.voiceInput.speakerFilter.profile.missingHint')}+ </p>+ </div>+ <div className="flex shrink-0 items-center gap-2">+ {status.enrolled ? (+ <Button+ variant="secondary"+ size="md"+ compact+ tone="quiet"+ type="button"+ onClick={() => {+ void deleteProfile();+ }}+ >+ {t('settings.voiceInput.speakerFilter.profile.delete')}+ </Button>+ ) : null}+ <Button variant="secondary" size="md" compact type="button" onClick={() => setEnrolling(true)}>+ {t(+ status.enrolled+ ? 'settings.voiceInput.speakerFilter.profile.reenroll'+ : 'settings.voiceInput.speakerFilter.profile.enroll',+ )}+ </Button>+ </div>+ </div>+ ) : status.enrolled ? (+ <div className="flex items-center justify-between gap-5">+ <p className="text-13 font-medium text-[var(--settings-section-title)]">+ {t('settings.voiceInput.speakerFilter.profile.enrolled')}+ </p>+ <Button+ variant="secondary"+ size="md"+ compact+ tone="quiet"+ type="button"+ onClick={() => {+ void deleteProfile();+ }}+ >+ {t('settings.voiceInput.speakerFilter.profile.delete')}+ </Button>+ </div>+ ) : null}++ {status.enrolled ? (+ <div className="flex flex-wrap items-center justify-between gap-x-5 gap-y-3">+ <div className="flex min-w-0 flex-1 basis-[240px] flex-col gap-1">+ <p className="text-13 font-medium text-[var(--settings-section-title)]">+ {t('settings.voiceInput.speakerFilter.strictness.label')}+ </p>+ <p className="text-12 leading-[1.4] text-[var(--settings-section-sublabel)] opacity-70">+ {t('settings.voiceInput.speakerFilter.strictness.hint')}+ </p>+ </div>+ <div className="flex shrink-0 items-center gap-2">+ <DefaultOverrideControls+ isCustomized={strictnessCustomized}+ onReset={() => {+ void onStrictnessReset().then((ok) => {+ if (ok) toast.success(t('settings.defaults.restored'));+ });+ }}+ />+ <SegmentedControl+ aria-label={t('settings.voiceInput.speakerFilter.strictness.label')}+ value={strictness}+ onValueChange={onStrictnessChange}+ options={SPEAKER_GATE_STRICTNESS_VALUES.map((value) => ({+ value,+ label: t(`settings.voiceInput.speakerFilter.strictness.options.${value}`),+ }))}+ />+ </div>+ </div>+ ) : null}+ </div>+ ) : null}++ {supported ? (+ <p className="text-12 leading-[1.4] text-[var(--settings-section-sublabel)] opacity-70">+ {t('settings.voiceInput.speakerFilter.privacy')}+ </p>+ ) : null}++ <VoiceSpeakerEnrollmentDialog+ open={enrolling}+ onOpenChange={setEnrolling}+ microphoneDeviceId={microphoneDeviceId}+ onEnrolled={setStatus}+ />+ </section>+ );+}++function ModelRow({ status, onDownload }: { status: VoiceSpeakerFilterStatus; onDownload: () => void }) {+ const { t } = useTranslation();+ const total = formatMegabytes(status.totalBytes || SPEAKER_MODEL_TOTAL_BYTES);++ if (status.modelState === 'downloading') {+ return (+ <div className="flex items-center justify-between gap-5">+ <p className="flex min-w-0 items-center gap-2 text-13 text-[var(--settings-section-title)]">+ <Loader2 size={14} className="shrink-0 animate-spin motion-reduce:animate-none" aria-hidden />+ {t('settings.voiceInput.speakerFilter.model.downloading', {+ done: formatMegabytes(status.downloadedBytes),+ total,+ })}+ </p>+ <Button+ variant="secondary"+ size="md"+ compact+ type="button"+ onClick={() => {+ void window.electronAPI.voiceInput.speakerFilter.cancelDownload();+ }}+ >+ {t('settings.voiceInput.speakerFilter.model.cancel')}+ </Button>+ </div>+ );+ }++ const failed = status.modelState === 'failed';+ return (+ <div className="flex items-center justify-between gap-5">+ <p+ role={failed ? 'alert' : undefined}+ className={cn(+ 'min-w-0 text-12 leading-[1.4]',+ failed ? 'text-[var(--error-fg)]' : 'text-[var(--settings-section-sublabel)]',+ )}+ >+ {failed+ ? t(`settings.voiceInput.speakerFilter.model.failed.${status.downloadError ?? 'network'}`)+ : t('settings.voiceInput.speakerFilter.model.needed', { size: total })}+ </p>+ <Button variant="secondary" size="md" compact type="button" onClick={onDownload}>+ {t(failed ? 'settings.voiceInput.speakerFilter.model.retry' : 'settings.voiceInput.speakerFilter.model.download')}+ </Button>+ </div>+ );+}++function formatMegabytes(bytes: number): string {+ return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;+}diff --git a/apps/desktop/src/renderer/components/settings/__tests__/VoiceSpeakerEnrollmentDialog.test.tsx b/apps/desktop/src/renderer/components/settings/__tests__/VoiceSpeakerEnrollmentDialog.test.tsxnew file mode 100644index 0000000000..0cce042bf2--- /dev/null+++ b/apps/desktop/src/renderer/components/settings/__tests__/VoiceSpeakerEnrollmentDialog.test.tsx@@ -0,0 +1,109 @@+// @vitest-environment jsdom++import { useState } from 'react';+import { act, cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';++const mocks = vi.hoisted(() => ({ permission: vi.fn(), record: vi.fn(), enroll: vi.fn() }));+vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: (key: string) => key }) }));+vi.mock('@/lib/toast', () => ({ toast: { success: vi.fn() } }));+vi.mock('@/voice-input/startGuards', () => ({ requestRendererMicrophonePermission: mocks.permission }));+vi.mock('@/voice-input/speakerEnrollmentRecorder', () => ({+ recordSpeakerEnrollmentClip: mocks.record,+ SpeakerEnrollmentAbortedError: class extends Error {},+ SpeakerEnrollmentNoAudioError: class extends Error {},+}));++import { VoiceSpeakerEnrollmentDialog } from '../VoiceSpeakerEnrollmentDialog';++const key = (name: string) => `settings.voiceInput.speakerFilter.enroll.${name}`;+function Harness() {+ const [open, setOpen] = useState(false);+ return <>+ <button onClick={() => setOpen(true)}>Enroll</button>+ <VoiceSpeakerEnrollmentDialog open={open} onOpenChange={setOpen} microphoneDeviceId={null} onEnrolled={vi.fn()} />+ </>;+}+function deferred<T>() {+ let resolve!: (value: T) => void;+ const promise = new Promise<T>((done) => { resolve = done; });+ return { promise, resolve };+}+async function openDialog() {+ const opener = screen.getByRole('button', { name: 'Enroll' });+ opener.focus();+ fireEvent.click(opener);+ await waitFor(() => expect(document.activeElement).toBe(screen.getByRole('button', { name: key('record') })));+ return opener;+}+beforeEach(() => {+ vi.resetAllMocks();+ mocks.permission.mockResolvedValue({ ok: true });+ mocks.record.mockResolvedValue(new ArrayBuffer(8));+ Object.defineProperty(window, 'electronAPI', { configurable: true, value: { voiceInput: { speakerFilter: { enroll: mocks.enroll } } } });+});+afterEach(cleanup);++describe('VoiceSpeakerEnrollmentDialog', () => {+ it('restores the opener after cancelling', async () => {+ render(<Harness />);+ const opener = await openDialog();+ fireEvent.click(screen.getByRole('button', { name: key('cancel') }));+ await waitFor(() => expect(document.activeElement).toBe(opener));+ });++ it('does not start recording when permission resolves after cancellation and reopening', async () => {+ const permission = deferred<{ ok: true }>();+ mocks.permission.mockReturnValueOnce(permission.promise);+ render(<Harness />);+ await openDialog();+ fireEvent.click(screen.getByRole('button', { name: key('record') }));+ fireEvent.click(screen.getByRole('button', { name: key('cancel') }));+ await waitFor(() => expect(screen.queryByRole('dialog')).toBeNull());+ await openDialog();+ await act(async () => { permission.resolve({ ok: true }); });+ expect(mocks.record).not.toHaveBeenCalled();+ });++ it('does not start recording after unmounting during permission request', async () => {+ const permission = deferred<{ ok: true }>();+ mocks.permission.mockReturnValueOnce(permission.promise);+ const view = render(<Harness />);+ await openDialog();+ fireEvent.click(screen.getByRole('button', { name: key('record') }));+ view.unmount();+ await act(async () => { permission.resolve({ ok: true }); });+ expect(mocks.record).not.toHaveBeenCalled();+ });++ it('ignores repeated activation while waiting for microphone permission', async () => {+ const permission = deferred<{ ok: true }>();+ mocks.permission.mockReturnValue(permission.promise);+ render(<Harness />);+ await openDialog();+ const record = screen.getByRole('button', { name: key('record') });+ fireEvent.click(record);+ fireEvent.click(record);+ await act(async () => { permission.resolve({ ok: true }); });+ expect(mocks.permission).toHaveBeenCalledTimes(1);+ expect(mocks.record).toHaveBeenCalledTimes(1);+ });++ it('focuses the next recording, then submit, and the rejected passage on validation failure', async () => {+ const enrollment = deferred<{ ok: false; reason: 'inconsistent'; clipIndex: number }>();+ mocks.enroll.mockReturnValue(enrollment.promise);+ render(<Harness />);+ await openDialog();+ for (let index = 0; index < 3; index += 1) {+ const clip = deferred<ArrayBuffer>();+ mocks.record.mockReturnValueOnce(clip.promise);+ await act(async () => { fireEvent.click(screen.getByRole('button', { name: key('record') })); });+ await act(async () => { clip.resolve(new ArrayBuffer(8)); });+ expect(document.activeElement).toBe(screen.getByRole('button', { name: key(index === 2 ? 'submit' : 'record') }));+ }+ await act(async () => { fireEvent.click(screen.getByRole('button', { name: key('submit') })); });+ await act(async () => { enrollment.resolve({ ok: false, reason: 'inconsistent', clipIndex: 1 }); });+ expect(screen.getByRole('alert').textContent).toBe(key('errors.inconsistent'));+ expect(document.activeElement).toBe(screen.getByRole('button', { name: key('record') }));+ });+});diff --git a/apps/desktop/src/renderer/components/settings/__tests__/VoiceSpeakerFilterCard.test.tsx b/apps/desktop/src/renderer/components/settings/__tests__/VoiceSpeakerFilterCard.test.tsxnew file mode 100644index 0000000000..b147aada64--- /dev/null+++ b/apps/desktop/src/renderer/components/settings/__tests__/VoiceSpeakerFilterCard.test.tsx@@ -0,0 +1,132 @@+// @vitest-environment jsdom++import { act, fireEvent, render, screen } from '@testing-library/react';+import { beforeEach, describe, expect, it, vi } from 'vitest';++import type { VoiceSpeakerFilterStatus } from '../../../../shared/voiceSpeakerFilter';++vi.mock('react-i18next', () => ({+ useTranslation: () => ({+ t: (key: string) => key,+ i18n: { language: 'en' },+ }),+}));+vi.mock('@/components/ui/tooltip', () => ({+ Tip: ({ children }: { children: React.ReactNode }) => children,+}));+vi.mock('@/lib/toast', () => ({ toast: { success: vi.fn(), error: vi.fn() } }));+vi.mock('@/components/ui/confirm-dialog-provider', () => ({+ useConfirmDialog: () => ({ confirm: vi.fn(async () => true) }),+}));++import { VoiceSpeakerFilterCard } from '../VoiceSpeakerFilterCard';++const baseStatus: VoiceSpeakerFilterStatus = {+ supported: true,+ modelState: 'missing',+ downloadedBytes: 0,+ totalBytes: 28_925_018,+ enrolled: false,+};++let pushStatus: ((status: VoiceSpeakerFilterStatus) => void) | null = null;+const api = {+ getStatus: vi.fn(),+ downloadModels: vi.fn(),+ cancelDownload: vi.fn(),+ enroll: vi.fn(),+ deleteProfile: vi.fn(),+ onStatusChanged: vi.fn((callback: (status: VoiceSpeakerFilterStatus) => void) => {+ pushStatus = callback;+ return () => {+ pushStatus = null;+ };+ }),+};++function mockStatus(status: VoiceSpeakerFilterStatus): void {+ api.getStatus.mockResolvedValue(status);+ api.downloadModels.mockResolvedValue({ ...status, modelState: 'downloading' });+}++beforeEach(() => {+ vi.clearAllMocks();+ Object.defineProperty(window, 'electronAPI', {+ configurable: true,+ value: { platform: 'darwin', voiceInput: { speakerFilter: api } },+ });+});++function renderCard(props: Partial<React.ComponentProps<typeof VoiceSpeakerFilterCard>> = {}) {+ const onEnabledChange = vi.fn();+ render(+ <VoiceSpeakerFilterCard+ enabled={false}+ strictness="standard"+ strictnessCustomized={false}+ microphoneDeviceId={null}+ onEnabledChange={onEnabledChange}+ onStrictnessChange={vi.fn()}+ onStrictnessReset={vi.fn(async () => true)}+ {...props}+ />,+ );+ return { onEnabledChange };+}++describe('VoiceSpeakerFilterCard', () => {+ it('turning the filter on for the first time starts the model download', async () => {+ mockStatus(baseStatus);+ const { onEnabledChange } = renderCard();+ const toggle = await screen.findByRole('switch', { name: 'settings.voiceInput.speakerFilter.ariaLabel' });+ await vi.waitFor(() => expect((toggle as HTMLButtonElement).disabled).toBe(false));++ await act(async () => {+ fireEvent.click(toggle);+ });++ expect(onEnabledChange).toHaveBeenCalledWith(true);+ expect(api.downloadModels).toHaveBeenCalledTimes(1);+ });++ it('does not download again when the models are already there', async () => {+ mockStatus({ ...baseStatus, modelState: 'ready' });+ renderCard();+ const toggle = await screen.findByRole('switch', { name: 'settings.voiceInput.speakerFilter.ariaLabel' });+ await vi.waitFor(() => expect((toggle as HTMLButtonElement).disabled).toBe(false));+ await act(async () => {+ fireEvent.click(toggle);+ });+ expect(api.downloadModels).not.toHaveBeenCalled();+ });++ it('asks for a voiceprint before showing strictness', async () => {+ mockStatus({ ...baseStatus, modelState: 'ready' });+ renderCard({ enabled: true });+ expect(await screen.findByText('settings.voiceInput.speakerFilter.profile.missing')).toBeTruthy();+ expect(screen.queryByText('settings.voiceInput.speakerFilter.strictness.label')).toBeNull();++ act(() => pushStatus?.({ ...baseStatus, modelState: 'ready', enrolled: true, enrolledAt: 1 }));+ expect(await screen.findByText('settings.voiceInput.speakerFilter.profile.enrolled')).toBeTruthy();+ expect(screen.getByRole('radiogroup', { name: 'settings.voiceInput.speakerFilter.strictness.label' })).toBeTruthy();+ });++ it('keeps delete available after the filter is turned off', async () => {+ mockStatus({ ...baseStatus, modelState: 'ready', enrolled: true, enrolledAt: 1 });+ api.deleteProfile.mockResolvedValue({ ...baseStatus, modelState: 'ready' });+ renderCard({ enabled: false });+ const remove = await screen.findByRole('button', { name: 'settings.voiceInput.speakerFilter.profile.delete' });+ await act(async () => {+ fireEvent.click(remove);+ });+ expect(api.deleteProfile).toHaveBeenCalledTimes(1);+ });++ it('disables the switch where voiceprints are unsupported', async () => {+ mockStatus({ ...baseStatus, supported: false });+ renderCard();+ expect(await screen.findByText('settings.voiceInput.speakerFilter.unsupported')).toBeTruthy();+ const toggle = screen.getByRole('switch', { name: 'settings.voiceInput.speakerFilter.ariaLabel' });+ expect((toggle as HTMLButtonElement).disabled).toBe(true);+ });+});diff --git a/apps/desktop/src/renderer/hooks/useVoiceInputSettings.ts b/apps/desktop/src/renderer/hooks/useVoiceInputSettings.tsindex fd98cd16b7..9458aefb17 100644--- a/apps/desktop/src/renderer/hooks/useVoiceInputSettings.ts+++ b/apps/desktop/src/renderer/hooks/useVoiceInputSettings.ts@@ -1,6 +1,6 @@import { useCallback, useEffect, useRef, useState } from 'react';import { useTranslation } from 'react-i18next';-import type { DictationDictionaryLearningAction } from '@cindy/voice-input-core';+import type { DictationDictionaryLearningAction, SpeakerGateStrictness } from '@cindy/voice-input-core';import { createLogger } from '@/lib/logger';import { toast } from '@/lib/toast';@@ -207,6 +207,10 @@ export function useVoiceInputSettings(): {setDictionarySyncEnabled: (enabled: boolean) => void;/** 同 {@link resetComposerLongPressEnabled}:null 删 override 恢复默认。 */resetDictionarySyncEnabled: () => Promise<boolean>;+ setSpeakerFilterEnabled: (enabled: boolean) => void;+ setSpeakerFilterStrictness: (strictness: SpeakerGateStrictness) => void;+ /** 同 {@link resetComposerLongPressEnabled}:null 删 override 恢复默认。 */+ resetSpeakerFilterStrictness: () => Promise<boolean>;/** 这几个返回持久化结果:成功才收口 UI(关对话框、清草稿、提示成功)。 */addDictionaryEntry: (text: string) => Promise<boolean>;importDictionaryEntries: (texts: string[]) => Promise<boolean>;@@ -316,6 +320,21 @@ export function useVoiceInputSettings(): {[runOverrideReset],);+ const setSpeakerFilterEnabled = useCallback(+ (speakerFilterEnabled: boolean) => updateSettings({ speakerFilterEnabled }),+ [updateSettings],+ );++ const setSpeakerFilterStrictness = useCallback(+ (speakerFilterStrictness: SpeakerGateStrictness) => updateSettings({ speakerFilterStrictness }),+ [updateSettings],+ );++ const resetSpeakerFilterStrictness = useCallback(+ () => runOverrideReset({ speakerFilterStrictness: null }),+ [runOverrideReset],+ );+// 词典的增改删都是语义化操作:主进程按「用户做了什么」更新同步状态,再把物化// 结果回投影成 settings。整份覆盖词条数组表达不了用户意图,也会被下一次物化冲掉。/**@@ -430,6 +449,9 @@ export function useVoiceInputSettings(): {setAutoDictionaryEnabled,setDictionarySyncEnabled,resetDictionarySyncEnabled,+ setSpeakerFilterEnabled,+ setSpeakerFilterStrictness,+ resetSpeakerFilterStrictness,addDictionaryEntry,importDictionaryEntries,renameDictionaryEntry,diff --git a/apps/desktop/src/renderer/hooks/useVoiceSpeakerFilterStatus.ts b/apps/desktop/src/renderer/hooks/useVoiceSpeakerFilterStatus.tsnew file mode 100644index 0000000000..75852abf9b--- /dev/null+++ b/apps/desktop/src/renderer/hooks/useVoiceSpeakerFilterStatus.ts@@ -0,0 +1,36 @@+import { useCallback, useEffect, useState } from 'react';++import { createLogger } from '@/lib/logger';+import type { VoiceSpeakerFilterStatus } from '../../shared/voiceSpeakerFilter';++const log = createLogger('useVoiceSpeakerFilterStatus');++/**+ * Model download and enrollment state of "recognize my voice". Main pushes every+ * change (download progress, enroll, delete), so this only seeds the first+ * value and then follows the push.+ */+export function useVoiceSpeakerFilterStatus(): {+ status: VoiceSpeakerFilterStatus | null;+ setStatus: (status: VoiceSpeakerFilterStatus) => void;+ refresh: () => void;+} {+ const [status, setStatus] = useState<VoiceSpeakerFilterStatus | null>(null);++ const refresh = useCallback(() => {+ void window.electronAPI.voiceInput.speakerFilter+ .getStatus()+ .then(setStatus)+ .catch((error) => {+ log.warn('speaker filter status failed:', error instanceof Error ? error.message : String(error));+ });+ }, []);++ useEffect(() => {+ const unsubscribe = window.electronAPI.voiceInput.speakerFilter.onStatusChanged(setStatus);+ refresh();+ return unsubscribe;+ }, [refresh]);++ return { status, setStatus, refresh };+}diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.jsonindex 82019c9eee..31215209f6 100644--- a/apps/desktop/src/renderer/i18n/locales/en/common.json+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json@@ -2138,7 +2138,8 @@"basics": "Basics","refinement": "Refinement","preferences": "Preferences",- "usageData": "Usage"+ "usageData": "Usage",+ "speakerFilter": "Voiceprint filter"},"serviceSource": {"label": "Voice service",@@ -2435,6 +2436,80 @@"copied": "Copied","copyFailed": "Copy failed"}+ },+ "speakerFilter": {+ "label": "Recognize my voice",+ "hint": "Mutes other people during voice input so only what you say is transcribed. Requires a recorded voiceprint; speech that overlaps yours cannot be fully removed.",+ "ariaLabel": "Toggle recognize my voice",+ "unsupported": "Voiceprint recognition is not available on this computer.",+ "privacy": "Your voiceprint stays on this computer, encrypted. It is never uploaded or synced to other devices.",+ "actionFailed": "Something went wrong. Try again later.",+ "model": {+ "needed": "The first use downloads a recognition model of about {{size}}.",+ "download": "Download",+ "downloading": "Downloading recognition model ({{done}} / {{total}})",+ "cancel": "Cancel",+ "retry": "Retry",+ "failed": {+ "network": "The recognition model failed to download. Check your network and try again.",+ "disk": "The recognition model could not be saved. Check your free disk space and try again.",+ "checksum": "The downloaded recognition model failed verification. Try again.",+ "unavailable": "The recognition model is unavailable right now. Try again later."+ }+ },+ "profile": {+ "missing": "No voiceprint yet",+ "missingHint": "Record your voiceprint to turn this on. It takes about 20 seconds.",+ "enrolled": "Voiceprint recorded",+ "enrolledAt": "Recorded {{date}}",+ "enroll": "Record voiceprint",+ "reenroll": "Record again",+ "delete": "Delete voiceprint",+ "deleted": "Voiceprint deleted",+ "deleteConfirm": {+ "title": "Delete voiceprint?",+ "description": "Voice input will stop filtering out other people until you record your voiceprint again.",+ "confirm": "Delete",+ "cancel": "Cancel"+ }+ },+ "strictness": {+ "label": "Strictness",+ "hint": "Stricter lets fewer other voices through, but in noisy places it may also cut off more of your own words.",+ "options": {+ "relaxed": "Relaxed",+ "standard": "Standard",+ "strict": "Strict"+ }+ },+ "enroll": {+ "title": "Record voiceprint",+ "description": "Where you usually use voice input, read the {{clips}} passages below in your normal voice. Each recording lasts {{seconds}} seconds. Make sure no one else is talking.",+ "stepsAriaLabel": "Passages to read",+ "step": "{{current}} of {{total}}",+ "record": "Start reading",+ "rerecord": "Record this one again",+ "recording": "Recording, {{seconds}} s left",+ "recorded": "Recorded",+ "cancel": "Cancel",+ "submit": "Done",+ "done": "Voiceprint recorded",+ "passages": {+ "p1": "This morning I will go over the plan for the week, and in the afternoon I will list the questions we need to discuss and send them out so everyone can read them first.",+ "p2": "If the weather is nice tomorrow, we can leave a little earlier, pick up some fruit and snacks on the way, and have lunch in the park.",+ "p3": "Please make this text more concise, keep the key numbers and conclusions, and then sum up the main points in three to five sentences."+ },+ "errors": {+ "too_short": "Passage {{index}} has too little speech. Record it again without long pauses.",+ "no_embedding": "No voiceprint could be read from passage {{index}}. Record it again.",+ "inconsistent": "Passage {{index}} does not sound like the same person as the others; another voice or noise may have been picked up. Record it again.",+ "models_missing": "The recognition model has not finished downloading. Try again shortly.",+ "storage_unavailable": "The system keychain is unavailable, so the voiceprint cannot be stored encrypted. Try again later.",+ "failed": "The voiceprint could not be created. Try again.",+ "microphone": "The microphone cannot be used. Check microphone permission and the device.",+ "noAudio": "No sound came from the microphone. Check the device and try again."+ }+ }}},"sessionImport": {diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.jsonindex 06dfced78d..e6623164f1 100644--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json@@ -2114,7 +2114,8 @@"basics": "基本","refinement": "整え方","preferences": "設定",- "usageData": "使用量"+ "usageData": "使用量",+ "speakerFilter": "声紋フィルター"},"serviceSource": {"label": "音声サービス",@@ -2411,6 +2412,80 @@"copied": "コピーしました","copyFailed": "コピーに失敗しました"}+ },+ "speakerFilter": {+ "label": "自分の声を認識",+ "hint": "音声入力中は周りの人の声をミュートし、あなたの話した内容だけを認識に送ります。事前に声紋の登録が必要です。あなたと同時に話された声は完全には取り除けません。",+ "ariaLabel": "「自分の声を認識」を切り替え",+ "unsupported": "このパソコンでは声紋認識を利用できません。",+ "privacy": "声紋はこのパソコンにだけ暗号化して保存され、アップロードや他のデバイスへの同期は行われません。",+ "actionFailed": "操作に失敗しました。しばらくしてからもう一度お試しください。",+ "model": {+ "needed": "初回は約 {{size}} の認識モデルをダウンロードします。",+ "download": "ダウンロード",+ "downloading": "認識モデルをダウンロード中({{done}} / {{total}})",+ "cancel": "キャンセル",+ "retry": "再試行",+ "failed": {+ "network": "認識モデルのダウンロードに失敗しました。ネットワークを確認してもう一度お試しください。",+ "disk": "認識モデルを保存できませんでした。ディスクの空き容量を確認してもう一度お試しください。",+ "checksum": "ダウンロードした認識モデルの検証に失敗しました。もう一度お試しください。",+ "unavailable": "現在、認識モデルを取得できません。しばらくしてからもう一度お試しください。"+ }+ },+ "profile": {+ "missing": "声紋が未登録です",+ "missingHint": "声紋を登録すると有効になります。約 20 秒かかります。",+ "enrolled": "声紋を登録済み",+ "enrolledAt": "{{date}} に登録",+ "enroll": "声紋を登録",+ "reenroll": "登録し直す",+ "delete": "声紋を削除",+ "deleted": "声紋を削除しました",+ "deleteConfirm": {+ "title": "声紋を削除しますか?",+ "description": "削除すると、もう一度登録するまで音声入力で周りの人の声を除外しなくなります。",+ "confirm": "削除",+ "cancel": "キャンセル"+ }+ },+ "strictness": {+ "label": "厳しさ",+ "hint": "厳しくするほど周りの人の声が入りにくくなりますが、騒がしい場所では自分の言葉も途切れやすくなります。",+ "options": {+ "relaxed": "ゆるめ",+ "standard": "標準",+ "strict": "厳しめ"+ }+ },+ "enroll": {+ "title": "声紋を登録",+ "description": "普段音声入力を使う場所で、下の {{clips}} つの文章をいつもの話し方で読み上げてください。1 つにつき {{seconds}} 秒録音します。録音中は他の人が話さないようにしてください。",+ "stepsAriaLabel": "読み上げる文章",+ "step": "{{current}} / {{total}}",+ "record": "読み上げを開始",+ "rerecord": "この文章を録り直す",+ "recording": "録音中、残り {{seconds}} 秒",+ "recorded": "録音済み",+ "cancel": "キャンセル",+ "submit": "完了",+ "done": "声紋を登録しました",+ "passages": {+ "p1": "今日の午前中は今週の作業予定を整理して、午後には話し合いたい課題をまとめて、みんなに先に送っておきます。",+ "p2": "明日天気が良ければ少し早めに出発して、途中で果物やお菓子を買い、お昼は公園で食べましょう。",+ "p3": "この文章をもう少し簡潔にして、重要な数字と結論は残したうえで、要点を三つから五つの文でまとめてください。"+ },+ "errors": {+ "too_short": "{{index}} つ目の録音は話している時間が短すぎます。長く止まらずに読み上げて、録り直してください。",+ "no_embedding": "{{index}} つ目の録音から声紋を読み取れませんでした。録り直してください。",+ "inconsistent": "{{index}} つ目の録音が他と同じ人の声に聞こえません。他の人の声や雑音が入った可能性があります。録り直してください。",+ "models_missing": "認識モデルのダウンロードがまだ完了していません。しばらくしてからお試しください。",+ "storage_unavailable": "システムのキーチェーンを利用できないため、声紋を暗号化して保存できません。しばらくしてからお試しください。",+ "failed": "声紋を作成できませんでした。もう一度お試しください。",+ "microphone": "マイクを使用できません。マイクの許可とデバイスを確認してください。",+ "noAudio": "マイクから音が届いていません。デバイスを確認してもう一度お試しください。"+ }+ }}},"sessionImport": {diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.jsonindex 94bd506dd4..041ce07769 100644--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json@@ -2114,7 +2114,8 @@"basics": "기본","refinement": "정리","preferences": "환경설정",- "usageData": "사용량"+ "usageData": "사용량",+ "speakerFilter": "성문 필터"},"serviceSource": {"label": "음성 서비스",@@ -2411,6 +2412,80 @@"copied": "복사되었습니다","copyFailed": "복사에 실패했습니다"}+ },+ "speakerFilter": {+ "label": "내 목소리 인식",+ "hint": "음성 입력 중 주변 사람의 목소리를 음소거하고 내가 말한 내용만 인식에 보냅니다. 먼저 성문을 등록해야 하며, 나와 동시에 말한 소리는 완전히 걸러지지 않습니다.",+ "ariaLabel": "내 목소리 인식 전환",+ "unsupported": "이 컴퓨터에서는 성문 인식을 사용할 수 없습니다.",+ "privacy": "성문은 이 컴퓨터에만 암호화되어 저장되며, 업로드되거나 다른 기기로 동기화되지 않습니다.",+ "actionFailed": "작업에 실패했습니다. 잠시 후 다시 시도하세요.",+ "model": {+ "needed": "처음 사용할 때 약 {{size}}의 인식 모델을 다운로드합니다.",+ "download": "다운로드",+ "downloading": "인식 모델 다운로드 중({{done}} / {{total}})",+ "cancel": "취소",+ "retry": "다시 시도",+ "failed": {+ "network": "인식 모델을 다운로드하지 못했습니다. 네트워크를 확인한 후 다시 시도하세요.",+ "disk": "인식 모델을 저장하지 못했습니다. 디스크 여유 공간을 확인한 후 다시 시도하세요.",+ "checksum": "다운로드한 인식 모델의 검증에 실패했습니다. 다시 시도하세요.",+ "unavailable": "지금은 인식 모델을 가져올 수 없습니다. 잠시 후 다시 시도하세요."+ }+ },+ "profile": {+ "missing": "등록된 성문이 없습니다",+ "missingHint": "성문을 등록하면 적용됩니다. 약 20초 걸립니다.",+ "enrolled": "성문 등록됨",+ "enrolledAt": "{{date}} 등록",+ "enroll": "성문 등록",+ "reenroll": "다시 등록",+ "delete": "성문 삭제",+ "deleted": "성문을 삭제했습니다",+ "deleteConfirm": {+ "title": "성문을 삭제할까요?",+ "description": "삭제하면 다시 등록할 때까지 음성 입력에서 주변 사람의 목소리를 걸러내지 않습니다.",+ "confirm": "삭제",+ "cancel": "취소"+ }+ },+ "strictness": {+ "label": "엄격도",+ "hint": "엄격할수록 주변 사람의 목소리가 덜 들어가지만, 시끄러운 곳에서는 내 말도 더 잘릴 수 있습니다.",+ "options": {+ "relaxed": "느슨하게",+ "standard": "표준",+ "strict": "엄격하게"+ }+ },+ "enroll": {+ "title": "성문 등록",+ "description": "평소 음성 입력을 사용하는 곳에서 아래 문장 {{clips}}개를 평소 말투로 읽어 주세요. 문장마다 {{seconds}}초씩 녹음합니다. 녹음하는 동안 다른 사람이 말하지 않도록 해 주세요.",+ "stepsAriaLabel": "읽을 문장",+ "step": "{{current}} / {{total}}",+ "record": "읽기 시작",+ "rerecord": "이 문장 다시 녹음",+ "recording": "녹음 중, {{seconds}}초 남음",+ "recorded": "녹음 완료",+ "cancel": "취소",+ "submit": "완료",+ "done": "성문을 등록했습니다",+ "passages": {+ "p1": "오늘 오전에는 이번 주 업무 일정을 정리하고, 오후에는 논의할 문제를 정리해서 모두에게 미리 보내 두겠습니다.",+ "p2": "내일 날씨가 좋으면 조금 일찍 출발해서 가는 길에 과일과 간식을 사고, 점심은 공원에서 먹어요.",+ "p3": "이 내용을 좀 더 간결하게 다듬고, 중요한 숫자와 결론은 남긴 다음 핵심을 세 문장에서 다섯 문장으로 요약해 주세요."+ },+ "errors": {+ "too_short": "{{index}}번째 녹음은 말한 시간이 너무 짧습니다. 오래 멈추지 말고 다시 녹음하세요.",+ "no_embedding": "{{index}}번째 녹음에서 성문을 읽지 못했습니다. 다시 녹음하세요.",+ "inconsistent": "{{index}}번째 녹음이 다른 녹음과 같은 사람의 목소리로 들리지 않습니다. 다른 사람의 목소리나 소음이 섞였을 수 있으니 다시 녹음하세요.",+ "models_missing": "인식 모델 다운로드가 아직 끝나지 않았습니다. 잠시 후 다시 시도하세요.",+ "storage_unavailable": "시스템 키체인을 사용할 수 없어 성문을 암호화해 저장할 수 없습니다. 잠시 후 다시 시도하세요.",+ "failed": "성문을 만들지 못했습니다. 다시 시도하세요.",+ "microphone": "마이크를 사용할 수 없습니다. 마이크 권한과 기기를 확인하세요.",+ "noAudio": "마이크에서 소리가 들어오지 않습니다. 기기를 확인한 후 다시 시도하세요."+ }+ }}},"sessionImport": {diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.jsonindex d87aa77c41..d955138a92 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json@@ -2114,7 +2114,8 @@"basics": "基础","refinement": "润色","preferences": "偏好",- "usageData": "用量"+ "usageData": "用量",+ "speakerFilter": "声纹过滤"},"serviceSource": {"label": "语音服务",@@ -2411,6 +2412,80 @@"copied": "已复制","copyFailed": "复制失败"}+ },+ "speakerFilter": {+ "label": "识别我的声音",+ "hint": "语音输入时把旁人的声音静音,只把你说的话送去识别。需要先录入声纹;别人和你同时说话时无法完全滤掉。",+ "ariaLabel": "切换识别我的声音",+ "unsupported": "这台电脑的系统暂不支持声纹识别。",+ "privacy": "声纹只保存在这台电脑上并加密存储,不会上传,也不会同步到其他设备。",+ "actionFailed": "操作失败,请稍后重试。",+ "model": {+ "needed": "首次使用需要下载约 {{size}} 的识别模型。",+ "download": "下载",+ "downloading": "正在下载识别模型({{done}} / {{total}})",+ "cancel": "取消",+ "retry": "重试",+ "failed": {+ "network": "识别模型下载失败,请检查网络后重试。",+ "disk": "识别模型无法保存,请检查磁盘空间后重试。",+ "checksum": "下载的识别模型校验未通过,请重试。",+ "unavailable": "暂时无法获取识别模型,请稍后重试。"+ }+ },+ "profile": {+ "missing": "还没有录入声纹",+ "missingHint": "录入声纹后才会生效,大约需要 20 秒。",+ "enrolled": "已录入声纹",+ "enrolledAt": "{{date}} 录入",+ "enroll": "录入声纹",+ "reenroll": "重新录入",+ "delete": "删除声纹",+ "deleted": "声纹已删除",+ "deleteConfirm": {+ "title": "删除声纹?",+ "description": "删除后语音输入不再过滤旁人的声音,直到你重新录入。",+ "confirm": "删除",+ "cancel": "取消"+ }+ },+ "strictness": {+ "label": "灵敏度",+ "hint": "越严格越不容易放进旁人的声音,但在嘈杂环境里也更容易剪掉你自己的话。",+ "options": {+ "relaxed": "宽松",+ "standard": "标准",+ "strict": "严格"+ }+ },+ "enroll": {+ "title": "录入声纹",+ "description": "请在平时使用语音输入的地方,用平常的语气朗读下面 {{clips}} 段文字,每段录音 {{seconds}} 秒。录音时请不要让别人说话。",+ "stepsAriaLabel": "朗读段落",+ "step": "第 {{current}} / {{total}} 段",+ "record": "开始朗读",+ "rerecord": "重录这段",+ "recording": "正在录音,还剩 {{seconds}} 秒",+ "recorded": "这段已录好",+ "cancel": "取消",+ "submit": "完成",+ "done": "声纹已录入",+ "passages": {+ "p1": "今天上午我先整理一下这周的工作安排,下午再把需要讨论的问题列出来,发给大家提前看看。",+ "p2": "如果明天的天气不错,我们可以早点出发,路上顺便买些水果和零食,中午就在公园里吃饭。",+ "p3": "请帮我把这段内容改得更简洁一些,保留关键数字和结论,然后用三到五句话总结一下重点。"+ },+ "errors": {+ "too_short": "第 {{index}} 段里说话的时间太短,请重录这段,朗读时不要停顿太久。",+ "no_embedding": "第 {{index}} 段没能识别出声纹,请重录这段。",+ "inconsistent": "第 {{index}} 段和其他几段不像同一个人,可能混进了别人的声音或噪音,请重录这段。",+ "models_missing": "识别模型还没有下载完成,请稍后再试。",+ "storage_unavailable": "系统钥匙串暂时不可用,声纹无法加密保存,请稍后重试。",+ "failed": "生成声纹失败,请重试。",+ "microphone": "无法使用麦克风,请检查麦克风权限和设备。",+ "noAudio": "麦克风没有传来声音,请检查设备后重试。"+ }+ }}},"sessionImport": {diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.jsonindex 97b22b6400..23e33584f6 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json@@ -2114,7 +2114,8 @@"basics": "基礎","refinement": "潤色","preferences": "偏好",- "usageData": "用量"+ "usageData": "用量",+ "speakerFilter": "聲紋過濾"},"serviceSource": {"label": "語音服務",@@ -2411,6 +2412,80 @@"copied": "已複製","copyFailed": "複製失敗"}+ },+ "speakerFilter": {+ "label": "辨識我的聲音",+ "hint": "語音輸入時將旁人的聲音靜音,只把你說的話送去辨識。需要先錄製聲紋;別人和你同時說話時無法完全濾掉。",+ "ariaLabel": "切換辨識我的聲音",+ "unsupported": "這台電腦的系統暫不支援聲紋辨識。",+ "privacy": "聲紋只儲存在這台電腦上並加密保存,不會上傳,也不會同步到其他裝置。",+ "actionFailed": "操作失敗,請稍後再試。",+ "model": {+ "needed": "首次使用需要下載約 {{size}} 的辨識模型。",+ "download": "下載",+ "downloading": "正在下載辨識模型({{done}} / {{total}})",+ "cancel": "取消",+ "retry": "重試",+ "failed": {+ "network": "辨識模型下載失敗,請檢查網路後重試。",+ "disk": "辨識模型無法儲存,請檢查磁碟空間後重試。",+ "checksum": "下載的辨識模型驗證未通過,請重試。",+ "unavailable": "暫時無法取得辨識模型,請稍後再試。"+ }+ },+ "profile": {+ "missing": "尚未錄製聲紋",+ "missingHint": "錄製聲紋後才會生效,大約需要 20 秒。",+ "enrolled": "已錄製聲紋",+ "enrolledAt": "{{date}} 錄製",+ "enroll": "錄製聲紋",+ "reenroll": "重新錄製",+ "delete": "刪除聲紋",+ "deleted": "聲紋已刪除",+ "deleteConfirm": {+ "title": "刪除聲紋?",+ "description": "刪除後語音輸入不再過濾旁人的聲音,直到你重新錄製。",+ "confirm": "刪除",+ "cancel": "取消"+ }+ },+ "strictness": {+ "label": "靈敏度",+ "hint": "越嚴格越不容易放進旁人的聲音,但在吵雜環境中也更容易剪掉你自己的話。",+ "options": {+ "relaxed": "寬鬆",+ "standard": "標準",+ "strict": "嚴格"+ }+ },+ "enroll": {+ "title": "錄製聲紋",+ "description": "請在平常使用語音輸入的地方,用平常的語氣朗讀下面 {{clips}} 段文字,每段錄音 {{seconds}} 秒。錄音時請不要讓別人說話。",+ "stepsAriaLabel": "朗讀段落",+ "step": "第 {{current}} / {{total}} 段",+ "record": "開始朗讀",+ "rerecord": "重錄這段",+ "recording": "正在錄音,還剩 {{seconds}} 秒",+ "recorded": "這段已錄好",+ "cancel": "取消",+ "submit": "完成",+ "done": "聲紋已錄製",+ "passages": {+ "p1": "今天上午我先整理一下這週的工作安排,下午再把需要討論的問題列出來,傳給大家提前看看。",+ "p2": "如果明天天氣不錯,我們可以早點出發,路上順便買些水果和零食,中午就在公園裡吃飯。",+ "p3": "請幫我把這段內容改得更簡潔一些,保留關鍵數字和結論,然後用三到五句話總結重點。"+ },+ "errors": {+ "too_short": "第 {{index}} 段裡說話的時間太短,請重錄這段,朗讀時不要停頓太久。",+ "no_embedding": "第 {{index}} 段沒能辨識出聲紋,請重錄這段。",+ "inconsistent": "第 {{index}} 段和其他幾段不像同一個人,可能混入了別人的聲音或噪音,請重錄這段。",+ "models_missing": "辨識模型尚未下載完成,請稍後再試。",+ "storage_unavailable": "系統鑰匙圈暫時無法使用,聲紋無法加密儲存,請稍後再試。",+ "failed": "產生聲紋失敗,請重試。",+ "microphone": "無法使用麥克風,請檢查麥克風權限和裝置。",+ "noAudio": "麥克風沒有傳來聲音,請檢查裝置後重試。"+ }+ }}},"sessionImport": {diff --git a/apps/desktop/src/renderer/vite-env.d.ts b/apps/desktop/src/renderer/vite-env.d.tsindex f1f147440e..40fb43ec4b 100644--- a/apps/desktop/src/renderer/vite-env.d.ts+++ b/apps/desktop/src/renderer/vite-env.d.ts@@ -241,6 +241,8 @@ type VoiceInputDictionaryAdviceInput =type VoiceInputDictionaryLearningAction =import('@cindy/voice-input-core').DictationDictionaryLearningAction;type VoiceInputSettingsData = import('../shared/voiceInputData').VoiceInputSettings;+type VoiceSpeakerFilterStatusData = import('../shared/voiceSpeakerFilter').VoiceSpeakerFilterStatus;+type VoiceSpeakerEnrollResultData = import('../shared/voiceSpeakerFilter').VoiceSpeakerEnrollResult;type VoiceInputSettingsPatchData = import('../shared/voiceInputData').VoiceInputSettingsPatch;type VoiceInputHistoryEntryData = import('../shared/voiceInputData').VoiceInputHistoryEntry;type VoiceInputDataSnapshot = import('../shared/voiceInputData').VoiceInputDataSnapshot;@@ -1850,6 +1852,16 @@ interface ElectronAPI {updateHistoryEntry: (id: string, text: string) => void;deleteHistoryEntry: (id: string) => void;onDataChanged: (callback: (payload: VoiceInputDataSnapshot) => void) => () => void;+ /** 「识别我的声音」:模型与声纹都留在本机,Renderer 只拿到状态。 */+ speakerFilter: {+ getStatus: () => Promise<VoiceSpeakerFilterStatusData>;+ downloadModels: () => Promise<VoiceSpeakerFilterStatusData>;+ cancelDownload: () => Promise<VoiceSpeakerFilterStatusData>;+ /** PCM16 单声道 16 kHz 朗读片段,数量固定为 VOICE_SPEAKER_ENROLLMENT_CLIP_COUNT。 */+ enroll: (clips: ArrayBuffer[]) => Promise<VoiceSpeakerEnrollResultData>;+ deleteProfile: () => Promise<VoiceSpeakerFilterStatusData>;+ onStatusChanged: (callback: (status: VoiceSpeakerFilterStatusData) => void) => () => void;+ };/** options.suspend = 录制期挂起(故意与存盘不同);不带它的请求会被 main 按存盘校验。 */setGlobalShortcut: (shortcut: VoiceInputShortcut | null,diff --git a/apps/desktop/src/renderer/voice-input/speakerEnrollmentRecorder.ts b/apps/desktop/src/renderer/voice-input/speakerEnrollmentRecorder.tsnew file mode 100644index 0000000000..9a222e7b8c--- /dev/null+++ b/apps/desktop/src/renderer/voice-input/speakerEnrollmentRecorder.ts@@ -0,0 +1,98 @@+import { createVoiceInputAudioProfile } from './audioProfile';+import { WebMicAudioEngine } from './WebMicAudioEngine';+import { getVoiceInputWorkletUrl } from './workletUrl';++export type SpeakerEnrollmentClipOptions = {+ /** Same microphone the user dictates with, so the voiceprint matches it. */+ deviceId?: string;+ durationMs: number;+ /** Peak level of the latest chunk in [0, 1], for the recording meter. */+ onLevel?: (level: number) => void;+ /** Elapsed fraction in [0, 1]. */+ onProgress?: (fraction: number) => void;+ signal?: AbortSignal;+};++export class SpeakerEnrollmentNoAudioError extends Error {+ constructor() {+ super('microphone delivered no audio');+ this.name = 'SpeakerEnrollmentNoAudioError';+ }+}++/** A stalled microphone fails the clip instead of hanging the dialog. */+const NO_AUDIO_GRACE_MS = 5_000;++export class SpeakerEnrollmentAbortedError extends Error {+ constructor() {+ super('speaker enrollment recording aborted');+ this.name = 'SpeakerEnrollmentAbortedError';+ }+}++/**+ * Records one read-aloud clip for voiceprint enrollment as PCM16 mono 16 kHz.+ *+ * Uses the dictation capture profile (same processing, no keep-alive) so the+ * enrolled voice sounds like the audio the gate later judges. Stops by+ * itself after `durationMs`; aborting releases the microphone and rejects.+ */+export async function recordSpeakerEnrollmentClip(options: SpeakerEnrollmentClipOptions): Promise<ArrayBuffer> {+ if (options.signal?.aborted) throw new SpeakerEnrollmentAbortedError();+ const engine = new WebMicAudioEngine({+ workletUrl: getVoiceInputWorkletUrl(),+ deviceId: options.deviceId,+ ...createVoiceInputAudioProfile(false),+ });+ const chunks: Int16Array[] = [];+ let samples = 0;+ const targetSamples = Math.round((options.durationMs / 1000) * 16_000);+ let finish: () => void = () => {};+ const done = new Promise<void>((resolve) => {+ finish = resolve;+ });++ engine.onPcm16k(({ pcm16k }) => {+ if (samples >= targetSamples) return;+ const chunk = new Int16Array(pcm16k.slice(0));+ chunks.push(chunk);+ samples += chunk.length;+ let peak = 0;+ for (let i = 0; i < chunk.length; i += 1) {+ const value = Math.abs(chunk[i]);+ if (value > peak) peak = value;+ }+ options.onLevel?.(peak / 32768);+ options.onProgress?.(Math.min(1, samples / targetSamples));+ if (samples >= targetSamples) finish();+ });++ const onAbort = (): void => finish();+ options.signal?.addEventListener('abort', onAbort, { once: true });+ let stalled = false;+ let watchdog: ReturnType<typeof setTimeout> | undefined;+ try {+ await engine.start();+ watchdog = setTimeout(() => {+ stalled = true;+ finish();+ }, options.durationMs + NO_AUDIO_GRACE_MS);+ await done;+ } finally {+ clearTimeout(watchdog);+ options.signal?.removeEventListener('abort', onAbort);+ await engine.stop().catch(() => undefined);+ }+ if (options.signal?.aborted) throw new SpeakerEnrollmentAbortedError();+ if (stalled && samples < targetSamples) throw new SpeakerEnrollmentNoAudioError();++ const out = new Int16Array(Math.min(samples, targetSamples));+ let offset = 0;+ for (const chunk of chunks) {+ const take = Math.min(chunk.length, out.length - offset);+ if (take <= 0) break;+ out.set(chunk.subarray(0, take), offset);+ offset += take;+ }+ return out.buffer;+}diff --git a/apps/desktop/src/shared/voiceInputData.ts b/apps/desktop/src/shared/voiceInputData.tsindex 386352bd30..9765724c90 100644--- a/apps/desktop/src/shared/voiceInputData.ts+++ b/apps/desktop/src/shared/voiceInputData.ts@@ -6,7 +6,13 @@ import type {DictationRefinementContext,} from '@cindy/voice-input-core';import type { CindyRegion } from '@cindy/maker-shared/brand-identity';-import { coalesceDictionaryLearningActions, DICTIONARY_CANDIDATE_PROMOTION_COUNT } from '@cindy/voice-input-core';+import {+ coalesceDictionaryLearningActions,+ DEFAULT_SPEAKER_GATE_STRICTNESS,+ DICTIONARY_CANDIDATE_PROMOTION_COUNT,+ isSpeakerGateStrictness,+ type SpeakerGateStrictness,+} from '@cindy/voice-input-core';export {compactVoiceInputHistoryIfNeeded,estimateVoiceInputHistoryContextChars,@@ -112,6 +118,18 @@ export interface VoiceInputSettings {composerLongPressEnabled: boolean;/** 用户对上面那个开关的显式选择;`undefined` = 从未自定义,跟随当前版本默认值。 */composerLongPressEnabledOverride?: boolean | null;+ /**+ * 「识别我的声音」:听写时按本机录入的声纹静音旁人。需要先下载模型并录入声纹;+ * 声纹缺失或模型未就绪时即使为 true 也不过滤。按设备、按账号保存,不跨设备同步。+ */+ speakerFilterEnabled: boolean;+ /**+ * 声纹过滤的灵敏度(**有效值** = 默认 + 用户 override)。阈值随验证数据会调,+ * 未自定义的用户跟随版本默认。写请走 {@link speakerFilterStrictnessOverride}。+ */+ speakerFilterStrictness: SpeakerGateStrictness;+ /** 用户对灵敏度的显式选择;`undefined` = 从未自定义,跟随当前版本默认值。 */+ speakerFilterStrictnessOverride?: SpeakerGateStrictness | null;dictionaryEntries: VoiceInputDictionaryEntry[];dictionaryCandidates: VoiceInputDictionaryCandidate[];suppressedAutomaticDictionaryTexts: string[];@@ -137,10 +155,11 @@ export interface VoiceInputDataSnapshot {* 按同一规则转写成 `*Override = null`。*/export type VoiceInputSettingsPatch = Partial<- Omit<VoiceInputSettings, 'dictionarySyncEnabled' | 'composerLongPressEnabled'>+ Omit<VoiceInputSettings, 'dictionarySyncEnabled' | 'composerLongPressEnabled' | 'speakerFilterStrictness'>> & {dictionarySyncEnabled?: boolean | null;composerLongPressEnabled?: boolean | null;+ speakerFilterStrictness?: SpeakerGateStrictness | null;};export type VoiceInputDictionaryLearningEvidence = Pick<@@ -503,6 +522,8 @@ export function getDefaultVoiceInputSettings(// 有效值 = 默认;override 缺省不写(见 dictionarySyncEnabledOverride 注释)。dictionarySyncEnabled: DEFAULT_DICTIONARY_SYNC_ENABLED,composerLongPressEnabled: DEFAULT_COMPOSER_LONG_PRESS_ENABLED,+ speakerFilterEnabled: false,+ speakerFilterStrictness: DEFAULT_SPEAKER_GATE_STRICTNESS,dictionaryEntries: [],dictionaryCandidates: [],suppressedAutomaticDictionaryTexts: [],@@ -560,6 +581,11 @@ export function normalizeVoiceInputSettings(// 默认不同时才当作用户的显式选择,相同则视为未自定义。...normalizeDictionarySyncOverride(candidate),...normalizeComposerLongPressOverride(candidate),+ speakerFilterEnabled:+ typeof candidate.speakerFilterEnabled === 'boolean'+ ? candidate.speakerFilterEnabled+ : defaults.speakerFilterEnabled,+ ...normalizeSpeakerFilterStrictnessOverride(candidate),dictionaryEntries: normalizeVoiceInputDictionaryEntries(candidate.dictionaryEntries ?? (candidate as { customDictionary?: unknown }).customDictionary,),@@ -974,6 +1000,16 @@ function normalizeComposerLongPressOverride(return { composerLongPressEnabled: override, composerLongPressEnabledOverride: override };}+function normalizeSpeakerFilterStrictnessOverride(+ candidate: Partial<VoiceInputSettings>,+): Pick<VoiceInputSettings, 'speakerFilterStrictness'> & { speakerFilterStrictnessOverride?: SpeakerGateStrictness } {+ const override = candidate.speakerFilterStrictnessOverride;+ if (!isSpeakerGateStrictness(override)) {+ return { speakerFilterStrictness: DEFAULT_SPEAKER_GATE_STRICTNESS };+ }+ return { speakerFilterStrictness: override, speakerFilterStrictnessOverride: override };+}+function isVoiceInputLanguage(value: unknown): value is VoiceInputLanguage {if (value === 'auto') return true;return typeof value === 'string' && (SUPPORTED_LOCALES as readonly string[]).includes(value);diff --git a/apps/desktop/src/shared/voiceSpeakerFilter.ts b/apps/desktop/src/shared/voiceSpeakerFilter.tsnew file mode 100644index 0000000000..fb645322b5--- /dev/null+++ b/apps/desktop/src/shared/voiceSpeakerFilter.ts@@ -0,0 +1,51 @@+/**+ * Wire contract for the voice-input speaker filter ("recognize my voice").+ *+ * The voiceprint never leaves this device: it is computed in main, stored+ * encrypted per account, and the renderer only ever sees whether one exists.+ */++export const VOICE_SPEAKER_FILTER_CHANNELS = {+ getStatus: 'voice-input:speaker:get-status',+ downloadModels: 'voice-input:speaker:download-models',+ cancelDownload: 'voice-input:speaker:cancel-download',+ enroll: 'voice-input:speaker:enroll',+ deleteProfile: 'voice-input:speaker:delete-profile',+ /** main → renderer push whenever the status below changes. */+ statusChanged: 'voice-input:speaker:status-changed',+} as const;++export type VoiceSpeakerModelState = 'missing' | 'downloading' | 'ready' | 'failed';++export type VoiceSpeakerFilterStatus = {+ /** False where the inference library is not shipped (e.g. Linux arm64). */+ supported: boolean;+ modelState: VoiceSpeakerModelState;+ downloadedBytes: number;+ totalBytes: number;+ /** Short failure kind for the last download, not a raw error message. */+ downloadError?: 'network' | 'disk' | 'checksum' | 'unavailable';+ enrolled: boolean;+ enrolledAt?: number;+};++/** Read-aloud clips collected during enrollment. */+export const VOICE_SPEAKER_ENROLLMENT_CLIP_COUNT = 3;+/** Each clip is PCM16 mono 16 kHz; anything longer is rejected by main. */+export const VOICE_SPEAKER_ENROLLMENT_MAX_CLIP_SEC = 20;+/** Recording UI stops each clip automatically after this long. */+export const VOICE_SPEAKER_ENROLLMENT_TARGET_CLIP_SEC = 6;++export type VoiceSpeakerEnrollRequest = {+ /** PCM16 little-endian mono 16 kHz clips. */+ clips: ArrayBuffer[];+};++export type VoiceSpeakerEnrollResult =+ | { ok: true; status: VoiceSpeakerFilterStatus }+ | {+ ok: false;+ reason: 'too_short' | 'no_embedding' | 'inconsistent' | 'models_missing' | 'storage_unavailable' | 'failed';+ /** Zero-based clip the user should re-record, when one is to blame. */+ clipIndex?: number;+ };diff --git a/apps/desktop/vite.speaker-gate-worker.config.ts b/apps/desktop/vite.speaker-gate-worker.config.tsnew file mode 100644index 0000000000..5c65ebf323--- /dev/null+++ b/apps/desktop/vite.speaker-gate-worker.config.ts@@ -0,0 +1,17 @@+import { defineConfig } from 'vite';++export default defineConfig({+ resolve: {+ conditions: ['node'],+ mainFields: ['module', 'jsnext:main', 'jsnext'],+ },+ build: {+ rollupOptions: {+ // Native addon, loaded at runtime from the unpacked node_modules.+ external: ['sherpa-onnx-node'],+ output: {+ inlineDynamicImports: true,+ },+ },+ },+});diff --git a/apps/mobile/app/sessions/[sessionId].tsx b/apps/mobile/app/sessions/[sessionId].tsxindex 21cbed8738..cbb64bef6b 100644--- a/apps/mobile/app/sessions/[sessionId].tsx+++ b/apps/mobile/app/sessions/[sessionId].tsx@@ -536,6 +536,7 @@ import {createMobileVoiceControllerSession,type MobileVoiceControllerSession,} from '@/session/mobileVoiceController';+import { createMobileSpeakerGate, warmMobileSpeakerFilter } from '@/session/mobileSpeakerFilter';import {createMobileVoiceDictionaryLearningTracker,type MobileVoiceDictionaryLearningTracker,@@ -5483,6 +5484,8 @@ export default function SessionScreen() {?? { start: initialDraft.length, end: initialDraft.length };const controller = createMobileVoiceControllerSession({credential,+ // "Recognize my voice": undefined unless enabled, enrolled and the models are on disk.+ audioGate: createMobileSpeakerGate(),...(prewarmedVoice ? { asr: prewarmedVoice.asr } : {}),connectionProvider: (providerId: string) => voiceContext.createAsrConnection(providerId),refinerTargetProvider: (providerId: string, options?: { refreshAccessToken?: boolean }) =>@@ -5758,6 +5761,7 @@ export default function SessionScreen() {// Keep the native audio-session warmup on the synchronous press-down path// (prewarmMobileVoiceStart re-runs it idempotently below).prewarmMobileRealtimeAudio();+ warmMobileSpeakerFilter();// 托管预热:凭登录态提前拿 voice-server 票据并开 ASR WebSocket。prewarmMobileVoiceStart(deviceId, {getAccessToken: () => auth.getAccessToken(),diff --git a/apps/mobile/app/sessions/new.tsx b/apps/mobile/app/sessions/new.tsxindex aab0c6e1b5..d92fdb03d7 100644--- a/apps/mobile/app/sessions/new.tsx+++ b/apps/mobile/app/sessions/new.tsx@@ -351,6 +351,7 @@ import {createMobileVoiceControllerSession,type MobileVoiceControllerSession,} from '@/session/mobileVoiceController';+import { createMobileSpeakerGate, warmMobileSpeakerFilter } from '@/session/mobileSpeakerFilter';import {createMobileVoiceDictionaryLearningTracker,type MobileVoiceDictionaryLearningTracker,@@ -3859,6 +3860,8 @@ export default function NewRemoteSessionScreen() {voicePendingSelectionEchoesRef.current = [];const controller = createMobileVoiceControllerSession({credential,+ // "Recognize my voice": undefined unless enabled, enrolled and the models are on disk.+ audioGate: createMobileSpeakerGate(),...(prewarmedVoice ? { asr: prewarmedVoice.asr } : {}),connectionProvider: (providerId: string) => voiceContext.createAsrConnection(providerId),refinerTargetProvider: (providerId: string, options?: { refreshAccessToken?: boolean }) =>@@ -4030,6 +4033,7 @@ export default function NewRemoteSessionScreen() {// Keep the native audio-session warmup on the synchronous press-down path// (prewarmMobileVoiceStart re-runs it idempotently below).prewarmMobileRealtimeAudio();+ warmMobileSpeakerFilter();// 托管预热:凭登录态提前拿 voice-server 票据并开 ASR WebSocket。prewarmMobileVoiceStart(selectedDeviceId, {getAccessToken: () => auth.getAccessToken(),diff --git a/apps/mobile/app/settings.tsx b/apps/mobile/app/settings.tsxindex e5653c74f8..8944dd43ae 100644--- a/apps/mobile/app/settings.tsx+++ b/apps/mobile/app/settings.tsx@@ -5,7 +5,7 @@ import * as Clipboard from 'expo-clipboard';import * as Updates from 'expo-updates';import { useUpdates } from 'expo-updates';import { useRouter } from 'expo-router';-import { useCallback, useEffect, useMemo, useRef, useState } from 'react';+import { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';import {Alert,DevSettings,@@ -111,6 +111,11 @@ import {SettingsGroup,SettingsSwitchRow,} from '@/session/SettingsGroupRows';+import {+ getMobileSpeakerFilterSnapshot,+ hydrateMobileSpeakerFilter,+ subscribeMobileSpeakerFilter,+} from '@/session/mobileSpeakerFilter';import { useSettingsDeviceDirectory } from '@/session/settingsDeviceDirectory';import { confirmLogout } from '@/session/confirmLogout';import { THEME_PREFERENCES, useTheme, useThemedStyles, type ThemeColors } from '@/theme';@@ -724,6 +729,14 @@ export default function SettingsScreen() {push('/settings/voice-dictionary');}, [push]);+ const speakerFilter = useSyncExternalStore(subscribeMobileSpeakerFilter, getMobileSpeakerFilterSnapshot);+ useEffect(() => {+ void hydrateMobileSpeakerFilter();+ }, []);+ const openVoiceSpeakerFilter = useCallback(() => {+ push('/settings/voice-speaker-filter');+ }, [push]);+// dictionaryRevision 只作为依赖存在:缓存是模块级的,刷新完成后靠它触发重算。const dictionaryEntries = useMemo(() =>@@ -876,6 +889,23 @@ export default function SettingsScreen() {/></SettingsGroup>+ {/* 识别我的声音:声纹只在本机;老安装包缺原生推理模块时不显示入口 */}+ {speakerFilter.supported ? (+ <SettingsGroup+ footer={t('settings.voiceSpeakerFilter.entryHint')}+ title={t('settings.voiceSpeakerFilter.sectionTitle')}+ >+ <ActionInfoRow+ accessibilityLabel={t('settings.voiceSpeakerFilter.openAccessibility')}+ key="voice-speaker-filter"+ label={t('settings.voiceSpeakerFilter.label')}+ onPress={openVoiceSpeakerFilter}+ testID="settings.voiceSpeakerFilter.row"+ value={t(speakerFilter.enabled ? 'settings.voiceSpeakerFilter.on' : 'settings.voiceSpeakerFilter.off')}+ />+ </SettingsGroup>+ ) : null}+<SettingsGroup title={t('sharedTask.title')}><ActionInfoRowaccessibilityLabel={t('sharedTask.manageSharing')}diff --git a/apps/mobile/app/settings/voice-speaker-filter.tsx b/apps/mobile/app/settings/voice-speaker-filter.tsxnew file mode 100644index 0000000000..858731093a--- /dev/null+++ b/apps/mobile/app/settings/voice-speaker-filter.tsx@@ -0,0 +1,473 @@+import { useRouter } from 'expo-router';+import { useCallback, useEffect, useRef, useState, useSyncExternalStore, type ReactNode } from 'react';+import { Alert, Pressable, ScrollView, StyleSheet, View } from 'react-native';+import { SafeAreaView } from 'react-native-safe-area-context';+import { useTranslation } from 'react-i18next';+import { Check } from 'lucide-react-native';+import {+ SPEAKER_ENROLLMENT_CLIP_COUNT,+ SPEAKER_GATE_STRICTNESS_VALUES,+ type SpeakerGateStrictness,+} from '@cindy/voice-input-core';++import { Text } from '@/components/AppText';+import { SimpleStackHeader, simpleScrollInsetProps, simpleScrollScreenSafeAreaEdges } from '@/platform/chrome';+import {+ ActionInfoRow,+ InfoRow,+ SettingsGroup,+ SettingsSwitchRow,+ useSettingsRowStyles,+} from '@/session/SettingsGroupRows';+import {+ cancelMobileSpeakerModelDownload,+ deleteMobileSpeakerProfile,+ downloadMobileSpeakerModels,+ enrollMobileSpeaker,+ getMobileSpeakerFilterSnapshot,+ hydrateMobileSpeakerFilter,+ setMobileSpeakerFilterEnabled,+ setMobileSpeakerFilterStrictness,+ subscribeMobileSpeakerFilter,+ type MobileSpeakerFilterSnapshot,+} from '@/session/mobileSpeakerFilter';+import {+ MobileSpeakerEnrollmentAbortedError,+ MobileSpeakerEnrollmentNoAudioError,+ recordMobileSpeakerClip,+} from '@/session/mobileSpeakerEnrollmentRecorder';+import { useTheme, useThemedStyles, type ThemeColors } from '@/theme';+import { iconSize, iconStroke, spacing } from '@/theme/tokens';+import { goBackGuarded } from '@/utils/backGuard';++const CLIP_SECONDS = 6;+const CLIP_INDEXES = Array.from({ length: SPEAKER_ENROLLMENT_CLIP_COUNT }, (_, index) => index);++type EnrollErrorKey =+ | 'too_short'+ | 'no_embedding'+ | 'inconsistent'+ | 'models_missing'+ | 'storage_unavailable'+ | 'failed'+ | 'microphone'+ | 'noAudio';++/**+ * 「识别我的声音」(设置的二级页)。+ *+ * 开关第一次打开时下载识别模型;模型就绪后朗读三段文字录入声纹;录好后可调灵敏度。+ * 声纹只存在这台手机(系统钥匙串 / Keystore),按账号分开,不同步、不上传。+ * 任一条件不满足时语音输入照常工作,只是不过滤。+ *+ * SettingsGroup 按直接子元素画分隔线,所以每组的行都以带 key 的数组给出,不包 Fragment。+ */+export default function VoiceSpeakerFilterScreen() {+ const router = useRouter();+ const { t } = useTranslation();+ const rowStyles = useSettingsRowStyles();+ const styles = useThemedStyles(makeStyles);+ const { colors } = useTheme();+ const state = useSyncExternalStore(subscribeMobileSpeakerFilter, getMobileSpeakerFilterSnapshot);++ const [enrolling, setEnrolling] = useState(false);+ const [clips, setClips] = useState<Array<ArrayBuffer | null>>(() => CLIP_INDEXES.map(() => null));+ const [current, setCurrent] = useState(0);+ const [recording, setRecording] = useState(false);+ const [progress, setProgress] = useState(0);+ const [saving, setSaving] = useState(false);+ const [enrollError, setEnrollError] = useState<{ key: EnrollErrorKey; clipIndex?: number } | null>(null);+ const abortRef = useRef<AbortController | null>(null);+ const clipsRef = useRef(clips);+ clipsRef.current = clips;+ const reportActionFailure = useCallback(() => {+ Alert.alert(t('settings.voiceSpeakerFilter.actionFailed'));+ }, [t]);++ useEffect(() => {+ void hydrateMobileSpeakerFilter();+ }, []);++ // Never leave the microphone open behind a closed screen.+ useEffect(() => () => abortRef.current?.abort(), []);++ const resetEnrollment = useCallback(() => {+ abortRef.current?.abort();+ abortRef.current = null;+ setClips(CLIP_INDEXES.map(() => null));+ setCurrent(0);+ setRecording(false);+ setProgress(0);+ setSaving(false);+ setEnrollError(null);+ }, []);++ const record = useCallback(async () => {+ if (abortRef.current || recording || saving) return;+ setEnrollError(null);+ const controller = new AbortController();+ abortRef.current = controller;+ const index = current;+ setRecording(true);+ setProgress(0);+ try {+ const clip = await recordMobileSpeakerClip({+ durationMs: CLIP_SECONDS * 1000,+ onProgress: (fraction) => {+ if (abortRef.current === controller && !controller.signal.aborted) setProgress(fraction);+ },+ signal: controller.signal,+ });+ if (abortRef.current !== controller || controller.signal.aborted) return;+ const next = [...clipsRef.current];+ next[index] = clip;+ setClips(next);+ const nextEmpty = CLIP_INDEXES.find((candidate) => !next[candidate]);+ if (nextEmpty !== undefined) setCurrent(nextEmpty);+ } catch (error) {+ if (abortRef.current !== controller || error instanceof MobileSpeakerEnrollmentAbortedError) return;+ // A denied permission and a failing device both mean "check the microphone".+ setEnrollError({ key: error instanceof MobileSpeakerEnrollmentNoAudioError ? 'noAudio' : 'microphone' });+ } finally {+ if (abortRef.current === controller) {+ abortRef.current = null;+ setRecording(false);+ }+ }+ }, [current, recording, saving]);++ const submit = useCallback(async () => {+ if (!clips.every((clip) => clip !== null) || saving || recording) return;+ setSaving(true);+ setEnrollError(null);+ const result = await enrollMobileSpeaker(clips as ArrayBuffer[]);+ setSaving(false);+ if (result.ok) {+ resetEnrollment();+ setEnrolling(false);+ return;+ }+ setEnrollError({ key: result.reason, clipIndex: result.clipIndex });+ if (result.clipIndex !== undefined) {+ const redo = result.clipIndex;+ setClips((previous) => previous.map((clip, index) => (index === redo ? null : clip)));+ setCurrent(redo);+ }+ }, [clips, recording, resetEnrollment, saving]);++ const confirmDelete = useCallback(() => {+ Alert.alert(+ t('settings.voiceSpeakerFilter.profile.deleteConfirm.title'),+ t('settings.voiceSpeakerFilter.profile.deleteConfirm.description'),+ [+ { text: t('settings.voiceSpeakerFilter.profile.deleteConfirm.cancel'), style: 'cancel' },+ {+ text: t('settings.voiceSpeakerFilter.profile.deleteConfirm.confirm'),+ style: 'destructive',+ onPress: () => {+ void deleteMobileSpeakerProfile().catch(reportActionFailure);+ },+ },+ ],+ );+ }, [reportActionFailure, t]);++ const showDetails = state.supported && state.hydrated && (state.enabled || state.enrolled);+ const modelsReady = state.modelState === 'ready';+ const allRecorded = clips.every((clip) => clip !== null);+ const recordLabel = t(clips[current]+ ? 'settings.voiceSpeakerFilter.enroll.rerecord'+ : 'settings.voiceSpeakerFilter.enroll.record');++ const deleteRow = (+ <ActionInfoRow+ key="delete"+ accessibilityLabel={t('settings.voiceSpeakerFilter.profile.delete')}+ label={t('settings.voiceSpeakerFilter.profile.delete')}+ onPress={confirmDelete}+ testID="settings.voiceSpeakerFilter.profile.delete"+ />+ );++ const enrollmentRows: ReactNode[] = [+ <View key="description" style={rowStyles.row}>+ <Text style={rowStyles.rowDetail}>+ {t('settings.voiceSpeakerFilter.enroll.description', {+ clips: SPEAKER_ENROLLMENT_CLIP_COUNT,+ seconds: CLIP_SECONDS,+ })}+ </Text>+ </View>,+ ...CLIP_INDEXES.map((index) => {+ const stepLabel = t('settings.voiceSpeakerFilter.enroll.step', {+ current: index + 1,+ total: SPEAKER_ENROLLMENT_CLIP_COUNT,+ });+ return (+ <Pressable+ key={`step-${index}`}+ accessibilityLabel={stepLabel}+ accessibilityRole="button"+ accessibilityState={{ selected: index === current, disabled: recording || saving }}+ disabled={recording || saving}+ onPress={() => {+ setCurrent(index);+ setEnrollError(null);+ }}+ style={({ pressed }) => [rowStyles.row, pressed && rowStyles.pressed]}+ testID={`settings.voiceSpeakerFilter.enroll.step.${index}`}+ >+ <View style={rowStyles.rowLine}>+ <Text style={rowStyles.rowLabel}>{stepLabel}</Text>+ {clips[index] ? (+ <Check color={colors.textSecondary} size={iconSize.md} strokeWidth={iconStroke.regular} />+ ) : null}+ </View>+ {index === current ? (+ <Text style={rowStyles.rowLabel}>+ {t(`settings.voiceSpeakerFilter.enroll.passages.p${index + 1}`)}+ </Text>+ ) : null}+ </Pressable>+ );+ }),+ <ActionInfoRow+ key="record"+ accessibilityLabel={recordLabel}+ disabled={recording || saving}+ label={recordLabel}+ onPress={() => {+ void record();+ }}+ testID="settings.voiceSpeakerFilter.enroll.record"+ value={recording+ ? t('settings.voiceSpeakerFilter.enroll.recording', {+ seconds: Math.max(0, Math.ceil(CLIP_SECONDS * (1 - progress))),+ })+ : ''}+ />,+ enrollError ? (+ <View key="error" style={rowStyles.row}>+ <Text accessibilityRole="alert" style={rowStyles.rowDetail}>+ {t(`settings.voiceSpeakerFilter.enroll.errors.${enrollError.key}`, {+ index: (enrollError.clipIndex ?? 0) + 1,+ })}+ </Text>+ </View>+ ) : null,+ <ActionInfoRow+ key="submit"+ accessibilityLabel={t('settings.voiceSpeakerFilter.enroll.submit')}+ disabled={!allRecorded || recording || saving}+ label={t('settings.voiceSpeakerFilter.enroll.submit')}+ onPress={() => {+ void submit();+ }}+ testID="settings.voiceSpeakerFilter.enroll.submit"+ value={saving ? t('settings.voiceSpeakerFilter.enroll.saving') : ''}+ />,+ <ActionInfoRow+ key="cancel"+ accessibilityLabel={t('settings.voiceSpeakerFilter.enroll.cancel')}+ disabled={saving}+ label={t('settings.voiceSpeakerFilter.enroll.cancel')}+ onPress={() => {+ resetEnrollment();+ setEnrolling(false);+ }}+ testID="settings.voiceSpeakerFilter.enroll.cancel"+ />,+ ];++ const profileRows: ReactNode[] = [+ <InfoRow+ key="status"+ detail={state.enrolled && state.enrolledAt+ ? t('settings.voiceSpeakerFilter.profile.enrolledAt', {+ date: new Date(state.enrolledAt).toLocaleDateString(),+ })+ : t('settings.voiceSpeakerFilter.profile.missingHint')}+ label={t(state.enrolled+ ? 'settings.voiceSpeakerFilter.profile.enrolled'+ : 'settings.voiceSpeakerFilter.profile.missing')}+ testID="settings.voiceSpeakerFilter.profile.status"+ value=""+ />,+ <ActionInfoRow+ key="enroll"+ accessibilityLabel={t(state.enrolled+ ? 'settings.voiceSpeakerFilter.profile.reenroll'+ : 'settings.voiceSpeakerFilter.profile.enroll')}+ label={t(state.enrolled+ ? 'settings.voiceSpeakerFilter.profile.reenroll'+ : 'settings.voiceSpeakerFilter.profile.enroll')}+ onPress={() => {+ resetEnrollment();+ setEnrolling(true);+ }}+ testID="settings.voiceSpeakerFilter.profile.enroll"+ />,+ state.enrolled ? deleteRow : null,+ ];++ return (+ <SafeAreaView edges={simpleScrollScreenSafeAreaEdges()} style={styles.safeArea} testID="settings.voiceSpeakerFilter.screen">+ <SimpleStackHeader+ scrollEdge+ backTestID="settings.voiceSpeakerFilter.backButton"+ onBack={() => goBackGuarded(router, '/settings')}+ title={t('settings.voiceSpeakerFilter.title')}+ />+ <ScrollView {...simpleScrollInsetProps} contentContainerStyle={styles.content} testID="settings.voiceSpeakerFilter.scroll">+ <SettingsGroup footer={t('settings.voiceSpeakerFilter.privacy')}>+ <SettingsSwitchRow+ accessibilityLabel={t('settings.voiceSpeakerFilter.label')}+ disabled={!state.supported || !state.hydrated || saving}+ hint={state.supported ? t('settings.voiceSpeakerFilter.hint') : t('settings.voiceSpeakerFilter.unsupported')}+ label={t('settings.voiceSpeakerFilter.label')}+ onValueChange={(value) => {+ if (!value) {+ resetEnrollment();+ setEnrolling(false);+ }+ void setMobileSpeakerFilterEnabled(value).catch(reportActionFailure);+ }}+ switchTestID="settings.voiceSpeakerFilter.toggle"+ testID="settings.voiceSpeakerFilter.toggleRow"+ value={state.enabled && state.supported}+ />+ </SettingsGroup>++ {showDetails && !modelsReady ? <ModelGroup state={state} /> : null}++ {showDetails && modelsReady ? (+ <SettingsGroup title={t('settings.voiceSpeakerFilter.profile.title')}>+ {enrolling ? enrollmentRows : profileRows}+ </SettingsGroup>+ ) : null}++ {showDetails && !modelsReady && state.enrolled ? (+ <SettingsGroup title={t('settings.voiceSpeakerFilter.profile.title')}>+ {deleteRow}+ </SettingsGroup>+ ) : null}++ {showDetails && state.enrolled && !enrolling ? (+ <SettingsGroup+ footer={t('settings.voiceSpeakerFilter.strictness.hint')}+ title={t('settings.voiceSpeakerFilter.strictness.label')}+ >+ {[+ ...SPEAKER_GATE_STRICTNESS_VALUES.map((value) => (+ <StrictnessRow+ key={value}+ onPress={() => {+ void setMobileSpeakerFilterStrictness(value).catch(reportActionFailure);+ }}+ selected={state.strictness === value}+ value={value}+ />+ )),+ state.strictnessCustomized ? (+ <ActionInfoRow+ key="restore"+ accessibilityLabel={t('settings.voiceSpeakerFilter.strictness.restoreDefault')}+ label={t('settings.voiceSpeakerFilter.strictness.restoreDefault')}+ onPress={() => {+ void setMobileSpeakerFilterStrictness(null).catch(reportActionFailure);+ }}+ testID="settings.voiceSpeakerFilter.strictness.restore"+ />+ ) : null,+ ]}+ </SettingsGroup>+ ) : null}+ </ScrollView>+ </SafeAreaView>+ );+}++function ModelGroup({ state }: { state: MobileSpeakerFilterSnapshot }) {+ const { t } = useTranslation();+ const rowStyles = useSettingsRowStyles();+ const total = formatMegabytes(state.totalBytes);+ if (state.modelState === 'downloading') {+ return (+ <SettingsGroup title={t('settings.voiceSpeakerFilter.model.title')}>+ <ActionInfoRow+ accessibilityLabel={t('settings.voiceSpeakerFilter.model.cancel')}+ detail={t('settings.voiceSpeakerFilter.model.downloading', {+ done: formatMegabytes(state.downloadedBytes),+ total,+ })}+ label={t('settings.voiceSpeakerFilter.model.cancel')}+ onPress={cancelMobileSpeakerModelDownload}+ testID="settings.voiceSpeakerFilter.model.cancel"+ />+ </SettingsGroup>+ );+ }+ const failed = state.modelState === 'failed';+ return (+ <SettingsGroup title={t('settings.voiceSpeakerFilter.model.title')}>+ {[+ failed ? (+ <View key="error" style={rowStyles.row}>+ <Text accessibilityRole="alert" style={rowStyles.rowDetail}>+ {t(`settings.voiceSpeakerFilter.model.failed.${state.downloadError ?? 'network'}`)}+ </Text>+ </View>+ ) : null,+ <ActionInfoRow+ key="download"+ accessibilityLabel={t(failed ? 'settings.voiceSpeakerFilter.model.retry' : 'settings.voiceSpeakerFilter.model.download')}+ detail={failed ? undefined : t('settings.voiceSpeakerFilter.model.needed', { size: total })}+ label={t(failed ? 'settings.voiceSpeakerFilter.model.retry' : 'settings.voiceSpeakerFilter.model.download')}+ onPress={() => {+ void downloadMobileSpeakerModels();+ }}+ testID="settings.voiceSpeakerFilter.model.download"+ />,+ ]}+ </SettingsGroup>+ );+}++function StrictnessRow({+ onPress,+ selected,+ value,+}: {+ onPress(): void;+ selected: boolean;+ value: SpeakerGateStrictness;+}) {+ const { t } = useTranslation();+ const rowStyles = useSettingsRowStyles();+ const { colors } = useTheme();+ const label = t(`settings.voiceSpeakerFilter.strictness.options.${value}`);+ return (+ <Pressable+ accessibilityLabel={label}+ accessibilityRole="radio"+ accessibilityState={{ checked: selected }}+ onPress={onPress}+ style={({ pressed }) => [rowStyles.row, pressed && rowStyles.pressed]}+ testID={`settings.voiceSpeakerFilter.strictness.${value}`}+ >+ <View style={rowStyles.rowLine}>+ <Text style={rowStyles.rowLabel}>{label}</Text>+ {selected ? <Check color={colors.textPrimary} size={iconSize.md} strokeWidth={iconStroke.regular} /> : null}+ </View>+ </Pressable>+ );+}++function formatMegabytes(bytes: number): string {+ return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;+}++const makeStyles = (colors: ThemeColors) => StyleSheet.create({+ safeArea: { backgroundColor: colors.surface, flex: 1 },+ content: { paddingBottom: spacing.xxl, paddingHorizontal: spacing.lg, paddingTop: spacing.lg },+});diff --git a/apps/mobile/modules/cindy-speaker-onnx/android/build.gradle b/apps/mobile/modules/cindy-speaker-onnx/android/build.gradlenew file mode 100644index 0000000000..2b11d8a03c--- /dev/null+++ b/apps/mobile/modules/cindy-speaker-onnx/android/build.gradle@@ -0,0 +1,24 @@+apply plugin: 'com.android.library'+apply plugin: 'org.jetbrains.kotlin.android'++group = 'com.xdtmaker.speakeronnx'+version = '0.1.0'++def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")+apply from: expoModulesCorePlugin+applyKotlinExpoModulesCorePlugin()+useCoreDependencies()+useDefaultAndroidSdkVersions()++android {+ namespace "com.xdtmaker.speakeronnx"++ defaultConfig {+ minSdkVersion 23+ }+}++dependencies {+ // Official Microsoft build; keep in step with onnxruntime-objc in ../ios/CindySpeakerOnnx.podspec.+ implementation "com.microsoft.onnxruntime:onnxruntime-android:1.30.0"+}diff --git a/apps/mobile/modules/cindy-speaker-onnx/android/src/main/AndroidManifest.xml b/apps/mobile/modules/cindy-speaker-onnx/android/src/main/AndroidManifest.xmlnew file mode 100644index 0000000000..94cbbcfc39--- /dev/null+++ b/apps/mobile/modules/cindy-speaker-onnx/android/src/main/AndroidManifest.xml@@ -0,0 +1 @@+<manifest xmlns:android="http://schemas.android.com/apk/res/android" />diff --git a/apps/mobile/modules/cindy-speaker-onnx/android/src/main/java/com/xdtmaker/speakeronnx/CindySpeakerOnnxModule.kt b/apps/mobile/modules/cindy-speaker-onnx/android/src/main/java/com/xdtmaker/speakeronnx/CindySpeakerOnnxModule.ktnew file mode 100644index 0000000000..73b269e21d--- /dev/null+++ b/apps/mobile/modules/cindy-speaker-onnx/android/src/main/java/com/xdtmaker/speakeronnx/CindySpeakerOnnxModule.kt@@ -0,0 +1,128 @@+package com.xdtmaker.speakeronnx++import ai.onnxruntime.OnnxTensor+import ai.onnxruntime.OrtEnvironment+import ai.onnxruntime.OrtSession+import android.util.Base64+import expo.modules.kotlin.exception.CodedException+import expo.modules.kotlin.modules.Module+import expo.modules.kotlin.modules.ModuleDefinition+import java.io.File+import java.nio.ByteBuffer+import java.nio.ByteOrder+import java.security.MessageDigest++/**+ * Runs the speaker filter models (Silero VAD and the voiceprint model) with+ * ONNX Runtime. Feature extraction and gating live in shared TypeScript; this+ * module only loads the two models and runs float32 tensors, one call at a+ * time (calls are serialized on this module's lock).+ */+class CindySpeakerOnnxModule : Module() {+ private val lock = Any()+ private var sessions: Map<String, OrtSession> = emptyMap()+ private var loadedPaths: Map<String, String> = emptyMap()++ override fun definition() = ModuleDefinition {+ Name("CindySpeakerOnnx")++ // Loads (or keeps) both models. Same paths as last time is a no-op.+ AsyncFunction("loadModels") { vadPath: String, embeddingPath: String ->+ synchronized(lock) {+ val wanted = mapOf("vad" to vadPath, "embedding" to embeddingPath)+ if (wanted == loadedPaths) return@synchronized+ val env = OrtEnvironment.getEnvironment()+ val next = LinkedHashMap<String, OrtSession>()+ try {+ wanted.forEach { (name, path) ->+ next[name] = OrtSession.SessionOptions().use { options ->+ options.setIntraOpNumThreads(1)+ env.createSession(path, options)+ }+ }+ } catch (error: Throwable) {+ // A later model may fail after an earlier native session was opened.+ next.values.forEach { runCatching { it.close() } }+ throw error+ }+ closeSessions()+ sessions = next+ loadedPaths = wanted+ }+ }++ AsyncFunction("unloadModels") {+ synchronized(lock) { closeSessions() }+ }++ // `packed` holds the little-endian float32 data of every input, in the+ // order of `names`, each sized by its `dims`. Returns, per output, its dims+ // and its float32 data as base64.+ AsyncFunction("run") { model: String, names: List<String>, dims: List<List<Int>>, packed: ByteArray ->+ synchronized(lock) {+ val session = sessions[model] ?: throw SpeakerOnnxException("model $model is not loaded")+ if (names.size != dims.size) throw SpeakerOnnxException("names and dims differ in length")+ val env = OrtEnvironment.getEnvironment()+ val inputs = LinkedHashMap<String, OnnxTensor>()+ try {+ var offset = 0+ names.forEachIndexed { index, name ->+ val shape = dims[index].map { it.toLong() }.toLongArray()+ val count = shape.fold(1L) { acc, value -> acc * value }.toInt()+ val byteCount = count * 4+ if (count < 0 || offset + byteCount > packed.size) {+ throw SpeakerOnnxException("input $name exceeds the packed data")+ }+ val buffer = ByteBuffer.wrap(packed, offset, byteCount).slice().order(ByteOrder.LITTLE_ENDIAN).asFloatBuffer()+ inputs[name] = OnnxTensor.createTensor(env, buffer, shape)+ offset += byteCount+ }+ if (offset != packed.size) throw SpeakerOnnxException("packed data has trailing bytes")+ session.run(inputs).use { result ->+ val out = HashMap<String, Map<String, Any>>()+ for ((name, value) in result) {+ val tensor = value as? OnnxTensor ?: continue+ val floats = tensor.floatBuffer+ val bytes = ByteBuffer.allocate(floats.remaining() * 4).order(ByteOrder.LITTLE_ENDIAN)+ bytes.asFloatBuffer().put(floats)+ out[name] = mapOf(+ "dims" to tensor.info.shape.map { it.toInt() },+ "base64" to Base64.encodeToString(bytes.array(), Base64.NO_WRAP),+ )+ }+ out+ }+ } finally {+ inputs.values.forEach { it.close() }+ }+ }+ }++ // Hex SHA-256 of a downloaded model file, read in chunks.+ AsyncFunction("sha256File") { path: String ->+ val digest = MessageDigest.getInstance("SHA-256")+ File(path.removePrefix("file://")).inputStream().use { input ->+ val buffer = ByteArray(1 shl 20)+ while (true) {+ val read = input.read(buffer)+ if (read < 0) break+ digest.update(buffer, 0, read)+ }+ }+ digest.digest().joinToString("") { "%02x".format(it) }+ }++ OnDestroy {+ synchronized(lock) { closeSessions() }+ }+ }++ private fun closeSessions() {+ sessions.values.forEach { runCatching { it.close() } }+ sessions = emptyMap()+ loadedPaths = emptyMap()+ }+}++class SpeakerOnnxException(message: String) :+ CodedException("ERR_SPEAKER_ONNX", "Speaker ONNX inference failed: $message", null)diff --git a/apps/mobile/modules/cindy-speaker-onnx/expo-module.config.json b/apps/mobile/modules/cindy-speaker-onnx/expo-module.config.jsonnew file mode 100644index 0000000000..9ea1b2d367--- /dev/null+++ b/apps/mobile/modules/cindy-speaker-onnx/expo-module.config.json@@ -0,0 +1,10 @@+{+ "platforms": ["apple", "android"],+ "apple": {+ "podspecPath": "./ios/CindySpeakerOnnx.podspec",+ "modules": ["CindySpeakerOnnxModule"]+ },+ "android": {+ "modules": ["com.xdtmaker.speakeronnx.CindySpeakerOnnxModule"]+ }+}diff --git a/apps/mobile/modules/cindy-speaker-onnx/ios/CindySpeakerOnnx.podspec b/apps/mobile/modules/cindy-speaker-onnx/ios/CindySpeakerOnnx.podspecnew file mode 100644index 0000000000..c9a724aa81--- /dev/null+++ b/apps/mobile/modules/cindy-speaker-onnx/ios/CindySpeakerOnnx.podspec@@ -0,0 +1,30 @@+require 'json'++package = JSON.parse(File.read(File.join(__dir__, '..', 'package.json')))++Pod::Spec.new do |s|+ s.name = 'CindySpeakerOnnx'+ s.version = package['version']+ s.summary = 'On-device ONNX inference for the Cindy voice input speaker filter.'+ s.description = 'Expo module that runs the speaker filter VAD and voiceprint models with ONNX Runtime.'+ s.license = { :type => 'Apache-2.0', :file => '../../../../../LICENSE' }+ s.author = 'Cindy'+ s.homepage = 'https://github.com/makecindy/cindy'+ s.platforms = {+ :ios => '16.4'+ }+ s.swift_version = '5.0'+ s.source = { git: 'https://github.com/makecindy/cindy.git' }+ s.static_framework = true++ s.dependency 'ExpoModulesCore'+ # Official Microsoft build; keep in step with onnxruntime-android in ../android/build.gradle.+ s.dependency 'onnxruntime-objc', '1.30.0'++ s.pod_target_xcconfig = {+ 'DEFINES_MODULE' => 'YES',+ 'SWIFT_COMPILATION_MODE' => 'wholemodule'+ }++ s.source_files = '**/*.{h,m,swift}'+enddiff --git a/apps/mobile/modules/cindy-speaker-onnx/ios/CindySpeakerOnnxModule.swift b/apps/mobile/modules/cindy-speaker-onnx/ios/CindySpeakerOnnxModule.swiftnew file mode 100644index 0000000000..0c15fe91f3--- /dev/null+++ b/apps/mobile/modules/cindy-speaker-onnx/ios/CindySpeakerOnnxModule.swift@@ -0,0 +1,116 @@+import CommonCrypto+import ExpoModulesCore+import Foundation+import onnxruntime_objc++/// Runs the speaker filter models (Silero VAD and the voiceprint model) with+/// ONNX Runtime. All feature extraction and gating logic lives in shared+/// TypeScript; this module only loads the two models and runs float32+/// tensors through them, one call at a time on its own serial queue.+public class CindySpeakerOnnxModule: Module {+ private let queue = DispatchQueue(label: "com.xdtmaker.speakeronnx", qos: .userInitiated)+ private var env: ORTEnv?+ private var sessions: [String: ORTSession] = [:]+ private var loadedPaths: [String: String] = [:]++ public func definition() -> ModuleDefinition {+ Name("CindySpeakerOnnx")++ /// Loads (or keeps) both models. Same paths as last time is a no-op.+ AsyncFunction("loadModels") { (vadPath: String, embeddingPath: String) in+ try self.queue.sync {+ let wanted = ["vad": vadPath, "embedding": embeddingPath]+ if wanted == self.loadedPaths { return }+ let env = try self.env ?? ORTEnv(loggingLevel: ORTLoggingLevel.warning)+ self.env = env+ var next: [String: ORTSession] = [:]+ for (name, path) in wanted {+ let options = try ORTSessionOptions()+ try options.setIntraOpNumThreads(1)+ next[name] = try ORTSession(env: env, modelPath: path, sessionOptions: options)+ }+ self.sessions = next+ self.loadedPaths = wanted+ }+ }++ AsyncFunction("unloadModels") {+ self.queue.sync {+ self.sessions = [:]+ self.loadedPaths = [:]+ }+ }++ /// `packed` holds the little-endian float32 data of every input, in the+ /// order of `names`, each sized by its `dims`. Returns, per output, its+ /// dims and its float32 data as base64.+ AsyncFunction("run") { (model: String, names: [String], dims: [[Int]], packed: Data) -> [String: [String: Any]] in+ try self.queue.sync {+ guard let session = self.sessions[model] else {+ throw SpeakerOnnxException("model \(model) is not loaded")+ }+ guard names.count == dims.count else {+ throw SpeakerOnnxException("names and dims differ in length")+ }+ var inputs: [String: ORTValue] = [:]+ var offset = 0+ for (index, name) in names.enumerated() {+ let shape = dims[index]+ let count = shape.reduce(1, *)+ let byteCount = count * MemoryLayout<Float>.size+ guard count >= 0, offset + byteCount <= packed.count else {+ throw SpeakerOnnxException("input \(name) exceeds the packed data")+ }+ let bytes = NSMutableData(data: packed.subdata(in: offset..<(offset + byteCount)))+ inputs[name] = try ORTValue(+ tensorData: bytes,+ elementType: ORTTensorElementDataType.float,+ shape: shape.map { NSNumber(value: $0) }+ )+ offset += byteCount+ }+ guard offset == packed.count else {+ throw SpeakerOnnxException("packed data has trailing bytes")+ }+ let outputNames = Set(try session.outputNames())+ let outputs = try session.run(withInputs: inputs, outputNames: outputNames, runOptions: nil)+ var result: [String: [String: Any]] = [:]+ for (name, value) in outputs {+ let info = try value.tensorTypeAndShapeInfo()+ let data = try value.tensorData() as Data+ result[name] = [+ "dims": info.shape.map { $0.intValue },+ "base64": data.base64EncodedString(),+ ]+ }+ return result+ }+ }++ /// Hex SHA-256 of a downloaded model file, read in chunks.+ AsyncFunction("sha256File") { (path: String) -> String in+ guard let handle = FileHandle(forReadingAtPath: path) else {+ throw SpeakerOnnxException("cannot open file")+ }+ defer { try? handle.close() }+ var context = CC_SHA256_CTX()+ CC_SHA256_Init(&context)+ while true {+ let chunk = handle.readData(ofLength: 1 << 20)+ if chunk.isEmpty { break }+ chunk.withUnsafeBytes { buffer in+ _ = CC_SHA256_Update(&context, buffer.baseAddress, CC_LONG(chunk.count))+ }+ }+ var digest = [UInt8](repeating: 0, count: Int(CC_SHA256_DIGEST_LENGTH))+ CC_SHA256_Final(&digest, &context)+ return digest.map { String(format: "%02x", $0) }.joined()+ }+ }+}++final class SpeakerOnnxException: GenericException<String> {+ override var reason: String {+ "Speaker ONNX inference failed: \(param)"+ }+}diff --git a/apps/mobile/modules/cindy-speaker-onnx/package.json b/apps/mobile/modules/cindy-speaker-onnx/package.jsonnew file mode 100644index 0000000000..d030fb36aa--- /dev/null+++ b/apps/mobile/modules/cindy-speaker-onnx/package.json@@ -0,0 +1,7 @@+{+ "name": "cindy-speaker-onnx",+ "version": "0.1.0",+ "main": "src/index.ts",+ "private": true,+ "license": "Apache-2.0"+}diff --git a/apps/mobile/modules/cindy-speaker-onnx/src/index.ts b/apps/mobile/modules/cindy-speaker-onnx/src/index.tsnew file mode 100644index 0000000000..45c4b0ac5a--- /dev/null+++ b/apps/mobile/modules/cindy-speaker-onnx/src/index.ts@@ -0,0 +1,73 @@+import { requireOptionalNativeModule } from 'expo-modules-core';++import type { OnnxTensor, SpeakerOnnxRunner } from '@cindy/voice-input-core';++type NativeOutput = { dims: number[]; base64: string };++type NativeSpeakerOnnxModule = {+ loadModels(vadPath: string, embeddingPath: string): Promise<void>;+ unloadModels(): Promise<void>;+ run(model: string, names: string[], dims: number[][], packed: Uint8Array): Promise<Record<string, NativeOutput>>;+ sha256File(path: string): Promise<string>;+};++const native = requireOptionalNativeModule<NativeSpeakerOnnxModule>('CindySpeakerOnnx');++/** False in builds made before this module existed (e.g. an OTA on an old binary). */+export function isSpeakerOnnxAvailable(): boolean {+ return native !== null;+}++function requireNative(): NativeSpeakerOnnxModule {+ if (!native) throw new Error('CindySpeakerOnnx native module is not available in this build');+ return native;+}++export function loadSpeakerModels(paths: { vad: string; embedding: string }): Promise<void> {+ return requireNative().loadModels(stripFileScheme(paths.vad), stripFileScheme(paths.embedding));+}++export function unloadSpeakerModels(): Promise<void> {+ return native ? native.unloadModels() : Promise.resolve();+}++export function sha256File(path: string): Promise<string> {+ return requireNative().sha256File(stripFileScheme(path));+}++/** The shared engine's model runner, backed by ONNX Runtime on the device. */+export const nativeSpeakerOnnxRunner: SpeakerOnnxRunner = {+ async run(model, inputs) {+ const names = Object.keys(inputs);+ const dims = names.map((name) => inputs[name].dims);+ const outputs = await requireNative().run(model, names, dims, packFloat32(names.map((name) => inputs[name].data)));+ const result: Record<string, OnnxTensor> = {};+ for (const [name, output] of Object.entries(outputs)) {+ result[name] = { dims: output.dims, data: base64ToFloat32(output.base64) };+ }+ return result;+ },+};++/** Concatenates float32 arrays as little-endian bytes (all RN targets are little-endian). */+export function packFloat32(arrays: Float32Array[]): Uint8Array {+ const total = arrays.reduce((sum, array) => sum + array.byteLength, 0);+ const out = new Uint8Array(total);+ let offset = 0;+ for (const array of arrays) {+ out.set(new Uint8Array(array.buffer, array.byteOffset, array.byteLength), offset);+ offset += array.byteLength;+ }+ return out;+}++export function base64ToFloat32(base64: string): Float32Array {+ const binary = atob(base64);+ const bytes = new Uint8Array(binary.length);+ for (let i = 0; i < binary.length; i += 1) bytes[i] = binary.charCodeAt(i);+ return new Float32Array(bytes.buffer, 0, Math.floor(bytes.byteLength / 4));+}++function stripFileScheme(path: string): string {+ return path.startsWith('file://') ? decodeURIComponent(path.slice('file://'.length)) : path;+}diff --git a/apps/mobile/scripts/sim-rebuild.mjs b/apps/mobile/scripts/sim-rebuild.mjsindex d9b9951bad..ccd1a82f74 100644--- a/apps/mobile/scripts/sim-rebuild.mjs+++ b/apps/mobile/scripts/sim-rebuild.mjs@@ -199,7 +199,7 @@ async function rebuildAndroidSimulator() {const gradle = process.platform === 'win32' ? 'gradlew.bat' : './gradlew';console.log('› Android gradle assembleDebug');if (process.platform === 'win32') {- run('cmd.exe', ['/d', '/s', '/c', 'gradlew.bat assembleDebug'], {+ run('cmd.exe', ['/d', '/s', '/c', '.\\gradlew.bat assembleDebug'], {cwd: androidDir,env: javaEnv,windowsVerbatimArguments: true,diff --git a/apps/mobile/src/__tests__/composerVoiceStartupFeedback.test.ts b/apps/mobile/src/__tests__/composerVoiceStartupFeedback.test.tsindex 3107587906..d146f5ee7c 100644--- a/apps/mobile/src/__tests__/composerVoiceStartupFeedback.test.ts+++ b/apps/mobile/src/__tests__/composerVoiceStartupFeedback.test.ts@@ -90,6 +90,7 @@ describe.each(['new.tsx', '[sessionId].tsx'])('%s voice startup feedback', (pageselectedDeviceId: 'host', deviceId: 'host',isMobileRealtimeAudioAvailable: () => true,prewarmMobileRealtimeAudio: vi.fn(), prewarmMobileVoiceStart: vi.fn(),+ warmMobileSpeakerFilter: vi.fn(),auth: { apiFetch: vi.fn() },voiceStartedOnPressInRef: { current: false },voiceRecordingActiveRef: recording,diff --git a/apps/mobile/src/__tests__/mobileSpeakerEnrollmentRecorder.test.ts b/apps/mobile/src/__tests__/mobileSpeakerEnrollmentRecorder.test.tsnew file mode 100644index 0000000000..cddb98d60d--- /dev/null+++ b/apps/mobile/src/__tests__/mobileSpeakerEnrollmentRecorder.test.ts@@ -0,0 +1,138 @@+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';++const audio = vi.hoisted(() => ({ get: vi.fn(), request: vi.fn(), start: vi.fn() }));+const app = vi.hoisted(() => ({+ currentState: 'active',+ listeners: new Set<(state: string) => void>(),+ addEventListener: (_event: string, listener: (state: string) => void) => {+ app.listeners.add(listener);+ return { remove: () => app.listeners.delete(listener) };+ },+}));+vi.mock('expo-audio', () => ({+ getRecordingPermissionsAsync: audio.get,+ requestRecordingPermissionsAsync: audio.request,+}));+vi.mock('react-native', () => ({ AppState: app }));+vi.mock('@/session/mobileRealtimeAudio', () => ({ startMobileRealtimeAudio: audio.start }));++import {+ MobileSpeakerEnrollmentAbortedError,+ MobileSpeakerEnrollmentNoAudioError,+ recordMobileSpeakerClip,+} from '@/session/mobileSpeakerEnrollmentRecorder';++function deferred<T>() {+ let resolve!: (value: T) => void;+ const promise = new Promise<T>((done) => { resolve = done; });+ return { promise, resolve };+}+function appState(state: string) {+ app.currentState = state;+ for (const listener of app.listeners) listener(state);+}+async function flush() {+ for (let i = 0; i < 12; i += 1) await Promise.resolve();+}+function emit(samples = 1600) {+ audio.start.mock.calls[0][0].onChunk({ pcm16: new Int16Array(samples).buffer });+}++describe('speaker enrollment microphone lifecycle', () => {+ const stop = vi.fn(async () => {});+ beforeEach(() => {+ vi.clearAllMocks();+ app.currentState = 'active';+ app.listeners.clear();+ audio.get.mockResolvedValue({ granted: true });+ audio.request.mockResolvedValue({ granted: true });+ audio.start.mockResolvedValue(stop);+ });+ afterEach(() => {+ expect(app.listeners.size).toBe(0);+ vi.useRealTimers();+ });++ it('requests first-use permission and waits for foreground before opening the microphone', async () => {+ const permission = deferred<{ granted: boolean }>();+ audio.get.mockResolvedValue({ granted: false });+ audio.request.mockImplementation(() => { appState('background'); return permission.promise; });+ const recording = recordMobileSpeakerClip({ durationMs: 100 });+ await flush();+ expect(audio.request).toHaveBeenCalledOnce();+ expect(audio.start).not.toHaveBeenCalled();+ permission.resolve({ granted: true });+ await flush();+ expect(audio.start).not.toHaveBeenCalled();+ appState('active');+ await flush();+ emit();+ expect((await recording).byteLength).toBe(3200);+ expect(stop).toHaveBeenCalledOnce();+ });++ it('does not start capture when permission is denied', async () => {+ audio.get.mockResolvedValue({ granted: false });+ audio.request.mockResolvedValue({ granted: false });+ await expect(recordMobileSpeakerClip({ durationMs: 100 })).rejects.toThrow('microphone permission denied');+ expect(audio.start).not.toHaveBeenCalled();+ });++ it('does not start after cancellation while the permission dialog is open', async () => {+ const permission = deferred<{ granted: boolean }>();+ audio.get.mockResolvedValue({ granted: false });+ audio.request.mockReturnValue(permission.promise);+ const controller = new AbortController();+ const recording = recordMobileSpeakerClip({ durationMs: 100, signal: controller.signal });+ const rejected = expect(recording).rejects.toBeInstanceOf(MobileSpeakerEnrollmentAbortedError);+ await flush();+ controller.abort();+ permission.resolve({ granted: true });+ await rejected;+ expect(audio.start).not.toHaveBeenCalled();+ });++ it('stops capture and discards late chunks when backgrounded', async () => {+ const progress = vi.fn();+ const recording = recordMobileSpeakerClip({ durationMs: 100, onProgress: progress });+ const rejected = expect(recording).rejects.toBeInstanceOf(MobileSpeakerEnrollmentAbortedError);+ await flush();+ appState('background');+ emit();+ await rejected;+ expect(stop).toHaveBeenCalledOnce();+ expect(progress).not.toHaveBeenCalled();+ });++ it('releases a microphone whose startup finishes after cancellation', async () => {+ const startup = deferred<() => Promise<void>>();+ audio.start.mockReturnValue(startup.promise);+ const controller = new AbortController();+ const recording = recordMobileSpeakerClip({ durationMs: 100, signal: controller.signal });+ const rejected = expect(recording).rejects.toBeInstanceOf(MobileSpeakerEnrollmentAbortedError);+ await flush();+ controller.abort();+ startup.resolve(stop);+ await rejected;+ expect(stop).toHaveBeenCalledOnce();+ });++ it('fails a stalled microphone and releases it', async () => {+ vi.useFakeTimers();+ const recording = recordMobileSpeakerClip({ durationMs: 100 });+ const rejected = expect(recording).rejects.toBeInstanceOf(MobileSpeakerEnrollmentNoAudioError);+ await flush();+ await vi.advanceTimersByTimeAsync(5100);+ await rejected;+ expect(stop).toHaveBeenCalledOnce();+ });++ it('does not request permission or start capture for an already cancelled recording', async () => {+ const controller = new AbortController();+ controller.abort();+ await expect(recordMobileSpeakerClip({ durationMs: 100, signal: controller.signal }))+ .rejects.toBeInstanceOf(MobileSpeakerEnrollmentAbortedError);+ expect(audio.get).not.toHaveBeenCalled();+ expect(audio.start).not.toHaveBeenCalled();+ });+});diff --git a/apps/mobile/src/__tests__/mobileSpeakerFilter.test.ts b/apps/mobile/src/__tests__/mobileSpeakerFilter.test.tsnew file mode 100644index 0000000000..c08af19bce--- /dev/null+++ b/apps/mobile/src/__tests__/mobileSpeakerFilter.test.ts@@ -0,0 +1,303 @@+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';+import { buildSpeakerEnrollment, SPEAKER_MODEL_ASSETS, SpeakerGate, speakerModelAsset, speakerModelLocalName } from '@cindy/voice-input-core';+import AsyncStorage from '@react-native-async-storage/async-storage';+import * as FileSystem from 'expo-file-system/legacy';+import { getSecureItem, setSecureItem } from '@/auth/secureStorage';+import { loadSpeakerModels, nativeSpeakerOnnxRunner } from '../../modules/cindy-speaker-onnx/src';++vi.mock('@cindy/voice-input-core', async (importOriginal) => {+ const actual = await importOriginal<typeof import('@cindy/voice-input-core')>();+ return { ...actual, buildSpeakerEnrollment: vi.fn(actual.buildSpeakerEnrollment) };+});++const asyncStore = new Map<string, string>();+const secureStore = new Map<string, string>();+const files = new Map<string, number>();+const sha = { value: '' };++vi.mock('@react-native-async-storage/async-storage', () => ({+ default: {+ getItem: vi.fn(async (key: string) => asyncStore.get(key) ?? null),+ setItem: vi.fn(async (key: string, value: string) => {+ asyncStore.set(key, value);+ }),+ removeItem: vi.fn(async (key: string) => {+ asyncStore.delete(key);+ }),+ },+}));+vi.mock('@/auth/secureStorage', () => ({+ getSecureItem: vi.fn(async (key: string) => secureStore.get(key) ?? null),+ setSecureItem: vi.fn(async (key: string, value: string) => {+ secureStore.set(key, value);+ }),+ deleteSecureItem: vi.fn(async (key: string) => {+ secureStore.delete(key);+ }),+}));+vi.mock('@/config/env', () => ({ ENDPOINT_MANIFEST_BASE_URL: 'https://cdn.example.com' }));+vi.mock('@/session/mobileVoiceDiagnostics', () => ({ logMobileVoice: vi.fn() }));+vi.mock('expo-file-system/legacy', () => ({+ cacheDirectory: 'file:///cache/',+ getInfoAsync: vi.fn(async (path: string) =>+ files.has(path) ? { exists: true, isDirectory: false, size: files.get(path) } : { exists: false }),+ makeDirectoryAsync: vi.fn(async () => undefined),+ readDirectoryAsync: vi.fn(async () => [...files.keys()].map((path) => path.slice('file:///cache/voice-models/'.length))),+ deleteAsync: vi.fn(async (path: string) => {+ files.delete(path);+ }),+ moveAsync: vi.fn(async ({ from, to }: { from: string; to: string }) => {+ files.set(to, files.get(from) ?? 0);+ files.delete(from);+ }),+ createDownloadResumable: vi.fn((url: string, target: string) => ({+ downloadAsync: async () => {+ const asset = SPEAKER_MODEL_ASSETS.find((candidate) => url.includes(candidate.sha256))!;+ files.set(target, asset.bytes);+ return { status: 200, uri: target };+ },+ cancelAsync: async () => undefined,+ })),+}));+vi.mock('../../modules/cindy-speaker-onnx/src', () => ({+ isSpeakerOnnxAvailable: () => true,+ loadSpeakerModels: vi.fn(async () => undefined),+ sha256File: vi.fn(async (path: string) => {+ if (sha.value) return sha.value;+ return SPEAKER_MODEL_ASSETS.find((asset) => path.includes(speakerModelLocalName(asset)))!.sha256;+ }),+ nativeSpeakerOnnxRunner: { run: vi.fn() },+}));++const { setMobileAuthOwner } = await import('@/auth/authOwnerGeneration');+const service = await import('@/session/mobileSpeakerFilter');++function installModels(): void {+ for (const asset of SPEAKER_MODEL_ASSETS) {+ files.set(`file:///cache/voice-models/${speakerModelLocalName(asset)}`, asset.bytes);+ }+}++function storeProfile(accountKey: string, modelSha256 = speakerModelAsset('embedding').sha256): void {+ const bytes = new Uint8Array(Float32Array.of(0.6, 0.8).buffer);+ secureStore.set(+ service.__testing.profileKey(accountKey),+ JSON.stringify({ version: 1, embedding: btoa(String.fromCharCode(...bytes)), createdAt: 42, modelSha256 }),+ );+}++async function signIn(id: string): Promise<string> {+ setMobileAuthOwner(id, 'global');+ await service.hydrateMobileSpeakerFilter();+ const { getMobileAuthOwner } = await import('@/auth/authOwnerGeneration');+ return getMobileAuthOwner().accountKey;+}++beforeEach(() => {+ vi.clearAllMocks();+ service.__testing.reset();+ asyncStore.clear();+ secureStore.clear();+ files.clear();+ sha.value = '';+ setMobileAuthOwner(null);+});++describe('mobile speaker filter', () => {+ afterEach(() => vi.useRealTimers());++ it.each(['load', 'run'] as const)('bounds stalled native %s during enrollment', async (operation) => {+ installModels();+ await signIn('user-a');+ if (operation === 'load') vi.mocked(loadSpeakerModels).mockImplementationOnce(() => new Promise(() => {}));+ else vi.mocked(nativeSpeakerOnnxRunner.run).mockImplementationOnce(() => new Promise(() => {}));+ vi.useFakeTimers();+ const pending = service.enrollMobileSpeaker([new ArrayBuffer(32_000)]);+ await vi.advanceTimersByTimeAsync(15_001);+ expect(await pending).toEqual({ ok: false, reason: 'failed' });+ expect(service.getMobileSpeakerFilterSnapshot().enrolled).toBe(false);+ expect(setSecureItem).not.toHaveBeenCalled();+ expect(vi.getTimerCount()).toBe(0);+ });++ it('restores the saved preference when local storage rejects a change', async () => {+ installModels();+ await signIn('user-a');+ vi.mocked(AsyncStorage.setItem).mockRejectedValueOnce(new Error('disk full'));+ await expect(service.setMobileSpeakerFilterEnabled(true)).rejects.toThrow('disk full');+ expect(service.getMobileSpeakerFilterSnapshot().enabled).toBe(false);+ vi.mocked(AsyncStorage.setItem).mockRejectedValueOnce(new Error('disk full'));+ await expect(service.setMobileSpeakerFilterStrictness('strict')).rejects.toThrow('disk full');+ expect(service.getMobileSpeakerFilterSnapshot()).toMatchObject({ strictness: 'standard', strictnessCustomized: false });+ });++ it('loads the new owner even when the previous owner hydration is still pending', async () => {+ let release!: (value: string | null) => void;+ vi.mocked(getSecureItem).mockImplementationOnce(() => new Promise((resolve) => { release = resolve; }));+ setMobileAuthOwner('user-a', 'global');+ const old = service.hydrateMobileSpeakerFilter();+ await vi.waitFor(() => expect(release).toBeTypeOf('function'));+ setMobileAuthOwner('user-b', 'global');+ const current = service.hydrateMobileSpeakerFilter();+ release(null);+ await Promise.all([old, current]);+ expect(service.getMobileSpeakerFilterSnapshot().hydrated).toBe(true);+ await service.setMobileSpeakerFilterStrictness('strict');+ expect(vi.mocked(AsyncStorage.setItem)).toHaveBeenCalledWith(+ expect.stringContaining('user-b'), expect.stringContaining('strict'),+ );+ });++ it('does not publish an old enrollment into the next account after secure storage completes', async () => {+ installModels();+ await signIn('user-a');+ vi.mocked(buildSpeakerEnrollment).mockResolvedValueOnce({ ok: true, embedding: Float32Array.of(1, 0), selfScore: 1, speechSec: 9 });+ let release!: () => void;+ vi.mocked(setSecureItem).mockImplementationOnce(() => new Promise((resolve) => { release = resolve; }));+ const pending = service.enrollMobileSpeaker([]);+ await vi.waitFor(() => expect(release).toBeTypeOf('function'));+ await signIn('user-b');+ release();+ expect(await pending).toEqual({ ok: false, reason: 'failed' });+ expect(service.getMobileSpeakerFilterSnapshot().enrolled).toBe(false);+ });++ it('keeps sign-out cleanup ordered after an in-flight secure write', async () => {+ installModels();+ const key = await signIn('user-a');+ vi.mocked(buildSpeakerEnrollment).mockResolvedValueOnce({ ok: true, embedding: Float32Array.of(1, 0), selfScore: 1, speechSec: 9 });+ let release!: () => void;+ vi.mocked(setSecureItem).mockImplementationOnce(async (name, value) => {+ await new Promise<void>((resolve) => { release = resolve; });+ secureStore.set(name, value);+ });+ const pending = service.enrollMobileSpeaker([]);+ await vi.waitFor(() => expect(release).toBeTypeOf('function'));+ setMobileAuthOwner(null);+ const { clearMobileSpeakerFilterForAccount } = await import('@/session/mobileSpeakerFilterStorage');+ const cleanup = clearMobileSpeakerFilterForAccount(key);+ await Promise.resolve();+ release();+ await Promise.all([pending, cleanup]);+ expect(secureStore.has(service.__testing.profileKey(key))).toBe(false);+ });++ it('honors cancellation before the first download task is created', async () => {+ await signIn('user-a');+ const download = service.downloadMobileSpeakerModels();+ service.cancelMobileSpeakerModelDownload();+ await download;+ expect(FileSystem.createDownloadResumable).not.toHaveBeenCalled();+ expect(service.getMobileSpeakerFilterSnapshot().modelState).toBe('missing');+ });++ it('defaults to off and builds no gate', async () => {+ await signIn('user-a');+ const state = service.getMobileSpeakerFilterSnapshot();+ expect(state).toMatchObject({ hydrated: true, enabled: false, strictness: 'standard', enrolled: false });+ expect(service.createMobileSpeakerGate()).toBeUndefined();+ });++ it('builds a gate only when on, enrolled and the models are on disk', async () => {+ installModels();+ setMobileAuthOwner('user-a', 'global');+ const { getMobileAuthOwner } = await import('@/auth/authOwnerGeneration');+ storeProfile(getMobileAuthOwner().accountKey);+ await service.hydrateMobileSpeakerFilter();+ expect(service.createMobileSpeakerGate()).toBeUndefined();++ await service.setMobileSpeakerFilterEnabled(true);+ expect(service.createMobileSpeakerGate()).toBeInstanceOf(SpeakerGate);+ });++ it('ignores a voiceprint made by another model', async () => {+ installModels();+ setMobileAuthOwner('user-a', 'global');+ const { getMobileAuthOwner } = await import('@/auth/authOwnerGeneration');+ storeProfile(getMobileAuthOwner().accountKey, 'f'.repeat(64));+ await service.hydrateMobileSpeakerFilter();+ expect(service.getMobileSpeakerFilterSnapshot().enrolled).toBe(false);+ });++ it('keeps switch, strictness and voiceprint per account', async () => {+ installModels();+ const a = await signIn('user-a');+ storeProfile(a);+ service.__testing.reset();+ await signIn('user-a');+ await service.setMobileSpeakerFilterEnabled(true);+ await service.setMobileSpeakerFilterStrictness('strict');+ expect(JSON.parse(asyncStore.get(service.__testing.prefsKey(a))!)).toEqual({+ version: 1,+ enabled: true,+ strictnessOverride: 'strict',+ });++ await signIn('user-b');+ expect(service.getMobileSpeakerFilterSnapshot()).toMatchObject({ enabled: false, strictness: 'standard', enrolled: false });+ expect(service.createMobileSpeakerGate()).toBeUndefined();+ });++ it('restoring the default strictness drops the override', async () => {+ const a = await signIn('user-a');+ await service.setMobileSpeakerFilterStrictness('relaxed');+ await service.setMobileSpeakerFilterStrictness(null);+ expect(service.getMobileSpeakerFilterSnapshot()).toMatchObject({ strictness: 'standard', strictnessCustomized: false });+ expect(JSON.parse(asyncStore.get(service.__testing.prefsKey(a))!).strictnessOverride).toBeUndefined();+ });++ it('hashes the account into the secure-store key', async () => {+ const key = service.__testing.profileKey('global:membership/with:odd chars');+ expect(key).toMatch(/^xdt\.voiceSpeakerProfile\.v1\.[0-9a-f]{32}$/);+ });++ it('downloads both models on first enable and verifies their hash', async () => {+ await signIn('user-a');+ await service.setMobileSpeakerFilterEnabled(true);+ await service.downloadMobileSpeakerModels();+ expect(service.getMobileSpeakerFilterSnapshot().modelState).toBe('ready');+ for (const asset of SPEAKER_MODEL_ASSETS) {+ expect(files.get(`file:///cache/voice-models/${speakerModelLocalName(asset)}`)).toBe(asset.bytes);+ }+ });++ it('rejects a download whose hash does not match and keeps nothing', async () => {+ await signIn('user-a');+ sha.value = '0'.repeat(64);+ await service.downloadMobileSpeakerModels();+ expect(service.getMobileSpeakerFilterSnapshot()).toMatchObject({ modelState: 'failed', downloadError: 'checksum' });+ expect([...files.keys()]).toEqual([]);+ });++ it('sign-out clears that account\'s voiceprint and settings but keeps the models', async () => {+ installModels();+ const a = await signIn('user-a');+ storeProfile(a);+ await service.setMobileSpeakerFilterEnabled(true);+ const other = 'global:someone-else';+ storeProfile(other);++ const { clearMobileSpeakerFilterForAccount } = await import('@/session/mobileSpeakerFilterStorage');+ setMobileAuthOwner(null);+ await clearMobileSpeakerFilterForAccount(a);++ expect(secureStore.has(service.__testing.profileKey(a))).toBe(false);+ expect(asyncStore.has(service.__testing.prefsKey(a))).toBe(false);+ expect(secureStore.has(service.__testing.profileKey(other))).toBe(true);+ expect(files.size).toBe(SPEAKER_MODEL_ASSETS.length);+ expect(service.getMobileSpeakerFilterSnapshot()).toMatchObject({ enabled: false, enrolled: false });+ expect(service.createMobileSpeakerGate()).toBeUndefined();+ });++ it('deletes the voiceprint', async () => {+ installModels();+ const a = await signIn('user-a');+ storeProfile(a);+ service.__testing.reset();+ await signIn('user-a');+ expect(service.getMobileSpeakerFilterSnapshot().enrolled).toBe(true);+ await service.deleteMobileSpeakerProfile();+ expect(secureStore.has(service.__testing.profileKey(a))).toBe(false);+ expect(service.getMobileSpeakerFilterSnapshot().enrolled).toBe(false);+ });+});diff --git a/apps/mobile/src/__tests__/simRebuildScript.test.ts b/apps/mobile/src/__tests__/simRebuildScript.test.tsindex 38246a1d70..a42377c949 100644--- a/apps/mobile/src/__tests__/simRebuildScript.test.ts+++ b/apps/mobile/src/__tests__/simRebuildScript.test.ts@@ -73,7 +73,8 @@ describe('sim-rebuild script invariants', () => {expect(source).toContain('await rebuildAndroidSimulator();');expect(source).toContain("'--platform', 'android', '--no-install'");expect(source).toContain("const gradle = process.platform === 'win32' ? 'gradlew.bat' : './gradlew';");- expect(source).toContain("run('cmd.exe', ['/d', '/s', '/c', 'gradlew.bat assembleDebug']");+ // Explicit cwd path also works with NoDefaultCurrentDirectoryInExePath enabled.+ expect(source).toContain("run('cmd.exe', ['/d', '/s', '/c', '.\\\\gradlew.bat assembleDebug']");expect(source).not.toContain('process.env.ComSpec');expect(source).toContain('resolvePnpmInvocation');expect(source).toContain('function runPnpm(args, opts = {})');diff --git a/apps/mobile/src/__tests__/speakerOnnxModule.test.ts b/apps/mobile/src/__tests__/speakerOnnxModule.test.tsnew file mode 100644index 0000000000..2b621dbb41--- /dev/null+++ b/apps/mobile/src/__tests__/speakerOnnxModule.test.ts@@ -0,0 +1,57 @@+import { describe, expect, it, vi } from 'vitest';++const nativeRun = vi.fn();++vi.mock('expo-modules-core', () => ({+ requireOptionalNativeModule: () => ({+ loadModels: vi.fn(),+ unloadModels: vi.fn(),+ sha256File: vi.fn(),+ run: nativeRun,+ }),+}));++const { base64ToFloat32, nativeSpeakerOnnxRunner, packFloat32 } = await import(+ '../../modules/cindy-speaker-onnx/src'+);++function float32ToBase64(values: number[]): string {+ const bytes = new Uint8Array(Float32Array.from(values).buffer);+ let binary = '';+ for (const byte of bytes) binary += String.fromCharCode(byte);+ return btoa(binary);+}++describe('cindy-speaker-onnx bridge', () => {+ it('packs inputs back to back, respecting subarray offsets', () => {+ const backing = Float32Array.of(9, 1, 2, 9);+ const packed = packFloat32([backing.subarray(1, 3), Float32Array.of(3)]);+ expect(Array.from(new Float32Array(packed.buffer))).toEqual([1, 2, 3]);+ });++ it('decodes base64 float32 output', () => {+ expect(Array.from(base64ToFloat32(float32ToBase64([0.5, -2, 1e-3])))).toEqual([+ 0.5,+ -2,+ Math.fround(1e-3),+ ]);+ });++ it('sends names, dims and packed data in a stable order and decodes every output', async () => {+ nativeRun.mockResolvedValueOnce({+ prob: { dims: [1, 1], base64: float32ToBase64([0.75]) },+ new_h: { dims: [2], base64: float32ToBase64([1, 2]) },+ });+ const out = await nativeSpeakerOnnxRunner.run('vad', {+ x: { data: Float32Array.of(1, 2), dims: [1, 2] },+ h: { data: Float32Array.of(3), dims: [1] },+ });+ const [model, names, dims, packed] = nativeRun.mock.calls[0];+ expect(model).toBe('vad');+ expect(names).toEqual(['x', 'h']);+ expect(dims).toEqual([[1, 2], [1]]);+ expect(Array.from(new Float32Array((packed as Uint8Array).buffer))).toEqual([1, 2, 3]);+ expect(out.prob).toEqual({ dims: [1, 1], data: Float32Array.of(0.75) });+ expect(Array.from(out.new_h.data)).toEqual([1, 2]);+ });+});diff --git a/apps/mobile/src/__tests__/voiceSpeakerFilterScreen.test.ts b/apps/mobile/src/__tests__/voiceSpeakerFilterScreen.test.tsnew file mode 100644index 0000000000..75f71ef9fa--- /dev/null+++ b/apps/mobile/src/__tests__/voiceSpeakerFilterScreen.test.ts@@ -0,0 +1,114 @@+import { readFileSync } from 'node:fs';+import { resolve } from 'node:path';+import ts from 'typescript';+import { describe, expect, it, vi } from 'vitest';++// Execute the real screen callbacks without mounting unrelated native settings UI.+const source = ts.createSourceFile('voice-speaker-filter.tsx',+ readFileSync(resolve(process.cwd(), 'app/settings/voice-speaker-filter.tsx'), 'utf8'),+ ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);+const callbacks = new Map<string, string>();+function visit(node: ts.Node) {+ if (ts.isVariableDeclaration(node) && node.initializer && ts.isCallExpression(node.initializer)+ && node.initializer.expression.getText(source) === 'useCallback') {+ callbacks.set(node.name.getText(source), node.initializer.arguments[0].getText(source));+ }+ if (ts.isJsxAttribute(node) && node.name.getText(source) === 'onValueChange'+ && node.initializer && ts.isJsxExpression(node.initializer) && node.initializer.expression) {+ callbacks.set('toggle', node.initializer.expression.getText(source));+ }+ ts.forEachChild(node, visit);+}+visit(source);+class Aborted extends Error {}+class NoAudio extends Error {}+function deferred<T>() {+ let resolve!: (value: T) => void;+ let reject!: (error: Error) => void;+ const promise = new Promise<T>((done, fail) => { resolve = done; reject = fail; });+ return { promise, resolve, reject };+}+function harness() {+ const bindings = {+ abortRef: { current: null as AbortController | null },+ clipsRef: { current: [null, null, null] },+ recording: false, saving: false, current: 0,+ CLIP_INDEXES: [0, 1, 2], CLIP_SECONDS: 6,+ setClips: vi.fn(), setCurrent: vi.fn(), setRecording: vi.fn(),+ setProgress: vi.fn(), setSaving: vi.fn(), setEnrollError: vi.fn(), setEnrolling: vi.fn(),+ setMobileSpeakerFilterEnabled: vi.fn(async () => {}),+ reportActionFailure: vi.fn(),+ recordMobileSpeakerClip: vi.fn(),+ MobileSpeakerEnrollmentAbortedError: Aborted,+ MobileSpeakerEnrollmentNoAudioError: NoAudio,+ };+ const js = ts.transpileModule(`+ const resetEnrollment = ${callbacks.get('resetEnrollment')};+ return { record: ${callbacks.get('record')}, reset: resetEnrollment, toggle: ${callbacks.get('toggle')} };+ `, { compilerOptions: { target: ts.ScriptTarget.ES2022 } }).outputText;+ const actions = new Function(...Object.keys(bindings), js)(...Object.values(bindings)) as {+ record(): Promise<void>; reset(): void; toggle(value: boolean): void;+ };+ return { ...bindings, ...actions };+}++describe('speaker enrollment screen cancellation', () => {+ it('reports a failed switch save instead of leaving an unhandled rejection', async () => {+ const h = harness();+ h.setMobileSpeakerFilterEnabled.mockRejectedValueOnce(new Error('disk full'));+ h.toggle(true);+ await Promise.resolve();+ expect(h.reportActionFailure).toHaveBeenCalledOnce();+ });++ it('does not start two recordings before React renders the busy state', async () => {+ const h = harness();+ const clip = deferred<ArrayBuffer>();+ h.recordMobileSpeakerClip.mockReturnValue(clip.promise);+ const first = h.record();+ await h.record();+ expect(h.recordMobileSpeakerClip).toHaveBeenCalledOnce();+ clip.resolve(new ArrayBuffer(4));+ await first;+ expect(h.abortRef.current).toBeNull();+ });++ it('ignores an old recording settling after cancel and restart', async () => {+ const h = harness();+ const oldClip = deferred<ArrayBuffer>();+ const newClip = deferred<ArrayBuffer>();+ h.recordMobileSpeakerClip.mockReturnValueOnce(oldClip.promise).mockReturnValueOnce(newClip.promise);+ const first = h.record();+ const oldOptions = h.recordMobileSpeakerClip.mock.calls[0][0];+ h.reset();+ const second = h.record();+ const newController = h.abortRef.current;+ h.setProgress.mockClear();+ h.setRecording.mockClear();+ oldOptions.onProgress(0.8);+ oldClip.reject(new Aborted());+ await first;+ expect(oldOptions.signal.aborted).toBe(true);+ expect(h.abortRef.current).toBe(newController);+ expect(h.setRecording).not.toHaveBeenCalled();+ expect(h.setProgress).not.toHaveBeenCalled();+ newClip.resolve(new ArrayBuffer(4));+ await second;+ expect(h.setRecording).toHaveBeenLastCalledWith(false);+ });++ it('turning the feature off cancels capture and closes enrollment', async () => {+ const h = harness();+ const clip = deferred<ArrayBuffer>();+ h.recordMobileSpeakerClip.mockReturnValue(clip.promise);+ const recording = h.record();+ const options = h.recordMobileSpeakerClip.mock.calls[0][0];+ h.toggle(false);+ expect(options.signal.aborted).toBe(true);+ expect(h.setEnrolling).toHaveBeenCalledWith(false);+ expect(h.setMobileSpeakerFilterEnabled).toHaveBeenCalledWith(false);+ clip.reject(new Aborted());+ await recording;+ expect(h.setClips).toHaveBeenCalledExactlyOnceWith([null, null, null]);+ });+});diff --git a/apps/mobile/src/auth/AuthContext.tsx b/apps/mobile/src/auth/AuthContext.tsxindex 3c3f4cbb58..717aeefb47 100644--- a/apps/mobile/src/auth/AuthContext.tsx+++ b/apps/mobile/src/auth/AuthContext.tsx@@ -127,6 +127,7 @@ import { updateCredentialAccessToken } from '@/remote-desktop/credentialIdentityimport { clearCachedSessionMessages } from '@/session/mobileSessionMessageCache';import { clearHistoryDisk } from '@/session/remoteHistoryDiskCache';import { clearAllMobileVoiceCredentials } from '@/session/mobileVoiceCredentialStore';+import { clearMobileSpeakerFilterForAccount } from '@/session/mobileSpeakerFilterStorage';import {clearAllMobileVoiceDictionaryCaches,setMobileVoiceDictionaryAccountScope,@@ -2940,6 +2941,8 @@ export function AuthProvider({ children }: { children: ReactNode }) {// 词典缓存按 host 设备分区、不含账号身份:同一台电脑在两个账号下是同一个// deviceId,不清就会让下一个账号读到上一个账号的词条并发给润色模型。await clearAllMobileVoiceDictionaryCaches().catch(() => undefined);+ // 声纹是这个账号的生物特征数据,随账号的其他本机数据一起清;模型文件不含账号数据,保留。+ await clearMobileSpeakerFilterForAccount(invitationHistoryAccountKey);await clearCachedSessionMessages().catch(() => undefined);await clearHistoryDisk();// 首页设备+会话快照与消息缓存一样属于账号数据,登出必须清掉。diff --git a/apps/mobile/src/i18n/locales/en/settings.json b/apps/mobile/src/i18n/locales/en/settings.jsonindex 761af32ee7..865c954727 100644--- a/apps/mobile/src/i18n/locales/en/settings.json+++ b/apps/mobile/src/i18n/locales/en/settings.json@@ -192,6 +192,84 @@"offlineHint": "Your computers are offline. Showing the last synced dictionary.","noDesktops": "Sign in to the same account on a computer to sync your dictionary."},+ "voiceSpeakerFilter": {+ "actionFailed": "The change could not be saved. Please try again.",+ "title": "Recognize my voice",+ "sectionTitle": "Voiceprint filter",+ "label": "Recognize my voice",+ "entryHint": "Mutes other people during voice input. Your voiceprint stays on this phone.",+ "openAccessibility": "Open recognize my voice settings",+ "on": "On",+ "off": "Off",+ "hint": "Mutes other people during voice input so only what you say is transcribed. Requires a recorded voiceprint; speech that overlaps yours cannot be fully removed.",+ "unsupported": "This version of the app does not support voiceprints. Update to the latest version.",+ "privacy": "Your voiceprint stays on this phone, encrypted. It is never uploaded or synced to other devices.",+ "model": {+ "title": "Recognition model",+ "needed": "The first use downloads a recognition model of about {{size}}. Wi-Fi is recommended.",+ "download": "Download recognition model",+ "downloading": "Downloading ({{done}} / {{total}})",+ "cancel": "Cancel download",+ "retry": "Download again",+ "failed": {+ "network": "The recognition model failed to download. Check your network and try again.",+ "disk": "The recognition model could not be saved. Check your phone's free storage and try again.",+ "checksum": "The downloaded recognition model failed verification. Try again.",+ "unavailable": "The recognition model is unavailable right now. Try again later."+ }+ },+ "profile": {+ "title": "Voiceprint",+ "missing": "No voiceprint yet",+ "missingHint": "Record your voiceprint to turn this on. It takes about 20 seconds.",+ "enrolled": "Voiceprint recorded",+ "enrolledAt": "Recorded {{date}}",+ "enroll": "Record voiceprint",+ "reenroll": "Record again",+ "delete": "Delete voiceprint",+ "deleteConfirm": {+ "title": "Delete voiceprint?",+ "description": "Voice input will stop filtering out other people until you record your voiceprint again.",+ "confirm": "Delete",+ "cancel": "Cancel"+ }+ },+ "strictness": {+ "label": "Strictness",+ "hint": "Stricter lets fewer other voices through, but in noisy places it may also cut off more of your own words.",+ "restoreDefault": "Restore default",+ "options": {+ "relaxed": "Relaxed",+ "standard": "Standard",+ "strict": "Strict"+ }+ },+ "enroll": {+ "description": "Where you usually use voice input, read the {{clips}} passages below in your normal voice. Each recording lasts {{seconds}} seconds. Make sure no one else is talking.",+ "step": "Passage {{current}} of {{total}}",+ "record": "Start reading",+ "rerecord": "Record this one again",+ "recording": "{{seconds}} s left",+ "saving": "Creating voiceprint…",+ "submit": "Finish",+ "cancel": "Cancel",+ "passages": {+ "p1": "This morning I will go over the plan for the week, and in the afternoon I will list the questions we need to discuss and send them out so everyone can read them first.",+ "p2": "If the weather is nice tomorrow, we can leave a little earlier, pick up some fruit and snacks on the way, and have lunch in the park.",+ "p3": "Please make this text more concise, keep the key numbers and conclusions, and then sum up the main points in three to five sentences."+ },+ "errors": {+ "too_short": "Passage {{index}} has too little speech. Record it again without long pauses.",+ "no_embedding": "No voiceprint could be read from passage {{index}}. Record it again.",+ "inconsistent": "Passage {{index}} does not sound like the same person as the others; another voice or noise may have been picked up. Record it again.",+ "models_missing": "The recognition model has not finished downloading. Try again shortly.",+ "storage_unavailable": "The system keychain is unavailable, so the voiceprint cannot be stored encrypted. Try again later.",+ "failed": "The voiceprint could not be created. Try again.",+ "microphone": "The microphone cannot be used. Check microphone permission and try again.",+ "noAudio": "No sound came from the microphone. Check it and try again."+ }+ }+ },"deviceNameEditor": {"screenTitle": "Device Name","placeholder": "Phone name",diff --git a/apps/mobile/src/i18n/locales/ja/settings.json b/apps/mobile/src/i18n/locales/ja/settings.jsonindex d66a1357ec..b5d6a0f50b 100644--- a/apps/mobile/src/i18n/locales/ja/settings.json+++ b/apps/mobile/src/i18n/locales/ja/settings.json@@ -192,6 +192,84 @@"offlineHint": "パソコンがオフラインのため、最後に同期した辞書を表示しています。","noDesktops": "パソコンで同じアカウントにログインすると辞書を同期できます。"},+ "voiceSpeakerFilter": {+ "actionFailed": "変更を保存できませんでした。もう一度お試しください。",+ "title": "自分の声を認識",+ "sectionTitle": "声紋フィルター",+ "label": "自分の声を認識",+ "entryHint": "音声入力中は周りの人の声をミュートします。声紋はこのスマートフォンにだけ保存されます。",+ "openAccessibility": "「自分の声を認識」の設定を開く",+ "on": "オン",+ "off": "オフ",+ "hint": "音声入力中は周りの人の声をミュートし、あなたの話した内容だけを認識に送ります。事前に声紋の登録が必要です。あなたと同時に話された声は完全には取り除けません。",+ "unsupported": "現在のバージョンは声紋に対応していません。最新バージョンに更新してください。",+ "privacy": "声紋はこのスマートフォンにだけ暗号化して保存され、アップロードや他のデバイスへの同期は行われません。",+ "model": {+ "title": "認識モデル",+ "needed": "初回は約 {{size}} の認識モデルをダウンロードします。Wi-Fi の利用をおすすめします。",+ "download": "認識モデルをダウンロード",+ "downloading": "ダウンロード中({{done}} / {{total}})",+ "cancel": "ダウンロードをキャンセル",+ "retry": "もう一度ダウンロード",+ "failed": {+ "network": "認識モデルのダウンロードに失敗しました。ネットワークを確認してもう一度お試しください。",+ "disk": "認識モデルを保存できませんでした。スマートフォンの空き容量を確認してもう一度お試しください。",+ "checksum": "ダウンロードした認識モデルの検証に失敗しました。もう一度お試しください。",+ "unavailable": "現在、認識モデルを取得できません。しばらくしてからもう一度お試しください。"+ }+ },+ "profile": {+ "title": "声紋",+ "missing": "声紋が未登録です",+ "missingHint": "声紋を登録すると有効になります。約 20 秒かかります。",+ "enrolled": "声紋を登録済み",+ "enrolledAt": "{{date}} に登録",+ "enroll": "声紋を登録",+ "reenroll": "登録し直す",+ "delete": "声紋を削除",+ "deleteConfirm": {+ "title": "声紋を削除しますか?",+ "description": "削除すると、もう一度登録するまで音声入力で周りの人の声を除外しなくなります。",+ "confirm": "削除",+ "cancel": "キャンセル"+ }+ },+ "strictness": {+ "label": "厳しさ",+ "hint": "厳しくするほど周りの人の声が入りにくくなりますが、騒がしい場所では自分の言葉も途切れやすくなります。",+ "restoreDefault": "デフォルトに戻す",+ "options": {+ "relaxed": "ゆるめ",+ "standard": "標準",+ "strict": "厳しめ"+ }+ },+ "enroll": {+ "description": "普段音声入力を使う場所で、下の {{clips}} つの文章をいつもの話し方で読み上げてください。1 つにつき {{seconds}} 秒録音します。録音中は他の人が話さないようにしてください。",+ "step": "{{current}} / {{total}} つ目",+ "record": "読み上げを開始",+ "rerecord": "この文章を録り直す",+ "recording": "残り {{seconds}} 秒",+ "saving": "声紋を作成中…",+ "submit": "登録を完了",+ "cancel": "キャンセル",+ "passages": {+ "p1": "今日の午前中は今週の作業予定を整理して、午後には話し合いたい課題をまとめて、みんなに先に送っておきます。",+ "p2": "明日天気が良ければ少し早めに出発して、途中で果物やお菓子を買い、お昼は公園で食べましょう。",+ "p3": "この文章をもう少し簡潔にして、重要な数字と結論は残したうえで、要点を三つから五つの文でまとめてください。"+ },+ "errors": {+ "too_short": "{{index}} つ目の録音は話している時間が短すぎます。長く止まらずに読み上げて、録り直してください。",+ "no_embedding": "{{index}} つ目の録音から声紋を読み取れませんでした。録り直してください。",+ "inconsistent": "{{index}} つ目の録音が他と同じ人の声に聞こえません。他の人の声や雑音が入った可能性があります。録り直してください。",+ "models_missing": "認識モデルのダウンロードがまだ完了していません。しばらくしてからお試しください。",+ "storage_unavailable": "システムのキーチェーンを利用できないため、声紋を暗号化して保存できません。しばらくしてからお試しください。",+ "failed": "声紋を作成できませんでした。もう一度お試しください。",+ "microphone": "マイクを使用できません。マイクの許可を確認してもう一度お試しください。",+ "noAudio": "マイクから音が届いていません。確認してもう一度お試しください。"+ }+ }+ },"deviceNameEditor": {"screenTitle": "デバイス名","placeholder": "この端末の名前",diff --git a/apps/mobile/src/i18n/locales/ko/settings.json b/apps/mobile/src/i18n/locales/ko/settings.jsonindex 713f24f34f..a5f78ad777 100644--- a/apps/mobile/src/i18n/locales/ko/settings.json+++ b/apps/mobile/src/i18n/locales/ko/settings.json@@ -192,6 +192,84 @@"offlineHint": "컴퓨터가 오프라인입니다. 마지막으로 동기화한 사전을 표시합니다.","noDesktops": "컴퓨터에서 같은 계정으로 로그인하면 사전이 동기화됩니다."},+ "voiceSpeakerFilter": {+ "actionFailed": "변경 사항을 저장하지 못했습니다. 다시 시도해 주세요.",+ "title": "내 목소리 인식",+ "sectionTitle": "성문 필터",+ "label": "내 목소리 인식",+ "entryHint": "음성 입력 중 주변 사람의 목소리를 음소거합니다. 성문은 이 휴대폰에만 저장됩니다.",+ "openAccessibility": "내 목소리 인식 설정 열기",+ "on": "켜짐",+ "off": "꺼짐",+ "hint": "음성 입력 중 주변 사람의 목소리를 음소거하고 내가 말한 내용만 인식에 보냅니다. 먼저 성문을 등록해야 하며, 나와 동시에 말한 소리는 완전히 걸러지지 않습니다.",+ "unsupported": "현재 설치된 버전은 성문을 지원하지 않습니다. 최신 버전으로 업데이트하세요.",+ "privacy": "성문은 이 휴대폰에만 암호화되어 저장되며, 업로드되거나 다른 기기로 동기화되지 않습니다.",+ "model": {+ "title": "인식 모델",+ "needed": "처음 사용할 때 약 {{size}}의 인식 모델을 다운로드합니다. Wi-Fi 연결을 권장합니다.",+ "download": "인식 모델 다운로드",+ "downloading": "다운로드 중({{done}} / {{total}})",+ "cancel": "다운로드 취소",+ "retry": "다시 다운로드",+ "failed": {+ "network": "인식 모델을 다운로드하지 못했습니다. 네트워크를 확인한 후 다시 시도하세요.",+ "disk": "인식 모델을 저장하지 못했습니다. 휴대폰 저장 공간을 확인한 후 다시 시도하세요.",+ "checksum": "다운로드한 인식 모델의 검증에 실패했습니다. 다시 시도하세요.",+ "unavailable": "지금은 인식 모델을 가져올 수 없습니다. 잠시 후 다시 시도하세요."+ }+ },+ "profile": {+ "title": "성문",+ "missing": "등록된 성문이 없습니다",+ "missingHint": "성문을 등록하면 적용됩니다. 약 20초 걸립니다.",+ "enrolled": "성문 등록됨",+ "enrolledAt": "{{date}} 등록",+ "enroll": "성문 등록",+ "reenroll": "다시 등록",+ "delete": "성문 삭제",+ "deleteConfirm": {+ "title": "성문을 삭제할까요?",+ "description": "삭제하면 다시 등록할 때까지 음성 입력에서 주변 사람의 목소리를 걸러내지 않습니다.",+ "confirm": "삭제",+ "cancel": "취소"+ }+ },+ "strictness": {+ "label": "엄격도",+ "hint": "엄격할수록 주변 사람의 목소리가 덜 들어가지만, 시끄러운 곳에서는 내 말도 더 잘릴 수 있습니다.",+ "restoreDefault": "기본값으로 복원",+ "options": {+ "relaxed": "느슨하게",+ "standard": "표준",+ "strict": "엄격하게"+ }+ },+ "enroll": {+ "description": "평소 음성 입력을 사용하는 곳에서 아래 문장 {{clips}}개를 평소 말투로 읽어 주세요. 문장마다 {{seconds}}초씩 녹음합니다. 녹음하는 동안 다른 사람이 말하지 않도록 해 주세요.",+ "step": "{{current}} / {{total}}번째 문장",+ "record": "읽기 시작",+ "rerecord": "이 문장 다시 녹음",+ "recording": "{{seconds}}초 남음",+ "saving": "성문 만드는 중…",+ "submit": "등록 완료",+ "cancel": "취소",+ "passages": {+ "p1": "오늘 오전에는 이번 주 업무 일정을 정리하고, 오후에는 논의할 문제를 정리해서 모두에게 미리 보내 두겠습니다.",+ "p2": "내일 날씨가 좋으면 조금 일찍 출발해서 가는 길에 과일과 간식을 사고, 점심은 공원에서 먹어요.",+ "p3": "이 내용을 좀 더 간결하게 다듬고, 중요한 숫자와 결론은 남긴 다음 핵심을 세 문장에서 다섯 문장으로 요약해 주세요."+ },+ "errors": {+ "too_short": "{{index}}번째 녹음은 말한 시간이 너무 짧습니다. 오래 멈추지 말고 다시 녹음하세요.",+ "no_embedding": "{{index}}번째 녹음에서 성문을 읽지 못했습니다. 다시 녹음하세요.",+ "inconsistent": "{{index}}번째 녹음이 다른 녹음과 같은 사람의 목소리로 들리지 않습니다. 다른 사람의 목소리나 소음이 섞였을 수 있으니 다시 녹음하세요.",+ "models_missing": "인식 모델 다운로드가 아직 끝나지 않았습니다. 잠시 후 다시 시도하세요.",+ "storage_unavailable": "시스템 키체인을 사용할 수 없어 성문을 암호화해 저장할 수 없습니다. 잠시 후 다시 시도하세요.",+ "failed": "성문을 만들지 못했습니다. 다시 시도하세요.",+ "microphone": "마이크를 사용할 수 없습니다. 마이크 권한을 확인한 후 다시 시도하세요.",+ "noAudio": "마이크에서 소리가 들어오지 않습니다. 확인한 후 다시 시도하세요."+ }+ }+ },"deviceNameEditor": {"screenTitle": "기기 이름","placeholder": "이 기기 이름",diff --git a/apps/mobile/src/i18n/locales/zh-CN/settings.json b/apps/mobile/src/i18n/locales/zh-CN/settings.jsonindex 156f248ca2..a93979e18c 100644--- a/apps/mobile/src/i18n/locales/zh-CN/settings.json+++ b/apps/mobile/src/i18n/locales/zh-CN/settings.json@@ -192,6 +192,84 @@"offlineHint": "电脑不在线,正在显示上次同步的词典","noDesktops": "在电脑上登录同一账号,即可同步词典"},+ "voiceSpeakerFilter": {+ "actionFailed": "操作未能保存,请重试。",+ "title": "识别我的声音",+ "sectionTitle": "声纹过滤",+ "label": "识别我的声音",+ "entryHint": "语音输入时把旁人的声音静音。声纹只保存在这台手机上。",+ "openAccessibility": "打开识别我的声音设置",+ "on": "已开启",+ "off": "未开启",+ "hint": "语音输入时把旁人的声音静音,只把你说的话送去识别。需要先录入声纹;别人和你同时说话时无法完全滤掉。",+ "unsupported": "当前安装的版本不支持声纹识别,请更新到最新版本。",+ "privacy": "声纹只保存在这台手机上并加密存储,不会上传,也不会同步到其他设备。",+ "model": {+ "title": "识别模型",+ "needed": "首次使用需要下载约 {{size}} 的识别模型,建议连接 Wi-Fi。",+ "download": "下载识别模型",+ "downloading": "正在下载({{done}} / {{total}})",+ "cancel": "取消下载",+ "retry": "重新下载",+ "failed": {+ "network": "识别模型下载失败,请检查网络后重试。",+ "disk": "识别模型无法保存,请检查手机存储空间后重试。",+ "checksum": "下载的识别模型校验未通过,请重试。",+ "unavailable": "暂时无法获取识别模型,请稍后重试。"+ }+ },+ "profile": {+ "title": "声纹",+ "missing": "还没有录入声纹",+ "missingHint": "录入声纹后才会生效,大约需要 20 秒。",+ "enrolled": "已录入声纹",+ "enrolledAt": "{{date}} 录入",+ "enroll": "录入声纹",+ "reenroll": "重新录入",+ "delete": "删除声纹",+ "deleteConfirm": {+ "title": "删除声纹?",+ "description": "删除后语音输入不再过滤旁人的声音,直到你重新录入。",+ "confirm": "删除",+ "cancel": "取消"+ }+ },+ "strictness": {+ "label": "灵敏度",+ "hint": "越严格越不容易放进旁人的声音,但在嘈杂环境里也更容易剪掉你自己的话。",+ "restoreDefault": "恢复默认",+ "options": {+ "relaxed": "宽松",+ "standard": "标准",+ "strict": "严格"+ }+ },+ "enroll": {+ "description": "请在平时使用语音输入的地方,用平常的语气朗读下面 {{clips}} 段文字,每段录音 {{seconds}} 秒。录音时请不要让别人说话。",+ "step": "第 {{current}} / {{total}} 段",+ "record": "开始朗读",+ "rerecord": "重录这段",+ "recording": "还剩 {{seconds}} 秒",+ "saving": "正在生成声纹…",+ "submit": "完成录入",+ "cancel": "取消",+ "passages": {+ "p1": "今天上午我先整理一下这周的工作安排,下午再把需要讨论的问题列出来,发给大家提前看看。",+ "p2": "如果明天的天气不错,我们可以早点出发,路上顺便买些水果和零食,中午就在公园里吃饭。",+ "p3": "请帮我把这段内容改得更简洁一些,保留关键数字和结论,然后用三到五句话总结一下重点。"+ },+ "errors": {+ "too_short": "第 {{index}} 段里说话的时间太短,请重录这段,朗读时不要停顿太久。",+ "no_embedding": "第 {{index}} 段没能识别出声纹,请重录这段。",+ "inconsistent": "第 {{index}} 段和其他几段不像同一个人,可能混进了别人的声音或噪音,请重录这段。",+ "models_missing": "识别模型还没有下载完成,请稍后再试。",+ "storage_unavailable": "系统钥匙串暂时不可用,声纹无法加密保存,请稍后重试。",+ "failed": "生成声纹失败,请重试。",+ "microphone": "无法使用麦克风,请检查麦克风权限后重试。",+ "noAudio": "麦克风没有传来声音,请检查后重试。"+ }+ }+ },"deviceNameEditor": {"screenTitle": "设备名称","placeholder": "本机名称",diff --git a/apps/mobile/src/i18n/locales/zh-TW/settings.json b/apps/mobile/src/i18n/locales/zh-TW/settings.jsonindex 046628a1f5..c3f8afb273 100644--- a/apps/mobile/src/i18n/locales/zh-TW/settings.json+++ b/apps/mobile/src/i18n/locales/zh-TW/settings.json@@ -192,6 +192,84 @@"offlineHint": "電腦不在線上,正在顯示上次同步的詞典","noDesktops": "在電腦上登入同一帳號,即可同步詞典"},+ "voiceSpeakerFilter": {+ "actionFailed": "操作未能儲存,請重試。",+ "title": "辨識我的聲音",+ "sectionTitle": "聲紋過濾",+ "label": "辨識我的聲音",+ "entryHint": "語音輸入時將旁人的聲音靜音。聲紋只儲存在這支手機上。",+ "openAccessibility": "開啟辨識我的聲音設定",+ "on": "已開啟",+ "off": "未開啟",+ "hint": "語音輸入時將旁人的聲音靜音,只把你說的話送去辨識。需要先錄製聲紋;別人和你同時說話時無法完全濾掉。",+ "unsupported": "目前安裝的版本不支援聲紋辨識,請更新到最新版本。",+ "privacy": "聲紋只儲存在這支手機上並加密保存,不會上傳,也不會同步到其他裝置。",+ "model": {+ "title": "辨識模型",+ "needed": "首次使用需要下載約 {{size}} 的辨識模型,建議連接 Wi-Fi。",+ "download": "下載辨識模型",+ "downloading": "正在下載({{done}} / {{total}})",+ "cancel": "取消下載",+ "retry": "重新下載",+ "failed": {+ "network": "辨識模型下載失敗,請檢查網路後重試。",+ "disk": "辨識模型無法儲存,請檢查手機儲存空間後重試。",+ "checksum": "下載的辨識模型驗證未通過,請重試。",+ "unavailable": "暫時無法取得辨識模型,請稍後再試。"+ }+ },+ "profile": {+ "title": "聲紋",+ "missing": "尚未錄製聲紋",+ "missingHint": "錄製聲紋後才會生效,大約需要 20 秒。",+ "enrolled": "已錄製聲紋",+ "enrolledAt": "{{date}} 錄製",+ "enroll": "錄製聲紋",+ "reenroll": "重新錄製",+ "delete": "刪除聲紋",+ "deleteConfirm": {+ "title": "刪除聲紋?",+ "description": "刪除後語音輸入不再過濾旁人的聲音,直到你重新錄製。",+ "confirm": "刪除",+ "cancel": "取消"+ }+ },+ "strictness": {+ "label": "靈敏度",+ "hint": "越嚴格越不容易放進旁人的聲音,但在吵雜環境中也更容易剪掉你自己的話。",+ "restoreDefault": "恢復預設",+ "options": {+ "relaxed": "寬鬆",+ "standard": "標準",+ "strict": "嚴格"+ }+ },+ "enroll": {+ "description": "請在平常使用語音輸入的地方,用平常的語氣朗讀下面 {{clips}} 段文字,每段錄音 {{seconds}} 秒。錄音時請不要讓別人說話。",+ "step": "第 {{current}} / {{total}} 段",+ "record": "開始朗讀",+ "rerecord": "重錄這段",+ "recording": "還剩 {{seconds}} 秒",+ "saving": "正在產生聲紋…",+ "submit": "完成錄製",+ "cancel": "取消",+ "passages": {+ "p1": "今天上午我先整理一下這週的工作安排,下午再把需要討論的問題列出來,傳給大家提前看看。",+ "p2": "如果明天天氣不錯,我們可以早點出發,路上順便買些水果和零食,中午就在公園裡吃飯。",+ "p3": "請幫我把這段內容改得更簡潔一些,保留關鍵數字和結論,然後用三到五句話總結重點。"+ },+ "errors": {+ "too_short": "第 {{index}} 段裡說話的時間太短,請重錄這段,朗讀時不要停頓太久。",+ "no_embedding": "第 {{index}} 段沒能辨識出聲紋,請重錄這段。",+ "inconsistent": "第 {{index}} 段和其他幾段不像同一個人,可能混入了別人的聲音或噪音,請重錄這段。",+ "models_missing": "辨識模型尚未下載完成,請稍後再試。",+ "storage_unavailable": "系統鑰匙圈暫時無法使用,聲紋無法加密儲存,請稍後再試。",+ "failed": "產生聲紋失敗,請重試。",+ "microphone": "無法使用麥克風,請檢查麥克風權限後重試。",+ "noAudio": "麥克風沒有傳來聲音,請檢查後重試。"+ }+ }+ },"deviceNameEditor": {"screenTitle": "裝置名稱","placeholder": "本機名稱",diff --git a/apps/mobile/src/session/mobileSpeakerEnrollmentRecorder.ts b/apps/mobile/src/session/mobileSpeakerEnrollmentRecorder.tsnew file mode 100644index 0000000000..9922c80ac5--- /dev/null+++ b/apps/mobile/src/session/mobileSpeakerEnrollmentRecorder.ts@@ -0,0 +1,122 @@+import { SPEAKER_GATE_SAMPLE_RATE } from '@cindy/voice-input-core';+import { getRecordingPermissionsAsync, requestRecordingPermissionsAsync } from 'expo-audio';+import { AppState } from 'react-native';++import { startMobileRealtimeAudio } from './mobileRealtimeAudio';+import { resolveMobileVoiceRecordingPermission, waitForMobileVoiceAppActive } from './mobileVoiceStartup';++export class MobileSpeakerEnrollmentAbortedError extends Error {+ constructor() {+ super('speaker enrollment recording aborted');+ this.name = 'MobileSpeakerEnrollmentAbortedError';+ }+}++export class MobileSpeakerEnrollmentNoAudioError extends Error {+ constructor() {+ super('microphone delivered no audio');+ this.name = 'MobileSpeakerEnrollmentNoAudioError';+ }+}++/** A stalled microphone fails the clip instead of hanging the screen. */+const NO_AUDIO_GRACE_MS = 5_000;++type RecordOptions = {+ durationMs: number;+ /** Elapsed fraction in [0, 1]. */+ onProgress?: (fraction: number) => void;+ signal?: AbortSignal;+ /** Injection point for tests. */+ startAudio?: typeof startMobileRealtimeAudio;+};++/**+ * Records one read-aloud clip for voiceprint enrollment as PCM16 mono 16 kHz,+ * through the same capture dictation uses, so the voiceprint matches the+ * audio the gate later judges. Stops by itself after `durationMs`.+ */+export async function recordMobileSpeakerClip(options: RecordOptions): Promise<ArrayBuffer> {+ if (options.signal?.aborted) throw new MobileSpeakerEnrollmentAbortedError();+ const startAudio = options.startAudio ?? startMobileRealtimeAudio;+ const targetSamples = Math.round((options.durationMs / 1000) * SPEAKER_GATE_SAMPLE_RATE);+ const chunks: Int16Array[] = [];+ let samples = 0;+ let failure: Error | null = null;+ let finish: () => void = () => {};+ const done = new Promise<void>((resolve) => {+ finish = resolve;+ });++ const lifecycle = new AbortController();+ const onAbort = (): void => {+ lifecycle.abort();+ finish();+ };+ options.signal?.addEventListener('abort', onAbort, { once: true });+ const subscribeToAppState = (listener: (state: string) => void): (() => void) => {+ const subscription = AppState.addEventListener('change', listener);+ return () => subscription.remove();+ };+ let removeBackgroundListener: (() => void) | undefined;+ let stop: (() => Promise<void>) | null = null;+ let watchdog: ReturnType<typeof setTimeout> | undefined;+ try {+ const permission = await resolveMobileVoiceRecordingPermission({+ getPermission: getRecordingPermissionsAsync,+ requestPermission: requestRecordingPermissionsAsync,+ isRequestCurrent: () => !lifecycle.signal.aborted,+ isAppActive: () => AppState.currentState === 'active',+ subscribeToAppState,+ signal: lifecycle.signal,+ waitForAppActive: () => waitForMobileVoiceAppActive({+ isAppActive: () => AppState.currentState === 'active',+ subscribe: subscribeToAppState,+ signal: lifecycle.signal,+ }),+ });+ if (permission === 'cancelled') throw new MobileSpeakerEnrollmentAbortedError();+ if (permission === 'denied') throw new Error('microphone permission denied');+ removeBackgroundListener = subscribeToAppState((state) => {+ if (state !== 'active') onAbort();+ });+ stop = await startAudio({+ sampleRate: SPEAKER_GATE_SAMPLE_RATE,+ onChunk: (chunk) => {+ if (lifecycle.signal.aborted || samples >= targetSamples) return;+ const pcm = new Int16Array(chunk.pcm16.slice(0, chunk.pcm16.byteLength - (chunk.pcm16.byteLength % 2)));+ chunks.push(pcm);+ samples += pcm.length;+ options.onProgress?.(Math.min(1, samples / targetSamples));+ if (samples >= targetSamples) finish();+ },+ onError: (error) => {+ failure = error;+ finish();+ },+ });+ watchdog = setTimeout(finish, options.durationMs + NO_AUDIO_GRACE_MS);+ await done;+ } catch (error) {+ if (lifecycle.signal.aborted) throw new MobileSpeakerEnrollmentAbortedError();+ throw error;+ } finally {+ clearTimeout(watchdog);+ removeBackgroundListener?.();+ options.signal?.removeEventListener('abort', onAbort);+ await stop?.().catch(() => undefined);+ }+ if (lifecycle.signal.aborted) throw new MobileSpeakerEnrollmentAbortedError();+ if (failure) throw failure;+ if (samples < targetSamples) throw new MobileSpeakerEnrollmentNoAudioError();++ const out = new Int16Array(targetSamples);+ let offset = 0;+ for (const chunk of chunks) {+ const take = Math.min(chunk.length, out.length - offset);+ if (take <= 0) break;+ out.set(chunk.subarray(0, take), offset);+ offset += take;+ }+ return out.buffer;+}diff --git a/apps/mobile/src/session/mobileSpeakerFilter.ts b/apps/mobile/src/session/mobileSpeakerFilter.tsnew file mode 100644index 0000000000..595e73f792--- /dev/null+++ b/apps/mobile/src/session/mobileSpeakerFilter.ts@@ -0,0 +1,597 @@+import AsyncStorage from '@react-native-async-storage/async-storage';+import * as FileSystem from 'expo-file-system/legacy';+import {+ buildSpeakerEnrollment,+ createOnnxSpeakerEnrollmentEngine,+ createOnnxSpeakerGateEngine,+ DEFAULT_SPEAKER_GATE_STRICTNESS,+ isSpeakerGateStrictness,+ pcm16ToFloat,+ SPEAKER_GATE_SAMPLE_RATE,+ SPEAKER_GATE_STRICTNESS_THRESHOLDS,+ SPEAKER_MODEL_ASSETS,+ SPEAKER_MODEL_TOTAL_BYTES,+ SpeakerGate,+ speakerModelAsset,+ speakerModelCdnPath,+ speakerModelLocalName,+ type SpeakerEnrollmentFailure,+ type SpeakerGateStrictness,+ type SpeakerModelAsset,+ type SpeakerOnnxRunner,+} from '@cindy/voice-input-core';++import { getMobileAuthOwner, isMobileAuthOwnerCurrent, subscribeMobileAuthOwner, type MobileAuthOwnerGeneration } from '@/auth/authOwnerGeneration';+import { deleteSecureItem, getSecureItem, setSecureItem } from '@/auth/secureStorage';+import { ENDPOINT_MANIFEST_BASE_URL } from '@/config/env';+import {+ isSpeakerOnnxAvailable,+ loadSpeakerModels,+ nativeSpeakerOnnxRunner,+ sha256File,+} from '../../modules/cindy-speaker-onnx/src';+import { serializeSpeakerFilterStorage, speakerFilterPrefsKey as prefsKey, speakerProfileKey as profileKey } from './mobileSpeakerFilterStorage';+import { logMobileVoice } from './mobileVoiceDiagnostics';++/*+ * "Recognize my voice" on mobile. Same models, thresholds and gate as desktop;+ * inference runs through ONNX Runtime in the cindy-speaker-onnx module.+ *+ * Everything dictation start needs is kept in memory so building the gate+ * never adds an await before the microphone opens. When anything is not+ * ready the run is simply not filtered.+ *+ * The voiceprint is biometric data: it stays on this device, in the OS+ * keychain/keystore through SecureStore, one per account, and is never+ * synced, uploaded or logged.+ */++export type MobileSpeakerModelState = 'missing' | 'downloading' | 'ready' | 'failed';++export type MobileSpeakerFilterSnapshot = {+ /** False on binaries built before the native module existed. */+ supported: boolean;+ hydrated: boolean;+ enabled: boolean;+ strictness: SpeakerGateStrictness;+ strictnessCustomized: boolean;+ modelState: MobileSpeakerModelState;+ downloadedBytes: number;+ totalBytes: number;+ downloadError?: 'network' | 'disk' | 'checksum' | 'unavailable';+ enrolled: boolean;+ enrolledAt?: number;+};++export type MobileSpeakerEnrollResult =+ | { ok: true }+ | { ok: false; reason: SpeakerEnrollmentFailure | 'models_missing' | 'storage_unavailable' | 'failed'; clipIndex?: number };++type StoredPrefs = { version: 1; enabled: boolean; strictnessOverride?: SpeakerGateStrictness };+type StoredProfile = { version: 1; embedding: string; createdAt: number; modelSha256: string };+type Profile = { embedding: Float32Array; createdAt: number };++const MAX_EMBEDDING_DIM = 4096;+const DOWNLOAD_STALL_MS = 60_000;++let snapshot: MobileSpeakerFilterSnapshot = initialSnapshot();+let profile: Profile | null = null;+let hydratedFor: string | null = null;+let hydrating: Promise<void> | null = null;+let hydrationOwner: MobileAuthOwnerGeneration | null = null;+let profileRevision = 0;+let prefsRevision = 0;+let downloading: Promise<void> | null = null;+let downloadAbort: AbortController | null = null;+let modelsLoaded: Promise<void> | null = null;+const listeners = new Set<() => void>();+let ownerSubscription: (() => void) | null = null;++function initialSnapshot(): MobileSpeakerFilterSnapshot {+ return {+ supported: isSpeakerOnnxAvailable(),+ hydrated: false,+ enabled: false,+ strictness: DEFAULT_SPEAKER_GATE_STRICTNESS,+ strictnessCustomized: false,+ modelState: 'missing',+ downloadedBytes: 0,+ totalBytes: SPEAKER_MODEL_TOTAL_BYTES,+ enrolled: false,+ };+}++function update(patch: Partial<MobileSpeakerFilterSnapshot>): void {+ snapshot = { ...snapshot, ...patch };+ for (const listener of listeners) listener();+}++export function getMobileSpeakerFilterSnapshot(): MobileSpeakerFilterSnapshot {+ return snapshot;+}++export function subscribeMobileSpeakerFilter(listener: () => void): () => void {+ listeners.add(listener);+ return () => {+ listeners.delete(listener);+ };+}++function modelsDir(): string | null {+ return FileSystem.cacheDirectory ? `${FileSystem.cacheDirectory}voice-models/` : null;+}++function modelPath(asset: SpeakerModelAsset): string | null {+ const dir = modelsDir();+ return dir ? `${dir}${speakerModelLocalName(asset)}` : null;+}++/**+ * Loads this account's switch, voiceprint and model presence into memory.+ * Safe to call often; follows account switches by itself.+ */+export function hydrateMobileSpeakerFilter(): Promise<void> {+ ownerSubscription ??= subscribeMobileAuthOwner(() => {+ void hydrateMobileSpeakerFilter();+ });+ const owner = getMobileAuthOwner();+ if (!hydrationOwner || !isMobileAuthOwnerCurrent(hydrationOwner)) {+ hydrationOwner = owner;+ hydrating = null;+ profile = null;+ hydratedFor = null;+ profileRevision += 1;+ snapshot = {+ ...initialSnapshot(),+ modelState: snapshot.modelState,+ downloadedBytes: snapshot.downloadedBytes,+ downloadError: snapshot.downloadError,+ };+ for (const listener of listeners) listener();+ }+ if (!owner.accountKey || owner.switching) {+ return Promise.resolve();+ }+ if (hydratedFor === owner.accountKey && snapshot.hydrated) return Promise.resolve();+ if (hydrating) return hydrating;+ const run = (async () => {+ const [[prefs, stored], models] = await Promise.all([+ serializeSpeakerFilterStorage(owner.accountKey, () => Promise.all([readPrefs(owner.accountKey), readProfile(owner.accountKey)])),+ modelsInstalled(),+ ]);+ if (!isMobileAuthOwnerCurrent(owner)) return;+ profile = stored;+ hydratedFor = owner.accountKey;+ update({+ supported: isSpeakerOnnxAvailable(),+ hydrated: true,+ enabled: prefs.enabled,+ strictness: prefs.strictnessOverride ?? DEFAULT_SPEAKER_GATE_STRICTNESS,+ strictnessCustomized: prefs.strictnessOverride !== undefined,+ modelState: downloading ? 'downloading' : models ? 'ready' : snapshot.modelState === 'failed' ? 'failed' : 'missing',+ ...(models ? { downloadedBytes: SPEAKER_MODEL_TOTAL_BYTES } : {}),+ enrolled: Boolean(stored),+ enrolledAt: stored?.createdAt,+ });+ })()+ .catch((error) => {+ logMobileVoice('warn', 'speaker filter hydrate failed', { error: errorMessage(error) });+ })+ .finally(() => {+ if (hydrating === run) hydrating = null;+ });+ hydrating = run;+ return run;+}++async function readPrefs(accountKey: string): Promise<{ enabled: boolean; strictnessOverride?: SpeakerGateStrictness }> {+ try {+ const raw = await AsyncStorage.getItem(prefsKey(accountKey));+ if (!raw) return { enabled: false };+ const parsed = JSON.parse(raw) as Partial<StoredPrefs>;+ return {+ enabled: parsed.enabled === true,+ ...(isSpeakerGateStrictness(parsed.strictnessOverride) ? { strictnessOverride: parsed.strictnessOverride } : {}),+ };+ } catch {+ return { enabled: false };+ }+}++async function writePrefs(): Promise<void> {+ const owner = getMobileAuthOwner();+ if (!owner.accountKey || hydratedFor !== owner.accountKey) return;+ const stored: StoredPrefs = {+ version: 1,+ enabled: snapshot.enabled,+ ...(snapshot.strictnessCustomized ? { strictnessOverride: snapshot.strictness } : {}),+ };+ await serializeSpeakerFilterStorage(owner.accountKey, async () => {+ if (isMobileAuthOwnerCurrent(owner)) await AsyncStorage.setItem(prefsKey(owner.accountKey), JSON.stringify(stored));+ });+}++async function readProfile(accountKey: string): Promise<Profile | null> {+ try {+ const raw = await getSecureItem(profileKey(accountKey));+ if (!raw) return null;+ const stored = JSON.parse(raw) as Partial<StoredProfile>;+ // A voiceprint from another embedding model cannot be compared: re-enroll.+ if (stored.version !== 1 || stored.modelSha256 !== speakerModelAsset('embedding').sha256) return null;+ if (typeof stored.embedding !== 'string') return null;+ const embedding = base64ToFloat32(stored.embedding);+ if (embedding.length === 0 || embedding.length > MAX_EMBEDDING_DIM || !embedding.every(Number.isFinite)) return null;+ return { embedding, createdAt: typeof stored.createdAt === 'number' ? stored.createdAt : 0 };+ } catch {+ return null;+ }+}++export async function setMobileSpeakerFilterEnabled(enabled: boolean): Promise<void> {+ const owner = getMobileAuthOwner();+ await hydrateMobileSpeakerFilter();+ if (!owner.accountKey || !isMobileAuthOwnerCurrent(owner)) return;+ const previous = snapshot.enabled;+ const revision = ++prefsRevision;+ update({ enabled });+ try {+ await writePrefs();+ } catch (error) {+ if (isMobileAuthOwnerCurrent(owner) && revision === prefsRevision) update({ enabled: previous });+ throw error;+ }+ if (!isMobileAuthOwnerCurrent(owner)) return;+ // The models are fetched the first time the user turns the filter on.+ if (enabled && (snapshot.modelState === 'missing' || snapshot.modelState === 'failed')) {+ void downloadMobileSpeakerModels();+ }+}++/** `null` restores the version default. */+export async function setMobileSpeakerFilterStrictness(strictness: SpeakerGateStrictness | null): Promise<void> {+ const owner = getMobileAuthOwner();+ await hydrateMobileSpeakerFilter();+ if (!owner.accountKey || !isMobileAuthOwnerCurrent(owner)) return;+ const previous = { strictness: snapshot.strictness, strictnessCustomized: snapshot.strictnessCustomized };+ const revision = ++prefsRevision;+ update(+ strictness === null+ ? { strictness: DEFAULT_SPEAKER_GATE_STRICTNESS, strictnessCustomized: false }+ : { strictness, strictnessCustomized: true },+ );+ try {+ await writePrefs();+ } catch (error) {+ if (isMobileAuthOwnerCurrent(owner) && revision === prefsRevision) update(previous);+ throw error;+ }+}++async function modelsInstalled(): Promise<boolean> {+ for (const asset of SPEAKER_MODEL_ASSETS) {+ const path = modelPath(asset);+ if (!path) return false;+ try {+ const info = await FileSystem.getInfoAsync(path);+ if (!info.exists || info.isDirectory || info.size !== asset.bytes) return false;+ } catch {+ return false;+ }+ }+ return true;+}++/** Starts (or joins) the one-time model download. */+export function downloadMobileSpeakerModels(): Promise<void> {+ if (!snapshot.supported) return Promise.resolve();+ if (downloading) return downloading;+ const controller = new AbortController();+ downloadAbort = controller;+ update({ modelState: 'downloading', downloadedBytes: 0, downloadError: undefined });+ const run = downloadAll(controller.signal)+ .then(() => {+ update({ modelState: 'ready', downloadedBytes: SPEAKER_MODEL_TOTAL_BYTES, downloadError: undefined });+ })+ .catch((error: unknown) => {+ const kind = error instanceof ModelDownloadError ? error.kind : 'network';+ logMobileVoice('warn', 'speaker model download failed', { kind: kind ?? 'cancelled' });+ update({ modelState: kind ? 'failed' : 'missing', downloadedBytes: 0, downloadError: kind ?? undefined });+ })+ .finally(() => {+ if (downloading === run) {+ downloading = null;+ downloadAbort = null;+ }+ });+ downloading = run;+ return run;+}++export function cancelMobileSpeakerModelDownload(): void {+ downloadAbort?.abort();+}++class ModelDownloadError extends Error {+ /** null = cancelled by the user. */+ constructor(readonly kind: MobileSpeakerFilterSnapshot['downloadError'] | null) {+ super(kind ?? 'cancelled');+ }+}++async function downloadAll(signal: AbortSignal): Promise<void> {+ const dir = modelsDir();+ if (!dir || !/^https:\/\//i.test(ENDPOINT_MANIFEST_BASE_URL)) throw new ModelDownloadError('unavailable');+ try {+ await FileSystem.makeDirectoryAsync(dir, { intermediates: true });+ } catch {+ throw new ModelDownloadError('disk');+ }+ let completed = 0;+ for (const asset of SPEAKER_MODEL_ASSETS) {+ const target = modelPath(asset)!;+ if (signal.aborted) throw new ModelDownloadError(null);+ const existing = await FileSystem.getInfoAsync(target).catch(() => null);+ if (existing?.exists && !existing.isDirectory && existing.size === asset.bytes) {+ completed += asset.bytes;+ continue;+ }+ await downloadOne(asset, target, signal, (loaded) => {+ update({ downloadedBytes: completed + Math.min(loaded, asset.bytes) });+ });+ completed += asset.bytes;+ logMobileVoice('info', 'speaker model downloaded', { file: asset.fileName, bytes: asset.bytes });+ }+ await removeStaleModels(dir);+}++async function downloadOne(+ asset: SpeakerModelAsset,+ target: string,+ signal: AbortSignal,+ onProgress: (loaded: number) => void,+): Promise<void> {+ if (signal.aborted) throw new ModelDownloadError(null);+ const partial = `${target}.part`;+ const url = `${ENDPOINT_MANIFEST_BASE_URL}/${speakerModelCdnPath(asset)}`;+ let lastProgressAt = Date.now();+ let lastNotified = 0;+ const task = FileSystem.createDownloadResumable(url, partial, {}, (event) => {+ if (signal.aborted) return;+ lastProgressAt = Date.now();+ if (lastProgressAt - lastNotified >= 250) {+ lastNotified = lastProgressAt;+ onProgress(event.totalBytesWritten);+ }+ });+ let stallTimer: ReturnType<typeof setInterval> | undefined;+ let onAbort: (() => void) | undefined;+ let cancelling: Promise<unknown> | undefined;+ const stopped = new Promise<never>((_, reject) => {+ const stop = (kind: ModelDownloadError['kind']) => {+ cancelling ??= task.cancelAsync().catch(() => undefined);+ reject(new ModelDownloadError(kind));+ };+ onAbort = () => stop(null);+ signal.addEventListener('abort', onAbort, { once: true });+ stallTimer = setInterval(() => {+ if (Date.now() - lastProgressAt > DOWNLOAD_STALL_MS) stop('network');+ }, 5_000);+ });+ // Only the race observes this; once the download settled it may never fire.+ stopped.catch(() => undefined);+ try {+ const result = await Promise.race([task.downloadAsync(), stopped]);+ if (!result) throw new ModelDownloadError('network');+ if (result.status >= 400 && result.status < 500) throw new ModelDownloadError('unavailable');+ if (result.status !== 200) throw new ModelDownloadError('network');+ const info = await FileSystem.getInfoAsync(partial);+ if (!info.exists || info.size !== asset.bytes) throw new ModelDownloadError('checksum');+ // The file only becomes visible to the gate after its content hash matched.+ if ((await sha256File(partial)) !== asset.sha256) throw new ModelDownloadError('checksum');+ if (signal.aborted) throw new ModelDownloadError(null);+ await FileSystem.deleteAsync(target, { idempotent: true });+ await FileSystem.moveAsync({ from: partial, to: target });+ } catch (error) {+ // Wait for native I/O to stop before deleting its destination or retrying.+ await cancelling;+ await FileSystem.deleteAsync(partial, { idempotent: true }).catch(() => undefined);+ if (error instanceof ModelDownloadError) throw error;+ throw new ModelDownloadError(signal.aborted ? null : 'network');+ } finally {+ clearInterval(stallTimer);+ if (onAbort) signal.removeEventListener('abort', onAbort);+ }+}++async function removeStaleModels(dir: string): Promise<void> {+ const keep = new Set(SPEAKER_MODEL_ASSETS.map(speakerModelLocalName));+ try {+ for (const name of await FileSystem.readDirectoryAsync(dir)) {+ if (keep.has(name)) continue;+ await FileSystem.deleteAsync(`${dir}${name}`, { idempotent: true }).catch(() => undefined);+ }+ } catch {+ // Retried on the next download.+ }+}++/** Runner that loads both models on first use and reuses them afterwards. */+const runner: SpeakerOnnxRunner = {+ async run(model, inputs) {+ await ensureModelsLoaded();+ return withInferenceTimeout(nativeSpeakerOnnxRunner.run(model, inputs));+ },+};++/** Enrollment also needs a deadline; the live gate's shorter deadline is not used there. */+async function withInferenceTimeout<T>(operation: Promise<T>): Promise<T> {+ let timer: ReturnType<typeof setTimeout> | undefined;+ try {+ return await Promise.race([operation, new Promise<never>((_, reject) => {+ timer = setTimeout(() => reject(new Error('speaker inference timed out')), 15_000);+ })]);+ } finally {+ clearTimeout(timer);+ }+}++function ensureModelsLoaded(): Promise<void> {+ if (modelsLoaded) return modelsLoaded;+ const vad = modelPath(speakerModelAsset('vad'));+ const embedding = modelPath(speakerModelAsset('embedding'));+ if (!vad || !embedding) return Promise.reject(new Error('speaker models are not installed'));+ const loading = withInferenceTimeout(loadSpeakerModels({ vad, embedding }));+ modelsLoaded = loading;+ // A failed load must not stick; the next run tries again.+ loading.catch(() => {+ if (modelsLoaded === loading) modelsLoaded = null;+ });+ return loading;+}++/** Loads the models ahead of the first chunk (call from voice prewarm). */+export function warmMobileSpeakerFilter(): void {+ void hydrateMobileSpeakerFilter().then(() => {+ if (snapshot.enabled && snapshot.enrolled && snapshot.modelState === 'ready') {+ ensureModelsLoaded().catch(() => undefined);+ }+ });+}++/**+ * The gate for one dictation run, or undefined when the filter is off or not+ * ready. Synchronous by design: it never delays opening the microphone.+ */+export function createMobileSpeakerGate(): SpeakerGate | undefined {+ void hydrateMobileSpeakerFilter();+ const owner = getMobileAuthOwner();+ if (!snapshot.supported || !snapshot.enabled || hydratedFor !== owner.accountKey || !profile) return undefined;+ if (snapshot.modelState !== 'ready') {+ // The OS may have purged the cached models; bring them back for next time.+ if (snapshot.modelState === 'missing') void downloadMobileSpeakerModels();+ return undefined;+ }+ const thresholds = SPEAKER_GATE_STRICTNESS_THRESHOLDS[snapshot.strictness];+ let accepted = 0;+ let rejected = 0;+ return new SpeakerGate({+ engine: createOnnxSpeakerGateEngine(runner),+ enrolledEmbedding: profile.embedding,+ threshold: thresholds.threshold,+ continueThreshold: thresholds.continueThreshold,+ onDecision: (decision) => {+ // Counts and scores only; never audio or the voiceprint.+ if (decision.accepted) accepted += 1;+ else rejected += 1;+ logMobileVoice('debug', 'speaker gate decision', {+ accepted: decision.accepted,+ score: Math.round(decision.score * 100) / 100,+ speechMs: Math.round(((decision.endSample - decision.startSample) / SPEAKER_GATE_SAMPLE_RATE) * 1000),+ computeMs: Math.round(decision.computeMs),+ acceptedSoFar: accepted,+ rejectedSoFar: rejected,+ });+ },+ onPassthrough: (reason) => {+ logMobileVoice('warn', 'speaker gate passthrough', { reason });+ },+ });+}++/** Builds and stores this account's voiceprint from PCM16 16 kHz clips. */+export async function enrollMobileSpeaker(clips: ArrayBuffer[]): Promise<MobileSpeakerEnrollResult> {+ const owner = getMobileAuthOwner();+ await hydrateMobileSpeakerFilter();+ if (!isMobileAuthOwnerCurrent(owner)) return { ok: false, reason: 'failed' };+ if (!owner.accountKey) return { ok: false, reason: 'failed' };+ if (snapshot.modelState !== 'ready') return { ok: false, reason: 'models_missing' };+ const revision = ++profileRevision;+ const current = () => isMobileAuthOwnerCurrent(owner) && revision === profileRevision;+ try {+ const result = await buildSpeakerEnrollment(+ createOnnxSpeakerEnrollmentEngine(runner),+ clips.map((clip) => pcm16ToFloat(clip)),+ );+ if (!result.ok) {+ logMobileVoice('info', 'speaker enrollment rejected', {+ reason: result.reason,+ clipIndex: result.clipIndex,+ selfScore: result.selfScore === undefined ? undefined : Math.round(result.selfScore * 100) / 100,+ });+ return { ok: false, reason: result.reason, clipIndex: result.clipIndex };+ }+ if (!current()) return { ok: false, reason: 'failed' };+ const createdAt = Date.now();+ const stored: StoredProfile = {+ version: 1,+ embedding: float32ToBase64(result.embedding),+ createdAt,+ modelSha256: speakerModelAsset('embedding').sha256,+ };+ try {+ await serializeSpeakerFilterStorage(owner.accountKey, async () => {+ if (current()) await setSecureItem(profileKey(owner.accountKey), JSON.stringify(stored));+ });+ } catch {+ return { ok: false, reason: 'storage_unavailable' };+ }+ if (!current()) return { ok: false, reason: 'failed' };+ profile = { embedding: result.embedding, createdAt };+ update({ enrolled: true, enrolledAt: createdAt });+ logMobileVoice('info', 'speaker enrolled', { selfScore: Math.round(result.selfScore * 100) / 100 });+ return { ok: true };+ } catch (error) {+ logMobileVoice('warn', 'speaker enrollment failed', { error: errorMessage(error) });+ return { ok: false, reason: 'failed' };+ }+}++export async function deleteMobileSpeakerProfile(): Promise<void> {+ const owner = getMobileAuthOwner();+ if (!owner.accountKey) return;+ const revision = ++profileRevision;+ await serializeSpeakerFilterStorage(owner.accountKey, () => deleteSecureItem(profileKey(owner.accountKey)));+ if (!isMobileAuthOwnerCurrent(owner)) return;+ if (revision !== profileRevision) return;+ profile = null;+ update({ enrolled: false, enrolledAt: undefined });+ logMobileVoice('info', 'speaker profile deleted');+}++function float32ToBase64(values: Float32Array): string {+ const bytes = new Uint8Array(values.buffer, values.byteOffset, values.byteLength);+ let binary = '';+ for (let i = 0; i < bytes.length; i += 1) binary += String.fromCharCode(bytes[i]);+ return btoa(binary);+}++function base64ToFloat32(base64: string): Float32Array {+ const binary = atob(base64);+ const bytes = new Uint8Array(binary.length);+ for (let i = 0; i < binary.length; i += 1) bytes[i] = binary.charCodeAt(i);+ return new Float32Array(bytes.buffer, 0, Math.floor(bytes.byteLength / 4));+}++function errorMessage(error: unknown): string {+ return error instanceof Error ? error.message : String(error);+}++export const __testing = {+ reset(): void {+ snapshot = initialSnapshot();+ profile = null;+ hydratedFor = null;+ hydrating = null;+ hydrationOwner = null;+ profileRevision = 0;+ prefsRevision = 0;+ downloading = null;+ downloadAbort = null;+ modelsLoaded = null;+ ownerSubscription?.();+ ownerSubscription = null;+ listeners.clear();+ },+ profileKey,+ prefsKey,+};diff --git a/apps/mobile/src/session/mobileSpeakerFilterStorage.ts b/apps/mobile/src/session/mobileSpeakerFilterStorage.tsnew file mode 100644index 0000000000..18560e291e--- /dev/null+++ b/apps/mobile/src/session/mobileSpeakerFilterStorage.ts@@ -0,0 +1,49 @@+import AsyncStorage from '@react-native-async-storage/async-storage';+import { sha256 } from '@noble/hashes/sha256';+import { bytesToHex, utf8ToBytes } from '@noble/hashes/utils';++import { deleteSecureItem } from '@/auth/secureStorage';++/*+ * Storage keys of "recognize my voice", kept apart from the service so sign-out+ * can clear them without loading the file system or the native module.+ */++const PREFS_PREFIX = 'cindy.mobile.voice-speaker-filter.v1.';+// SecureStore keys only allow [A-Za-z0-9._-]; the account key is hashed.+const PROFILE_PREFIX = 'xdt.voiceSpeakerProfile.v1.';+const pending = new Map<string, Promise<unknown>>();++/** Keep deletion (including sign-out) after writes already in flight. */+export function serializeSpeakerFilterStorage<T>(accountKey: string, operation: () => Promise<T>): Promise<T> {+ const run = (pending.get(accountKey) ?? Promise.resolve()).catch(() => undefined).then(operation);+ pending.set(accountKey, run);+ const clear = () => {+ if (pending.get(accountKey) === run) pending.delete(accountKey);+ };+ void run.then(clear, clear);+ return run;+}++export function speakerFilterPrefsKey(accountKey: string): string {+ return PREFS_PREFIX + accountKey;+}++export function speakerProfileKey(accountKey: string): string {+ return PROFILE_PREFIX + bytesToHex(sha256(utf8ToBytes(accountKey))).slice(0, 32);+}++/**+ * Sign-out cleanup: the voiceprint and its settings are this account's+ * biometric data and leave with its other local data. The account-free+ * model files stay. The in-memory copy resets itself when the owner clears.+ */+export async function clearMobileSpeakerFilterForAccount(accountKey: string): Promise<void> {+ if (!accountKey) return;+ await serializeSpeakerFilterStorage(accountKey, async () => {+ await Promise.all([+ deleteSecureItem(speakerProfileKey(accountKey)).catch(() => undefined),+ AsyncStorage.removeItem(speakerFilterPrefsKey(accountKey)).catch(() => undefined),+ ]);+ });+}diff --git a/apps/mobile/src/session/mobileVoiceController.ts b/apps/mobile/src/session/mobileVoiceController.tsindex 15fb3f2a0b..133f86068f 100644--- a/apps/mobile/src/session/mobileVoiceController.ts+++ b/apps/mobile/src/session/mobileVoiceController.ts@@ -5,6 +5,7 @@ import {VoiceInputController,VoiceTimelineLogger,type AsrProvider,+ type AudioGate,type AudioTrace,type DictationRefinementContext,type EditableRange,@@ -107,6 +108,11 @@ type MobileVoiceControllerOptions = {end: number;}) => void;onTimelineEvent?: (event: VoiceTimelineEvent) => void;+ /**+ * Optional filter between the microphone and the ASR ("recognize my voice").+ * Undefined keeps the unfiltered behavior.+ */+ audioGate?: AudioGate;};type MobileVoiceInputHistorySource = readonly string[] | (() => readonly string[] | undefined);@@ -390,6 +396,7 @@ export function createMobileVoiceControllerSession(// A reconnect allocates another managed session and can hit the account// limit; report that instead of the generic "stopped receiving" failure.recoveryErrorMessage: mobileVoiceRateLimitMessage,+ audioGate: options.audioGate,logger: new VoiceTimelineLogger((event) => {recordTimeline(event);options.onTimelineEvent?.(event);diff --git a/docs/dev-rules/credentials-and-local-storage.md b/docs/dev-rules/credentials-and-local-storage.mdindex 871c1f05ad..e1e3fa8d8a 100644--- a/docs/dev-rules/credentials-and-local-storage.md+++ b/docs/dev-rules/credentials-and-local-storage.md@@ -201,6 +201,10 @@ Desktop 的运行时 refresh 遇到瞬时失败后,主动调用与定时重试| macOS 菜单栏 helper(开发构建) | `userData/menubar/`,开发时由 `swiftc` 编译的 helper 及其 wordmark 图片和源码哈希;打包版改用 `resources/tools/menubar/`,不在 userData 落盘 || 供应商分享:受邀者会话登记 | `userData/remote-agent/guest-sessions.json`(控制端摘要 → 本机侧任务与原生会话 id),只用来限制受邀者只能恢复自己的会话,并在分享删除时精确清理影子工作区、附件与会话记录 || 供应商分享:跨区域标记 | `userData/remote-agent/provider-share-regions.json`,账号摘要 → 对方区域;**不含凭证**。跨区连接凭证只在内存里,用新身份名片重新换取;没有标记的账号从不联系对方区域 |+| 语音输入声纹(生物特征) | `userData/owners/<账号>/voice-speaker-profile.json`,「识别我的声音」录入的声纹向量与录入时间,经 `safeStorage` 加密后整体落盘(钥匙串不可用时拒绝写入,不降级明文);记录生成它的模型哈希,换模型后视为未录入。只在本机,不同步、不上传、不进日志(日志只记分数与次数);用户删除即删文件。录入用的朗读音频只在内存中处理,不落盘 |+| 语音输入声纹识别模型 | `userData/voice-models/<哈希前缀>-<文件名>.onnx`,按内容哈希从区域 CDN 下载并在可见前校验 SHA-256;不含个人数据,本机所有账号共用。新版本模型下载完成后删除旧版本文件 |+| Mobile 语音输入声纹(生物特征) | SecureStore(iOS 钥匙串 / Android Keystore)键 `xdt.voiceSpeakerProfile.v1.<账号 key 的 SHA-256 前 32 位>`,内容同 Desktop:声纹向量、录入时间与模型哈希;开关与灵敏度 override 在 AsyncStorage `cindy.mobile.voice-speaker-filter.v1.<账号 key>`。只在本机,不同步、不上传、不进日志;退出登录时随该账号的其他本机数据一起删除(模型文件保留);朗读音频只在内存中处理 |+| Mobile 语音输入声纹识别模型 | `cacheDirectory/voice-models/`,与 Desktop 同一组按内容哈希下载、校验 SHA-256 后才可见的文件;放缓存目录以免进入 iCloud / Android 备份。系统清理缓存后,下次语音输入发现缺失会在后台重新下载,本次不过滤 || 用户明确导出的文件 | 用户选择或任务明确指定的目标路径 |- 内置 Skill 的官方身份只授予当前 manifest 已提交且指纹匹配的 bundle:`.active` 必须是diff --git a/docs/legal/notices/THIRD-PARTY-NOTICES.txt b/docs/legal/notices/THIRD-PARTY-NOTICES.txtindex 3fea5a43aa..2581f47031 100644--- a/docs/legal/notices/THIRD-PARTY-NOTICES.txt+++ b/docs/legal/notices/THIRD-PARTY-NOTICES.txt@@ -465,6 +465,213 @@ Exact bundled library versions:Corresponding build recipes and pinned upstream source locations are available at the exact sharp-libvips tag above. The bundled libvips version is 8.18.3.+------------------------------------------------------------------------------+3D-Speaker CAM++ zh-en advanced (runtime-downloaded model) sha256:aa3cfc16963a10586a9393f5035d6d6b57e98d358b347f80c2a30bf4f00ceba2+License: Apache-2.0+Source: https://modelscope.cn/models/iic/speech_campplus_sv_zh_en_16k-common_advanced+------------------------------------------------------------------------------+Apache License+ Version 2.0, January 2004+ http://www.apache.org/licenses/++ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION++ 1. Definitions.++ "License" shall mean the terms and conditions for use, reproduction,+ and distribution as defined by Sections 1 through 9 of this document.++ "Licensor" shall mean the copyright owner or entity authorized by+ the copyright owner that is granting the License.++ "Legal Entity" shall mean the union of the acting entity and all+ other entities that control, are controlled by, or are under common+ control with that entity. For the purposes of this definition,+ "control" means (i) the power, direct or indirect, to cause the+ direction or management of such entity, whether by contract or+ otherwise, or (ii) ownership of fifty percent (50%) or more of the+ outstanding shares, or (iii) beneficial ownership of such entity.++ "You" (or "Your") shall mean an individual or Legal Entity+ exercising permissions granted by this License.++ "Source" form shall mean the preferred form for making modifications,+ including but not limited to software source code, documentation+ source, and configuration files.++ "Object" form shall mean any form resulting from mechanical+ transformation or translation of a Source form, including but+ not limited to compiled object code, generated documentation,+ and conversions to other media types.++ "Work" shall mean the work of authorship, whether in Source or+ Object form, made available under the License, as indicated by a+ copyright notice that is included in or attached to the work+ (an example is provided in the Appendix below).++ "Derivative Works" shall mean any work, whether in Source or Object+ form, that is based on (or derived from) the Work and for which the+ editorial revisions, annotations, elaborations, or other modifications+ represent, as a whole, an original work of authorship. For the purposes+ of this License, Derivative Works shall not include works that remain+ separable from, or merely link (or bind by name) to the interfaces of,+ the Work and Derivative Works thereof.++ "Contribution" shall mean any work of authorship, including+ the original version of the Work and any modifications or additions+ to that Work or Derivative Works thereof, that is intentionally+ submitted to Licensor for inclusion in the Work by the copyright owner+ or by an individual or Legal Entity authorized to submit on behalf of+ the copyright owner. For the purposes of this definition, "submitted"+ means any form of electronic, verbal, or written communication sent+ to the Licensor or its representatives, including but not limited to+ communication on electronic mailing lists, source code control systems,+ and issue tracking systems that are managed by, or on behalf of, the+ Licensor for the purpose of discussing and improving the Work, but+ excluding communication that is conspicuously marked or otherwise+ designated in writing by the copyright owner as "Not a Contribution."++ "Contributor" shall mean Licensor and any individual or Legal Entity+ on behalf of whom a Contribution has been received by Licensor and+ subsequently incorporated within the Work.++ 2. Grant of Copyright License. Subject to the terms and conditions of+ this License, each Contributor hereby grants to You a perpetual,+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable+ copyright license to reproduce, prepare Derivative Works of,+ publicly display, publicly perform, sublicense, and distribute the+ Work and such Derivative Works in Source or Object form.++ 3. Grant of Patent License. Subject to the terms and conditions of+ this License, each Contributor hereby grants to You a perpetual,+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable+ (except as stated in this section) patent license to make, have made,+ use, offer to sell, sell, import, and otherwise transfer the Work,+ where such license applies only to those patent claims licensable+ by such Contributor that are necessarily infringed by their+ Contribution(s) alone or by combination of their Contribution(s)+ with the Work to which such Contribution(s) was submitted. If You+ institute patent litigation against any entity (including a+ cross-claim or counterclaim in a lawsuit) alleging that the Work+ or a Contribution incorporated within the Work constitutes direct+ or contributory patent infringement, then any patent licenses+ granted to You under this License for that Work shall terminate+ as of the date such litigation is filed.++ 4. Redistribution. You may reproduce and distribute copies of the+ Work or Derivative Works thereof in any medium, with or without+ modifications, and in Source or Object form, provided that You+ meet the following conditions:++ (a) You must give any other recipients of the Work or+ Derivative Works a copy of this License; and++ (b) You must cause any modified files to carry prominent notices+ stating that You changed the files; and++ (c) You must retain, in the Source form of any Derivative Works+ that You distribute, all copyright, patent, trademark, and+ attribution notices from the Source form of the Work,+ excluding those notices that do not pertain to any part of+ the Derivative Works; and++ (d) If the Work includes a "NOTICE" text file as part of its+ distribution, then any Derivative Works that You distribute must+ include a readable copy of the attribution notices contained+ within such NOTICE file, excluding those notices that do not+ pertain to any part of the Derivative Works, in at least one+ of the following places: within a NOTICE text file distributed+ as part of the Derivative Works; within the Source form or+ documentation, if provided along with the Derivative Works; or,+ within a display generated by the Derivative Works, if and+ wherever such third-party notices normally appear. The contents+ of the NOTICE file are for informational purposes only and+ do not modify the License. You may add Your own attribution+ notices within Derivative Works that You distribute, alongside+ or as an addendum to the NOTICE text from the Work, provided+ that such additional attribution notices cannot be construed+ as modifying the License.++ You may add Your own copyright statement to Your modifications and+ may provide additional or different license terms and conditions+ for use, reproduction, or distribution of Your modifications, or+ for any such Derivative Works as a whole, provided Your use,+ reproduction, and distribution of the Work otherwise complies with+ the conditions stated in this License.++ 5. Submission of Contributions. Unless You explicitly state otherwise,+ any Contribution intentionally submitted for inclusion in the Work+ by You to the Licensor shall be under the terms and conditions of+ this License, without any additional terms or conditions.+ Notwithstanding the above, nothing herein shall supersede or modify+ the terms of any separate license agreement you may have executed+ with Licensor regarding such Contributions.++ 6. Trademarks. This License does not grant permission to use the trade+ names, trademarks, service marks, or product names of the Licensor,+ except as required for reasonable and customary use in describing the+ origin of the Work and reproducing the content of the NOTICE file.++ 7. Disclaimer of Warranty. Unless required by applicable law or+ agreed to in writing, Licensor provides the Work (and each+ Contributor provides its Contributions) on an "AS IS" BASIS,+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or+ implied, including, without limitation, any warranties or conditions+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A+ PARTICULAR PURPOSE. You are solely responsible for determining the+ appropriateness of using or redistributing the Work and assume any+ risks associated with Your exercise of permissions under this License.++ 8. Limitation of Liability. In no event and under no legal theory,+ whether in tort (including negligence), contract, or otherwise,+ unless required by applicable law (such as deliberate and grossly+ negligent acts) or agreed to in writing, shall any Contributor be+ liable to You for damages, including any direct, indirect, special,+ incidental, or consequential damages of any character arising as a+ result of this License or out of the use or inability to use the+ Work (including but not limited to damages for loss of goodwill,+ work stoppage, computer failure or malfunction, or any and all+ other commercial damages or losses), even if such Contributor+ has been advised of the possibility of such damages.++ 9. Accepting Warranty or Additional Liability. While redistributing+ the Work or Derivative Works thereof, You may choose to offer,+ and charge a fee for, acceptance of support, warranty, indemnity,+ or other liability obligations and/or rights consistent with this+ License. However, in accepting such obligations, You may act only+ on Your own behalf and on Your sole responsibility, not on behalf+ of any other Contributor, and only if You agree to indemnify,+ defend, and hold each Contributor harmless for any liability+ incurred by, or claims asserted against, such Contributor by reason+ of your accepting any such warranty or additional liability.++ END OF TERMS AND CONDITIONS++ APPENDIX: How to apply the Apache License to your work.++ To apply the Apache License to your work, attach the following+ boilerplate notice, with the fields enclosed by brackets "[]"+ replaced with your own identifying information. (Don't include+ the brackets!) The text should be enclosed in the appropriate+ comment syntax for the file format. We also recommend that a+ file or class name and description of purpose be included on the+ same "printed page" as the copyright notice for easier+ identification within third-party archives.++ Copyright [yyyy] [name of copyright owner]++ Licensed under the Apache License, Version 2.0 (the "License");+ you may not use this file except in compliance with the License.+ You may obtain a copy of the License at++ http://www.apache.org/licenses/LICENSE-2.0++ Unless required by applicable law or agreed to in writing, software+ distributed under the License is distributed on an "AS IS" BASIS,+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ See the License for the specific language governing permissions and+ limitations under the License.+------------------------------------------------------------------------------Android SDK Platform-Tools (bundled binaries) 32.0.0License: LicenseRef-Android-Platform-Tools-Notice@@ -4361,6 +4568,56 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS INTHE SOFTWARE.+------------------------------------------------------------------------------+ONNX Runtime (native inference library) 1.30.0+License: MIT+Source: https://github.com/microsoft/onnxruntime+------------------------------------------------------------------------------+Copyright (c) Microsoft Corporation++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in+all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+THE SOFTWARE.++------------------------------------------------------------------------------+ONNX Runtime (native inference library) bundled with sherpa-onnx-node 1.13.8+License: MIT+Source: https://github.com/microsoft/onnxruntime+------------------------------------------------------------------------------+Copyright (c) Microsoft Corporation++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in+all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+THE SOFTWARE.+------------------------------------------------------------------------------OpenAI Codex CLI (runtime-downloaded binary) 0.159.2License: Apache-2.0@@ -4911,6 +5168,31 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS INTHE SOFTWARE.+------------------------------------------------------------------------------+Silero VAD (runtime-downloaded model) sha256:9e2449e1087496d8d4caba907f23e0bd3f78d91fa552479bb9c23ac09cbb1fd6+License: MIT+Source: https://github.com/snakers4/silero-vad+------------------------------------------------------------------------------+Copyright (c) 2020-present Silero Team++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in+all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+THE SOFTWARE.+------------------------------------------------------------------------------SQLite (compiled into better-sqlite3) see better-sqlite3 package version aboveLicense: LicenseRef-Public-Domain@@ -5210,7 +5492,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.==============================================================================-SECTION 2: npm packages (1439 packages)+SECTION 2: npm packages (1446 packages)==============================================================================- @antfu/[email protected] — MIT — https://github.com/antfu/install-pkg@@ -5938,6 +6220,7 @@ SECTION 2: npm packages (1439 packages)- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo+- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo- [email protected] — Apache-2.0 — https://github.com/coveooss/exponential-backoff- [email protected] — MIT — https://github.com/expressjs/express@@ -6488,6 +6771,12 @@ SECTION 2: npm packages (1439 packages)- [email protected] — MIT — https://github.com/sindresorhus/shell-env- [email protected] — MIT — https://github.com/sindresorhus/shell-path- [email protected] — MIT — http://github.com/ljharb/shell-quote+- [email protected] — Apache-2.0 — https://github.com/csukuangfj/sherpa-onnx+- [email protected] — Apache-2.0 — https://github.com/csukuangfj/sherpa-onnx+- [email protected] — Apache-2.0 — https://github.com/csukuangfj/sherpa-onnx+- [email protected] — Apache-2.0 — https://github.com/csukuangfj/sherpa-onnx+- [email protected] — Apache-2.0 — https://github.com/csukuangfj/sherpa-onnx+- [email protected] — Apache-2.0 — https://github.com/csukuangfj/sherpa-onnx- [email protected] — MIT — https://github.com/ljharb/side-channel- [email protected] — MIT — https://github.com/ljharb/side-channel-list- [email protected] — MIT — https://github.com/ljharb/side-channel-map@@ -30461,7 +30750,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.-------------------------------------------------------------------------------[146] Applies to: npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected]+[146] Applies to: npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected]------------------------------------------------------------------------------The MIT License (MIT)@@ -49617,6 +49906,12 @@ Packages without a standalone license file (license per package.json):- npm:[email protected] (MIT)- npm:[email protected] (ISC)- npm:[email protected] (MIT)+- npm:[email protected] (Apache-2.0)+- npm:[email protected] (Apache-2.0)+- npm:[email protected] (Apache-2.0)+- npm:[email protected] (Apache-2.0)+- npm:[email protected] (Apache-2.0)+- npm:[email protected] (Apache-2.0)- npm:[email protected] (MIT)- npm:[email protected] (MIT)- npm:[email protected] (MIT)diff --git a/docs/legal/notices/desktop-linux.txt b/docs/legal/notices/desktop-linux.txtindex 94d6504903..4a2b32d447 100644--- a/docs/legal/notices/desktop-linux.txt+++ b/docs/legal/notices/desktop-linux.txt@@ -22,6 +22,263 @@ Restricted or proprietary components are disclosed in the companion file.SECTION 1: Non-npm components==============================================================================+------------------------------------------------------------------------------+Silero VAD (runtime-downloaded model) sha256:9e2449e1087496d8d4caba907f23e0bd3f78d91fa552479bb9c23ac09cbb1fd6+License: MIT+Source: https://github.com/snakers4/silero-vad+------------------------------------------------------------------------------+Copyright (c) 2020-present Silero Team++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in+all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+THE SOFTWARE.++------------------------------------------------------------------------------+3D-Speaker CAM++ zh-en advanced (runtime-downloaded model) sha256:aa3cfc16963a10586a9393f5035d6d6b57e98d358b347f80c2a30bf4f00ceba2+License: Apache-2.0+Source: https://modelscope.cn/models/iic/speech_campplus_sv_zh_en_16k-common_advanced+------------------------------------------------------------------------------+Apache License+ Version 2.0, January 2004+ http://www.apache.org/licenses/++ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION++ 1. Definitions.++ "License" shall mean the terms and conditions for use, reproduction,+ and distribution as defined by Sections 1 through 9 of this document.++ "Licensor" shall mean the copyright owner or entity authorized by+ the copyright owner that is granting the License.++ "Legal Entity" shall mean the union of the acting entity and all+ other entities that control, are controlled by, or are under common+ control with that entity. For the purposes of this definition,+ "control" means (i) the power, direct or indirect, to cause the+ direction or management of such entity, whether by contract or+ otherwise, or (ii) ownership of fifty percent (50%) or more of the+ outstanding shares, or (iii) beneficial ownership of such entity.++ "You" (or "Your") shall mean an individual or Legal Entity+ exercising permissions granted by this License.++ "Source" form shall mean the preferred form for making modifications,+ including but not limited to software source code, documentation+ source, and configuration files.++ "Object" form shall mean any form resulting from mechanical+ transformation or translation of a Source form, including but+ not limited to compiled object code, generated documentation,+ and conversions to other media types.++ "Work" shall mean the work of authorship, whether in Source or+ Object form, made available under the License, as indicated by a+ copyright notice that is included in or attached to the work+ (an example is provided in the Appendix below).++ "Derivative Works" shall mean any work, whether in Source or Object+ form, that is based on (or derived from) the Work and for which the+ editorial revisions, annotations, elaborations, or other modifications+ represent, as a whole, an original work of authorship. For the purposes+ of this License, Derivative Works shall not include works that remain+ separable from, or merely link (or bind by name) to the interfaces of,+ the Work and Derivative Works thereof.++ "Contribution" shall mean any work of authorship, including+ the original version of the Work and any modifications or additions+ to that Work or Derivative Works thereof, that is intentionally+ submitted to Licensor for inclusion in the Work by the copyright owner+ or by an individual or Legal Entity authorized to submit on behalf of+ the copyright owner. For the purposes of this definition, "submitted"+ means any form of electronic, verbal, or written communication sent+ to the Licensor or its representatives, including but not limited to+ communication on electronic mailing lists, source code control systems,+ and issue tracking systems that are managed by, or on behalf of, the+ Licensor for the purpose of discussing and improving the Work, but+ excluding communication that is conspicuously marked or otherwise+ designated in writing by the copyright owner as "Not a Contribution."++ "Contributor" shall mean Licensor and any individual or Legal Entity+ on behalf of whom a Contribution has been received by Licensor and+ subsequently incorporated within the Work.++ 2. Grant of Copyright License. Subject to the terms and conditions of+ this License, each Contributor hereby grants to You a perpetual,+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable+ copyright license to reproduce, prepare Derivative Works of,+ publicly display, publicly perform, sublicense, and distribute the+ Work and such Derivative Works in Source or Object form.++ 3. Grant of Patent License. Subject to the terms and conditions of+ this License, each Contributor hereby grants to You a perpetual,+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable+ (except as stated in this section) patent license to make, have made,+ use, offer to sell, sell, import, and otherwise transfer the Work,+ where such license applies only to those patent claims licensable+ by such Contributor that are necessarily infringed by their+ Contribution(s) alone or by combination of their Contribution(s)+ with the Work to which such Contribution(s) was submitted. If You+ institute patent litigation against any entity (including a+ cross-claim or counterclaim in a lawsuit) alleging that the Work+ or a Contribution incorporated within the Work constitutes direct+ or contributory patent infringement, then any patent licenses+ granted to You under this License for that Work shall terminate+ as of the date such litigation is filed.++ 4. Redistribution. You may reproduce and distribute copies of the+ Work or Derivative Works thereof in any medium, with or without+ modifications, and in Source or Object form, provided that You+ meet the following conditions:++ (a) You must give any other recipients of the Work or+ Derivative Works a copy of this License; and++ (b) You must cause any modified files to carry prominent notices+ stating that You changed the files; and++ (c) You must retain, in the Source form of any Derivative Works+ that You distribute, all copyright, patent, trademark, and+ attribution notices from the Source form of the Work,+ excluding those notices that do not pertain to any part of+ the Derivative Works; and++ (d) If the Work includes a "NOTICE" text file as part of its+ distribution, then any Derivative Works that You distribute must+ include a readable copy of the attribution notices contained+ within such NOTICE file, excluding those notices that do not+ pertain to any part of the Derivative Works, in at least one+ of the following places: within a NOTICE text file distributed+ as part of the Derivative Works; within the Source form or+ documentation, if provided along with the Derivative Works; or,+ within a display generated by the Derivative Works, if and+ wherever such third-party notices normally appear. The contents+ of the NOTICE file are for informational purposes only and+ do not modify the License. You may add Your own attribution+ notices within Derivative Works that You distribute, alongside+ or as an addendum to the NOTICE text from the Work, provided+ that such additional attribution notices cannot be construed+ as modifying the License.++ You may add Your own copyright statement to Your modifications and+ may provide additional or different license terms and conditions+ for use, reproduction, or distribution of Your modifications, or+ for any such Derivative Works as a whole, provided Your use,+ reproduction, and distribution of the Work otherwise complies with+ the conditions stated in this License.++ 5. Submission of Contributions. Unless You explicitly state otherwise,+ any Contribution intentionally submitted for inclusion in the Work+ by You to the Licensor shall be under the terms and conditions of+ this License, without any additional terms or conditions.+ Notwithstanding the above, nothing herein shall supersede or modify+ the terms of any separate license agreement you may have executed+ with Licensor regarding such Contributions.++ 6. Trademarks. This License does not grant permission to use the trade+ names, trademarks, service marks, or product names of the Licensor,+ except as required for reasonable and customary use in describing the+ origin of the Work and reproducing the content of the NOTICE file.++ 7. Disclaimer of Warranty. Unless required by applicable law or+ agreed to in writing, Licensor provides the Work (and each+ Contributor provides its Contributions) on an "AS IS" BASIS,+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or+ implied, including, without limitation, any warranties or conditions+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A+ PARTICULAR PURPOSE. You are solely responsible for determining the+ appropriateness of using or redistributing the Work and assume any+ risks associated with Your exercise of permissions under this License.++ 8. Limitation of Liability. In no event and under no legal theory,+ whether in tort (including negligence), contract, or otherwise,+ unless required by applicable law (such as deliberate and grossly+ negligent acts) or agreed to in writing, shall any Contributor be+ liable to You for damages, including any direct, indirect, special,+ incidental, or consequential damages of any character arising as a+ result of this License or out of the use or inability to use the+ Work (including but not limited to damages for loss of goodwill,+ work stoppage, computer failure or malfunction, or any and all+ other commercial damages or losses), even if such Contributor+ has been advised of the possibility of such damages.++ 9. Accepting Warranty or Additional Liability. While redistributing+ the Work or Derivative Works thereof, You may choose to offer,+ and charge a fee for, acceptance of support, warranty, indemnity,+ or other liability obligations and/or rights consistent with this+ License. However, in accepting such obligations, You may act only+ on Your own behalf and on Your sole responsibility, not on behalf+ of any other Contributor, and only if You agree to indemnify,+ defend, and hold each Contributor harmless for any liability+ incurred by, or claims asserted against, such Contributor by reason+ of your accepting any such warranty or additional liability.++ END OF TERMS AND CONDITIONS++ APPENDIX: How to apply the Apache License to your work.++ To apply the Apache License to your work, attach the following+ boilerplate notice, with the fields enclosed by brackets "[]"+ replaced with your own identifying information. (Don't include+ the brackets!) The text should be enclosed in the appropriate+ comment syntax for the file format. We also recommend that a+ file or class name and description of purpose be included on the+ same "printed page" as the copyright notice for easier+ identification within third-party archives.++ Copyright [yyyy] [name of copyright owner]++ Licensed under the Apache License, Version 2.0 (the "License");+ you may not use this file except in compliance with the License.+ You may obtain a copy of the License at++ http://www.apache.org/licenses/LICENSE-2.0++ Unless required by applicable law or agreed to in writing, software+ distributed under the License is distributed on an "AS IS" BASIS,+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ See the License for the specific language governing permissions and+ limitations under the License.++------------------------------------------------------------------------------+ONNX Runtime (native inference library) bundled with sherpa-onnx-node 1.13.8+License: MIT+Source: https://github.com/microsoft/onnxruntime+------------------------------------------------------------------------------+Copyright (c) Microsoft Corporation++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in+all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+THE SOFTWARE.+------------------------------------------------------------------------------ripgrep (bundled binary) 15.1.0License: MIT OR Unlicense@@ -1340,7 +1597,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS INTHE SOFTWARE.==============================================================================-SECTION 2: npm packages (909 packages)+SECTION 2: npm packages (912 packages)==============================================================================- @antfu/[email protected] — MIT — https://github.com/antfu/install-pkg@@ -2151,6 +2408,9 @@ SECTION 2: npm packages (909 packages)- [email protected] — MIT — https://github.com/sindresorhus/shebang-regex- [email protected] — MIT — https://github.com/sindresorhus/shell-env- [email protected] — MIT — https://github.com/sindresorhus/shell-path+- [email protected] — Apache-2.0 — https://github.com/csukuangfj/sherpa-onnx+- [email protected] — Apache-2.0 — https://github.com/csukuangfj/sherpa-onnx+- [email protected] — Apache-2.0 — https://github.com/csukuangfj/sherpa-onnx- [email protected] — MIT — https://github.com/ljharb/side-channel- [email protected] — MIT — https://github.com/ljharb/side-channel-list- [email protected] — MIT — https://github.com/ljharb/side-channel-map@@ -18473,3 +18733,6 @@ Packages without a standalone license file (license per package.json):- npm:[email protected] (MIT)- npm:[email protected] (MIT)- npm:[email protected] (ISC)+- npm:[email protected] (Apache-2.0)+- npm:[email protected] (Apache-2.0)+- npm:[email protected] (Apache-2.0)diff --git a/docs/legal/notices/desktop-macos.txt b/docs/legal/notices/desktop-macos.txtindex 9daf470e59..82721a8f54 100644--- a/docs/legal/notices/desktop-macos.txt+++ b/docs/legal/notices/desktop-macos.txt@@ -22,6 +22,263 @@ Restricted or proprietary components are disclosed in the companion file.SECTION 1: Non-npm components==============================================================================+------------------------------------------------------------------------------+Silero VAD (runtime-downloaded model) sha256:9e2449e1087496d8d4caba907f23e0bd3f78d91fa552479bb9c23ac09cbb1fd6+License: MIT+Source: https://github.com/snakers4/silero-vad+------------------------------------------------------------------------------+Copyright (c) 2020-present Silero Team++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in+all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+THE SOFTWARE.++------------------------------------------------------------------------------+3D-Speaker CAM++ zh-en advanced (runtime-downloaded model) sha256:aa3cfc16963a10586a9393f5035d6d6b57e98d358b347f80c2a30bf4f00ceba2+License: Apache-2.0+Source: https://modelscope.cn/models/iic/speech_campplus_sv_zh_en_16k-common_advanced+------------------------------------------------------------------------------+Apache License+ Version 2.0, January 2004+ http://www.apache.org/licenses/++ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION++ 1. Definitions.++ "License" shall mean the terms and conditions for use, reproduction,+ and distribution as defined by Sections 1 through 9 of this document.++ "Licensor" shall mean the copyright owner or entity authorized by+ the copyright owner that is granting the License.++ "Legal Entity" shall mean the union of the acting entity and all+ other entities that control, are controlled by, or are under common+ control with that entity. For the purposes of this definition,+ "control" means (i) the power, direct or indirect, to cause the+ direction or management of such entity, whether by contract or+ otherwise, or (ii) ownership of fifty percent (50%) or more of the+ outstanding shares, or (iii) beneficial ownership of such entity.++ "You" (or "Your") shall mean an individual or Legal Entity+ exercising permissions granted by this License.++ "Source" form shall mean the preferred form for making modifications,+ including but not limited to software source code, documentation+ source, and configuration files.++ "Object" form shall mean any form resulting from mechanical+ transformation or translation of a Source form, including but+ not limited to compiled object code, generated documentation,+ and conversions to other media types.++ "Work" shall mean the work of authorship, whether in Source or+ Object form, made available under the License, as indicated by a+ copyright notice that is included in or attached to the work+ (an example is provided in the Appendix below).++ "Derivative Works" shall mean any work, whether in Source or Object+ form, that is based on (or derived from) the Work and for which the+ editorial revisions, annotations, elaborations, or other modifications+ represent, as a whole, an original work of authorship. For the purposes+ of this License, Derivative Works shall not include works that remain+ separable from, or merely link (or bind by name) to the interfaces of,+ the Work and Derivative Works thereof.++ "Contribution" shall mean any work of authorship, including+ the original version of the Work and any modifications or additions+ to that Work or Derivative Works thereof, that is intentionally+ submitted to Licensor for inclusion in the Work by the copyright owner+ or by an individual or Legal Entity authorized to submit on behalf of+ the copyright owner. For the purposes of this definition, "submitted"+ means any form of electronic, verbal, or written communication sent+ to the Licensor or its representatives, including but not limited to+ communication on electronic mailing lists, source code control systems,+ and issue tracking systems that are managed by, or on behalf of, the+ Licensor for the purpose of discussing and improving the Work, but+ excluding communication that is conspicuously marked or otherwise+ designated in writing by the copyright owner as "Not a Contribution."++ "Contributor" shall mean Licensor and any individual or Legal Entity+ on behalf of whom a Contribution has been received by Licensor and+ subsequently incorporated within the Work.++ 2. Grant of Copyright License. Subject to the terms and conditions of+ this License, each Contributor hereby grants to You a perpetual,+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable+ copyright license to reproduce, prepare Derivative Works of,+ publicly display, publicly perform, sublicense, and distribute the+ Work and such Derivative Works in Source or Object form.++ 3. Grant of Patent License. Subject to the terms and conditions of+ this License, each Contributor hereby grants to You a perpetual,+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable+ (except as stated in this section) patent license to make, have made,+ use, offer to sell, sell, import, and otherwise transfer the Work,+ where such license applies only to those patent claims licensable+ by such Contributor that are necessarily infringed by their+ Contribution(s) alone or by combination of their Contribution(s)+ with the Work to which such Contribution(s) was submitted. If You+ institute patent litigation against any entity (including a+ cross-claim or counterclaim in a lawsuit) alleging that the Work+ or a Contribution incorporated within the Work constitutes direct+ or contributory patent infringement, then any patent licenses+ granted to You under this License for that Work shall terminate+ as of the date such litigation is filed.++ 4. Redistribution. You may reproduce and distribute copies of the+ Work or Derivative Works thereof in any medium, with or without+ modifications, and in Source or Object form, provided that You+ meet the following conditions:++ (a) You must give any other recipients of the Work or+ Derivative Works a copy of this License; and++ (b) You must cause any modified files to carry prominent notices+ stating that You changed the files; and++ (c) You must retain, in the Source form of any Derivative Works+ that You distribute, all copyright, patent, trademark, and+ attribution notices from the Source form of the Work,+ excluding those notices that do not pertain to any part of+ the Derivative Works; and++ (d) If the Work includes a "NOTICE" text file as part of its+ distribution, then any Derivative Works that You distribute must+ include a readable copy of the attribution notices contained+ within such NOTICE file, excluding those notices that do not+ pertain to any part of the Derivative Works, in at least one+ of the following places: within a NOTICE text file distributed+ as part of the Derivative Works; within the Source form or+ documentation, if provided along with the Derivative Works; or,+ within a display generated by the Derivative Works, if and+ wherever such third-party notices normally appear. The contents+ of the NOTICE file are for informational purposes only and+ do not modify the License. You may add Your own attribution+ notices within Derivative Works that You distribute, alongside+ or as an addendum to the NOTICE text from the Work, provided+ that such additional attribution notices cannot be construed+ as modifying the License.++ You may add Your own copyright statement to Your modifications and+ may provide additional or different license terms and conditions+ for use, reproduction, or distribution of Your modifications, or+ for any such Derivative Works as a whole, provided Your use,+ reproduction, and distribution of the Work otherwise complies with+ the conditions stated in this License.++ 5. Submission of Contributions. Unless You explicitly state otherwise,+ any Contribution intentionally submitted for inclusion in the Work+ by You to the Licensor shall be under the terms and conditions of+ this License, without any additional terms or conditions.+ Notwithstanding the above, nothing herein shall supersede or modify+ the terms of any separate license agreement you may have executed+ with Licensor regarding such Contributions.++ 6. Trademarks. This License does not grant permission to use the trade+ names, trademarks, service marks, or product names of the Licensor,+ except as required for reasonable and customary use in describing the+ origin of the Work and reproducing the content of the NOTICE file.++ 7. Disclaimer of Warranty. Unless required by applicable law or+ agreed to in writing, Licensor provides the Work (and each+ Contributor provides its Contributions) on an "AS IS" BASIS,+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or+ implied, including, without limitation, any warranties or conditions+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A+ PARTICULAR PURPOSE. You are solely responsible for determining the+ appropriateness of using or redistributing the Work and assume any+ risks associated with Your exercise of permissions under this License.++ 8. Limitation of Liability. In no event and under no legal theory,+ whether in tort (including negligence), contract, or otherwise,+ unless required by applicable law (such as deliberate and grossly+ negligent acts) or agreed to in writing, shall any Contributor be+ liable to You for damages, including any direct, indirect, special,+ incidental, or consequential damages of any character arising as a+ result of this License or out of the use or inability to use the+ Work (including but not limited to damages for loss of goodwill,+ work stoppage, computer failure or malfunction, or any and all+ other commercial damages or losses), even if such Contributor+ has been advised of the possibility of such damages.++ 9. Accepting Warranty or Additional Liability. While redistributing+ the Work or Derivative Works thereof, You may choose to offer,+ and charge a fee for, acceptance of support, warranty, indemnity,+ or other liability obligations and/or rights consistent with this+ License. However, in accepting such obligations, You may act only+ on Your own behalf and on Your sole responsibility, not on behalf+ of any other Contributor, and only if You agree to indemnify,+ defend, and hold each Contributor harmless for any liability+ incurred by, or claims asserted against, such Contributor by reason+ of your accepting any such warranty or additional liability.++ END OF TERMS AND CONDITIONS++ APPENDIX: How to apply the Apache License to your work.++ To apply the Apache License to your work, attach the following+ boilerplate notice, with the fields enclosed by brackets "[]"+ replaced with your own identifying information. (Don't include+ the brackets!) The text should be enclosed in the appropriate+ comment syntax for the file format. We also recommend that a+ file or class name and description of purpose be included on the+ same "printed page" as the copyright notice for easier+ identification within third-party archives.++ Copyright [yyyy] [name of copyright owner]++ Licensed under the Apache License, Version 2.0 (the "License");+ you may not use this file except in compliance with the License.+ You may obtain a copy of the License at++ http://www.apache.org/licenses/LICENSE-2.0++ Unless required by applicable law or agreed to in writing, software+ distributed under the License is distributed on an "AS IS" BASIS,+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ See the License for the specific language governing permissions and+ limitations under the License.++------------------------------------------------------------------------------+ONNX Runtime (native inference library) bundled with sherpa-onnx-node 1.13.8+License: MIT+Source: https://github.com/microsoft/onnxruntime+------------------------------------------------------------------------------+Copyright (c) Microsoft Corporation++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in+all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+THE SOFTWARE.+------------------------------------------------------------------------------ripgrep (bundled binary) 15.1.0License: MIT OR Unlicense@@ -1549,7 +1806,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS INTHE SOFTWARE.==============================================================================-SECTION 2: npm packages (909 packages)+SECTION 2: npm packages (912 packages)==============================================================================- @antfu/[email protected] — MIT — https://github.com/antfu/install-pkg@@ -2360,6 +2617,9 @@ SECTION 2: npm packages (909 packages)- [email protected] — MIT — https://github.com/sindresorhus/shebang-regex- [email protected] — MIT — https://github.com/sindresorhus/shell-env- [email protected] — MIT — https://github.com/sindresorhus/shell-path+- [email protected] — Apache-2.0 — https://github.com/csukuangfj/sherpa-onnx+- [email protected] — Apache-2.0 — https://github.com/csukuangfj/sherpa-onnx+- [email protected] — Apache-2.0 — https://github.com/csukuangfj/sherpa-onnx- [email protected] — MIT — https://github.com/ljharb/side-channel- [email protected] — MIT — https://github.com/ljharb/side-channel-list- [email protected] — MIT — https://github.com/ljharb/side-channel-map@@ -18682,3 +18942,6 @@ Packages without a standalone license file (license per package.json):- npm:[email protected] (MIT)- npm:[email protected] (MIT)- npm:[email protected] (ISC)+- npm:[email protected] (Apache-2.0)+- npm:[email protected] (Apache-2.0)+- npm:[email protected] (Apache-2.0)diff --git a/docs/legal/notices/desktop-win.txt b/docs/legal/notices/desktop-win.txtindex 56f2323651..60365374f5 100644--- a/docs/legal/notices/desktop-win.txt+++ b/docs/legal/notices/desktop-win.txt@@ -22,6 +22,263 @@ Restricted or proprietary components are disclosed in the companion file.SECTION 1: Non-npm components==============================================================================+------------------------------------------------------------------------------+Silero VAD (runtime-downloaded model) sha256:9e2449e1087496d8d4caba907f23e0bd3f78d91fa552479bb9c23ac09cbb1fd6+License: MIT+Source: https://github.com/snakers4/silero-vad+------------------------------------------------------------------------------+Copyright (c) 2020-present Silero Team++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in+all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+THE SOFTWARE.++------------------------------------------------------------------------------+3D-Speaker CAM++ zh-en advanced (runtime-downloaded model) sha256:aa3cfc16963a10586a9393f5035d6d6b57e98d358b347f80c2a30bf4f00ceba2+License: Apache-2.0+Source: https://modelscope.cn/models/iic/speech_campplus_sv_zh_en_16k-common_advanced+------------------------------------------------------------------------------+Apache License+ Version 2.0, January 2004+ http://www.apache.org/licenses/++ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION++ 1. Definitions.++ "License" shall mean the terms and conditions for use, reproduction,+ and distribution as defined by Sections 1 through 9 of this document.++ "Licensor" shall mean the copyright owner or entity authorized by+ the copyright owner that is granting the License.++ "Legal Entity" shall mean the union of the acting entity and all+ other entities that control, are controlled by, or are under common+ control with that entity. For the purposes of this definition,+ "control" means (i) the power, direct or indirect, to cause the+ direction or management of such entity, whether by contract or+ otherwise, or (ii) ownership of fifty percent (50%) or more of the+ outstanding shares, or (iii) beneficial ownership of such entity.++ "You" (or "Your") shall mean an individual or Legal Entity+ exercising permissions granted by this License.++ "Source" form shall mean the preferred form for making modifications,+ including but not limited to software source code, documentation+ source, and configuration files.++ "Object" form shall mean any form resulting from mechanical+ transformation or translation of a Source form, including but+ not limited to compiled object code, generated documentation,+ and conversions to other media types.++ "Work" shall mean the work of authorship, whether in Source or+ Object form, made available under the License, as indicated by a+ copyright notice that is included in or attached to the work+ (an example is provided in the Appendix below).++ "Derivative Works" shall mean any work, whether in Source or Object+ form, that is based on (or derived from) the Work and for which the+ editorial revisions, annotations, elaborations, or other modifications+ represent, as a whole, an original work of authorship. For the purposes+ of this License, Derivative Works shall not include works that remain+ separable from, or merely link (or bind by name) to the interfaces of,+ the Work and Derivative Works thereof.++ "Contribution" shall mean any work of authorship, including+ the original version of the Work and any modifications or additions+ to that Work or Derivative Works thereof, that is intentionally+ submitted to Licensor for inclusion in the Work by the copyright owner+ or by an individual or Legal Entity authorized to submit on behalf of+ the copyright owner. For the purposes of this definition, "submitted"+ means any form of electronic, verbal, or written communication sent+ to the Licensor or its representatives, including but not limited to+ communication on electronic mailing lists, source code control systems,+ and issue tracking systems that are managed by, or on behalf of, the+ Licensor for the purpose of discussing and improving the Work, but+ excluding communication that is conspicuously marked or otherwise+ designated in writing by the copyright owner as "Not a Contribution."++ "Contributor" shall mean Licensor and any individual or Legal Entity+ on behalf of whom a Contribution has been received by Licensor and+ subsequently incorporated within the Work.++ 2. Grant of Copyright License. Subject to the terms and conditions of+ this License, each Contributor hereby grants to You a perpetual,+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable+ copyright license to reproduce, prepare Derivative Works of,+ publicly display, publicly perform, sublicense, and distribute the+ Work and such Derivative Works in Source or Object form.++ 3. Grant of Patent License. Subject to the terms and conditions of+ this License, each Contributor hereby grants to You a perpetual,+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable+ (except as stated in this section) patent license to make, have made,+ use, offer to sell, sell, import, and otherwise transfer the Work,+ where such license applies only to those patent claims licensable+ by such Contributor that are necessarily infringed by their+ Contribution(s) alone or by combination of their Contribution(s)+ with the Work to which such Contribution(s) was submitted. If You+ institute patent litigation against any entity (including a+ cross-claim or counterclaim in a lawsuit) alleging that the Work+ or a Contribution incorporated within the Work constitutes direct+ or contributory patent infringement, then any patent licenses+ granted to You under this License for that Work shall terminate+ as of the date such litigation is filed.++ 4. Redistribution. You may reproduce and distribute copies of the+ Work or Derivative Works thereof in any medium, with or without+ modifications, and in Source or Object form, provided that You+ meet the following conditions:++ (a) You must give any other recipients of the Work or+ Derivative Works a copy of this License; and++ (b) You must cause any modified files to carry prominent notices+ stating that You changed the files; and++ (c) You must retain, in the Source form of any Derivative Works+ that You distribute, all copyright, patent, trademark, and+ attribution notices from the Source form of the Work,+ excluding those notices that do not pertain to any part of+ the Derivative Works; and++ (d) If the Work includes a "NOTICE" text file as part of its+ distribution, then any Derivative Works that You distribute must+ include a readable copy of the attribution notices contained+ within such NOTICE file, excluding those notices that do not+ pertain to any part of the Derivative Works, in at least one+ of the following places: within a NOTICE text file distributed+ as part of the Derivative Works; within the Source form or+ documentation, if provided along with the Derivative Works; or,+ within a display generated by the Derivative Works, if and+ wherever such third-party notices normally appear. The contents+ of the NOTICE file are for informational purposes only and+ do not modify the License. You may add Your own attribution+ notices within Derivative Works that You distribute, alongside+ or as an addendum to the NOTICE text from the Work, provided+ that such additional attribution notices cannot be construed+ as modifying the License.++ You may add Your own copyright statement to Your modifications and+ may provide additional or different license terms and conditions+ for use, reproduction, or distribution of Your modifications, or+ for any such Derivative Works as a whole, provided Your use,+ reproduction, and distribution of the Work otherwise complies with+ the conditions stated in this License.++ 5. Submission of Contributions. Unless You explicitly state otherwise,+ any Contribution intentionally submitted for inclusion in the Work+ by You to the Licensor shall be under the terms and conditions of+ this License, without any additional terms or conditions.+ Notwithstanding the above, nothing herein shall supersede or modify+ the terms of any separate license agreement you may have executed+ with Licensor regarding such Contributions.++ 6. Trademarks. This License does not grant permission to use the trade+ names, trademarks, service marks, or product names of the Licensor,+ except as required for reasonable and customary use in describing the+ origin of the Work and reproducing the content of the NOTICE file.++ 7. Disclaimer of Warranty. Unless required by applicable law or+ agreed to in writing, Licensor provides the Work (and each+ Contributor provides its Contributions) on an "AS IS" BASIS,+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or+ implied, including, without limitation, any warranties or conditions+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A+ PARTICULAR PURPOSE. You are solely responsible for determining the+ appropriateness of using or redistributing the Work and assume any+ risks associated with Your exercise of permissions under this License.++ 8. Limitation of Liability. In no event and under no legal theory,+ whether in tort (including negligence), contract, or otherwise,+ unless required by applicable law (such as deliberate and grossly+ negligent acts) or agreed to in writing, shall any Contributor be+ liable to You for damages, including any direct, indirect, special,+ incidental, or consequential damages of any character arising as a+ result of this License or out of the use or inability to use the+ Work (including but not limited to damages for loss of goodwill,+ work stoppage, computer failure or malfunction, or any and all+ other commercial damages or losses), even if such Contributor+ has been advised of the possibility of such damages.++ 9. Accepting Warranty or Additional Liability. While redistributing+ the Work or Derivative Works thereof, You may choose to offer,+ and charge a fee for, acceptance of support, warranty, indemnity,+ or other liability obligations and/or rights consistent with this+ License. However, in accepting such obligations, You may act only+ on Your own behalf and on Your sole responsibility, not on behalf+ of any other Contributor, and only if You agree to indemnify,+ defend, and hold each Contributor harmless for any liability+ incurred by, or claims asserted against, such Contributor by reason+ of your accepting any such warranty or additional liability.++ END OF TERMS AND CONDITIONS++ APPENDIX: How to apply the Apache License to your work.++ To apply the Apache License to your work, attach the following+ boilerplate notice, with the fields enclosed by brackets "[]"+ replaced with your own identifying information. (Don't include+ the brackets!) The text should be enclosed in the appropriate+ comment syntax for the file format. We also recommend that a+ file or class name and description of purpose be included on the+ same "printed page" as the copyright notice for easier+ identification within third-party archives.++ Copyright [yyyy] [name of copyright owner]++ Licensed under the Apache License, Version 2.0 (the "License");+ you may not use this file except in compliance with the License.+ You may obtain a copy of the License at++ http://www.apache.org/licenses/LICENSE-2.0++ Unless required by applicable law or agreed to in writing, software+ distributed under the License is distributed on an "AS IS" BASIS,+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ See the License for the specific language governing permissions and+ limitations under the License.++------------------------------------------------------------------------------+ONNX Runtime (native inference library) bundled with sherpa-onnx-node 1.13.8+License: MIT+Source: https://github.com/microsoft/onnxruntime+------------------------------------------------------------------------------+Copyright (c) Microsoft Corporation++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in+all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+THE SOFTWARE.+------------------------------------------------------------------------------ripgrep (bundled binary) 15.1.0License: MIT OR Unlicense@@ -3912,7 +4169,7 @@ necessary. Here is a sample; alter the names:That's all there is to it!==============================================================================-SECTION 2: npm packages (903 packages)+SECTION 2: npm packages (905 packages)==============================================================================- @antfu/[email protected] — MIT — https://github.com/antfu/install-pkg@@ -4717,6 +4974,8 @@ SECTION 2: npm packages (903 packages)- [email protected] — MIT — https://github.com/sindresorhus/shebang-regex- [email protected] — MIT — https://github.com/sindresorhus/shell-env- [email protected] — MIT — https://github.com/sindresorhus/shell-path+- [email protected] — Apache-2.0 — https://github.com/csukuangfj/sherpa-onnx+- [email protected] — Apache-2.0 — https://github.com/csukuangfj/sherpa-onnx- [email protected] — MIT — https://github.com/ljharb/side-channel- [email protected] — MIT — https://github.com/ljharb/side-channel-list- [email protected] — MIT — https://github.com/ljharb/side-channel-map@@ -42208,3 +42467,5 @@ Packages without a standalone license file (license per package.json):- npm:[email protected] (MIT)- npm:[email protected] (MIT)- npm:[email protected] (ISC)+- npm:[email protected] (Apache-2.0)+- npm:[email protected] (Apache-2.0)diff --git a/docs/legal/notices/mobile-android.txt b/docs/legal/notices/mobile-android.txtindex 4587414ef1..d39ec278b1 100644--- a/docs/legal/notices/mobile-android.txt+++ b/docs/legal/notices/mobile-android.txt@@ -23,6 +23,263 @@ Restricted or proprietary components are disclosed in the companion file.SECTION 1: Non-npm components==============================================================================+------------------------------------------------------------------------------+Silero VAD (runtime-downloaded model) sha256:9e2449e1087496d8d4caba907f23e0bd3f78d91fa552479bb9c23ac09cbb1fd6+License: MIT+Source: https://github.com/snakers4/silero-vad+------------------------------------------------------------------------------+Copyright (c) 2020-present Silero Team++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in+all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+THE SOFTWARE.++------------------------------------------------------------------------------+3D-Speaker CAM++ zh-en advanced (runtime-downloaded model) sha256:aa3cfc16963a10586a9393f5035d6d6b57e98d358b347f80c2a30bf4f00ceba2+License: Apache-2.0+Source: https://modelscope.cn/models/iic/speech_campplus_sv_zh_en_16k-common_advanced+------------------------------------------------------------------------------+Apache License+ Version 2.0, January 2004+ http://www.apache.org/licenses/++ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION++ 1. Definitions.++ "License" shall mean the terms and conditions for use, reproduction,+ and distribution as defined by Sections 1 through 9 of this document.++ "Licensor" shall mean the copyright owner or entity authorized by+ the copyright owner that is granting the License.++ "Legal Entity" shall mean the union of the acting entity and all+ other entities that control, are controlled by, or are under common+ control with that entity. For the purposes of this definition,+ "control" means (i) the power, direct or indirect, to cause the+ direction or management of such entity, whether by contract or+ otherwise, or (ii) ownership of fifty percent (50%) or more of the+ outstanding shares, or (iii) beneficial ownership of such entity.++ "You" (or "Your") shall mean an individual or Legal Entity+ exercising permissions granted by this License.++ "Source" form shall mean the preferred form for making modifications,+ including but not limited to software source code, documentation+ source, and configuration files.++ "Object" form shall mean any form resulting from mechanical+ transformation or translation of a Source form, including but+ not limited to compiled object code, generated documentation,+ and conversions to other media types.++ "Work" shall mean the work of authorship, whether in Source or+ Object form, made available under the License, as indicated by a+ copyright notice that is included in or attached to the work+ (an example is provided in the Appendix below).++ "Derivative Works" shall mean any work, whether in Source or Object+ form, that is based on (or derived from) the Work and for which the+ editorial revisions, annotations, elaborations, or other modifications+ represent, as a whole, an original work of authorship. For the purposes+ of this License, Derivative Works shall not include works that remain+ separable from, or merely link (or bind by name) to the interfaces of,+ the Work and Derivative Works thereof.++ "Contribution" shall mean any work of authorship, including+ the original version of the Work and any modifications or additions+ to that Work or Derivative Works thereof, that is intentionally+ submitted to Licensor for inclusion in the Work by the copyright owner+ or by an individual or Legal Entity authorized to submit on behalf of+ the copyright owner. For the purposes of this definition, "submitted"+ means any form of electronic, verbal, or written communication sent+ to the Licensor or its representatives, including but not limited to+ communication on electronic mailing lists, source code control systems,+ and issue tracking systems that are managed by, or on behalf of, the+ Licensor for the purpose of discussing and improving the Work, but+ excluding communication that is conspicuously marked or otherwise+ designated in writing by the copyright owner as "Not a Contribution."++ "Contributor" shall mean Licensor and any individual or Legal Entity+ on behalf of whom a Contribution has been received by Licensor and+ subsequently incorporated within the Work.++ 2. Grant of Copyright License. Subject to the terms and conditions of+ this License, each Contributor hereby grants to You a perpetual,+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable+ copyright license to reproduce, prepare Derivative Works of,+ publicly display, publicly perform, sublicense, and distribute the+ Work and such Derivative Works in Source or Object form.++ 3. Grant of Patent License. Subject to the terms and conditions of+ this License, each Contributor hereby grants to You a perpetual,+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable+ (except as stated in this section) patent license to make, have made,+ use, offer to sell, sell, import, and otherwise transfer the Work,+ where such license applies only to those patent claims licensable+ by such Contributor that are necessarily infringed by their+ Contribution(s) alone or by combination of their Contribution(s)+ with the Work to which such Contribution(s) was submitted. If You+ institute patent litigation against any entity (including a+ cross-claim or counterclaim in a lawsuit) alleging that the Work+ or a Contribution incorporated within the Work constitutes direct+ or contributory patent infringement, then any patent licenses+ granted to You under this License for that Work shall terminate+ as of the date such litigation is filed.++ 4. Redistribution. You may reproduce and distribute copies of the+ Work or Derivative Works thereof in any medium, with or without+ modifications, and in Source or Object form, provided that You+ meet the following conditions:++ (a) You must give any other recipients of the Work or+ Derivative Works a copy of this License; and++ (b) You must cause any modified files to carry prominent notices+ stating that You changed the files; and++ (c) You must retain, in the Source form of any Derivative Works+ that You distribute, all copyright, patent, trademark, and+ attribution notices from the Source form of the Work,+ excluding those notices that do not pertain to any part of+ the Derivative Works; and++ (d) If the Work includes a "NOTICE" text file as part of its+ distribution, then any Derivative Works that You distribute must+ include a readable copy of the attribution notices contained+ within such NOTICE file, excluding those notices that do not+ pertain to any part of the Derivative Works, in at least one+ of the following places: within a NOTICE text file distributed+ as part of the Derivative Works; within the Source form or+ documentation, if provided along with the Derivative Works; or,+ within a display generated by the Derivative Works, if and+ wherever such third-party notices normally appear. The contents+ of the NOTICE file are for informational purposes only and+ do not modify the License. You may add Your own attribution+ notices within Derivative Works that You distribute, alongside+ or as an addendum to the NOTICE text from the Work, provided+ that such additional attribution notices cannot be construed+ as modifying the License.++ You may add Your own copyright statement to Your modifications and+ may provide additional or different license terms and conditions+ for use, reproduction, or distribution of Your modifications, or+ for any such Derivative Works as a whole, provided Your use,+ reproduction, and distribution of the Work otherwise complies with+ the conditions stated in this License.++ 5. Submission of Contributions. Unless You explicitly state otherwise,+ any Contribution intentionally submitted for inclusion in the Work+ by You to the Licensor shall be under the terms and conditions of+ this License, without any additional terms or conditions.+ Notwithstanding the above, nothing herein shall supersede or modify+ the terms of any separate license agreement you may have executed+ with Licensor regarding such Contributions.++ 6. Trademarks. This License does not grant permission to use the trade+ names, trademarks, service marks, or product names of the Licensor,+ except as required for reasonable and customary use in describing the+ origin of the Work and reproducing the content of the NOTICE file.++ 7. Disclaimer of Warranty. Unless required by applicable law or+ agreed to in writing, Licensor provides the Work (and each+ Contributor provides its Contributions) on an "AS IS" BASIS,+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or+ implied, including, without limitation, any warranties or conditions+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A+ PARTICULAR PURPOSE. You are solely responsible for determining the+ appropriateness of using or redistributing the Work and assume any+ risks associated with Your exercise of permissions under this License.++ 8. Limitation of Liability. In no event and under no legal theory,+ whether in tort (including negligence), contract, or otherwise,+ unless required by applicable law (such as deliberate and grossly+ negligent acts) or agreed to in writing, shall any Contributor be+ liable to You for damages, including any direct, indirect, special,+ incidental, or consequential damages of any character arising as a+ result of this License or out of the use or inability to use the+ Work (including but not limited to damages for loss of goodwill,+ work stoppage, computer failure or malfunction, or any and all+ other commercial damages or losses), even if such Contributor+ has been advised of the possibility of such damages.++ 9. Accepting Warranty or Additional Liability. While redistributing+ the Work or Derivative Works thereof, You may choose to offer,+ and charge a fee for, acceptance of support, warranty, indemnity,+ or other liability obligations and/or rights consistent with this+ License. However, in accepting such obligations, You may act only+ on Your own behalf and on Your sole responsibility, not on behalf+ of any other Contributor, and only if You agree to indemnify,+ defend, and hold each Contributor harmless for any liability+ incurred by, or claims asserted against, such Contributor by reason+ of your accepting any such warranty or additional liability.++ END OF TERMS AND CONDITIONS++ APPENDIX: How to apply the Apache License to your work.++ To apply the Apache License to your work, attach the following+ boilerplate notice, with the fields enclosed by brackets "[]"+ replaced with your own identifying information. (Don't include+ the brackets!) The text should be enclosed in the appropriate+ comment syntax for the file format. We also recommend that a+ file or class name and description of purpose be included on the+ same "printed page" as the copyright notice for easier+ identification within third-party archives.++ Copyright [yyyy] [name of copyright owner]++ Licensed under the Apache License, Version 2.0 (the "License");+ you may not use this file except in compliance with the License.+ You may obtain a copy of the License at++ http://www.apache.org/licenses/LICENSE-2.0++ Unless required by applicable law or agreed to in writing, software+ distributed under the License is distributed on an "AS IS" BASIS,+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ See the License for the specific language governing permissions and+ limitations under the License.++------------------------------------------------------------------------------+ONNX Runtime (native inference library) 1.30.0+License: MIT+Source: https://github.com/microsoft/onnxruntime+------------------------------------------------------------------------------+Copyright (c) Microsoft Corporation++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in+all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+THE SOFTWARE.+------------------------------------------------------------------------------LiteLLM mascot SVG path (adapted)License: MIT@@ -798,7 +1055,7 @@ Apache Licenselimitations under the License.==============================================================================-SECTION 2: npm packages (611 packages)+SECTION 2: npm packages (618 packages)==============================================================================- @babel/[email protected] — MIT — https://github.com/babel/babel@@ -872,7 +1129,7 @@ SECTION 2: npm packages (611 packages)- @babel/[email protected] — MIT — https://github.com/babel/babel- @egjs/[email protected] — MIT — https://github.com/naver/hammer.js- @expo-google-fonts/[email protected] — MIT AND Apache-2.0 — https://github.com/expo/google-fonts-- @expo/[email protected] — MIT — https://github.com/expo/expo+- @expo/[email protected] — MIT — https://github.com/expo/expo- @expo/[email protected] — MIT — https://github.com/expo/code-signing-certificates- @expo/[email protected] — MIT — https://github.com/expo/expo- @expo/[email protected] — MIT — https://github.com/expo/expo@@ -881,23 +1138,24 @@ SECTION 2: npm packages (611 packages)- @expo/[email protected] — MIT — https://github.com/expo/expo- @expo/[email protected] — MIT — https://github.com/expo/expo- @expo/[email protected] — MIT — https://github.com/expo/expo+- @expo/[email protected] — MIT — https://github.com/expo/expo- @expo/[email protected] — MIT — https://github.com/expo/expo-modules-macros-plugin-- @expo/[email protected] — MIT — https://github.com/expo/expo+- @expo/[email protected] — MIT — https://github.com/expo/expo- @expo/[email protected] — MIT — https://github.com/expo/expo- @expo/[email protected] — MIT — https://github.com/expo/expo- @expo/[email protected] — MIT — https://github.com/expo/expo- @expo/[email protected] — MIT — https://github.com/expo/expo- @expo/[email protected] — MIT — https://github.com/expo/expo/tree/main/packages/@expo/log-box- @expo/[email protected] — MIT — https://github.com/expo/expo-metro-- @expo/[email protected] — MIT — https://github.com/expo/expo-- @expo/[email protected] — MIT — https://github.com/expo/expo+- @expo/[email protected] — MIT — https://github.com/expo/expo+- @expo/[email protected] — MIT — https://github.com/expo/expo- @expo/[email protected] — MIT — https://github.com/expo/expo- @expo/[email protected] — MIT — https://github.com/expo/expo- @expo/[email protected] — MIT — https://github.com/expo/expo- @expo/[email protected] — MIT — https://github.com/expo/expo-- @expo/[email protected] — MIT — https://github.com/expo/expo+- @expo/[email protected] — MIT — https://github.com/expo/expo- @expo/[email protected] — MIT — https://github.com/expo/expo-- @expo/[email protected] — MIT — https://github.com/expo/expo+- @expo/[email protected] — MIT — https://github.com/expo/expo- @expo/[email protected] — MIT — https://github.com/expo/expo- @expo/[email protected] — MIT- @expo/[email protected] — MIT — https://github.com/expo/spawn-async@@ -915,6 +1173,7 @@ SECTION 2: npm packages (611 packages)- @jridgewell/[email protected] — MIT — https://github.com/jridgewell/sourcemaps- @jridgewell/[email protected] — MIT — https://github.com/jridgewell/sourcemaps- @legendapp/[email protected] — MIT — https://github.com/LegendApp/legend-list+- @noble/[email protected] — MIT — https://github.com/paulmillr/noble-curves- @noble/[email protected] — MIT — https://github.com/paulmillr/noble-hashes- @radix-ui/[email protected] — MIT — https://github.com/radix-ui/primitives- @radix-ui/[email protected] — MIT — https://github.com/radix-ui/primitives@@ -972,7 +1231,7 @@ SECTION 2: npm packages (611 packages)- [email protected] — MIT — https://github.com/jshttp/accepts- [email protected] — MIT — https://github.com/acornjs/acorn- [email protected] — MIT — https://github.com/TooTallNate/proxy-agents-- [email protected] — MIT — https://github.com/expo/agent-cli-detector+- [email protected] — MIT — https://github.com/expo/agent-cli-detector- [email protected] — MIT — https://github.com/IonicaBizau/anser- [email protected] — MIT — https://github.com/sindresorhus/ansi-escapes- [email protected] — MIT — https://github.com/chalk/ansi-regex@@ -993,7 +1252,7 @@ SECTION 2: npm packages (611 packages)- [email protected] — MIT — https://github.com/facebook/hermes- [email protected] — MIT — https://github.com/facebook/hermes- [email protected] — MIT — https://github.com/facebook/flow-- [email protected] — MIT — https://github.com/expo/expo+- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/jaulz/badgin- [email protected] — MIT — https://github.com/juliangruber/balanced-match- [email protected] — MIT — https://github.com/beatgammit/base64-js@@ -1072,35 +1331,38 @@ SECTION 2: npm packages (611 packages)- [email protected] — MIT — https://github.com/sindresorhus/escape-string-regexp- [email protected] — MIT — https://github.com/jshttp/etag- [email protected] — MIT — https://github.com/mysticatea/event-target-shim-- [email protected] — MIT — https://github.com/expo/expo+- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo-- [email protected] — MIT — https://github.com/expo/expo+- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo-- [email protected] — MIT — https://github.com/expo/expo+- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo+- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo+- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo+- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo-- [email protected] — MIT — https://github.com/expo/expo+- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo-- [email protected] — MIT — https://github.com/expo/expo-- [email protected] — MIT — https://github.com/expo/expo-- [email protected] — MIT — https://github.com/expo/expo+- [email protected] — MIT — https://github.com/expo/expo+- [email protected] — MIT — https://github.com/expo/expo+- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/arunabhverma/expo-paste-input@@ -1114,6 +1376,7 @@ SECTION 2: npm packages (611 packages)- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo+- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo- [email protected] — Apache-2.0 — https://github.com/coveooss/exponential-backoff- [email protected] — MIT — https://github.com/epoberezkin/fast-deep-equal@@ -1180,7 +1443,7 @@ SECTION 2: npm packages (611 packages)- [email protected] — MIT — https://github.com/kitten/lan-network- [email protected] — MIT — https://github.com/sindresorhus/leven- [email protected] — Apache-2.0-- [email protected] — MPL-2.0 — https://github.com/parcel-bundler/lightningcss+- [email protected] — MPL-2.0 — https://github.com/parcel-bundler/lightningcss- [email protected] — MIT — https://github.com/lodash/lodash- [email protected] — MIT — https://github.com/lodash/lodash- [email protected] — MIT — https://github.com/sindresorhus/log-symbols@@ -1238,6 +1501,7 @@ SECTION 2: npm packages (611 packages)- [email protected] — MIT — https://github.com/vercel/ms- [email protected] — MIT — https://github.com/expo/multitars- [email protected] — MIT — https://github.com/ai/nanoid+- [email protected] — MIT — https://github.com/ai/nanoid- [email protected] — MIT — https://github.com/jshttp/negotiator- [email protected] — MIT — https://github.com/jshttp/negotiator- [email protected] — MIT — https://github.com/jshttp/negotiator@@ -1268,7 +1532,7 @@ SECTION 2: npm packages (611 packages)- [email protected] — MIT — https://github.com/micromatch/picomatch- [email protected] — MIT — https://github.com/TooTallNate/node-plist- [email protected] — MIT — https://github.com/lukeapage/pngjs2-- [email protected] — MIT — https://github.com/postcss/postcss+- [email protected] — MIT — https://github.com/postcss/postcss- [email protected] — MIT — https://github.com/TrySound/postcss-value-parser- [email protected] — MIT — https://github.com/jestjs/jest- [email protected] — ISC — https://github.com/npm/proc-log@@ -1574,7 +1838,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.-------------------------------------------------------------------------------[7] Applies to: npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected]+[7] Applies to: npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected]------------------------------------------------------------------------------The MIT License (MIT)@@ -1624,7 +1888,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.-------------------------------------------------------------------------------[9] Applies to: npm:@expo/[email protected]+[9] Applies to: npm:@expo/[email protected], npm:@expo/[email protected]------------------------------------------------------------------------------The MIT License (MIT)@@ -1865,7 +2129,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.-------------------------------------------------------------------------------[19] Applies to: npm:@noble/[email protected]+[19] Applies to: npm:@noble/[email protected], npm:@noble/[email protected]------------------------------------------------------------------------------The MIT License (MIT)@@ -2176,7 +2440,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THESOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.-------------------------------------------------------------------------------[32] Applies to: npm:[email protected], npm:[email protected]+[32] Applies to: npm:[email protected], npm:[email protected]------------------------------------------------------------------------------MIT License@@ -5879,7 +6143,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.-------------------------------------------------------------------------------[132] Applies to: npm:[email protected]+[132] Applies to: npm:[email protected]------------------------------------------------------------------------------Mozilla Public License Version 2.0==================================@@ -7054,7 +7318,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.-------------------------------------------------------------------------------[150] Applies to: npm:[email protected]+[150] Applies to: npm:[email protected], npm:[email protected]------------------------------------------------------------------------------The MIT License (MIT)@@ -7783,7 +8047,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS INTHE SOFTWARE.-------------------------------------------------------------------------------[168] Applies to: npm:[email protected]+[168] Applies to: npm:[email protected]------------------------------------------------------------------------------The MIT License (MIT)diff --git a/docs/legal/notices/mobile-ios.txt b/docs/legal/notices/mobile-ios.txtindex 8406a3aaf5..aa571b90da 100644--- a/docs/legal/notices/mobile-ios.txt+++ b/docs/legal/notices/mobile-ios.txt@@ -23,6 +23,263 @@ Restricted or proprietary components are disclosed in the companion file.SECTION 1: Non-npm components==============================================================================+------------------------------------------------------------------------------+Silero VAD (runtime-downloaded model) sha256:9e2449e1087496d8d4caba907f23e0bd3f78d91fa552479bb9c23ac09cbb1fd6+License: MIT+Source: https://github.com/snakers4/silero-vad+------------------------------------------------------------------------------+Copyright (c) 2020-present Silero Team++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in+all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+THE SOFTWARE.++------------------------------------------------------------------------------+3D-Speaker CAM++ zh-en advanced (runtime-downloaded model) sha256:aa3cfc16963a10586a9393f5035d6d6b57e98d358b347f80c2a30bf4f00ceba2+License: Apache-2.0+Source: https://modelscope.cn/models/iic/speech_campplus_sv_zh_en_16k-common_advanced+------------------------------------------------------------------------------+Apache License+ Version 2.0, January 2004+ http://www.apache.org/licenses/++ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION++ 1. Definitions.++ "License" shall mean the terms and conditions for use, reproduction,+ and distribution as defined by Sections 1 through 9 of this document.++ "Licensor" shall mean the copyright owner or entity authorized by+ the copyright owner that is granting the License.++ "Legal Entity" shall mean the union of the acting entity and all+ other entities that control, are controlled by, or are under common+ control with that entity. For the purposes of this definition,+ "control" means (i) the power, direct or indirect, to cause the+ direction or management of such entity, whether by contract or+ otherwise, or (ii) ownership of fifty percent (50%) or more of the+ outstanding shares, or (iii) beneficial ownership of such entity.++ "You" (or "Your") shall mean an individual or Legal Entity+ exercising permissions granted by this License.++ "Source" form shall mean the preferred form for making modifications,+ including but not limited to software source code, documentation+ source, and configuration files.++ "Object" form shall mean any form resulting from mechanical+ transformation or translation of a Source form, including but+ not limited to compiled object code, generated documentation,+ and conversions to other media types.++ "Work" shall mean the work of authorship, whether in Source or+ Object form, made available under the License, as indicated by a+ copyright notice that is included in or attached to the work+ (an example is provided in the Appendix below).++ "Derivative Works" shall mean any work, whether in Source or Object+ form, that is based on (or derived from) the Work and for which the+ editorial revisions, annotations, elaborations, or other modifications+ represent, as a whole, an original work of authorship. For the purposes+ of this License, Derivative Works shall not include works that remain+ separable from, or merely link (or bind by name) to the interfaces of,+ the Work and Derivative Works thereof.++ "Contribution" shall mean any work of authorship, including+ the original version of the Work and any modifications or additions+ to that Work or Derivative Works thereof, that is intentionally+ submitted to Licensor for inclusion in the Work by the copyright owner+ or by an individual or Legal Entity authorized to submit on behalf of+ the copyright owner. For the purposes of this definition, "submitted"+ means any form of electronic, verbal, or written communication sent+ to the Licensor or its representatives, including but not limited to+ communication on electronic mailing lists, source code control systems,+ and issue tracking systems that are managed by, or on behalf of, the+ Licensor for the purpose of discussing and improving the Work, but+ excluding communication that is conspicuously marked or otherwise+ designated in writing by the copyright owner as "Not a Contribution."++ "Contributor" shall mean Licensor and any individual or Legal Entity+ on behalf of whom a Contribution has been received by Licensor and+ subsequently incorporated within the Work.++ 2. Grant of Copyright License. Subject to the terms and conditions of+ this License, each Contributor hereby grants to You a perpetual,+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable+ copyright license to reproduce, prepare Derivative Works of,+ publicly display, publicly perform, sublicense, and distribute the+ Work and such Derivative Works in Source or Object form.++ 3. Grant of Patent License. Subject to the terms and conditions of+ this License, each Contributor hereby grants to You a perpetual,+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable+ (except as stated in this section) patent license to make, have made,+ use, offer to sell, sell, import, and otherwise transfer the Work,+ where such license applies only to those patent claims licensable+ by such Contributor that are necessarily infringed by their+ Contribution(s) alone or by combination of their Contribution(s)+ with the Work to which such Contribution(s) was submitted. If You+ institute patent litigation against any entity (including a+ cross-claim or counterclaim in a lawsuit) alleging that the Work+ or a Contribution incorporated within the Work constitutes direct+ or contributory patent infringement, then any patent licenses+ granted to You under this License for that Work shall terminate+ as of the date such litigation is filed.++ 4. Redistribution. You may reproduce and distribute copies of the+ Work or Derivative Works thereof in any medium, with or without+ modifications, and in Source or Object form, provided that You+ meet the following conditions:++ (a) You must give any other recipients of the Work or+ Derivative Works a copy of this License; and++ (b) You must cause any modified files to carry prominent notices+ stating that You changed the files; and++ (c) You must retain, in the Source form of any Derivative Works+ that You distribute, all copyright, patent, trademark, and+ attribution notices from the Source form of the Work,+ excluding those notices that do not pertain to any part of+ the Derivative Works; and++ (d) If the Work includes a "NOTICE" text file as part of its+ distribution, then any Derivative Works that You distribute must+ include a readable copy of the attribution notices contained+ within such NOTICE file, excluding those notices that do not+ pertain to any part of the Derivative Works, in at least one+ of the following places: within a NOTICE text file distributed+ as part of the Derivative Works; within the Source form or+ documentation, if provided along with the Derivative Works; or,+ within a display generated by the Derivative Works, if and+ wherever such third-party notices normally appear. The contents+ of the NOTICE file are for informational purposes only and+ do not modify the License. You may add Your own attribution+ notices within Derivative Works that You distribute, alongside+ or as an addendum to the NOTICE text from the Work, provided+ that such additional attribution notices cannot be construed+ as modifying the License.++ You may add Your own copyright statement to Your modifications and+ may provide additional or different license terms and conditions+ for use, reproduction, or distribution of Your modifications, or+ for any such Derivative Works as a whole, provided Your use,+ reproduction, and distribution of the Work otherwise complies with+ the conditions stated in this License.++ 5. Submission of Contributions. Unless You explicitly state otherwise,+ any Contribution intentionally submitted for inclusion in the Work+ by You to the Licensor shall be under the terms and conditions of+ this License, without any additional terms or conditions.+ Notwithstanding the above, nothing herein shall supersede or modify+ the terms of any separate license agreement you may have executed+ with Licensor regarding such Contributions.++ 6. Trademarks. This License does not grant permission to use the trade+ names, trademarks, service marks, or product names of the Licensor,+ except as required for reasonable and customary use in describing the+ origin of the Work and reproducing the content of the NOTICE file.++ 7. Disclaimer of Warranty. Unless required by applicable law or+ agreed to in writing, Licensor provides the Work (and each+ Contributor provides its Contributions) on an "AS IS" BASIS,+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or+ implied, including, without limitation, any warranties or conditions+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A+ PARTICULAR PURPOSE. You are solely responsible for determining the+ appropriateness of using or redistributing the Work and assume any+ risks associated with Your exercise of permissions under this License.++ 8. Limitation of Liability. In no event and under no legal theory,+ whether in tort (including negligence), contract, or otherwise,+ unless required by applicable law (such as deliberate and grossly+ negligent acts) or agreed to in writing, shall any Contributor be+ liable to You for damages, including any direct, indirect, special,+ incidental, or consequential damages of any character arising as a+ result of this License or out of the use or inability to use the+ Work (including but not limited to damages for loss of goodwill,+ work stoppage, computer failure or malfunction, or any and all+ other commercial damages or losses), even if such Contributor+ has been advised of the possibility of such damages.++ 9. Accepting Warranty or Additional Liability. While redistributing+ the Work or Derivative Works thereof, You may choose to offer,+ and charge a fee for, acceptance of support, warranty, indemnity,+ or other liability obligations and/or rights consistent with this+ License. However, in accepting such obligations, You may act only+ on Your own behalf and on Your sole responsibility, not on behalf+ of any other Contributor, and only if You agree to indemnify,+ defend, and hold each Contributor harmless for any liability+ incurred by, or claims asserted against, such Contributor by reason+ of your accepting any such warranty or additional liability.++ END OF TERMS AND CONDITIONS++ APPENDIX: How to apply the Apache License to your work.++ To apply the Apache License to your work, attach the following+ boilerplate notice, with the fields enclosed by brackets "[]"+ replaced with your own identifying information. (Don't include+ the brackets!) The text should be enclosed in the appropriate+ comment syntax for the file format. We also recommend that a+ file or class name and description of purpose be included on the+ same "printed page" as the copyright notice for easier+ identification within third-party archives.++ Copyright [yyyy] [name of copyright owner]++ Licensed under the Apache License, Version 2.0 (the "License");+ you may not use this file except in compliance with the License.+ You may obtain a copy of the License at++ http://www.apache.org/licenses/LICENSE-2.0++ Unless required by applicable law or agreed to in writing, software+ distributed under the License is distributed on an "AS IS" BASIS,+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ See the License for the specific language governing permissions and+ limitations under the License.++------------------------------------------------------------------------------+ONNX Runtime (native inference library) 1.30.0+License: MIT+Source: https://github.com/microsoft/onnxruntime+------------------------------------------------------------------------------+Copyright (c) Microsoft Corporation++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in+all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+THE SOFTWARE.+------------------------------------------------------------------------------LiteLLM mascot SVG path (adapted)License: MIT@@ -384,7 +641,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS INTHE SOFTWARE.==============================================================================-SECTION 2: npm packages (611 packages)+SECTION 2: npm packages (618 packages)==============================================================================- @babel/[email protected] — MIT — https://github.com/babel/babel@@ -458,7 +715,7 @@ SECTION 2: npm packages (611 packages)- @babel/[email protected] — MIT — https://github.com/babel/babel- @egjs/[email protected] — MIT — https://github.com/naver/hammer.js- @expo-google-fonts/[email protected] — MIT AND Apache-2.0 — https://github.com/expo/google-fonts-- @expo/[email protected] — MIT — https://github.com/expo/expo+- @expo/[email protected] — MIT — https://github.com/expo/expo- @expo/[email protected] — MIT — https://github.com/expo/code-signing-certificates- @expo/[email protected] — MIT — https://github.com/expo/expo- @expo/[email protected] — MIT — https://github.com/expo/expo@@ -467,23 +724,24 @@ SECTION 2: npm packages (611 packages)- @expo/[email protected] — MIT — https://github.com/expo/expo- @expo/[email protected] — MIT — https://github.com/expo/expo- @expo/[email protected] — MIT — https://github.com/expo/expo+- @expo/[email protected] — MIT — https://github.com/expo/expo- @expo/[email protected] — MIT — https://github.com/expo/expo-modules-macros-plugin-- @expo/[email protected] — MIT — https://github.com/expo/expo+- @expo/[email protected] — MIT — https://github.com/expo/expo- @expo/[email protected] — MIT — https://github.com/expo/expo- @expo/[email protected] — MIT — https://github.com/expo/expo- @expo/[email protected] — MIT — https://github.com/expo/expo- @expo/[email protected] — MIT — https://github.com/expo/expo- @expo/[email protected] — MIT — https://github.com/expo/expo/tree/main/packages/@expo/log-box- @expo/[email protected] — MIT — https://github.com/expo/expo-metro-- @expo/[email protected] — MIT — https://github.com/expo/expo-- @expo/[email protected] — MIT — https://github.com/expo/expo+- @expo/[email protected] — MIT — https://github.com/expo/expo+- @expo/[email protected] — MIT — https://github.com/expo/expo- @expo/[email protected] — MIT — https://github.com/expo/expo- @expo/[email protected] — MIT — https://github.com/expo/expo- @expo/[email protected] — MIT — https://github.com/expo/expo- @expo/[email protected] — MIT — https://github.com/expo/expo-- @expo/[email protected] — MIT — https://github.com/expo/expo+- @expo/[email protected] — MIT — https://github.com/expo/expo- @expo/[email protected] — MIT — https://github.com/expo/expo-- @expo/[email protected] — MIT — https://github.com/expo/expo+- @expo/[email protected] — MIT — https://github.com/expo/expo- @expo/[email protected] — MIT — https://github.com/expo/expo- @expo/[email protected] — MIT- @expo/[email protected] — MIT — https://github.com/expo/spawn-async@@ -501,6 +759,7 @@ SECTION 2: npm packages (611 packages)- @jridgewell/[email protected] — MIT — https://github.com/jridgewell/sourcemaps- @jridgewell/[email protected] — MIT — https://github.com/jridgewell/sourcemaps- @legendapp/[email protected] — MIT — https://github.com/LegendApp/legend-list+- @noble/[email protected] — MIT — https://github.com/paulmillr/noble-curves- @noble/[email protected] — MIT — https://github.com/paulmillr/noble-hashes- @radix-ui/[email protected] — MIT — https://github.com/radix-ui/primitives- @radix-ui/[email protected] — MIT — https://github.com/radix-ui/primitives@@ -558,7 +817,7 @@ SECTION 2: npm packages (611 packages)- [email protected] — MIT — https://github.com/jshttp/accepts- [email protected] — MIT — https://github.com/acornjs/acorn- [email protected] — MIT — https://github.com/TooTallNate/proxy-agents-- [email protected] — MIT — https://github.com/expo/agent-cli-detector+- [email protected] — MIT — https://github.com/expo/agent-cli-detector- [email protected] — MIT — https://github.com/IonicaBizau/anser- [email protected] — MIT — https://github.com/sindresorhus/ansi-escapes- [email protected] — MIT — https://github.com/chalk/ansi-regex@@ -579,7 +838,7 @@ SECTION 2: npm packages (611 packages)- [email protected] — MIT — https://github.com/facebook/hermes- [email protected] — MIT — https://github.com/facebook/hermes- [email protected] — MIT — https://github.com/facebook/flow-- [email protected] — MIT — https://github.com/expo/expo+- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/jaulz/badgin- [email protected] — MIT — https://github.com/juliangruber/balanced-match- [email protected] — MIT — https://github.com/beatgammit/base64-js@@ -658,35 +917,38 @@ SECTION 2: npm packages (611 packages)- [email protected] — MIT — https://github.com/sindresorhus/escape-string-regexp- [email protected] — MIT — https://github.com/jshttp/etag- [email protected] — MIT — https://github.com/mysticatea/event-target-shim-- [email protected] — MIT — https://github.com/expo/expo+- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo-- [email protected] — MIT — https://github.com/expo/expo+- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo-- [email protected] — MIT — https://github.com/expo/expo+- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo+- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo+- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo+- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo-- [email protected] — MIT — https://github.com/expo/expo+- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo-- [email protected] — MIT — https://github.com/expo/expo-- [email protected] — MIT — https://github.com/expo/expo-- [email protected] — MIT — https://github.com/expo/expo+- [email protected] — MIT — https://github.com/expo/expo+- [email protected] — MIT — https://github.com/expo/expo+- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/arunabhverma/expo-paste-input@@ -700,6 +962,7 @@ SECTION 2: npm packages (611 packages)- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo+- [email protected] — MIT — https://github.com/expo/expo- [email protected] — MIT — https://github.com/expo/expo- [email protected] — Apache-2.0 — https://github.com/coveooss/exponential-backoff- [email protected] — MIT — https://github.com/epoberezkin/fast-deep-equal@@ -766,7 +1029,7 @@ SECTION 2: npm packages (611 packages)- [email protected] — MIT — https://github.com/kitten/lan-network- [email protected] — MIT — https://github.com/sindresorhus/leven- [email protected] — Apache-2.0-- [email protected] — MPL-2.0 — https://github.com/parcel-bundler/lightningcss+- [email protected] — MPL-2.0 — https://github.com/parcel-bundler/lightningcss- [email protected] — MIT — https://github.com/lodash/lodash- [email protected] — MIT — https://github.com/lodash/lodash- [email protected] — MIT — https://github.com/sindresorhus/log-symbols@@ -824,6 +1087,7 @@ SECTION 2: npm packages (611 packages)- [email protected] — MIT — https://github.com/vercel/ms- [email protected] — MIT — https://github.com/expo/multitars- [email protected] — MIT — https://github.com/ai/nanoid+- [email protected] — MIT — https://github.com/ai/nanoid- [email protected] — MIT — https://github.com/jshttp/negotiator- [email protected] — MIT — https://github.com/jshttp/negotiator- [email protected] — MIT — https://github.com/jshttp/negotiator@@ -854,7 +1118,7 @@ SECTION 2: npm packages (611 packages)- [email protected] — MIT — https://github.com/micromatch/picomatch- [email protected] — MIT — https://github.com/TooTallNate/node-plist- [email protected] — MIT — https://github.com/lukeapage/pngjs2-- [email protected] — MIT — https://github.com/postcss/postcss+- [email protected] — MIT — https://github.com/postcss/postcss- [email protected] — MIT — https://github.com/TrySound/postcss-value-parser- [email protected] — MIT — https://github.com/jestjs/jest- [email protected] — ISC — https://github.com/npm/proc-log@@ -1160,7 +1424,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.-------------------------------------------------------------------------------[7] Applies to: npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected]+[7] Applies to: npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:@expo/[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected], npm:[email protected]------------------------------------------------------------------------------The MIT License (MIT)@@ -1210,7 +1474,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.-------------------------------------------------------------------------------[9] Applies to: npm:@expo/[email protected]+[9] Applies to: npm:@expo/[email protected], npm:@expo/[email protected]------------------------------------------------------------------------------The MIT License (MIT)@@ -1451,7 +1715,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.-------------------------------------------------------------------------------[19] Applies to: npm:@noble/[email protected]+[19] Applies to: npm:@noble/[email protected], npm:@noble/[email protected]------------------------------------------------------------------------------The MIT License (MIT)@@ -1762,7 +2026,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THESOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.-------------------------------------------------------------------------------[32] Applies to: npm:[email protected], npm:[email protected]+[32] Applies to: npm:[email protected], npm:[email protected]------------------------------------------------------------------------------MIT License@@ -5465,7 +5729,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.-------------------------------------------------------------------------------[132] Applies to: npm:[email protected]+[132] Applies to: npm:[email protected]------------------------------------------------------------------------------Mozilla Public License Version 2.0==================================@@ -6640,7 +6904,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.-------------------------------------------------------------------------------[150] Applies to: npm:[email protected]+[150] Applies to: npm:[email protected], npm:[email protected]------------------------------------------------------------------------------The MIT License (MIT)@@ -7369,7 +7633,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS INTHE SOFTWARE.-------------------------------------------------------------------------------[168] Applies to: npm:[email protected]+[168] Applies to: npm:[email protected]------------------------------------------------------------------------------The MIT License (MIT)diff --git a/docs/legal/notices/sbom/desktop-linux.spdx.json b/docs/legal/notices/sbom/desktop-linux.spdx.jsonindex 2225bafb18..db1db29a75 100644--- a/docs/legal/notices/sbom/desktop-linux.spdx.json+++ b/docs/legal/notices/sbom/desktop-linux.spdx.json@@ -3,9 +3,9 @@"dataLicense": "CC0-1.0","SPDXID": "SPDXRef-DOCUMENT","name": "cindy-desktop-linux",- "documentNamespace": "https://cindy.app/spdx/desktop-linux/e3a83b3761b37d27c2456441a6ef6b5a892ca7f116846697246be21330a6b953",+ "documentNamespace": "https://cindy.app/spdx/desktop-linux/2e06ef7d87c434e68df12514d52b81eacc09a9aac5c9176344eec7b58784298f","creationInfo": {- "created": "2026-10-06T01:25:03Z",+ "created": "2026-10-09T19:41:25Z","creators": ["Tool: scripts/generate-third-party-notices.mjs"]@@ -31,6 +31,16 @@"licenseDeclared": "LicenseRef-Sharp-Third-Party-Licenses","copyrightText": "NOASSERTION"},+ {+ "name": "3D-Speaker CAM++ zh-en advanced (runtime-downloaded model)",+ "SPDXID": "SPDXRef-Package-2eb4a603ce39b403",+ "versionInfo": "sha256:aa3cfc16963a10586a9393f5035d6d6b57e98d358b347f80c2a30bf4f00ceba2",+ "downloadLocation": "https://modelscope.cn/models/iic/speech_campplus_sv_zh_en_16k-common_advanced",+ "filesAnalyzed": false,+ "licenseConcluded": "Apache-2.0",+ "licenseDeclared": "Apache-2.0",+ "copyrightText": "NOASSERTION"+ },{"name": "drawio viewer (vendored)","SPDXID": "SPDXRef-Package-ef29a7e5a6f64477",@@ -81,6 +91,16 @@"licenseDeclared": "MIT","copyrightText": "NOASSERTION"},+ {+ "name": "ONNX Runtime (native inference library)",+ "SPDXID": "SPDXRef-Package-4e0ad65af2083a00",+ "versionInfo": "bundled with sherpa-onnx-node 1.13.8",+ "downloadLocation": "https://github.com/microsoft/onnxruntime",+ "filesAnalyzed": false,+ "licenseConcluded": "MIT",+ "licenseDeclared": "MIT",+ "copyrightText": "NOASSERTION"+ },{"name": "OpenAI Codex CLI (runtime-downloaded binary)","SPDXID": "SPDXRef-Package-618e13d446a4c6e4",@@ -151,6 +171,16 @@"licenseDeclared": "MIT OR Unlicense","copyrightText": "NOASSERTION"},+ {+ "name": "Silero VAD (runtime-downloaded model)",+ "SPDXID": "SPDXRef-Package-1d15b57c9978e089",+ "versionInfo": "sha256:9e2449e1087496d8d4caba907f23e0bd3f78d91fa552479bb9c23ac09cbb1fd6",+ "downloadLocation": "https://github.com/snakers4/silero-vad",+ "filesAnalyzed": false,+ "licenseConcluded": "MIT",+ "licenseDeclared": "MIT",+ "copyrightText": "NOASSERTION"+ },{"name": "SQLite (compiled into better-sqlite3)","SPDXID": "SPDXRef-Package-58ed2a8cf5178d41",@@ -13927,6 +13957,57 @@}]},+ {+ "name": "sherpa-onnx-linux-arm64",+ "SPDXID": "SPDXRef-Package-7db8d101520c80ad",+ "versionInfo": "1.13.8",+ "downloadLocation": "https://github.com/csukuangfj/sherpa-onnx",+ "filesAnalyzed": false,+ "licenseConcluded": "Apache-2.0",+ "licenseDeclared": "Apache-2.0",+ "copyrightText": "NOASSERTION",+ "externalRefs": [+ {+ "referenceCategory": "PACKAGE-MANAGER",+ "referenceType": "purl",+ "referenceLocator": "pkg:npm/[email protected]"+ }+ ]+ },+ {+ "name": "sherpa-onnx-linux-x64",+ "SPDXID": "SPDXRef-Package-f23a19d108a72dd8",+ "versionInfo": "1.13.8",+ "downloadLocation": "https://github.com/csukuangfj/sherpa-onnx",+ "filesAnalyzed": false,+ "licenseConcluded": "Apache-2.0",+ "licenseDeclared": "Apache-2.0",+ "copyrightText": "NOASSERTION",+ "externalRefs": [+ {+ "referenceCategory": "PACKAGE-MANAGER",+ "referenceType": "purl",+ "referenceLocator": "pkg:npm/[email protected]"+ }+ ]+ },+ {+ "name": "sherpa-onnx-node",+ "SPDXID": "SPDXRef-Package-5a79f55f36b8ec3a",+ "versionInfo": "1.13.8",+ "downloadLocation": "https://github.com/csukuangfj/sherpa-onnx",+ "filesAnalyzed": false,+ "licenseConcluded": "Apache-2.0",+ "licenseDeclared": "Apache-2.0",+ "copyrightText": "NOASSERTION",+ "externalRefs": [+ {+ "referenceCategory": "PACKAGE-MANAGER",+ "referenceType": "purl",+ "referenceLocator": "pkg:npm/[email protected]"+ }+ ]+ },{"name": "side-channel","SPDXID": "SPDXRef-Package-b92f70c0533794b9",@@ -15656,6 +15737,11 @@"relationshipType": "DESCRIBES","relatedSpdxElement": "SPDXRef-Package-af90f607ac5ef2d5"},+ {+ "spdxElementId": "SPDXRef-DOCUMENT",+ "relationshipType": "DESCRIBES",+ "relatedSpdxElement": "SPDXRef-Package-2eb4a603ce39b403"+ },{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",@@ -15681,6 +15767,11 @@"relationshipType": "DESCRIBES","relatedSpdxElement": "SPDXRef-Package-42f340d5003334bd"},+ {+ "spdxElementId": "SPDXRef-DOCUMENT",+ "relationshipType": "DESCRIBES",+ "relatedSpdxElement": "SPDXRef-Package-4e0ad65af2083a00"+ },{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",@@ -15716,6 +15807,11 @@"relationshipType": "DESCRIBES","relatedSpdxElement": "SPDXRef-Package-616963e2fc3a9428"},+ {+ "spdxElementId": "SPDXRef-DOCUMENT",+ "relationshipType": "DESCRIBES",+ "relatedSpdxElement": "SPDXRef-Package-1d15b57c9978e089"+ },{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",@@ -19776,6 +19872,21 @@"relationshipType": "DESCRIBES","relatedSpdxElement": "SPDXRef-Package-9905b9d4e1f2b3aa"},+ {+ "spdxElementId": "SPDXRef-DOCUMENT",+ "relationshipType": "DESCRIBES",+ "relatedSpdxElement": "SPDXRef-Package-7db8d101520c80ad"+ },+ {+ "spdxElementId": "SPDXRef-DOCUMENT",+ "relationshipType": "DESCRIBES",+ "relatedSpdxElement": "SPDXRef-Package-f23a19d108a72dd8"+ },+ {+ "spdxElementId": "SPDXRef-DOCUMENT",+ "relationshipType": "DESCRIBES",+ "relatedSpdxElement": "SPDXRef-Package-5a79f55f36b8ec3a"+ },{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",diff --git a/docs/legal/notices/sbom/desktop-macos.spdx.json b/docs/legal/notices/sbom/desktop-macos.spdx.jsonindex fce4b3e3de..13b6a6499c 100644--- a/docs/legal/notices/sbom/desktop-macos.spdx.json+++ b/docs/legal/notices/sbom/desktop-macos.spdx.json@@ -3,9 +3,9 @@"dataLicense": "CC0-1.0","SPDXID": "SPDXRef-DOCUMENT","name": "cindy-desktop-macos",- "documentNamespace": "https://cindy.app/spdx/desktop-macos/acda3a49c9907075859872bce4297dd4fe5f737e8ffa940a088b21574e4ac10a",+ "documentNamespace": "https://cindy.app/spdx/desktop-macos/23e08a62f78ec33a04efef6f7279a14cc2586d5ce90b2c0e856449ffe9af57fa","creationInfo": {- "created": "2026-10-06T01:25:03Z",+ "created": "2026-10-09T19:41:25Z","creators": ["Tool: scripts/generate-third-party-notices.mjs"]@@ -31,6 +31,16 @@"licenseDeclared": "LicenseRef-Sharp-Third-Party-Licenses","copyrightText": "NOASSERTION"},+ {+ "name": "3D-Speaker CAM++ zh-en advanced (runtime-downloaded model)",+ "SPDXID": "SPDXRef-Package-2eb4a603ce39b403",+ "versionInfo": "sha256:aa3cfc16963a10586a9393f5035d6d6b57e98d358b347f80c2a30bf4f00ceba2",+ "downloadLocation": "https://modelscope.cn/models/iic/speech_campplus_sv_zh_en_16k-common_advanced",+ "filesAnalyzed": false,+ "licenseConcluded": "Apache-2.0",+ "licenseDeclared": "Apache-2.0",+ "copyrightText": "NOASSERTION"+ },{"name": "Code Island NotchPanelShape & mascot parameters (adapted)","SPDXID": "SPDXRef-Package-19432fe60a02f6f2",@@ -101,6 +111,16 @@"licenseDeclared": "MIT","copyrightText": "NOASSERTION"},+ {+ "name": "ONNX Runtime (native inference library)",+ "SPDXID": "SPDXRef-Package-4e0ad65af2083a00",+ "versionInfo": "bundled with sherpa-onnx-node 1.13.8",+ "downloadLocation": "https://github.com/microsoft/onnxruntime",+ "filesAnalyzed": false,+ "licenseConcluded": "MIT",+ "licenseDeclared": "MIT",+ "copyrightText": "NOASSERTION"+ },{"name": "OpenAI Codex CLI (runtime-downloaded binary)","SPDXID": "SPDXRef-Package-618e13d446a4c6e4",@@ -171,6 +191,16 @@"licenseDeclared": "MIT OR Unlicense","copyrightText": "NOASSERTION"},+ {+ "name": "Silero VAD (runtime-downloaded model)",+ "SPDXID": "SPDXRef-Package-1d15b57c9978e089",+ "versionInfo": "sha256:9e2449e1087496d8d4caba907f23e0bd3f78d91fa552479bb9c23ac09cbb1fd6",+ "downloadLocation": "https://github.com/snakers4/silero-vad",+ "filesAnalyzed": false,+ "licenseConcluded": "MIT",+ "licenseDeclared": "MIT",+ "copyrightText": "NOASSERTION"+ },{"name": "SQLite (compiled into better-sqlite3)","SPDXID": "SPDXRef-Package-58ed2a8cf5178d41",@@ -13947,6 +13977,57 @@}]},+ {+ "name": "sherpa-onnx-darwin-arm64",+ "SPDXID": "SPDXRef-Package-158e910b72798972",+ "versionInfo": "1.13.8",+ "downloadLocation": "https://github.com/csukuangfj/sherpa-onnx",+ "filesAnalyzed": false,+ "licenseConcluded": "Apache-2.0",+ "licenseDeclared": "Apache-2.0",+ "copyrightText": "NOASSERTION",+ "externalRefs": [+ {+ "referenceCategory": "PACKAGE-MANAGER",+ "referenceType": "purl",+ "referenceLocator": "pkg:npm/[email protected]"+ }+ ]+ },+ {+ "name": "sherpa-onnx-darwin-x64",+ "SPDXID": "SPDXRef-Package-98e8dc28219f638f",+ "versionInfo": "1.13.8",+ "downloadLocation": "https://github.com/csukuangfj/sherpa-onnx",+ "filesAnalyzed": false,+ "licenseConcluded": "Apache-2.0",+ "licenseDeclared": "Apache-2.0",+ "copyrightText": "NOASSERTION",+ "externalRefs": [+ {+ "referenceCategory": "PACKAGE-MANAGER",+ "referenceType": "purl",+ "referenceLocator": "pkg:npm/[email protected]"+ }+ ]+ },+ {+ "name": "sherpa-onnx-node",+ "SPDXID": "SPDXRef-Package-5a79f55f36b8ec3a",+ "versionInfo": "1.13.8",+ "downloadLocation": "https://github.com/csukuangfj/sherpa-onnx",+ "filesAnalyzed": false,+ "licenseConcluded": "Apache-2.0",+ "licenseDeclared": "Apache-2.0",+ "copyrightText": "NOASSERTION",+ "externalRefs": [+ {+ "referenceCategory": "PACKAGE-MANAGER",+ "referenceType": "purl",+ "referenceLocator": "pkg:npm/[email protected]"+ }+ ]+ },{"name": "side-channel","SPDXID": "SPDXRef-Package-b92f70c0533794b9",@@ -15676,6 +15757,11 @@"relationshipType": "DESCRIBES","relatedSpdxElement": "SPDXRef-Package-ec651a334874cc0c"},+ {+ "spdxElementId": "SPDXRef-DOCUMENT",+ "relationshipType": "DESCRIBES",+ "relatedSpdxElement": "SPDXRef-Package-2eb4a603ce39b403"+ },{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",@@ -15711,6 +15797,11 @@"relationshipType": "DESCRIBES","relatedSpdxElement": "SPDXRef-Package-42f340d5003334bd"},+ {+ "spdxElementId": "SPDXRef-DOCUMENT",+ "relationshipType": "DESCRIBES",+ "relatedSpdxElement": "SPDXRef-Package-4e0ad65af2083a00"+ },{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",@@ -15746,6 +15837,11 @@"relationshipType": "DESCRIBES","relatedSpdxElement": "SPDXRef-Package-616963e2fc3a9428"},+ {+ "spdxElementId": "SPDXRef-DOCUMENT",+ "relationshipType": "DESCRIBES",+ "relatedSpdxElement": "SPDXRef-Package-1d15b57c9978e089"+ },{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",@@ -19806,6 +19902,21 @@"relationshipType": "DESCRIBES","relatedSpdxElement": "SPDXRef-Package-9905b9d4e1f2b3aa"},+ {+ "spdxElementId": "SPDXRef-DOCUMENT",+ "relationshipType": "DESCRIBES",+ "relatedSpdxElement": "SPDXRef-Package-158e910b72798972"+ },+ {+ "spdxElementId": "SPDXRef-DOCUMENT",+ "relationshipType": "DESCRIBES",+ "relatedSpdxElement": "SPDXRef-Package-98e8dc28219f638f"+ },+ {+ "spdxElementId": "SPDXRef-DOCUMENT",+ "relationshipType": "DESCRIBES",+ "relatedSpdxElement": "SPDXRef-Package-5a79f55f36b8ec3a"+ },{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",diff --git a/docs/legal/notices/sbom/desktop-win.spdx.json b/docs/legal/notices/sbom/desktop-win.spdx.jsonindex aaea379034..c27434841a 100644--- a/docs/legal/notices/sbom/desktop-win.spdx.json+++ b/docs/legal/notices/sbom/desktop-win.spdx.json@@ -3,9 +3,9 @@"dataLicense": "CC0-1.0","SPDXID": "SPDXRef-DOCUMENT","name": "cindy-desktop-win",- "documentNamespace": "https://cindy.app/spdx/desktop-win/046abf82222d2bfe7eea4905777f8ec4441513b411323f0ae7bb889c714ff89b",+ "documentNamespace": "https://cindy.app/spdx/desktop-win/2db7bbcf13182b26f48513dc70ba71c3d091a065b9d8fb4a9e6cdcfbee674d93","creationInfo": {- "created": "2026-10-06T01:25:03Z",+ "created": "2026-10-09T19:41:25Z","creators": ["Tool: scripts/generate-third-party-notices.mjs"]@@ -21,6 +21,16 @@"licenseDeclared": "LicenseRef-Sharp-Third-Party-Licenses","copyrightText": "NOASSERTION"},+ {+ "name": "3D-Speaker CAM++ zh-en advanced (runtime-downloaded model)",+ "SPDXID": "SPDXRef-Package-2eb4a603ce39b403",+ "versionInfo": "sha256:aa3cfc16963a10586a9393f5035d6d6b57e98d358b347f80c2a30bf4f00ceba2",+ "downloadLocation": "https://modelscope.cn/models/iic/speech_campplus_sv_zh_en_16k-common_advanced",+ "filesAnalyzed": false,+ "licenseConcluded": "Apache-2.0",+ "licenseDeclared": "Apache-2.0",+ "copyrightText": "NOASSERTION"+ },{"name": "Android SDK Platform-Tools (bundled binaries)","SPDXID": "SPDXRef-Package-8cc04840a3d0a472",@@ -81,6 +91,16 @@"licenseDeclared": "MIT","copyrightText": "NOASSERTION"},+ {+ "name": "ONNX Runtime (native inference library)",+ "SPDXID": "SPDXRef-Package-4e0ad65af2083a00",+ "versionInfo": "bundled with sherpa-onnx-node 1.13.8",+ "downloadLocation": "https://github.com/microsoft/onnxruntime",+ "filesAnalyzed": false,+ "licenseConcluded": "MIT",+ "licenseDeclared": "MIT",+ "copyrightText": "NOASSERTION"+ },{"name": "OpenAI Codex CLI (runtime-downloaded binary)","SPDXID": "SPDXRef-Package-618e13d446a4c6e4",@@ -151,6 +171,16 @@"licenseDeclared": "MIT OR Unlicense","copyrightText": "NOASSERTION"},+ {+ "name": "Silero VAD (runtime-downloaded model)",+ "SPDXID": "SPDXRef-Package-1d15b57c9978e089",+ "versionInfo": "sha256:9e2449e1087496d8d4caba907f23e0bd3f78d91fa552479bb9c23ac09cbb1fd6",+ "downloadLocation": "https://github.com/snakers4/silero-vad",+ "filesAnalyzed": false,+ "licenseConcluded": "MIT",+ "licenseDeclared": "MIT",+ "copyrightText": "NOASSERTION"+ },{"name": "SQLite (compiled into better-sqlite3)","SPDXID": "SPDXRef-Package-58ed2a8cf5178d41",@@ -18806,6 +18836,40 @@}]},+ {+ "name": "sherpa-onnx-node",+ "SPDXID": "SPDXRef-Package-5a79f55f36b8ec3a",+ "versionInfo": "1.13.8",+ "downloadLocation": "https://github.com/csukuangfj/sherpa-onnx",+ "filesAnalyzed": false,+ "licenseConcluded": "Apache-2.0",+ "licenseDeclared": "Apache-2.0",+ "copyrightText": "NOASSERTION",+ "externalRefs": [+ {+ "referenceCategory": "PACKAGE-MANAGER",+ "referenceType": "purl",+ "referenceLocator": "pkg:npm/[email protected]"+ }+ ]+ },+ {+ "name": "sherpa-onnx-win-x64",+ "SPDXID": "SPDXRef-Package-5d6e174c6d9e0a2f",+ "versionInfo": "1.13.8",+ "downloadLocation": "https://github.com/csukuangfj/sherpa-onnx",+ "filesAnalyzed": false,+ "licenseConcluded": "Apache-2.0",+ "licenseDeclared": "Apache-2.0",+ "copyrightText": "NOASSERTION",+ "externalRefs": [+ {+ "referenceCategory": "PACKAGE-MANAGER",+ "referenceType": "purl",+ "referenceLocator": "pkg:npm/[email protected]"+ }+ ]+ },{"name": "side-channel","SPDXID": "SPDXRef-Package-b92f70c0533794b9",@@ -20530,6 +20594,11 @@"relationshipType": "DESCRIBES","relatedSpdxElement": "SPDXRef-Package-b5da0d7342486908"},+ {+ "spdxElementId": "SPDXRef-DOCUMENT",+ "relationshipType": "DESCRIBES",+ "relatedSpdxElement": "SPDXRef-Package-2eb4a603ce39b403"+ },{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",@@ -20560,6 +20629,11 @@"relationshipType": "DESCRIBES","relatedSpdxElement": "SPDXRef-Package-42f340d5003334bd"},+ {+ "spdxElementId": "SPDXRef-DOCUMENT",+ "relationshipType": "DESCRIBES",+ "relatedSpdxElement": "SPDXRef-Package-4e0ad65af2083a00"+ },{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",@@ -20595,6 +20669,11 @@"relationshipType": "DESCRIBES","relatedSpdxElement": "SPDXRef-Package-616963e2fc3a9428"},+ {+ "spdxElementId": "SPDXRef-DOCUMENT",+ "relationshipType": "DESCRIBES",+ "relatedSpdxElement": "SPDXRef-Package-1d15b57c9978e089"+ },{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",@@ -26090,6 +26169,16 @@"relationshipType": "DESCRIBES","relatedSpdxElement": "SPDXRef-Package-9905b9d4e1f2b3aa"},+ {+ "spdxElementId": "SPDXRef-DOCUMENT",+ "relationshipType": "DESCRIBES",+ "relatedSpdxElement": "SPDXRef-Package-5a79f55f36b8ec3a"+ },+ {+ "spdxElementId": "SPDXRef-DOCUMENT",+ "relationshipType": "DESCRIBES",+ "relatedSpdxElement": "SPDXRef-Package-5d6e174c6d9e0a2f"+ },{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",diff --git a/docs/legal/notices/sbom/mobile-android.spdx.json b/docs/legal/notices/sbom/mobile-android.spdx.jsonindex 1523e11c66..2d70868caa 100644--- a/docs/legal/notices/sbom/mobile-android.spdx.json+++ b/docs/legal/notices/sbom/mobile-android.spdx.json@@ -3,14 +3,24 @@"dataLicense": "CC0-1.0","SPDXID": "SPDXRef-DOCUMENT","name": "cindy-mobile-android",- "documentNamespace": "https://cindy.app/spdx/mobile-android/dd75db18ed7f49134892bf750cfad168c898c5f8a0456a20e38bfc7667c2120f",+ "documentNamespace": "https://cindy.app/spdx/mobile-android/7b10cc78b1ec6789a8f0f2746c512659e480e41fed68f912aa0a06b1ca054f09","creationInfo": {- "created": "2026-09-10T10:12:32Z",+ "created": "2026-10-09T19:41:25Z","creators": ["Tool: scripts/generate-third-party-notices.mjs"]},"packages": [+ {+ "name": "3D-Speaker CAM++ zh-en advanced (runtime-downloaded model)",+ "SPDXID": "SPDXRef-Package-2eb4a603ce39b403",+ "versionInfo": "sha256:aa3cfc16963a10586a9393f5035d6d6b57e98d358b347f80c2a30bf4f00ceba2",+ "downloadLocation": "https://modelscope.cn/models/iic/speech_campplus_sv_zh_en_16k-common_advanced",+ "filesAnalyzed": false,+ "licenseConcluded": "Apache-2.0",+ "licenseDeclared": "Apache-2.0",+ "copyrightText": "NOASSERTION"+ },{"name": "androidx.biometric:biometric","SPDXID": "SPDXRef-Package-6f75599db059a549",@@ -71,6 +81,26 @@"licenseDeclared": "MIT","copyrightText": "NOASSERTION"},+ {+ "name": "ONNX Runtime (native inference library)",+ "SPDXID": "SPDXRef-Package-3e9d926567425854",+ "versionInfo": "1.30.0",+ "downloadLocation": "https://github.com/microsoft/onnxruntime",+ "filesAnalyzed": false,+ "licenseConcluded": "MIT",+ "licenseDeclared": "MIT",+ "copyrightText": "NOASSERTION"+ },+ {+ "name": "Silero VAD (runtime-downloaded model)",+ "SPDXID": "SPDXRef-Package-1d15b57c9978e089",+ "versionInfo": "sha256:9e2449e1087496d8d4caba907f23e0bd3f78d91fa552479bb9c23ac09cbb1fd6",+ "downloadLocation": "https://github.com/snakers4/silero-vad",+ "filesAnalyzed": false,+ "licenseConcluded": "MIT",+ "licenseDeclared": "MIT",+ "copyrightText": "NOASSERTION"+ },{"name": "@babel/code-frame","SPDXID": "SPDXRef-Package-59e6d9f0e83e9c3b",@@ -1280,8 +1310,8 @@},{"name": "@expo/cli",- "SPDXID": "SPDXRef-Package-20e7a8f375c2feb7",- "versionInfo": "57.0.19",+ "SPDXID": "SPDXRef-Package-4c38605492dc9a11",+ "versionInfo": "57.0.25","downloadLocation": "https://github.com/expo/expo","filesAnalyzed": false,"licenseConcluded": "MIT",@@ -1291,7 +1321,7 @@{"referenceCategory": "PACKAGE-MANAGER","referenceType": "purl",- "referenceLocator": "pkg:npm/%40expo/[email protected]"+ "referenceLocator": "pkg:npm/%40expo/[email protected]"}]},@@ -1431,6 +1461,23 @@}]},+ {+ "name": "@expo/env",+ "SPDXID": "SPDXRef-Package-576decfc4b9c7655",+ "versionInfo": "2.4.3",+ "downloadLocation": "https://github.com/expo/expo",+ "filesAnalyzed": false,+ "licenseConcluded": "MIT",+ "licenseDeclared": "MIT",+ "copyrightText": "NOASSERTION",+ "externalRefs": [+ {+ "referenceCategory": "PACKAGE-MANAGER",+ "referenceType": "purl",+ "referenceLocator": "pkg:npm/%40expo/[email protected]"+ }+ ]+ },{"name": "@expo/expo-modules-macros-plugin","SPDXID": "SPDXRef-Package-a9b72b527dd55c2c",@@ -1450,8 +1497,8 @@},{"name": "@expo/fingerprint",- "SPDXID": "SPDXRef-Package-cf2499e732152ff1",- "versionInfo": "0.20.10",+ "SPDXID": "SPDXRef-Package-60465f81b52b3ddb",+ "versionInfo": "0.20.13","downloadLocation": "https://github.com/expo/expo","filesAnalyzed": false,"licenseConcluded": "MIT",@@ -1461,7 +1508,7 @@{"referenceCategory": "PACKAGE-MANAGER","referenceType": "purl",- "referenceLocator": "pkg:npm/%40expo/[email protected]"+ "referenceLocator": "pkg:npm/%40expo/[email protected]"}]},@@ -1569,8 +1616,8 @@},{"name": "@expo/metro-config",- "SPDXID": "SPDXRef-Package-7ba1e9724ad8c5a0",- "versionInfo": "57.0.11",+ "SPDXID": "SPDXRef-Package-6376cf19819959f5",+ "versionInfo": "57.0.12","downloadLocation": "https://github.com/expo/expo","filesAnalyzed": false,"licenseConcluded": "MIT",@@ -1580,14 +1627,14 @@{"referenceCategory": "PACKAGE-MANAGER","referenceType": "purl",- "referenceLocator": "pkg:npm/%40expo/[email protected]"+ "referenceLocator": "pkg:npm/%40expo/[email protected]"}]},{"name": "@expo/metro-file-map",- "SPDXID": "SPDXRef-Package-9613d6cca786e5b8",- "versionInfo": "57.0.2",+ "SPDXID": "SPDXRef-Package-e1d9cff7365c3636",+ "versionInfo": "57.0.3","downloadLocation": "https://github.com/expo/expo","filesAnalyzed": false,"licenseConcluded": "MIT",@@ -1597,7 +1644,7 @@{"referenceCategory": "PACKAGE-MANAGER","referenceType": "purl",- "referenceLocator": "pkg:npm/%40expo/[email protected]"+ "referenceLocator": "pkg:npm/%40expo/[email protected]"}]},@@ -1671,8 +1718,8 @@},{"name": "@expo/prebuild-config",- "SPDXID": "SPDXRef-Package-828ab691dacd318f",- "versionInfo": "57.0.15",+ "SPDXID": "SPDXRef-Package-d97431c86c672165",+ "versionInfo": "57.0.16","downloadLocation": "https://github.com/expo/expo","filesAnalyzed": false,"licenseConcluded": "MIT",@@ -1682,7 +1729,7 @@{"referenceCategory": "PACKAGE-MANAGER","referenceType": "purl",- "referenceLocator": "pkg:npm/%40expo/[email protected]"+ "referenceLocator": "pkg:npm/%40expo/[email protected]"}]},@@ -1705,8 +1752,8 @@},{"name": "@expo/router-server",- "SPDXID": "SPDXRef-Package-952f3858313b4378",- "versionInfo": "57.0.8",+ "SPDXID": "SPDXRef-Package-0fe2b3c7a719a1ee",+ "versionInfo": "57.0.10","downloadLocation": "https://github.com/expo/expo","filesAnalyzed": false,"licenseConcluded": "MIT",@@ -1716,7 +1763,7 @@{"referenceCategory": "PACKAGE-MANAGER","referenceType": "purl",- "referenceLocator": "pkg:npm/%40expo/[email protected]"+ "referenceLocator": "pkg:npm/%40expo/[email protected]"}]},@@ -2009,6 +2056,23 @@}]},+ {+ "name": "@noble/curves",+ "SPDXID": "SPDXRef-Package-a3f158ba6fd26723",+ "versionInfo": "1.9.7",+ "downloadLocation": "https://github.com/paulmillr/noble-curves",+ "filesAnalyzed": false,+ "licenseConcluded": "MIT",+ "licenseDeclared": "MIT",+ "copyrightText": "NOASSERTION",+ "externalRefs": [+ {+ "referenceCategory": "PACKAGE-MANAGER",+ "referenceType": "purl",+ "referenceLocator": "pkg:npm/%40noble/[email protected]"+ }+ ]+ },{"name": "@noble/hashes","SPDXID": "SPDXRef-Package-25ee07bb1d0db01a",@@ -2980,8 +3044,8 @@},{"name": "agent-cli-detector",- "SPDXID": "SPDXRef-Package-941d66f44d7533af",- "versionInfo": "0.1.6",+ "SPDXID": "SPDXRef-Package-c34d67768780f084",+ "versionInfo": "0.1.7","downloadLocation": "https://github.com/expo/agent-cli-detector","filesAnalyzed": false,"licenseConcluded": "MIT",@@ -2991,7 +3055,7 @@{"referenceCategory": "PACKAGE-MANAGER","referenceType": "purl",- "referenceLocator": "pkg:npm/[email protected]"+ "referenceLocator": "pkg:npm/[email protected]"}]},@@ -3337,8 +3401,8 @@},{"name": "babel-preset-expo",- "SPDXID": "SPDXRef-Package-a5b27d8080aa66fa",- "versionInfo": "57.0.9",+ "SPDXID": "SPDXRef-Package-f775f16f3653e52b",+ "versionInfo": "57.0.12","downloadLocation": "https://github.com/expo/expo","filesAnalyzed": false,"licenseConcluded": "MIT",@@ -3348,7 +3412,7 @@{"referenceCategory": "PACKAGE-MANAGER","referenceType": "purl",- "referenceLocator": "pkg:npm/[email protected]"+ "referenceLocator": "pkg:npm/[email protected]"}]},@@ -4680,8 +4744,8 @@},{"name": "expo",- "SPDXID": "SPDXRef-Package-a21f8aa8ea316bba",- "versionInfo": "57.0.17",+ "SPDXID": "SPDXRef-Package-4dca5c601c955e19",+ "versionInfo": "57.0.23","downloadLocation": "https://github.com/expo/expo","filesAnalyzed": false,"licenseConcluded": "MIT",@@ -4691,7 +4755,7 @@{"referenceCategory": "PACKAGE-MANAGER","referenceType": "purl",- "referenceLocator": "pkg:npm/[email protected]"+ "referenceLocator": "pkg:npm/[email protected]"}]},@@ -4731,8 +4795,8 @@},{"name": "expo-asset",- "SPDXID": "SPDXRef-Package-eb081b986ec50ba8",- "versionInfo": "57.0.15",+ "SPDXID": "SPDXRef-Package-455b2ad94eb0a0ab",+ "versionInfo": "57.0.17","downloadLocation": "https://github.com/expo/expo","filesAnalyzed": false,"licenseConcluded": "MIT",@@ -4742,7 +4806,7 @@{"referenceCategory": "PACKAGE-MANAGER","referenceType": "purl",- "referenceLocator": "pkg:npm/[email protected]"+ "referenceLocator": "pkg:npm/[email protected]"}]},@@ -4799,8 +4863,8 @@},{"name": "expo-build-properties",- "SPDXID": "SPDXRef-Package-db974288258db9d5",- "versionInfo": "57.0.15",+ "SPDXID": "SPDXRef-Package-c4ee9ea980e5bffb",+ "versionInfo": "57.0.20","downloadLocation": "https://github.com/expo/expo","filesAnalyzed": false,"licenseConcluded": "MIT",@@ -4810,7 +4874,7 @@{"referenceCategory": "PACKAGE-MANAGER","referenceType": "purl",- "referenceLocator": "pkg:npm/[email protected]"+ "referenceLocator": "pkg:npm/[email protected]"}]},@@ -4848,6 +4912,23 @@}]},+ {+ "name": "expo-constants",+ "SPDXID": "SPDXRef-Package-fb60b8597c3bdfd9",+ "versionInfo": "57.0.18",+ "downloadLocation": "https://github.com/expo/expo",+ "filesAnalyzed": false,+ "licenseConcluded": "MIT",+ "licenseDeclared": "MIT",+ "copyrightText": "NOASSERTION",+ "externalRefs": [+ {+ "referenceCategory": "PACKAGE-MANAGER",+ "referenceType": "purl",+ "referenceLocator": "pkg:npm/[email protected]"+ }+ ]+ },{"name": "expo-crypto","SPDXID": "SPDXRef-Package-437ab5e1d8c16256",@@ -4916,6 +4997,23 @@}]},+ {+ "name": "expo-file-system",+ "SPDXID": "SPDXRef-Package-153d64b34e15820d",+ "versionInfo": "57.0.7",+ "downloadLocation": "https://github.com/expo/expo",+ "filesAnalyzed": false,+ "licenseConcluded": "MIT",+ "licenseDeclared": "MIT",+ "copyrightText": "NOASSERTION",+ "externalRefs": [+ {+ "referenceCategory": "PACKAGE-MANAGER",+ "referenceType": "purl",+ "referenceLocator": "pkg:npm/[email protected]"+ }+ ]+ },{"name": "expo-font","SPDXID": "SPDXRef-Package-ca53585bedabf1bf",@@ -4933,6 +5031,23 @@}]},+ {+ "name": "expo-font",+ "SPDXID": "SPDXRef-Package-ed32bff73604a72e",+ "versionInfo": "57.0.4",+ "downloadLocation": "https://github.com/expo/expo",+ "filesAnalyzed": false,+ "licenseConcluded": "MIT",+ "licenseDeclared": "MIT",+ "copyrightText": "NOASSERTION",+ "externalRefs": [+ {+ "referenceCategory": "PACKAGE-MANAGER",+ "referenceType": "purl",+ "referenceLocator": "pkg:npm/[email protected]"+ }+ ]+ },{"name": "expo-glass-effect","SPDXID": "SPDXRef-Package-c383b71921578672",@@ -5037,8 +5152,8 @@},{"name": "expo-keep-awake",- "SPDXID": "SPDXRef-Package-e5bcaadc6e015d5e",- "versionInfo": "57.0.1",+ "SPDXID": "SPDXRef-Package-ee5cd43d9d869116",+ "versionInfo": "57.0.2","downloadLocation": "https://github.com/expo/expo","filesAnalyzed": false,"licenseConcluded": "MIT",@@ -5048,7 +5163,7 @@{"referenceCategory": "PACKAGE-MANAGER","referenceType": "purl",- "referenceLocator": "pkg:npm/[email protected]"+ "referenceLocator": "pkg:npm/[email protected]"}]},@@ -5122,8 +5237,8 @@},{"name": "expo-modules-autolinking",- "SPDXID": "SPDXRef-Package-f35e90f38d6ead79",- "versionInfo": "57.0.12",+ "SPDXID": "SPDXRef-Package-a0d21c01c890ee2a",+ "versionInfo": "57.0.13","downloadLocation": "https://github.com/expo/expo","filesAnalyzed": false,"licenseConcluded": "MIT",@@ -5133,14 +5248,14 @@{"referenceCategory": "PACKAGE-MANAGER","referenceType": "purl",- "referenceLocator": "pkg:npm/[email protected]"+ "referenceLocator": "pkg:npm/[email protected]"}]},{"name": "expo-modules-core",- "SPDXID": "SPDXRef-Package-b3b6449f3773b175",- "versionInfo": "57.0.14",+ "SPDXID": "SPDXRef-Package-3e3fa24f2480a101",+ "versionInfo": "57.0.18","downloadLocation": "https://github.com/expo/expo","filesAnalyzed": false,"licenseConcluded": "MIT",@@ -5150,14 +5265,14 @@{"referenceCategory": "PACKAGE-MANAGER","referenceType": "purl",- "referenceLocator": "pkg:npm/[email protected]"+ "referenceLocator": "pkg:npm/[email protected]"}]},{"name": "expo-modules-jsi",- "SPDXID": "SPDXRef-Package-bf533b3e2ed3f7f5",- "versionInfo": "57.0.6",+ "SPDXID": "SPDXRef-Package-fbe5efe5f2a826b5",+ "versionInfo": "57.1.0","downloadLocation": "https://github.com/expo/expo","filesAnalyzed": false,"licenseConcluded": "MIT",@@ -5167,7 +5282,7 @@{"referenceCategory": "PACKAGE-MANAGER","referenceType": "purl",- "referenceLocator": "pkg:npm/[email protected]"+ "referenceLocator": "pkg:npm/[email protected]"}]},@@ -5392,6 +5507,23 @@}]},+ {+ "name": "expo-video",+ "SPDXID": "SPDXRef-Package-a1434d7b53d4b95e",+ "versionInfo": "57.0.5",+ "downloadLocation": "https://github.com/expo/expo",+ "filesAnalyzed": false,+ "licenseConcluded": "MIT",+ "licenseDeclared": "MIT",+ "copyrightText": "NOASSERTION",+ "externalRefs": [+ {+ "referenceCategory": "PACKAGE-MANAGER",+ "referenceType": "purl",+ "referenceLocator": "pkg:npm/[email protected]"+ }+ ]+ },{"name": "expo-web-browser","SPDXID": "SPDXRef-Package-d7af0c7232fa828c",@@ -6516,8 +6648,8 @@},{"name": "lightningcss",- "SPDXID": "SPDXRef-Package-4ae3a8c2073b4202",- "versionInfo": "1.32.0",+ "SPDXID": "SPDXRef-Package-e3c68a8ebf6f2087",+ "versionInfo": "1.33.0","downloadLocation": "https://github.com/parcel-bundler/lightningcss","filesAnalyzed": false,"licenseConcluded": "MPL-2.0",@@ -6527,7 +6659,7 @@{"referenceCategory": "PACKAGE-MANAGER","referenceType": "purl",- "referenceLocator": "pkg:npm/[email protected]"+ "referenceLocator": "pkg:npm/[email protected]"}]},@@ -7500,6 +7632,23 @@}]},+ {+ "name": "nanoid",+ "SPDXID": "SPDXRef-Package-f1f7e9b95d53e9e2",+ "versionInfo": "3.3.18",+ "downloadLocation": "https://github.com/ai/nanoid",+ "filesAnalyzed": false,+ "licenseConcluded": "MIT",+ "licenseDeclared": "MIT",+ "copyrightText": "NOASSERTION",+ "externalRefs": [+ {+ "referenceCategory": "PACKAGE-MANAGER",+ "referenceType": "purl",+ "referenceLocator": "pkg:npm/[email protected]"+ }+ ]+ },{"name": "negotiator","SPDXID": "SPDXRef-Package-1afb2f733dd049f3",@@ -8012,8 +8161,8 @@},{"name": "postcss",- "SPDXID": "SPDXRef-Package-de2734fc17053fb9",- "versionInfo": "8.5.19",+ "SPDXID": "SPDXRef-Package-1434cfbc120afcc9",+ "versionInfo": "8.5.28","downloadLocation": "https://github.com/postcss/postcss","filesAnalyzed": false,"licenseConcluded": "MIT",@@ -8023,7 +8172,7 @@{"referenceCategory": "PACKAGE-MANAGER","referenceType": "purl",- "referenceLocator": "pkg:npm/[email protected]"+ "referenceLocator": "pkg:npm/[email protected]"}]},@@ -10460,6 +10609,11 @@}],"relationships": [+ {+ "spdxElementId": "SPDXRef-DOCUMENT",+ "relationshipType": "DESCRIBES",+ "relatedSpdxElement": "SPDXRef-Package-2eb4a603ce39b403"+ },{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",@@ -10490,6 +10644,16 @@"relationshipType": "DESCRIBES","relatedSpdxElement": "SPDXRef-Package-82458194310410e0"},+ {+ "spdxElementId": "SPDXRef-DOCUMENT",+ "relationshipType": "DESCRIBES",+ "relatedSpdxElement": "SPDXRef-Package-3e9d926567425854"+ },+ {+ "spdxElementId": "SPDXRef-DOCUMENT",+ "relationshipType": "DESCRIBES",+ "relatedSpdxElement": "SPDXRef-Package-1d15b57c9978e089"+ },{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",@@ -10848,7 +11012,7 @@{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",- "relatedSpdxElement": "SPDXRef-Package-20e7a8f375c2feb7"+ "relatedSpdxElement": "SPDXRef-Package-4c38605492dc9a11"},{"spdxElementId": "SPDXRef-DOCUMENT",@@ -10890,6 +11054,11 @@"relationshipType": "DESCRIBES","relatedSpdxElement": "SPDXRef-Package-e80db337b2d7f036"},+ {+ "spdxElementId": "SPDXRef-DOCUMENT",+ "relationshipType": "DESCRIBES",+ "relatedSpdxElement": "SPDXRef-Package-576decfc4b9c7655"+ },{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",@@ -10898,7 +11067,7 @@{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",- "relatedSpdxElement": "SPDXRef-Package-cf2499e732152ff1"+ "relatedSpdxElement": "SPDXRef-Package-60465f81b52b3ddb"},{"spdxElementId": "SPDXRef-DOCUMENT",@@ -10933,12 +11102,12 @@{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",- "relatedSpdxElement": "SPDXRef-Package-7ba1e9724ad8c5a0"+ "relatedSpdxElement": "SPDXRef-Package-6376cf19819959f5"},{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",- "relatedSpdxElement": "SPDXRef-Package-9613d6cca786e5b8"+ "relatedSpdxElement": "SPDXRef-Package-e1d9cff7365c3636"},{"spdxElementId": "SPDXRef-DOCUMENT",@@ -10963,7 +11132,7 @@{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",- "relatedSpdxElement": "SPDXRef-Package-828ab691dacd318f"+ "relatedSpdxElement": "SPDXRef-Package-d97431c86c672165"},{"spdxElementId": "SPDXRef-DOCUMENT",@@ -10973,7 +11142,7 @@{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",- "relatedSpdxElement": "SPDXRef-Package-952f3858313b4378"+ "relatedSpdxElement": "SPDXRef-Package-0fe2b3c7a719a1ee"},{"spdxElementId": "SPDXRef-DOCUMENT",@@ -11060,6 +11229,11 @@"relationshipType": "DESCRIBES","relatedSpdxElement": "SPDXRef-Package-0c68eb85c54800d9"},+ {+ "spdxElementId": "SPDXRef-DOCUMENT",+ "relationshipType": "DESCRIBES",+ "relatedSpdxElement": "SPDXRef-Package-a3f158ba6fd26723"+ },{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",@@ -11348,7 +11522,7 @@{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",- "relatedSpdxElement": "SPDXRef-Package-941d66f44d7533af"+ "relatedSpdxElement": "SPDXRef-Package-c34d67768780f084"},{"spdxElementId": "SPDXRef-DOCUMENT",@@ -11453,7 +11627,7 @@{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",- "relatedSpdxElement": "SPDXRef-Package-a5b27d8080aa66fa"+ "relatedSpdxElement": "SPDXRef-Package-f775f16f3653e52b"},{"spdxElementId": "SPDXRef-DOCUMENT",@@ -11848,7 +12022,7 @@{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",- "relatedSpdxElement": "SPDXRef-Package-a21f8aa8ea316bba"+ "relatedSpdxElement": "SPDXRef-Package-4dca5c601c955e19"},{"spdxElementId": "SPDXRef-DOCUMENT",@@ -11863,7 +12037,7 @@{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",- "relatedSpdxElement": "SPDXRef-Package-eb081b986ec50ba8"+ "relatedSpdxElement": "SPDXRef-Package-455b2ad94eb0a0ab"},{"spdxElementId": "SPDXRef-DOCUMENT",@@ -11883,7 +12057,7 @@{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",- "relatedSpdxElement": "SPDXRef-Package-db974288258db9d5"+ "relatedSpdxElement": "SPDXRef-Package-c4ee9ea980e5bffb"},{"spdxElementId": "SPDXRef-DOCUMENT",@@ -11895,6 +12069,11 @@"relationshipType": "DESCRIBES","relatedSpdxElement": "SPDXRef-Package-178ca4d8f21ab312"},+ {+ "spdxElementId": "SPDXRef-DOCUMENT",+ "relationshipType": "DESCRIBES",+ "relatedSpdxElement": "SPDXRef-Package-fb60b8597c3bdfd9"+ },{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",@@ -11915,11 +12094,21 @@"relationshipType": "DESCRIBES","relatedSpdxElement": "SPDXRef-Package-3afcf9f00a2e8de5"},+ {+ "spdxElementId": "SPDXRef-DOCUMENT",+ "relationshipType": "DESCRIBES",+ "relatedSpdxElement": "SPDXRef-Package-153d64b34e15820d"+ },{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES","relatedSpdxElement": "SPDXRef-Package-ca53585bedabf1bf"},+ {+ "spdxElementId": "SPDXRef-DOCUMENT",+ "relationshipType": "DESCRIBES",+ "relatedSpdxElement": "SPDXRef-Package-ed32bff73604a72e"+ },{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",@@ -11953,7 +12142,7 @@{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",- "relatedSpdxElement": "SPDXRef-Package-e5bcaadc6e015d5e"+ "relatedSpdxElement": "SPDXRef-Package-ee5cd43d9d869116"},{"spdxElementId": "SPDXRef-DOCUMENT",@@ -11978,17 +12167,17 @@{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",- "relatedSpdxElement": "SPDXRef-Package-f35e90f38d6ead79"+ "relatedSpdxElement": "SPDXRef-Package-a0d21c01c890ee2a"},{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",- "relatedSpdxElement": "SPDXRef-Package-b3b6449f3773b175"+ "relatedSpdxElement": "SPDXRef-Package-3e3fa24f2480a101"},{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",- "relatedSpdxElement": "SPDXRef-Package-bf533b3e2ed3f7f5"+ "relatedSpdxElement": "SPDXRef-Package-fbe5efe5f2a826b5"},{"spdxElementId": "SPDXRef-DOCUMENT",@@ -12055,6 +12244,11 @@"relationshipType": "DESCRIBES","relatedSpdxElement": "SPDXRef-Package-8b849016e1749034"},+ {+ "spdxElementId": "SPDXRef-DOCUMENT",+ "relationshipType": "DESCRIBES",+ "relatedSpdxElement": "SPDXRef-Package-a1434d7b53d4b95e"+ },{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",@@ -12388,7 +12582,7 @@{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",- "relatedSpdxElement": "SPDXRef-Package-4ae3a8c2073b4202"+ "relatedSpdxElement": "SPDXRef-Package-e3c68a8ebf6f2087"},{"spdxElementId": "SPDXRef-DOCUMENT",@@ -12675,6 +12869,11 @@"relationshipType": "DESCRIBES","relatedSpdxElement": "SPDXRef-Package-80ad184a0e4c0576"},+ {+ "spdxElementId": "SPDXRef-DOCUMENT",+ "relationshipType": "DESCRIBES",+ "relatedSpdxElement": "SPDXRef-Package-f1f7e9b95d53e9e2"+ },{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",@@ -12828,7 +13027,7 @@{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",- "relatedSpdxElement": "SPDXRef-Package-de2734fc17053fb9"+ "relatedSpdxElement": "SPDXRef-Package-1434cfbc120afcc9"},{"spdxElementId": "SPDXRef-DOCUMENT",diff --git a/docs/legal/notices/sbom/mobile-ios.spdx.json b/docs/legal/notices/sbom/mobile-ios.spdx.jsonindex ff6ca62de5..e05a0bfa9a 100644--- a/docs/legal/notices/sbom/mobile-ios.spdx.json+++ b/docs/legal/notices/sbom/mobile-ios.spdx.json@@ -3,14 +3,24 @@"dataLicense": "CC0-1.0","SPDXID": "SPDXRef-DOCUMENT","name": "cindy-mobile-ios",- "documentNamespace": "https://cindy.app/spdx/mobile-ios/88943e24e7cee9f96720104195d988ca90749b20f22b29825c8c755898d9e593",+ "documentNamespace": "https://cindy.app/spdx/mobile-ios/195ab0d7a13705576a098da85509873559924059ab8af30df7ab0ddc18b309ad","creationInfo": {- "created": "2026-09-10T10:12:32Z",+ "created": "2026-10-09T19:41:25Z","creators": ["Tool: scripts/generate-third-party-notices.mjs"]},"packages": [+ {+ "name": "3D-Speaker CAM++ zh-en advanced (runtime-downloaded model)",+ "SPDXID": "SPDXRef-Package-2eb4a603ce39b403",+ "versionInfo": "sha256:aa3cfc16963a10586a9393f5035d6d6b57e98d358b347f80c2a30bf4f00ceba2",+ "downloadLocation": "https://modelscope.cn/models/iic/speech_campplus_sv_zh_en_16k-common_advanced",+ "filesAnalyzed": false,+ "licenseConcluded": "Apache-2.0",+ "licenseDeclared": "Apache-2.0",+ "copyrightText": "NOASSERTION"+ },{"name": "JetBrains Mono fonts","SPDXID": "SPDXRef-Package-4aed76e603981340",@@ -51,6 +61,26 @@"licenseDeclared": "MIT","copyrightText": "NOASSERTION"},+ {+ "name": "ONNX Runtime (native inference library)",+ "SPDXID": "SPDXRef-Package-3e9d926567425854",+ "versionInfo": "1.30.0",+ "downloadLocation": "https://github.com/microsoft/onnxruntime",+ "filesAnalyzed": false,+ "licenseConcluded": "MIT",+ "licenseDeclared": "MIT",+ "copyrightText": "NOASSERTION"+ },+ {+ "name": "Silero VAD (runtime-downloaded model)",+ "SPDXID": "SPDXRef-Package-1d15b57c9978e089",+ "versionInfo": "sha256:9e2449e1087496d8d4caba907f23e0bd3f78d91fa552479bb9c23ac09cbb1fd6",+ "downloadLocation": "https://github.com/snakers4/silero-vad",+ "filesAnalyzed": false,+ "licenseConcluded": "MIT",+ "licenseDeclared": "MIT",+ "copyrightText": "NOASSERTION"+ },{"name": "TapTapSDK/Core","SPDXID": "SPDXRef-Package-962056ba719a6ad6",@@ -1270,8 +1300,8 @@},{"name": "@expo/cli",- "SPDXID": "SPDXRef-Package-20e7a8f375c2feb7",- "versionInfo": "57.0.19",+ "SPDXID": "SPDXRef-Package-4c38605492dc9a11",+ "versionInfo": "57.0.25","downloadLocation": "https://github.com/expo/expo","filesAnalyzed": false,"licenseConcluded": "MIT",@@ -1281,7 +1311,7 @@{"referenceCategory": "PACKAGE-MANAGER","referenceType": "purl",- "referenceLocator": "pkg:npm/%40expo/[email protected]"+ "referenceLocator": "pkg:npm/%40expo/[email protected]"}]},@@ -1421,6 +1451,23 @@}]},+ {+ "name": "@expo/env",+ "SPDXID": "SPDXRef-Package-576decfc4b9c7655",+ "versionInfo": "2.4.3",+ "downloadLocation": "https://github.com/expo/expo",+ "filesAnalyzed": false,+ "licenseConcluded": "MIT",+ "licenseDeclared": "MIT",+ "copyrightText": "NOASSERTION",+ "externalRefs": [+ {+ "referenceCategory": "PACKAGE-MANAGER",+ "referenceType": "purl",+ "referenceLocator": "pkg:npm/%40expo/[email protected]"+ }+ ]+ },{"name": "@expo/expo-modules-macros-plugin","SPDXID": "SPDXRef-Package-a9b72b527dd55c2c",@@ -1440,8 +1487,8 @@},{"name": "@expo/fingerprint",- "SPDXID": "SPDXRef-Package-cf2499e732152ff1",- "versionInfo": "0.20.10",+ "SPDXID": "SPDXRef-Package-60465f81b52b3ddb",+ "versionInfo": "0.20.13","downloadLocation": "https://github.com/expo/expo","filesAnalyzed": false,"licenseConcluded": "MIT",@@ -1451,7 +1498,7 @@{"referenceCategory": "PACKAGE-MANAGER","referenceType": "purl",- "referenceLocator": "pkg:npm/%40expo/[email protected]"+ "referenceLocator": "pkg:npm/%40expo/[email protected]"}]},@@ -1559,8 +1606,8 @@},{"name": "@expo/metro-config",- "SPDXID": "SPDXRef-Package-7ba1e9724ad8c5a0",- "versionInfo": "57.0.11",+ "SPDXID": "SPDXRef-Package-6376cf19819959f5",+ "versionInfo": "57.0.12","downloadLocation": "https://github.com/expo/expo","filesAnalyzed": false,"licenseConcluded": "MIT",@@ -1570,14 +1617,14 @@{"referenceCategory": "PACKAGE-MANAGER","referenceType": "purl",- "referenceLocator": "pkg:npm/%40expo/[email protected]"+ "referenceLocator": "pkg:npm/%40expo/[email protected]"}]},{"name": "@expo/metro-file-map",- "SPDXID": "SPDXRef-Package-9613d6cca786e5b8",- "versionInfo": "57.0.2",+ "SPDXID": "SPDXRef-Package-e1d9cff7365c3636",+ "versionInfo": "57.0.3","downloadLocation": "https://github.com/expo/expo","filesAnalyzed": false,"licenseConcluded": "MIT",@@ -1587,7 +1634,7 @@{"referenceCategory": "PACKAGE-MANAGER","referenceType": "purl",- "referenceLocator": "pkg:npm/%40expo/[email protected]"+ "referenceLocator": "pkg:npm/%40expo/[email protected]"}]},@@ -1661,8 +1708,8 @@},{"name": "@expo/prebuild-config",- "SPDXID": "SPDXRef-Package-828ab691dacd318f",- "versionInfo": "57.0.15",+ "SPDXID": "SPDXRef-Package-d97431c86c672165",+ "versionInfo": "57.0.16","downloadLocation": "https://github.com/expo/expo","filesAnalyzed": false,"licenseConcluded": "MIT",@@ -1672,7 +1719,7 @@{"referenceCategory": "PACKAGE-MANAGER","referenceType": "purl",- "referenceLocator": "pkg:npm/%40expo/[email protected]"+ "referenceLocator": "pkg:npm/%40expo/[email protected]"}]},@@ -1695,8 +1742,8 @@},{"name": "@expo/router-server",- "SPDXID": "SPDXRef-Package-952f3858313b4378",- "versionInfo": "57.0.8",+ "SPDXID": "SPDXRef-Package-0fe2b3c7a719a1ee",+ "versionInfo": "57.0.10","downloadLocation": "https://github.com/expo/expo","filesAnalyzed": false,"licenseConcluded": "MIT",@@ -1706,7 +1753,7 @@{"referenceCategory": "PACKAGE-MANAGER","referenceType": "purl",- "referenceLocator": "pkg:npm/%40expo/[email protected]"+ "referenceLocator": "pkg:npm/%40expo/[email protected]"}]},@@ -1999,6 +2046,23 @@}]},+ {+ "name": "@noble/curves",+ "SPDXID": "SPDXRef-Package-a3f158ba6fd26723",+ "versionInfo": "1.9.7",+ "downloadLocation": "https://github.com/paulmillr/noble-curves",+ "filesAnalyzed": false,+ "licenseConcluded": "MIT",+ "licenseDeclared": "MIT",+ "copyrightText": "NOASSERTION",+ "externalRefs": [+ {+ "referenceCategory": "PACKAGE-MANAGER",+ "referenceType": "purl",+ "referenceLocator": "pkg:npm/%40noble/[email protected]"+ }+ ]+ },{"name": "@noble/hashes","SPDXID": "SPDXRef-Package-25ee07bb1d0db01a",@@ -2970,8 +3034,8 @@},{"name": "agent-cli-detector",- "SPDXID": "SPDXRef-Package-941d66f44d7533af",- "versionInfo": "0.1.6",+ "SPDXID": "SPDXRef-Package-c34d67768780f084",+ "versionInfo": "0.1.7","downloadLocation": "https://github.com/expo/agent-cli-detector","filesAnalyzed": false,"licenseConcluded": "MIT",@@ -2981,7 +3045,7 @@{"referenceCategory": "PACKAGE-MANAGER","referenceType": "purl",- "referenceLocator": "pkg:npm/[email protected]"+ "referenceLocator": "pkg:npm/[email protected]"}]},@@ -3327,8 +3391,8 @@},{"name": "babel-preset-expo",- "SPDXID": "SPDXRef-Package-a5b27d8080aa66fa",- "versionInfo": "57.0.9",+ "SPDXID": "SPDXRef-Package-f775f16f3653e52b",+ "versionInfo": "57.0.12","downloadLocation": "https://github.com/expo/expo","filesAnalyzed": false,"licenseConcluded": "MIT",@@ -3338,7 +3402,7 @@{"referenceCategory": "PACKAGE-MANAGER","referenceType": "purl",- "referenceLocator": "pkg:npm/[email protected]"+ "referenceLocator": "pkg:npm/[email protected]"}]},@@ -4670,8 +4734,8 @@},{"name": "expo",- "SPDXID": "SPDXRef-Package-a21f8aa8ea316bba",- "versionInfo": "57.0.17",+ "SPDXID": "SPDXRef-Package-4dca5c601c955e19",+ "versionInfo": "57.0.23","downloadLocation": "https://github.com/expo/expo","filesAnalyzed": false,"licenseConcluded": "MIT",@@ -4681,7 +4745,7 @@{"referenceCategory": "PACKAGE-MANAGER","referenceType": "purl",- "referenceLocator": "pkg:npm/[email protected]"+ "referenceLocator": "pkg:npm/[email protected]"}]},@@ -4721,8 +4785,8 @@},{"name": "expo-asset",- "SPDXID": "SPDXRef-Package-eb081b986ec50ba8",- "versionInfo": "57.0.15",+ "SPDXID": "SPDXRef-Package-455b2ad94eb0a0ab",+ "versionInfo": "57.0.17","downloadLocation": "https://github.com/expo/expo","filesAnalyzed": false,"licenseConcluded": "MIT",@@ -4732,7 +4796,7 @@{"referenceCategory": "PACKAGE-MANAGER","referenceType": "purl",- "referenceLocator": "pkg:npm/[email protected]"+ "referenceLocator": "pkg:npm/[email protected]"}]},@@ -4789,8 +4853,8 @@},{"name": "expo-build-properties",- "SPDXID": "SPDXRef-Package-db974288258db9d5",- "versionInfo": "57.0.15",+ "SPDXID": "SPDXRef-Package-c4ee9ea980e5bffb",+ "versionInfo": "57.0.20","downloadLocation": "https://github.com/expo/expo","filesAnalyzed": false,"licenseConcluded": "MIT",@@ -4800,7 +4864,7 @@{"referenceCategory": "PACKAGE-MANAGER","referenceType": "purl",- "referenceLocator": "pkg:npm/[email protected]"+ "referenceLocator": "pkg:npm/[email protected]"}]},@@ -4838,6 +4902,23 @@}]},+ {+ "name": "expo-constants",+ "SPDXID": "SPDXRef-Package-fb60b8597c3bdfd9",+ "versionInfo": "57.0.18",+ "downloadLocation": "https://github.com/expo/expo",+ "filesAnalyzed": false,+ "licenseConcluded": "MIT",+ "licenseDeclared": "MIT",+ "copyrightText": "NOASSERTION",+ "externalRefs": [+ {+ "referenceCategory": "PACKAGE-MANAGER",+ "referenceType": "purl",+ "referenceLocator": "pkg:npm/[email protected]"+ }+ ]+ },{"name": "expo-crypto","SPDXID": "SPDXRef-Package-437ab5e1d8c16256",@@ -4906,6 +4987,23 @@}]},+ {+ "name": "expo-file-system",+ "SPDXID": "SPDXRef-Package-153d64b34e15820d",+ "versionInfo": "57.0.7",+ "downloadLocation": "https://github.com/expo/expo",+ "filesAnalyzed": false,+ "licenseConcluded": "MIT",+ "licenseDeclared": "MIT",+ "copyrightText": "NOASSERTION",+ "externalRefs": [+ {+ "referenceCategory": "PACKAGE-MANAGER",+ "referenceType": "purl",+ "referenceLocator": "pkg:npm/[email protected]"+ }+ ]+ },{"name": "expo-font","SPDXID": "SPDXRef-Package-ca53585bedabf1bf",@@ -4923,6 +5021,23 @@}]},+ {+ "name": "expo-font",+ "SPDXID": "SPDXRef-Package-ed32bff73604a72e",+ "versionInfo": "57.0.4",+ "downloadLocation": "https://github.com/expo/expo",+ "filesAnalyzed": false,+ "licenseConcluded": "MIT",+ "licenseDeclared": "MIT",+ "copyrightText": "NOASSERTION",+ "externalRefs": [+ {+ "referenceCategory": "PACKAGE-MANAGER",+ "referenceType": "purl",+ "referenceLocator": "pkg:npm/[email protected]"+ }+ ]+ },{"name": "expo-glass-effect","SPDXID": "SPDXRef-Package-c383b71921578672",@@ -5027,8 +5142,8 @@},{"name": "expo-keep-awake",- "SPDXID": "SPDXRef-Package-e5bcaadc6e015d5e",- "versionInfo": "57.0.1",+ "SPDXID": "SPDXRef-Package-ee5cd43d9d869116",+ "versionInfo": "57.0.2","downloadLocation": "https://github.com/expo/expo","filesAnalyzed": false,"licenseConcluded": "MIT",@@ -5038,7 +5153,7 @@{"referenceCategory": "PACKAGE-MANAGER","referenceType": "purl",- "referenceLocator": "pkg:npm/[email protected]"+ "referenceLocator": "pkg:npm/[email protected]"}]},@@ -5112,8 +5227,8 @@},{"name": "expo-modules-autolinking",- "SPDXID": "SPDXRef-Package-f35e90f38d6ead79",- "versionInfo": "57.0.12",+ "SPDXID": "SPDXRef-Package-a0d21c01c890ee2a",+ "versionInfo": "57.0.13","downloadLocation": "https://github.com/expo/expo","filesAnalyzed": false,"licenseConcluded": "MIT",@@ -5123,14 +5238,14 @@{"referenceCategory": "PACKAGE-MANAGER","referenceType": "purl",- "referenceLocator": "pkg:npm/[email protected]"+ "referenceLocator": "pkg:npm/[email protected]"}]},{"name": "expo-modules-core",- "SPDXID": "SPDXRef-Package-b3b6449f3773b175",- "versionInfo": "57.0.14",+ "SPDXID": "SPDXRef-Package-3e3fa24f2480a101",+ "versionInfo": "57.0.18","downloadLocation": "https://github.com/expo/expo","filesAnalyzed": false,"licenseConcluded": "MIT",@@ -5140,14 +5255,14 @@{"referenceCategory": "PACKAGE-MANAGER","referenceType": "purl",- "referenceLocator": "pkg:npm/[email protected]"+ "referenceLocator": "pkg:npm/[email protected]"}]},{"name": "expo-modules-jsi",- "SPDXID": "SPDXRef-Package-bf533b3e2ed3f7f5",- "versionInfo": "57.0.6",+ "SPDXID": "SPDXRef-Package-fbe5efe5f2a826b5",+ "versionInfo": "57.1.0","downloadLocation": "https://github.com/expo/expo","filesAnalyzed": false,"licenseConcluded": "MIT",@@ -5157,7 +5272,7 @@{"referenceCategory": "PACKAGE-MANAGER","referenceType": "purl",- "referenceLocator": "pkg:npm/[email protected]"+ "referenceLocator": "pkg:npm/[email protected]"}]},@@ -5382,6 +5497,23 @@}]},+ {+ "name": "expo-video",+ "SPDXID": "SPDXRef-Package-a1434d7b53d4b95e",+ "versionInfo": "57.0.5",+ "downloadLocation": "https://github.com/expo/expo",+ "filesAnalyzed": false,+ "licenseConcluded": "MIT",+ "licenseDeclared": "MIT",+ "copyrightText": "NOASSERTION",+ "externalRefs": [+ {+ "referenceCategory": "PACKAGE-MANAGER",+ "referenceType": "purl",+ "referenceLocator": "pkg:npm/[email protected]"+ }+ ]+ },{"name": "expo-web-browser","SPDXID": "SPDXRef-Package-d7af0c7232fa828c",@@ -6506,8 +6638,8 @@},{"name": "lightningcss",- "SPDXID": "SPDXRef-Package-4ae3a8c2073b4202",- "versionInfo": "1.32.0",+ "SPDXID": "SPDXRef-Package-e3c68a8ebf6f2087",+ "versionInfo": "1.33.0","downloadLocation": "https://github.com/parcel-bundler/lightningcss","filesAnalyzed": false,"licenseConcluded": "MPL-2.0",@@ -6517,7 +6649,7 @@{"referenceCategory": "PACKAGE-MANAGER","referenceType": "purl",- "referenceLocator": "pkg:npm/[email protected]"+ "referenceLocator": "pkg:npm/[email protected]"}]},@@ -7490,6 +7622,23 @@}]},+ {+ "name": "nanoid",+ "SPDXID": "SPDXRef-Package-f1f7e9b95d53e9e2",+ "versionInfo": "3.3.18",+ "downloadLocation": "https://github.com/ai/nanoid",+ "filesAnalyzed": false,+ "licenseConcluded": "MIT",+ "licenseDeclared": "MIT",+ "copyrightText": "NOASSERTION",+ "externalRefs": [+ {+ "referenceCategory": "PACKAGE-MANAGER",+ "referenceType": "purl",+ "referenceLocator": "pkg:npm/[email protected]"+ }+ ]+ },{"name": "negotiator","SPDXID": "SPDXRef-Package-1afb2f733dd049f3",@@ -8002,8 +8151,8 @@},{"name": "postcss",- "SPDXID": "SPDXRef-Package-de2734fc17053fb9",- "versionInfo": "8.5.19",+ "SPDXID": "SPDXRef-Package-1434cfbc120afcc9",+ "versionInfo": "8.5.28","downloadLocation": "https://github.com/postcss/postcss","filesAnalyzed": false,"licenseConcluded": "MIT",@@ -8013,7 +8162,7 @@{"referenceCategory": "PACKAGE-MANAGER","referenceType": "purl",- "referenceLocator": "pkg:npm/[email protected]"+ "referenceLocator": "pkg:npm/[email protected]"}]},@@ -10450,6 +10599,11 @@}],"relationships": [+ {+ "spdxElementId": "SPDXRef-DOCUMENT",+ "relationshipType": "DESCRIBES",+ "relatedSpdxElement": "SPDXRef-Package-2eb4a603ce39b403"+ },{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",@@ -10470,6 +10624,16 @@"relationshipType": "DESCRIBES","relatedSpdxElement": "SPDXRef-Package-82458194310410e0"},+ {+ "spdxElementId": "SPDXRef-DOCUMENT",+ "relationshipType": "DESCRIBES",+ "relatedSpdxElement": "SPDXRef-Package-3e9d926567425854"+ },+ {+ "spdxElementId": "SPDXRef-DOCUMENT",+ "relationshipType": "DESCRIBES",+ "relatedSpdxElement": "SPDXRef-Package-1d15b57c9978e089"+ },{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",@@ -10833,7 +10997,7 @@{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",- "relatedSpdxElement": "SPDXRef-Package-20e7a8f375c2feb7"+ "relatedSpdxElement": "SPDXRef-Package-4c38605492dc9a11"},{"spdxElementId": "SPDXRef-DOCUMENT",@@ -10875,6 +11039,11 @@"relationshipType": "DESCRIBES","relatedSpdxElement": "SPDXRef-Package-e80db337b2d7f036"},+ {+ "spdxElementId": "SPDXRef-DOCUMENT",+ "relationshipType": "DESCRIBES",+ "relatedSpdxElement": "SPDXRef-Package-576decfc4b9c7655"+ },{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",@@ -10883,7 +11052,7 @@{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",- "relatedSpdxElement": "SPDXRef-Package-cf2499e732152ff1"+ "relatedSpdxElement": "SPDXRef-Package-60465f81b52b3ddb"},{"spdxElementId": "SPDXRef-DOCUMENT",@@ -10918,12 +11087,12 @@{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",- "relatedSpdxElement": "SPDXRef-Package-7ba1e9724ad8c5a0"+ "relatedSpdxElement": "SPDXRef-Package-6376cf19819959f5"},{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",- "relatedSpdxElement": "SPDXRef-Package-9613d6cca786e5b8"+ "relatedSpdxElement": "SPDXRef-Package-e1d9cff7365c3636"},{"spdxElementId": "SPDXRef-DOCUMENT",@@ -10948,7 +11117,7 @@{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",- "relatedSpdxElement": "SPDXRef-Package-828ab691dacd318f"+ "relatedSpdxElement": "SPDXRef-Package-d97431c86c672165"},{"spdxElementId": "SPDXRef-DOCUMENT",@@ -10958,7 +11127,7 @@{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",- "relatedSpdxElement": "SPDXRef-Package-952f3858313b4378"+ "relatedSpdxElement": "SPDXRef-Package-0fe2b3c7a719a1ee"},{"spdxElementId": "SPDXRef-DOCUMENT",@@ -11045,6 +11214,11 @@"relationshipType": "DESCRIBES","relatedSpdxElement": "SPDXRef-Package-0c68eb85c54800d9"},+ {+ "spdxElementId": "SPDXRef-DOCUMENT",+ "relationshipType": "DESCRIBES",+ "relatedSpdxElement": "SPDXRef-Package-a3f158ba6fd26723"+ },{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",@@ -11333,7 +11507,7 @@{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",- "relatedSpdxElement": "SPDXRef-Package-941d66f44d7533af"+ "relatedSpdxElement": "SPDXRef-Package-c34d67768780f084"},{"spdxElementId": "SPDXRef-DOCUMENT",@@ -11438,7 +11612,7 @@{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",- "relatedSpdxElement": "SPDXRef-Package-a5b27d8080aa66fa"+ "relatedSpdxElement": "SPDXRef-Package-f775f16f3653e52b"},{"spdxElementId": "SPDXRef-DOCUMENT",@@ -11833,7 +12007,7 @@{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",- "relatedSpdxElement": "SPDXRef-Package-a21f8aa8ea316bba"+ "relatedSpdxElement": "SPDXRef-Package-4dca5c601c955e19"},{"spdxElementId": "SPDXRef-DOCUMENT",@@ -11848,7 +12022,7 @@{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",- "relatedSpdxElement": "SPDXRef-Package-eb081b986ec50ba8"+ "relatedSpdxElement": "SPDXRef-Package-455b2ad94eb0a0ab"},{"spdxElementId": "SPDXRef-DOCUMENT",@@ -11868,7 +12042,7 @@{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",- "relatedSpdxElement": "SPDXRef-Package-db974288258db9d5"+ "relatedSpdxElement": "SPDXRef-Package-c4ee9ea980e5bffb"},{"spdxElementId": "SPDXRef-DOCUMENT",@@ -11880,6 +12054,11 @@"relationshipType": "DESCRIBES","relatedSpdxElement": "SPDXRef-Package-178ca4d8f21ab312"},+ {+ "spdxElementId": "SPDXRef-DOCUMENT",+ "relationshipType": "DESCRIBES",+ "relatedSpdxElement": "SPDXRef-Package-fb60b8597c3bdfd9"+ },{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",@@ -11900,11 +12079,21 @@"relationshipType": "DESCRIBES","relatedSpdxElement": "SPDXRef-Package-3afcf9f00a2e8de5"},+ {+ "spdxElementId": "SPDXRef-DOCUMENT",+ "relationshipType": "DESCRIBES",+ "relatedSpdxElement": "SPDXRef-Package-153d64b34e15820d"+ },{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES","relatedSpdxElement": "SPDXRef-Package-ca53585bedabf1bf"},+ {+ "spdxElementId": "SPDXRef-DOCUMENT",+ "relationshipType": "DESCRIBES",+ "relatedSpdxElement": "SPDXRef-Package-ed32bff73604a72e"+ },{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",@@ -11938,7 +12127,7 @@{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",- "relatedSpdxElement": "SPDXRef-Package-e5bcaadc6e015d5e"+ "relatedSpdxElement": "SPDXRef-Package-ee5cd43d9d869116"},{"spdxElementId": "SPDXRef-DOCUMENT",@@ -11963,17 +12152,17 @@{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",- "relatedSpdxElement": "SPDXRef-Package-f35e90f38d6ead79"+ "relatedSpdxElement": "SPDXRef-Package-a0d21c01c890ee2a"},{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",- "relatedSpdxElement": "SPDXRef-Package-b3b6449f3773b175"+ "relatedSpdxElement": "SPDXRef-Package-3e3fa24f2480a101"},{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",- "relatedSpdxElement": "SPDXRef-Package-bf533b3e2ed3f7f5"+ "relatedSpdxElement": "SPDXRef-Package-fbe5efe5f2a826b5"},{"spdxElementId": "SPDXRef-DOCUMENT",@@ -12040,6 +12229,11 @@"relationshipType": "DESCRIBES","relatedSpdxElement": "SPDXRef-Package-8b849016e1749034"},+ {+ "spdxElementId": "SPDXRef-DOCUMENT",+ "relationshipType": "DESCRIBES",+ "relatedSpdxElement": "SPDXRef-Package-a1434d7b53d4b95e"+ },{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",@@ -12373,7 +12567,7 @@{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",- "relatedSpdxElement": "SPDXRef-Package-4ae3a8c2073b4202"+ "relatedSpdxElement": "SPDXRef-Package-e3c68a8ebf6f2087"},{"spdxElementId": "SPDXRef-DOCUMENT",@@ -12660,6 +12854,11 @@"relationshipType": "DESCRIBES","relatedSpdxElement": "SPDXRef-Package-80ad184a0e4c0576"},+ {+ "spdxElementId": "SPDXRef-DOCUMENT",+ "relationshipType": "DESCRIBES",+ "relatedSpdxElement": "SPDXRef-Package-f1f7e9b95d53e9e2"+ },{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",@@ -12813,7 +13012,7 @@{"spdxElementId": "SPDXRef-DOCUMENT","relationshipType": "DESCRIBES",- "relatedSpdxElement": "SPDXRef-Package-de2734fc17053fb9"+ "relatedSpdxElement": "SPDXRef-Package-1434cfbc120afcc9"},{"spdxElementId": "SPDXRef-DOCUMENT",diff --git a/i18n/GLOSSARY.md b/i18n/GLOSSARY.mdindex 08cf4049b6..827ea134a6 100644--- a/i18n/GLOSSARY.md+++ b/i18n/GLOSSARY.md@@ -597,6 +597,10 @@ Cindy 里的**持久 AI 助手实体**(原名 Bot):有长期身份、自语音输入的用户自定义术语表(人名、产品名、代号与其常见误识别写法),在同账号的电脑之间自动同步、手机只读查看。当前先采用四语直译并登记为待讨论术语,避免与「自定义词典」「术语表」「用户词库」等说法混用。+### Voiceprint++语音输入「识别我的声音」录入的本人声音特征,只存在本机、不同步。可写「录入声纹」「删除声纹」;不要写成声音指纹、声音模板。+### WallpaperDesktop appearance setting for an in-app visual background layer.diff --git a/i18n/glossary.json b/i18n/glossary.jsonindex bb361b481f..2f7cea4bcc 100644--- a/i18n/glossary.json+++ b/i18n/glossary.json@@ -2422,6 +2422,19 @@},"checkCase": false,"note": "伙伴独立事务清单,含交办与获准信息中的主动发现;项目、执行任务与PR仅可选关联。不替代Session任务生命周期。"+ },+ {+ "id": "voiceprint",+ "status": "proposed",+ "en": "Voiceprint",+ "translations": {+ "zh-CN": "声纹",+ "zh-TW": "聲紋",+ "ja": "声紋",+ "ko": "성문"+ },+ "checkCase": false,+ "note": "语音输入「识别我的声音」录入的本人声音特征,只存在本机、不同步。可写「录入声纹」「删除声纹」;不要写成声音指纹、声音模板。"}]}diff --git a/packages/voice-input-core/src/SpeakerGate.ts b/packages/voice-input-core/src/SpeakerGate.tsnew file mode 100644index 0000000000..1db30c82b5--- /dev/null+++ b/packages/voice-input-core/src/SpeakerGate.ts@@ -0,0 +1,418 @@+import type { AudioTrace } from './types';++/**+ * Receives audio that already passed an AudioGate, in capture order. Chunks+ * keep their original size and trace; rejected speech arrives as silence.+ */+export type AudioGateEmit = (chunk: ArrayBuffer, trace?: AudioTrace) => void;++/**+ * Optional filter between microphone capture and the controller. The+ * controller owns the run lifecycle; the gate only decides which samples+ * reach the ASR. Every implementation must preserve order and never drop a+ * chunk: muted audio is replaced by silence so the ASR clock stays intact.+ */+export interface AudioGate {+ /** Starts a fresh run. Audio from an earlier run is never emitted again. */+ begin(emit: AudioGateEmit): void;+ push(chunk: ArrayBuffer, trace?: AudioTrace): void;+ /** Decides everything still held and emits it. Resolves once emitted. */+ finish(): Promise<void>;+ /** Drops held audio without emitting it (cancel / failure). */+ abort(): void;+}++/**+ * Platform inference behind the speaker gate. Desktop runs it in a worker+ * thread and mobile in a native module; both load the same VAD and speaker+ * embedding models.+ */+export interface SpeakerGateEngine {+ /** Clears VAD state before a new run. */+ resetVad(): Promise<void>;+ /**+ * Runs VAD over whole frames of SPEAKER_GATE_VAD_FRAME samples and returns+ * one "speech detected" flag per frame, in order.+ */+ detectSpeech(samples: Float32Array): Promise<boolean[]>;+ /** Speaker embedding of 16 kHz mono samples; null when the clip is unusable. */+ embed(samples: Float32Array): Promise<Float32Array | null>;+}++export type SpeakerGateDecision = {+ startSample: number;+ endSample: number;+ score: number;+ accepted: boolean;+ computeMs: number;+};++export type SpeakerGateOptions = {+ engine: SpeakerGateEngine;+ enrolledEmbedding: Float32Array;+ /** Score needed when speech starts. */+ threshold?: number;+ /** Lower score needed to keep going right after an accepted window. */+ continueThreshold?: number;+ /** Longest speech held before a decision. */+ windowSec?: number;+ /** Shortest audio used for one embedding, crossing short pauses. */+ minVerifySec?: number;+ /** Silence held back so a late VAD onset still covers the first syllable. */+ prerollSec?: number;+ /** One engine call taking longer than this disables the gate for the run. */+ engineTimeoutMs?: number;+ /** finish() never holds the user's stop longer than this. */+ finishTimeoutMs?: number;+ onDecision?: (decision: SpeakerGateDecision) => void;+ /** The gate stopped filtering this run and now passes audio through. */+ onPassthrough?: (reason: string) => void;+};++export const SPEAKER_GATE_SAMPLE_RATE = 16_000;+export const SPEAKER_GATE_VAD_FRAME = 512;++/** Defaults measured in the 2026-10 validation (CAM++ zh-en, 1.5 s window). */+export const SPEAKER_GATE_DEFAULTS = {+ threshold: 0.5,+ continueThreshold: 0.4,+ windowSec: 1.5,+ minVerifySec: 1.0,+ prerollSec: 0.5,+ engineTimeoutMs: 3_000,+ finishTimeoutMs: 1_500,+} as const;++export type SpeakerGateStrictness = 'relaxed' | 'standard' | 'strict';++export const SPEAKER_GATE_STRICTNESS_VALUES: readonly SpeakerGateStrictness[] = [+ 'relaxed',+ 'standard',+ 'strict',+];++export const DEFAULT_SPEAKER_GATE_STRICTNESS: SpeakerGateStrictness = 'standard';++/**+ * Thresholds behind the user-facing strictness levels. In validation the+ * owner's own windows scored about 0.8 and one similar-sounding bystander+ * 0.44–0.50: "strict" blocks that bystander, "relaxed" clips the owner less in+ * noisy rooms.+ */+export const SPEAKER_GATE_STRICTNESS_THRESHOLDS: Readonly<+ Record<SpeakerGateStrictness, { threshold: number; continueThreshold: number }>+> = {+ relaxed: { threshold: 0.42, continueThreshold: 0.32 },+ standard: { threshold: SPEAKER_GATE_DEFAULTS.threshold, continueThreshold: SPEAKER_GATE_DEFAULTS.continueThreshold },+ strict: { threshold: 0.55, continueThreshold: 0.45 },+};++export function isSpeakerGateStrictness(value: unknown): value is SpeakerGateStrictness {+ return typeof value === 'string' && (SPEAKER_GATE_STRICTNESS_VALUES as readonly string[]).includes(value);+}++type HeldChunk = {+ samples: Int16Array;+ trace?: AudioTrace;+ start: number;+};++class EngineTimeoutError extends Error {}++/**+ * SpeakerGate passes the enrolled speaker's voice and mutes everyone else.+ *+ * Silence is released after a short pre-roll. Speech is held until the speaker+ * pauses or a full window has accumulated, then compared with the enrolled+ * voiceprint. Inference is asynchronous, so all work runs on one serial queue+ * and audio is emitted strictly in capture order.+ *+ * The gate fails open: an engine error or timeout releases everything held and+ * passes the rest of the run through unchanged. Losing the user's own words is+ * worse than letting a bystander through.+ */+export class SpeakerGate implements AudioGate {+ private readonly engine: SpeakerGateEngine;+ private readonly enrolled: Float32Array;+ private readonly threshold: number;+ private readonly continueThreshold: number;+ private readonly windowSamples: number;+ private readonly minVerifySamples: number;+ private readonly prerollSamples: number;+ private readonly engineTimeoutMs: number;+ private readonly finishTimeoutMs: number;+ private readonly onDecision?: (decision: SpeakerGateDecision) => void;+ private readonly onPassthrough?: (reason: string) => void;++ private emit: AudioGateEmit | null = null;+ private runToken = 0;+ private queue: Promise<void> = Promise.resolve();+ private passthrough = false;+ private held: HeldChunk[] = [];+ private total = 0;+ private released = 0;+ private vadPos = 0;+ private vadCarry: Float32Array = new Float32Array(0);+ private inSpeech = false;+ private pendingStart = 0;+ private lastAcceptedEnd = -1;+ // Most recent judged speech, used as embedding context across short pauses.+ private speechTail: Float32Array;+ private speechTailLength = 0;++ constructor(options: SpeakerGateOptions) {+ this.engine = options.engine;+ this.enrolled = options.enrolledEmbedding;+ this.threshold = options.threshold ?? SPEAKER_GATE_DEFAULTS.threshold;+ this.continueThreshold = options.continueThreshold ?? SPEAKER_GATE_DEFAULTS.continueThreshold;+ this.windowSamples = seconds(options.windowSec ?? SPEAKER_GATE_DEFAULTS.windowSec);+ this.minVerifySamples = seconds(options.minVerifySec ?? SPEAKER_GATE_DEFAULTS.minVerifySec);+ this.prerollSamples = seconds(options.prerollSec ?? SPEAKER_GATE_DEFAULTS.prerollSec);+ this.engineTimeoutMs = options.engineTimeoutMs ?? SPEAKER_GATE_DEFAULTS.engineTimeoutMs;+ this.finishTimeoutMs = options.finishTimeoutMs ?? SPEAKER_GATE_DEFAULTS.finishTimeoutMs;+ this.onDecision = options.onDecision;+ this.onPassthrough = options.onPassthrough;+ this.speechTail = new Float32Array(Math.max(this.windowSamples, this.minVerifySamples));+ }++ begin(emit: AudioGateEmit): void {+ this.resetRun();+ this.emit = emit;+ const token = this.runToken;+ this.enqueue(token, () => this.withTimeout(this.engine.resetVad()));+ }++ push(chunk: ArrayBuffer, trace?: AudioTrace): void {+ if (!this.emit) return;+ const samples = new Int16Array(chunk.slice(0, chunk.byteLength - (chunk.byteLength % 2)));+ if (this.passthrough) {+ this.emit(samples.buffer, trace);+ return;+ }+ this.held.push({ samples, trace, start: this.total });+ this.total += samples.length;+ this.vadCarry = concatFloat(this.vadCarry, toFloat(samples));+ const token = this.runToken;+ this.enqueue(token, () => this.analyze(token));+ }++ async finish(): Promise<void> {+ if (!this.emit) return;+ const token = this.runToken;+ this.enqueue(token, async () => {+ if (this.inSpeech && this.total > this.pendingStart) {+ await this.decide(token, this.pendingStart, this.total);+ }+ if (token !== this.runToken || this.passthrough) return;+ this.inSpeech = false;+ this.releaseUpTo(this.total);+ });+ let timer: ReturnType<typeof setTimeout> | undefined;+ const timedOut = await Promise.race([+ this.queue.then(() => false),+ new Promise<boolean>((resolve) => {+ timer = setTimeout(() => resolve(true), this.finishTimeoutMs);+ }),+ ]);+ clearTimeout(timer);+ if (token !== this.runToken) return;+ if (timedOut) this.enterPassthrough('finish_timeout');+ // Whatever happened above, nothing of this run may stay held.+ this.releaseUpTo(this.total);+ }++ abort(): void {+ this.resetRun();+ }++ private resetRun(): void {+ this.runToken += 1;+ this.emit = null;+ this.queue = Promise.resolve();+ this.passthrough = false;+ this.held = [];+ this.total = 0;+ this.released = 0;+ this.vadPos = 0;+ this.vadCarry = new Float32Array(0);+ this.inSpeech = false;+ this.pendingStart = 0;+ this.lastAcceptedEnd = -1;+ this.speechTailLength = 0;+ }++ private enqueue(token: number, task: () => Promise<void>): void {+ this.queue = this.queue.then(async () => {+ if (token !== this.runToken || this.passthrough) return;+ try {+ await task();+ } catch (error) {+ if (token !== this.runToken) return;+ this.enterPassthrough(error instanceof EngineTimeoutError+ ? 'engine_timeout'+ : `engine_error: ${error instanceof Error ? error.message : String(error)}`);+ }+ });+ }++ private async analyze(token: number): Promise<void> {+ const frames = Math.floor(this.vadCarry.length / SPEAKER_GATE_VAD_FRAME);+ if (frames === 0) return;+ const usable = frames * SPEAKER_GATE_VAD_FRAME;+ const input = this.vadCarry.slice(0, usable);+ this.vadCarry = this.vadCarry.slice(usable);+ const flags = await this.withTimeout(this.engine.detectSpeech(input));+ if (token !== this.runToken || this.passthrough) return;+ for (let i = 0; i < frames; i += 1) {+ this.vadPos += SPEAKER_GATE_VAD_FRAME;+ await this.step(token, this.vadPos, flags[i] === true);+ if (token !== this.runToken || this.passthrough) return;+ }+ }++ private async step(token: number, frameEnd: number, detected: boolean): Promise<void> {+ if (detected && !this.inSpeech) {+ this.inSpeech = true;+ this.pendingStart = this.released;+ }+ if (this.inSpeech) {+ if (frameEnd - this.pendingStart >= this.windowSamples) {+ await this.decide(token, this.pendingStart, frameEnd);+ if (token !== this.runToken || this.passthrough) return;+ }+ if (!detected) {+ this.inSpeech = false;+ if (frameEnd > this.pendingStart) await this.decide(token, this.pendingStart, frameEnd);+ }+ return;+ }+ this.releaseUpTo(frameEnd - this.prerollSamples);+ }++ private async decide(token: number, start: number, end: number): Promise<void> {+ const speech = this.readHeld(start, end);+ this.appendSpeechTail(speech);+ const context = this.speechTailSlice(Math.max(this.minVerifySamples, end - start));+ const startedAt = now();+ const embedding = await this.withTimeout(this.engine.embed(context));+ if (token !== this.runToken || this.passthrough) return;+ const computeMs = now() - startedAt;+ const score = embedding ? cosineSimilarity(embedding, this.enrolled) : -1;+ const continuing = this.lastAcceptedEnd >= 0 && start <= this.lastAcceptedEnd;+ const accepted = score >= (continuing ? this.continueThreshold : this.threshold);+ if (accepted) this.lastAcceptedEnd = end;+ else this.muteHeld(start, end);+ this.onDecision?.({ startSample: start, endSample: end, score, accepted, computeMs });+ this.pendingStart = end;+ this.releaseUpTo(end);+ }++ private releaseUpTo(upTo: number): void {+ if (upTo > this.released) this.released = Math.min(upTo, this.total);+ const emit = this.emit;+ if (!emit) return;+ while (this.held.length > 0) {+ const chunk = this.held[0];+ if (chunk.start + chunk.samples.length > this.released) break;+ this.held.shift();+ emit(chunk.samples.buffer as ArrayBuffer, chunk.trace);+ }+ }++ private enterPassthrough(reason: string): void {+ if (this.passthrough) return;+ this.passthrough = true;+ this.inSpeech = false;+ this.vadCarry = new Float32Array(0);+ this.released = this.total;+ this.releaseUpTo(this.total);+ this.onPassthrough?.(reason);+ }++ private readHeld(start: number, end: number): Float32Array {+ const out = new Float32Array(Math.max(0, end - start));+ for (const chunk of this.held) {+ const chunkEnd = chunk.start + chunk.samples.length;+ if (chunkEnd <= start || chunk.start >= end) continue;+ const from = Math.max(start, chunk.start);+ const to = Math.min(end, chunkEnd);+ for (let i = from; i < to; i += 1) out[i - start] = chunk.samples[i - chunk.start] / 32768;+ }+ return out;+ }++ private muteHeld(start: number, end: number): void {+ for (const chunk of this.held) {+ const chunkEnd = chunk.start + chunk.samples.length;+ if (chunkEnd <= start || chunk.start >= end) continue;+ chunk.samples.fill(0, Math.max(start, chunk.start) - chunk.start, Math.min(end, chunkEnd) - chunk.start);+ }+ }++ private appendSpeechTail(samples: Float32Array): void {+ const capacity = this.speechTail.length;+ if (samples.length >= capacity) {+ this.speechTail.set(samples.subarray(samples.length - capacity));+ this.speechTailLength = capacity;+ return;+ }+ const keep = Math.min(this.speechTailLength, capacity - samples.length);+ this.speechTail.copyWithin(0, this.speechTailLength - keep, this.speechTailLength);+ this.speechTail.set(samples, keep);+ this.speechTailLength = keep + samples.length;+ }++ private speechTailSlice(length: number): Float32Array {+ const take = Math.min(length, this.speechTailLength);+ return this.speechTail.slice(this.speechTailLength - take, this.speechTailLength);+ }++ private withTimeout<T>(promise: Promise<T>): Promise<T> {+ let timer: ReturnType<typeof setTimeout> | undefined;+ const timeout = new Promise<never>((_, reject) => {+ timer = setTimeout(() => reject(new EngineTimeoutError('engine timeout')), this.engineTimeoutMs);+ });+ return Promise.race([promise, timeout]).finally(() => clearTimeout(timer));+ }+}++export function cosineSimilarity(a: Float32Array, b: Float32Array): number {+ if (a.length !== b.length || a.length === 0) return -1;+ let dot = 0;+ let na = 0;+ let nb = 0;+ for (let i = 0; i < a.length; i += 1) {+ dot += a[i] * b[i];+ na += a[i] * a[i];+ nb += b[i] * b[i];+ }+ if (na === 0 || nb === 0) return -1;+ return dot / Math.sqrt(na * nb);+}++/** PCM16 little-endian to float samples in [-1, 1). */+export function pcm16ToFloat(pcm: ArrayBuffer): Float32Array {+ return toFloat(new Int16Array(pcm, 0, Math.floor(pcm.byteLength / 2)));+}++function toFloat(samples: Int16Array): Float32Array {+ const out = new Float32Array(samples.length);+ for (let i = 0; i < samples.length; i += 1) out[i] = samples[i] / 32768;+ return out;+}++function concatFloat(a: Float32Array, b: Float32Array): Float32Array {+ if (a.length === 0) return b;+ const out = new Float32Array(a.length + b.length);+ out.set(a);+ out.set(b, a.length);+ return out;+}++function seconds(value: number): number {+ return Math.round(value * SPEAKER_GATE_SAMPLE_RATE);+}++function now(): number {+ return typeof performance !== 'undefined' ? performance.now() : Date.now();+}diff --git a/packages/voice-input-core/src/VoiceInputController.ts b/packages/voice-input-core/src/VoiceInputController.tsindex 5ea15e2b56..0542fb1bfb 100644--- a/packages/voice-input-core/src/VoiceInputController.ts+++ b/packages/voice-input-core/src/VoiceInputController.ts@@ -13,6 +13,7 @@ import type {VoiceInputTerminalOutcome,} from './types';import { VoiceTimelineLogger } from './VoiceTimelineLogger';+import type { AudioGate } from './SpeakerGate';import { hasAdditionalSentence } from './pauseRefinement';type DictationRefiner = {@@ -45,6 +46,12 @@ type VoiceInputControllerOptions = {pauseRefinementEnabled?: boolean;/** Host opt-in for known recovery failures; undefined keeps the generic error. */recoveryErrorMessage?: (error: unknown) => string | undefined;+ /**+ * Optional filter in front of the ASR (e.g. the speaker gate). Activity and+ * stall accounting see the filtered audio, so a run where only bystanders+ * spoke ends as "no speech" instead of an empty-transcript failure.+ */+ audioGate?: AudioGate;};type CryptoWithUuid = {@@ -94,6 +101,7 @@ export class VoiceInputController {private readonly stableWaitMs: number;private readonly pauseRefinementEnabled: boolean;private readonly recoveryErrorMessage?: (error: unknown) => string | undefined;+ private readonly audioGate?: AudioGate;private lastSoundAt = 0;private lastTranscriptChangeAt = 0;private pauseRefinement?: PendingRefinement;@@ -160,6 +168,7 @@ export class VoiceInputController {this.stableWaitMs = options.stableWaitMs ?? 500;this.pauseRefinementEnabled = options.pauseRefinementEnabled ?? false;this.recoveryErrorMessage = options.recoveryErrorMessage;+ this.audioGate = options.audioGate;this.asr.onEvent((event) => this.handleAsrEvent(event));}@@ -198,6 +207,8 @@ export class VoiceInputController {this.lastTranscriptChangeAt = performance.now();this.pauseRefinement = undefined;this.liveRefinementPreview = undefined;+ const gateRunId = this.runId;+ this.audioGate?.begin((chunk, trace) => this.forwardAudio(gateRunId, chunk, trace));this.startStallWatchdog();this.setState('listening');this.logger.record({ type: 'start_clicked', runId: this.runId, at: Date.now() });@@ -213,6 +224,20 @@ export class VoiceInputController {appendAudio(chunk: ArrayBuffer, trace?: AudioTrace): void {if (this.state !== 'listening') return;+ if (this.audioGate) {+ this.audioGate.push(chunk, trace);+ return;+ }+ this.forwardAudio(this.runId, chunk, trace);+ }++ /**+ * Hands audio that passed the optional gate to the ASR. The gate releases+ * held audio while stop() flushes it, so 'submitting' is still accepted.+ */+ private forwardAudio(runId: string, chunk: ArrayBuffer, trace?: AudioTrace): void {+ if (runId !== this.runId) return;+ if (this.state !== 'listening' && this.state !== 'submitting') return;if (!this.firstAudioChunkSeen) {this.firstAudioChunkSeen = true;this.logger.record({@@ -242,6 +267,12 @@ export class VoiceInputController {this.stopStallWatchdog();this.setState('submitting');this.logger.record({ type: 'stop_clicked', runId, at: Date.now() });+ // Release audio still held by the gate before the provider flushes. The+ // gate fails open and bounds its own time, so this never rejects or hangs.+ // Without a gate, stop() must not gain an extra await: the optimistic+ // refinement below relies on starting in the same tick.+ if (this.audioGate) await this.audioGate.finish().catch(() => undefined);+ if (runId !== this.runId || this.leftSubmittingState()) return;const optimisticRefinement = this.startOptimisticRefinement(runId);try {@@ -350,6 +381,7 @@ export class VoiceInputController {if (!this.runId) return;const runId = this.runId;this.currentRunCancelled = true;+ this.audioGate?.abort();this.stopStallWatchdog();this.pendingStableResolvers.splice(0).forEach((resolve) => resolve(undefined));this.logger.record({ type: 'cancelled', runId, at: Date.now() });@@ -714,6 +746,7 @@ export class VoiceInputController {// recovery_failed). Without this guard the renderer toasts both, which// shows the user a confusing second error after they already saw the first.if (this.state === 'error' || this.state === 'done') return;+ this.audioGate?.abort();if (this.runId) {this.logger.record({ type: 'error', runId: this.runId, at: Date.now(), message });}diff --git a/packages/voice-input-core/src/__tests__/SpeakerGate.test.ts b/packages/voice-input-core/src/__tests__/SpeakerGate.test.tsnew file mode 100644index 0000000000..b57b3ceffb--- /dev/null+++ b/packages/voice-input-core/src/__tests__/SpeakerGate.test.ts@@ -0,0 +1,291 @@+import { describe, expect, it } from 'vitest';++import {+ SPEAKER_GATE_SAMPLE_RATE,+ SPEAKER_GATE_VAD_FRAME,+ SpeakerGate,+ type SpeakerGateDecision,+ type SpeakerGateEngine,+} from '../SpeakerGate.js';+import { buildSpeakerEnrollment, type SpeakerEnrollmentEngine } from '../speakerEnrollment.js';+import type { AudioTrace } from '../types.js';++// Synthetic voices: the owner is a positive DC level, a bystander a negative+// one. The fake engine "embeds" by the sign of the mean, which is enough to+// exercise the gate's holding, ordering and muting without real models.+const OWNER = 8_000;+const BYSTANDER = -8_000;+const OWNER_PRINT = new Float32Array([1, 0]);++class FakeEngine implements SpeakerGateEngine {+ embedCalls = 0;+ failEmbed = false;+ hangEmbed = false;++ async resetVad(): Promise<void> {}++ async detectSpeech(samples: Float32Array): Promise<boolean[]> {+ const flags: boolean[] = [];+ for (let i = 0; i + SPEAKER_GATE_VAD_FRAME <= samples.length; i += SPEAKER_GATE_VAD_FRAME) {+ let energy = 0;+ for (let j = i; j < i + SPEAKER_GATE_VAD_FRAME; j += 1) energy += Math.abs(samples[j]);+ flags.push(energy / SPEAKER_GATE_VAD_FRAME > 0.05);+ }+ return flags;+ }++ async embed(samples: Float32Array): Promise<Float32Array | null> {+ this.embedCalls += 1;+ if (this.failEmbed) throw new Error('model crashed');+ if (this.hangEmbed) return new Promise(() => {});+ let sum = 0;+ for (const sample of samples) sum += sample;+ return sum >= 0 ? new Float32Array([1, 0]) : new Float32Array([0, 1]);+ }+}++type Emitted = { samples: Int16Array; trace?: AudioTrace };++function makeAudio(parts: Array<[level: number, seconds: number]>): Int16Array {+ const total = parts.reduce((sum, [, sec]) => sum + Math.round(sec * SPEAKER_GATE_SAMPLE_RATE), 0);+ const out = new Int16Array(total);+ let offset = 0;+ for (const [level, sec] of parts) {+ const length = Math.round(sec * SPEAKER_GATE_SAMPLE_RATE);+ out.fill(level, offset, offset + length);+ offset += length;+ }+ return out;+}++/** Pushes audio in 40 ms chunks, the cadence the desktop capture uses. */+function pushAll(gate: SpeakerGate, audio: Int16Array): void {+ const chunk = 640;+ for (let i = 0, index = 0; i < audio.length; i += chunk, index += 1) {+ const slice = audio.slice(i, Math.min(audio.length, i + chunk));+ gate.push(slice.buffer, {+ capturedAt: index,+ convertedAt: index,+ chunkIndex: index,+ sampleRate: SPEAKER_GATE_SAMPLE_RATE,+ durationMs: 40,+ });+ }+}++function joined(emitted: Emitted[]): Int16Array {+ const out = new Int16Array(emitted.reduce((sum, item) => sum + item.samples.length, 0));+ let offset = 0;+ for (const item of emitted) {+ out.set(item.samples, offset);+ offset += item.samples.length;+ }+ return out;+}++function countLevel(samples: Int16Array, from: number, to: number, level: number): number {+ let count = 0;+ for (let i = Math.round(from * SPEAKER_GATE_SAMPLE_RATE); i < Math.round(to * SPEAKER_GATE_SAMPLE_RATE); i += 1) {+ if (samples[i] === level) count += 1;+ }+ return count;+}++function startGate(engine: FakeEngine, extra: Partial<ConstructorParameters<typeof SpeakerGate>[0]> = {}) {+ const emitted: Emitted[] = [];+ const decisions: SpeakerGateDecision[] = [];+ const passthrough: string[] = [];+ const gate = new SpeakerGate({+ engine,+ enrolledEmbedding: OWNER_PRINT,+ onDecision: (decision) => decisions.push(decision),+ onPassthrough: (reason) => passthrough.push(reason),+ ...extra,+ });+ gate.begin((chunk, trace) => emitted.push({ samples: new Int16Array(chunk), trace }));+ return { gate, emitted, decisions, passthrough };+}++describe('SpeakerGate', () => {+ it('does not release new audio when an aborted finish resumes', async () => {+ let release!: (value: Float32Array) => void;+ const engine = new FakeEngine();+ engine.embed = () => new Promise((resolve) => { release = resolve; });+ const { gate } = startGate(engine);+ pushAll(gate, makeAudio([[OWNER, 0.5]]));+ await new Promise((resolve) => setTimeout(resolve, 0));+ const finishing = gate.finish();+ await new Promise((resolve) => setTimeout(resolve, 0));+ const oldRelease = release;+ gate.abort();+ const emitted: Emitted[] = [];+ gate.begin((chunk) => emitted.push({ samples: new Int16Array(chunk) }));+ pushAll(gate, makeAudio([[BYSTANDER, 0.5]]));+ oldRelease(OWNER_PRINT);+ await finishing;+ expect(emitted).toEqual([]);+ gate.abort();+ });++ it('passes the owner, mutes a bystander and keeps every chunk in order', async () => {+ const engine = new FakeEngine();+ const { gate, emitted, decisions } = startGate(engine);+ const audio = makeAudio([[0, 0.6], [OWNER, 2], [0, 1], [BYSTANDER, 2], [0, 0.6]]);++ pushAll(gate, audio);+ await gate.finish();++ const out = joined(emitted);+ expect(out.length).toBe(audio.length);+ expect(emitted.map((item) => item.trace?.chunkIndex)).toEqual(+ Array.from({ length: emitted.length }, (_, index) => index),+ );+ // Owner speech (0.6–2.6 s) survives, bystander speech (3.6–5.6 s) is gone.+ expect(countLevel(out, 0.6, 2.6, OWNER)).toBe(Math.round(2 * SPEAKER_GATE_SAMPLE_RATE));+ expect(countLevel(out, 3.6, 5.6, BYSTANDER)).toBe(0);+ expect(decisions.some((decision) => decision.accepted)).toBe(true);+ expect(decisions.some((decision) => !decision.accepted)).toBe(true);+ });++ it('holds speech until a decision instead of leaking it early', async () => {+ const engine = new FakeEngine();+ const { gate, emitted } = startGate(engine);++ pushAll(gate, makeAudio([[BYSTANDER, 0.8]]));+ await new Promise((resolve) => setTimeout(resolve, 0));+ expect(joined(emitted).some((sample) => sample === BYSTANDER)).toBe(false);++ await gate.finish();+ expect(joined(emitted).some((sample) => sample === BYSTANDER)).toBe(false);+ expect(joined(emitted).length).toBe(Math.round(0.8 * SPEAKER_GATE_SAMPLE_RATE));+ });++ it('fails open and passes the rest of the run through when the engine errors', async () => {+ const engine = new FakeEngine();+ engine.failEmbed = true;+ const { gate, emitted, passthrough } = startGate(engine);+ const audio = makeAudio([[BYSTANDER, 2], [0, 0.5]]);++ pushAll(gate, audio);+ await gate.finish();++ expect(passthrough).toEqual(['engine_error: model crashed']);+ expect(joined(emitted)).toEqual(audio);+ });++ it('bounds finish() when the engine hangs and releases held audio', async () => {+ const engine = new FakeEngine();+ engine.hangEmbed = true;+ const { gate, emitted, passthrough } = startGate(engine, {+ engineTimeoutMs: 10_000,+ finishTimeoutMs: 20,+ });+ const audio = makeAudio([[OWNER, 0.5]]);++ pushAll(gate, audio);+ await gate.finish();++ expect(passthrough).toEqual(['finish_timeout']);+ expect(joined(emitted)).toEqual(audio);+ });++ it('drops held audio on abort and never emits it into a later run', async () => {+ const engine = new FakeEngine();+ const { gate, emitted } = startGate(engine);+ pushAll(gate, makeAudio([[OWNER, 0.8]]));+ gate.abort();++ const second: Emitted[] = [];+ gate.begin((chunk, trace) => second.push({ samples: new Int16Array(chunk), trace }));+ pushAll(gate, makeAudio([[0, 1]]));+ await gate.finish();++ expect(joined(emitted).some((sample) => sample === OWNER)).toBe(false);+ expect(joined(second).length).toBe(SPEAKER_GATE_SAMPLE_RATE);+ expect(joined(second).every((sample) => sample === 0)).toBe(true);+ });+});++class FakeEnrollmentEngine implements SpeakerEnrollmentEngine {+ constructor(private readonly prints: Array<Float32Array | null>) {}+ private index = 0;++ async extractSpeech(samples: Float32Array): Promise<Float32Array> {+ return samples;+ }++ async embed(): Promise<Float32Array | null> {+ const print = this.prints[this.index];+ this.index += 1;+ return print;+ }+}++describe('buildSpeakerEnrollment', () => {+ const clip = (sec: number) => new Float32Array(Math.round(sec * SPEAKER_GATE_SAMPLE_RATE));++ it('averages consistent clips into one normalized voiceprint', async () => {+ const engine = new FakeEnrollmentEngine([+ new Float32Array([2, 0.2]),+ new Float32Array([1, 0]),+ new Float32Array([3, -0.3]),+ ]);+ const result = await buildSpeakerEnrollment(engine, [clip(3), clip(3), clip(3)]);++ expect(result.ok).toBe(true);+ if (!result.ok) return;+ const norm = Math.hypot(result.embedding[0], result.embedding[1]);+ expect(norm).toBeCloseTo(1, 5);+ expect(result.selfScore).toBeGreaterThan(0.9);+ expect(result.speechSec).toBeCloseTo(9, 5);+ });++ it('rejects a clip without enough speech', async () => {+ const engine = new FakeEnrollmentEngine([new Float32Array([1, 0]), new Float32Array([1, 0])]);+ const result = await buildSpeakerEnrollment(engine, [clip(3), clip(1)]);++ expect(result).toMatchObject({ ok: false, reason: 'too_short', clipIndex: 1 });+ });++ it('rejects clips that do not sound like one person', async () => {+ const engine = new FakeEnrollmentEngine([+ new Float32Array([1, 0]),+ new Float32Array([1, 0]),+ new Float32Array([-1, 0.1]),+ ]);+ const result = await buildSpeakerEnrollment(engine, [clip(3), clip(3), clip(3)]);++ expect(result).toMatchObject({ ok: false, reason: 'inconsistent', clipIndex: 2 });+ });++ it('reports a clip the model could not embed', async () => {+ const engine = new FakeEnrollmentEngine([null]);+ const result = await buildSpeakerEnrollment(engine, [clip(3)]);++ expect(result).toMatchObject({ ok: false, reason: 'no_embedding', clipIndex: 0 });+ });++ it.each([+ ['non-finite', new Float32Array([NaN, 1])],+ ['infinite', new Float32Array([Infinity, 1])],+ ['empty', new Float32Array(0)],+ ['zero', new Float32Array([0, 0])],+ ['wrong dimension', new Float32Array([1])],+ ])('rejects a %s embedding without accepting a broken voiceprint', async (_, invalid) => {+ const engine = new FakeEnrollmentEngine([OWNER_PRINT, invalid, OWNER_PRINT]);+ const result = await buildSpeakerEnrollment(engine, [clip(3), clip(3), clip(3)]);++ expect(result).toMatchObject({ ok: false, reason: 'no_embedding', clipIndex: 1 });+ });++ it('does not let a different speaker inflate their own enrollment match', async () => {+ const engine = new FakeEnrollmentEngine([+ new Float32Array([1, 0]),+ new Float32Array([1, 0]),+ new Float32Array([0.3, Math.sqrt(1 - 0.3 ** 2)]),+ ]);+ const result = await buildSpeakerEnrollment(engine, [clip(3), clip(3), clip(3)]);++ expect(result).toMatchObject({ ok: false, reason: 'inconsistent', clipIndex: 2 });+ });+});diff --git a/packages/voice-input-core/src/__tests__/VoiceInputController.test.ts b/packages/voice-input-core/src/__tests__/VoiceInputController.test.tsindex ccd5ed68d6..d5e019f0ad 100644--- a/packages/voice-input-core/src/__tests__/VoiceInputController.test.ts+++ b/packages/voice-input-core/src/__tests__/VoiceInputController.test.ts@@ -2,8 +2,10 @@ import { describe, expect, it, vi } from 'vitest';import { VoiceInputController } from '../VoiceInputController.js';import { VoiceTimelineLogger } from '../VoiceTimelineLogger.js';+import type { AudioGate } from '../SpeakerGate.js';import type {AsrEvent,+ AudioTrace,AsrProvider,EditableRange,SpeechSegment,@@ -69,6 +71,33 @@ function pcmChunk(amplitude: number): ArrayBuffer {}describe('VoiceInputController', () => {+ it('does not flush or stop a new run after cancellation during gate finish', async () => {+ let release!: () => void;+ const asr = new FakeAsrProvider();+ const flush = vi.spyOn(asr, 'flushAudio');+ const stop = vi.spyOn(asr, 'stop');+ const controller = new VoiceInputController({+ asr,+ audioGate: {+ begin: () => {}, push: () => {}, abort: () => {},+ finish: () => new Promise<void>((resolve) => { release = resolve; }),+ },+ logger: new VoiceTimelineLogger(),+ stableWaitMs: 0,+ callbacks: { onDraftChanged: () => {}, onSubmitted: () => undefined },+ });+ await controller.start();+ const stopping = controller.stop();+ await controller.cancel();+ await controller.start();+ release();+ await stopping;+ expect(flush).not.toHaveBeenCalled();+ expect(stop).toHaveBeenCalledTimes(1);+ expect(controller.currentState).toBe('listening');+ await controller.cancel();+ });+it('starts without a global crypto implementation', async () => {const originalCrypto = Object.getOwnPropertyDescriptor(globalThis, 'crypto');Object.defineProperty(globalThis, 'crypto', {@@ -253,6 +282,59 @@ describe('VoiceInputController', () => {expect(errors).toEqual([]);});+ it('treats a run the audio gate fully muted as no speech', async () => {+ const asr = new FakeAsrProvider();+ const outcomes: string[] = [];+ const errors: string[] = [];+ let emit: ((chunk: ArrayBuffer, trace?: AudioTrace) => void) | null = null;+ const held: Array<{ chunk: ArrayBuffer; trace?: AudioTrace }> = [];+ const audioGate: AudioGate = {+ begin: (next) => {+ emit = next;+ },+ push: (chunk, trace) => {+ held.push({ chunk: new Int16Array(chunk.byteLength / 2).buffer, trace });+ },+ // Releases only while stop() awaits it, like the speaker gate's flush.+ finish: async () => {+ held.splice(0).forEach(({ chunk, trace }) => emit?.(chunk, trace));+ },+ abort: () => {+ held.length = 0;+ },+ };+ const controller = new VoiceInputController({+ asr,+ logger: new VoiceTimelineLogger(),+ stableWaitMs: 0,+ audioGate,+ callbacks: {+ onStateChanged: (_state, outcome) => {+ if (outcome) outcomes.push(outcome);+ },+ onDraftChanged: () => {},+ onSubmitted: () => undefined,+ onError: (message) => errors.push(message),+ },+ });++ await controller.start();+ controller.appendAudio(pcmChunk(1_000), {+ capturedAt: 0,+ convertedAt: 0,+ chunkIndex: 0,+ sampleRate: 16_000,+ durationMs: 10,+ });+ expect(asr.appended).toBe(0);+ await controller.stop();++ expect(asr.appended).toBe(1);+ expect(controller.currentState).toBe('done');+ expect(outcomes.at(-1)).toBe('no_speech');+ expect(errors).toEqual([]);+ });+it('surfaces an error when speech was detected but the transcript is empty', async () => {const asr = new FakeAsrProvider();const states: VoiceInputState[] = [];diff --git a/packages/voice-input-core/src/__tests__/onnxSpeakerEngine.test.ts b/packages/voice-input-core/src/__tests__/onnxSpeakerEngine.test.tsnew file mode 100644index 0000000000..03b4662a95--- /dev/null+++ b/packages/voice-input-core/src/__tests__/onnxSpeakerEngine.test.ts@@ -0,0 +1,159 @@+import { describe, expect, it } from 'vitest';++import {+ computeKaldiFbank,+ fbankFrameCount,+ KALDI_FBANK_DIM,+ subtractFbankMean,+} from '../speaker-onnx/kaldiFbank.js';+import {+ computeSpeakerEmbedding,+ createOnnxSpeakerGateEngine,+ extractSpeech,+ SileroVadDetector,+ type OnnxTensor,+ type SpeakerOnnxRunner,+} from '../speaker-onnx/onnxSpeakerEngine.js';++/*+ * The real models are not available in CI. Equivalence with sherpa-onnx+ * (embeddings, per-frame VAD flags, extracted speech) was measured against+ * the desktop engine on the real models; these tests pin the logic around+ * the models with a scripted runner.+ */++function scriptedRunner(probabilities: number[]): SpeakerOnnxRunner & { calls: Record<string, OnnxTensor>[] } {+ let index = 0;+ const calls: Record<string, OnnxTensor>[] = [];+ return {+ calls,+ async run(model, inputs): Promise<Record<string, OnnxTensor>> {+ calls.push(inputs);+ if (model === 'embedding') {+ const frames = inputs.x.dims[1];+ return { embedding: { data: Float32Array.from({ length: 4 }, (_, i) => frames + i), dims: [1, 4] } };+ }+ const prob = probabilities[index] ?? 0;+ index += 1;+ return {+ prob: { data: Float32Array.of(prob), dims: [1, 1] },+ new_h: { data: new Float32Array(128).fill(index), dims: [2, 1, 64] },+ new_c: { data: new Float32Array(128).fill(-index), dims: [2, 1, 64] },+ };+ },+ };+}++const FRAME = 512;+const frames = (count: number) => new Float32Array(count * FRAME);++describe('kaldi fbank', () => {+ it('counts frames like kaldi without snipping edges', () => {+ expect(fbankFrameCount(0)).toBe(0);+ expect(fbankFrameCount(79)).toBe(0);+ expect(fbankFrameCount(80)).toBe(1);+ expect(fbankFrameCount(16_000)).toBe(100);+ expect(computeKaldiFbank(new Float32Array(16_000)).numFrames).toBe(100);+ });++ it('puts a pure tone in the mel bin around its frequency', () => {+ const samples = Float32Array.from({ length: 16_000 }, (_, i) => 0.5 * Math.sin((2 * Math.PI * 1000 * i) / 16_000));+ const { data, numFrames } = computeKaldiFbank(samples);+ const middle = Math.floor(numFrames / 2) * KALDI_FBANK_DIM;+ let peak = 0;+ for (let b = 1; b < KALDI_FBANK_DIM; b += 1) if (data[middle + b] > data[middle + peak]) peak = b;+ // 1 kHz is mel 1000; with 80 bins from 20 Hz to 7600 Hz that is bin 28.+ expect(peak).toBeGreaterThanOrEqual(27);+ expect(peak).toBeLessThanOrEqual(29);+ });++ it('floors silence at log(FLT_EPSILON) instead of -Infinity', () => {+ const { data } = computeKaldiFbank(new Float32Array(1_600));+ expect(Array.from(data).every((value) => Number.isFinite(value))).toBe(true);+ });++ it('subtracts the per-bin mean over frames', () => {+ const samples = Float32Array.from({ length: 8_000 }, (_, i) => Math.sin(i / 7) * 0.2 + Math.sin(i / 3) * 0.1);+ const features = computeKaldiFbank(samples);+ subtractFbankMean(features);+ for (let b = 0; b < KALDI_FBANK_DIM; b += 1) {+ let sum = 0;+ for (let f = 0; f < features.numFrames; f += 1) sum += features.data[f * KALDI_FBANK_DIM + b];+ expect(Math.abs(sum / features.numFrames)).toBeLessThan(1e-4);+ }+ });+});++describe('SileroVadDetector', () => {+ it('needs 0.25 s of speech before it reports speech, then holds through short pauses', async () => {+ // The first loud frame starts the clock; speech counts once 4000 samples+ // passed since then, i.e. on the 9th loud frame.+ const probs = [...Array(10).fill(0.9), ...Array(5).fill(0.1), ...Array(5).fill(0.9), ...Array(12).fill(0.1)];+ const vad = new SileroVadDetector(scriptedRunner(probs));+ const flags: boolean[] = [];+ for (let i = 0; i < probs.length; i += 1) flags.push(await vad.push(new Float32Array(FRAME)));+ expect(flags.slice(0, 8)).toEqual(Array(8).fill(false));+ // A 5-frame dip (2560 samples) is shorter than the 4000-sample silence.+ expect(flags.slice(8, 20)).toEqual(Array(12).fill(true));+ // Speech ends once silence lasted 4000 samples: 8 frames still count.+ expect(flags.slice(20, 28)).toEqual(Array(8).fill(true));+ expect(flags[28]).toBe(false);+ });++ it('carries the LSTM state from one frame to the next and resets it', async () => {+ const runner = scriptedRunner([0, 0, 0]);+ const vad = new SileroVadDetector(runner);+ await vad.push(new Float32Array(FRAME));+ await vad.push(new Float32Array(FRAME));+ expect(runner.calls[0].h.data[0]).toBe(0);+ expect(runner.calls[1].h.data[0]).toBe(1);+ expect(runner.calls[1].c.data[0]).toBe(-1);+ vad.reset();+ await vad.push(new Float32Array(FRAME));+ expect(runner.calls[2].h.data[0]).toBe(0);+ });++ it('rejects frames of the wrong size', async () => {+ await expect(new SileroVadDetector(scriptedRunner([])).push(new Float32Array(100))).rejects.toThrow();+ });+});++describe('ONNX speaker engines', () => {+ it('extracts speech segments with the same padding as sherpa-onnx', async () => {+ const probs = [...Array(20).fill(0.1), ...Array(20).fill(0.9), ...Array(20).fill(0.1)];+ const samples = frames(60);+ const speech = await extractSpeech(scriptedRunner(probs), samples);+ // Start: detected at frame 28 (tail 14848) minus 2 frames and 4000 samples;+ // end: 4000 samples after the first frame silence was confirmed.+ const start = 29 * FRAME - 2 * FRAME - 4000;+ const end = 48 * FRAME - 4000 + FRAME;+ expect(speech.length).toBe(end - start);+ });++ it('flushes a segment still open at the end of the clip', async () => {+ const probs = [...Array(4).fill(0.1), ...Array(30).fill(0.9)];+ const speech = await extractSpeech(scriptedRunner(probs), frames(34));+ expect(speech.length).toBeGreaterThan(0);+ });++ it('returns no embedding for a clip without a single frame', async () => {+ const runner = scriptedRunner([]);+ expect(await computeSpeakerEmbedding(runner, new Float32Array(10))).toBeNull();+ expect(runner.calls).toHaveLength(0);+ });++ it('feeds mean-normalized fbank frames to the embedding model', async () => {+ const runner = scriptedRunner([]);+ const embedding = await computeSpeakerEmbedding(runner, Float32Array.from({ length: 16_000 }, (_, i) => Math.sin(i)));+ expect(runner.calls[0].x.dims).toEqual([1, 100, KALDI_FBANK_DIM]);+ expect(Array.from(embedding ?? [])).toEqual([100, 101, 102, 103]);+ });++ it('gives each gate run its own VAD flags, one per whole frame', async () => {+ const engine = createOnnxSpeakerGateEngine(scriptedRunner(Array(20).fill(0.9)));+ await engine.resetVad();+ const flags = await engine.detectSpeech(new Float32Array(10 * FRAME + 100));+ expect(flags).toHaveLength(10);+ expect(flags[9]).toBe(true);+ });+});diff --git a/packages/voice-input-core/src/index.ts b/packages/voice-input-core/src/index.tsindex 28b7e9c0e6..445e43a5bd 100644--- a/packages/voice-input-core/src/index.ts+++ b/packages/voice-input-core/src/index.ts@@ -1,5 +1,10 @@export * from './types';export * from './BufferedAsrProvider';+export * from './SpeakerGate';+export * from './speakerEnrollment';+export * from './speakerModels';+export * from './speaker-onnx/kaldiFbank';+export * from './speaker-onnx/onnxSpeakerEngine';export * from './VoiceInputController';export * from './VoiceTimelineLogger';export * from './DictationRefiner';diff --git a/packages/voice-input-core/src/speaker-onnx/kaldiFbank.ts b/packages/voice-input-core/src/speaker-onnx/kaldiFbank.tsnew file mode 100644index 0000000000..02d80cda42--- /dev/null+++ b/packages/voice-input-core/src/speaker-onnx/kaldiFbank.ts@@ -0,0 +1,185 @@+/**+ * Log mel filterbank features, computed exactly as sherpa-onnx feeds its+ * speaker embedding models (kaldi-native-fbank with sherpa's defaults):+ * 16 kHz, 25 ms frames every 10 ms, edges reflected instead of snipped,+ * DC removed, pre-emphasis 0.97, Povey window, 512-point FFT, power+ * spectrum, 80 mel bins between 20 Hz and 7600 Hz, natural log.+ *+ * Desktop runs sherpa-onnx itself; mobile runs the same ONNX models through+ * onnxruntime with these features, so both produce the same voiceprints.+ */++const SAMPLE_RATE = 16_000;+const FRAME_LENGTH = 400;+const FRAME_SHIFT = 160;+const FFT_SIZE = 512;+const NUM_FFT_BINS = FFT_SIZE / 2;+const PREEMPH = 0.97;+const LOW_FREQ = 20;+const HIGH_FREQ = SAMPLE_RATE / 2 - 400;+const FLT_EPSILON = 1.1920928955078125e-7;++export const KALDI_FBANK_DIM = 80;++export type FbankFeatures = {+ /** Row-major [numFrames, KALDI_FBANK_DIM]. */+ data: Float32Array;+ numFrames: number;+};++type MelBin = { offset: number; weights: Float32Array };++let povey: Float64Array | null = null;+let melBins: MelBin[] | null = null;+let twiddles: { cos: Float64Array; sin: Float64Array; bitReverse: Uint16Array } | null = null;++function poveyWindow(): Float64Array {+ if (povey) return povey;+ const window = new Float64Array(FRAME_LENGTH);+ const a = (2 * Math.PI) / (FRAME_LENGTH - 1);+ for (let i = 0; i < FRAME_LENGTH; i += 1) window[i] = Math.pow(0.5 - 0.5 * Math.cos(a * i), 0.85);+ povey = window;+ return window;+}++function melScale(freq: number): number {+ return 1127 * Math.log(1 + freq / 700);+}++function melBanks(): MelBin[] {+ if (melBins) return melBins;+ const fftBinWidth = SAMPLE_RATE / FFT_SIZE;+ const melLow = melScale(LOW_FREQ);+ const melHigh = melScale(HIGH_FREQ);+ const delta = (melHigh - melLow) / (KALDI_FBANK_DIM + 1);+ const bins: MelBin[] = [];+ for (let bin = 0; bin < KALDI_FBANK_DIM; bin += 1) {+ const left = melLow + bin * delta;+ const center = left + delta;+ const right = center + delta;+ let first = -1;+ let last = -1;+ const weights = new Float32Array(NUM_FFT_BINS);+ for (let i = 0; i < NUM_FFT_BINS; i += 1) {+ const mel = melScale(fftBinWidth * i);+ if (mel > left && mel < right) {+ weights[i] = mel <= center ? (mel - left) / (center - left) : (right - mel) / (right - center);+ if (first < 0) first = i;+ last = i;+ }+ }+ bins.push(first < 0 ? { offset: 0, weights: new Float32Array(0) } : { offset: first, weights: weights.slice(first, last + 1) });+ }+ melBins = bins;+ return bins;+}++function fftTables() {+ if (twiddles) return twiddles;+ const cos = new Float64Array(FFT_SIZE / 2);+ const sin = new Float64Array(FFT_SIZE / 2);+ for (let i = 0; i < FFT_SIZE / 2; i += 1) {+ cos[i] = Math.cos((2 * Math.PI * i) / FFT_SIZE);+ sin[i] = -Math.sin((2 * Math.PI * i) / FFT_SIZE);+ }+ const bits = Math.log2(FFT_SIZE);+ const bitReverse = new Uint16Array(FFT_SIZE);+ for (let i = 0; i < FFT_SIZE; i += 1) {+ let reversed = 0;+ for (let b = 0; b < bits; b += 1) reversed |= ((i >> b) & 1) << (bits - 1 - b);+ bitReverse[i] = reversed;+ }+ twiddles = { cos, sin, bitReverse };+ return twiddles;+}++/** In-place radix-2 FFT of a real frame; writes the power spectrum into `power`. */+function powerSpectrum(frame: Float64Array, re: Float64Array, im: Float64Array, power: Float64Array): void {+ const { cos, sin, bitReverse } = fftTables();+ for (let i = 0; i < FFT_SIZE; i += 1) {+ re[bitReverse[i]] = frame[i];+ im[i] = 0;+ }+ for (let size = 2; size <= FFT_SIZE; size *= 2) {+ const half = size / 2;+ const step = FFT_SIZE / size;+ for (let start = 0; start < FFT_SIZE; start += size) {+ for (let k = 0; k < half; k += 1) {+ const wr = cos[k * step];+ const wi = sin[k * step];+ const a = start + k;+ const b = a + half;+ const tr = re[b] * wr - im[b] * wi;+ const ti = re[b] * wi + im[b] * wr;+ re[b] = re[a] - tr;+ im[b] = im[a] - ti;+ re[a] += tr;+ im[a] += ti;+ }+ }+ }+ for (let i = 0; i <= NUM_FFT_BINS; i += 1) power[i] = re[i] * re[i] + im[i] * im[i];+}++/** Number of frames for `numSamples` once input is finished (kaldi, snip_edges=false). */+export function fbankFrameCount(numSamples: number): number {+ return Math.floor((numSamples + FRAME_SHIFT / 2) / FRAME_SHIFT);+}++/** Fbank features of 16 kHz mono samples in [-1, 1]. */+export function computeKaldiFbank(samples: Float32Array): FbankFeatures {+ const numSamples = samples.length;+ const numFrames = numSamples === 0 ? 0 : fbankFrameCount(numSamples);+ const data = new Float32Array(numFrames * KALDI_FBANK_DIM);+ if (numFrames === 0) return { data, numFrames };++ const window = poveyWindow();+ const bins = melBanks();+ const frame = new Float64Array(FFT_SIZE);+ const re = new Float64Array(FFT_SIZE);+ const im = new Float64Array(FFT_SIZE);+ const power = new Float64Array(NUM_FFT_BINS + 1);++ for (let f = 0; f < numFrames; f += 1) {+ const begin = FRAME_SHIFT * f + FRAME_SHIFT / 2 - FRAME_LENGTH / 2;+ let mean = 0;+ for (let s = 0; s < FRAME_LENGTH; s += 1) {+ let index = begin + s;+ // Reflect around the edges, as kaldi does when not snipping them.+ while (index < 0 || index >= numSamples) {+ index = index < 0 ? -index - 1 : 2 * numSamples - 1 - index;+ }+ frame[s] = samples[index];+ mean += frame[s];+ }+ mean /= FRAME_LENGTH;+ for (let s = 0; s < FRAME_LENGTH; s += 1) frame[s] -= mean;+ for (let s = FRAME_LENGTH - 1; s > 0; s -= 1) frame[s] -= PREEMPH * frame[s - 1];+ frame[0] -= PREEMPH * frame[0];+ for (let s = 0; s < FRAME_LENGTH; s += 1) frame[s] *= window[s];+ frame.fill(0, FRAME_LENGTH);++ powerSpectrum(frame, re, im, power);++ const row = f * KALDI_FBANK_DIM;+ for (let b = 0; b < KALDI_FBANK_DIM; b += 1) {+ const { offset, weights } = bins[b];+ let energy = 0;+ for (let i = 0; i < weights.length; i += 1) energy += weights[i] * power[offset + i];+ data[row + b] = Math.log(Math.max(energy, FLT_EPSILON));+ }+ }+ return { data, numFrames };+}++/** Subtracts each mel bin's mean over all frames (3D-Speaker "global-mean"). */+export function subtractFbankMean(features: FbankFeatures): void {+ const { data, numFrames } = features;+ if (numFrames === 0) return;+ for (let b = 0; b < KALDI_FBANK_DIM; b += 1) {+ let sum = 0;+ for (let f = 0; f < numFrames; f += 1) sum += data[f * KALDI_FBANK_DIM + b];+ const mean = sum / numFrames;+ for (let f = 0; f < numFrames; f += 1) data[f * KALDI_FBANK_DIM + b] -= mean;+ }+}diff --git a/packages/voice-input-core/src/speaker-onnx/onnxSpeakerEngine.ts b/packages/voice-input-core/src/speaker-onnx/onnxSpeakerEngine.tsnew file mode 100644index 0000000000..218fa7d745--- /dev/null+++ b/packages/voice-input-core/src/speaker-onnx/onnxSpeakerEngine.ts@@ -0,0 +1,230 @@+import { SPEAKER_GATE_SAMPLE_RATE, SPEAKER_GATE_VAD_FRAME, type SpeakerGateEngine } from '../SpeakerGate';+import type { SpeakerEnrollmentEngine } from '../speakerEnrollment';+import { computeKaldiFbank, KALDI_FBANK_DIM, subtractFbankMean } from './kaldiFbank';++export type OnnxTensor = {+ data: Float32Array;+ dims: number[];+};++/**+ * Runs one of the two speaker models with float32 tensors. Mobile implements+ * it with onnxruntime in a native module; tests use onnxruntime-node.+ */+export interface SpeakerOnnxRunner {+ run(model: 'vad' | 'embedding', inputs: Record<string, OnnxTensor>): Promise<Record<string, OnnxTensor>>;+}++/**+ * VAD settings, identical to the desktop worker's sherpa-onnx config so both+ * platforms gate the same audio the same way.+ */+const VAD = {+ threshold: 0.5,+ minSpeechSamples: 0.25 * SPEAKER_GATE_SAMPLE_RATE,+ minSilenceSamples: 0.25 * SPEAKER_GATE_SAMPLE_RATE,+ maxSpeechSamples: 20 * SPEAKER_GATE_SAMPLE_RATE,+ // Applied once one utterance exceeds maxSpeechSamples, as sherpa-onnx does.+ longThreshold: 0.9,+ longMinSilenceSamples: 0.1 * SPEAKER_GATE_SAMPLE_RATE,+} as const;++const LSTM_STATE_DIMS = [2, 1, 64];+const LSTM_STATE_SIZE = 2 * 64;++/**+ * Port of sherpa-onnx's SileroVadModel (k2-fsa export: inputs x/h/c) and+ * VoiceActivityDetector, frame for frame. `push` takes exactly one 512-sample+ * frame and reports whether speech is currently detected, the same flag the+ * desktop worker reads with `isDetected()` after each frame.+ */+export class SileroVadDetector {+ private h = new Float32Array(LSTM_STATE_SIZE);+ private c = new Float32Array(LSTM_STATE_SIZE);+ // SileroVadModel state.+ private triggered = false;+ private currentSample = 0;+ private tempStart = 0;+ private tempEnd = 0;+ private threshold: number = VAD.threshold;+ private minSilenceSamples: number = VAD.minSilenceSamples;+ // VoiceActivityDetector state: absolute sample indices of its ring buffer.+ private head = 0;+ private tail = 0;+ private start = -1;+ private readonly segments: Array<[number, number]> = [];++ constructor(private readonly runner: SpeakerOnnxRunner) {}++ reset(): void {+ this.h = new Float32Array(LSTM_STATE_SIZE);+ this.c = new Float32Array(LSTM_STATE_SIZE);+ this.triggered = false;+ this.currentSample = 0;+ this.tempStart = 0;+ this.tempEnd = 0;+ this.head = 0;+ this.tail = 0;+ this.start = -1;+ this.segments.length = 0;+ }++ get detected(): boolean {+ return this.start !== -1;+ }++ /** Finished speech segments as [start, end) absolute sample indices. */+ takeSegments(): Array<[number, number]> {+ return this.segments.splice(0);+ }++ async push(frame: Float32Array): Promise<boolean> {+ if (frame.length !== SPEAKER_GATE_VAD_FRAME) throw new Error(`VAD frame must be ${SPEAKER_GATE_VAD_FRAME} samples`);+ if (this.tail - this.head > VAD.maxSpeechSamples) {+ this.minSilenceSamples = VAD.longMinSilenceSamples;+ this.threshold = VAD.longThreshold;+ } else {+ this.minSilenceSamples = VAD.minSilenceSamples;+ this.threshold = VAD.threshold;+ }++ this.tail += SPEAKER_GATE_VAD_FRAME;+ const isSpeech = this.isSpeech(await this.probability(frame));++ if (isSpeech) {+ if (this.start === -1) {+ this.start = Math.max(this.tail - 2 * SPEAKER_GATE_VAD_FRAME - VAD.minSpeechSamples, this.head);+ }+ } else {+ if (this.start !== -1 && this.tail > this.head) {+ const end = this.tail - this.minSilenceSamples;+ this.segments.push([this.start, end]);+ this.head = end;+ }+ if (this.start === -1) {+ const end = this.tail - 2 * SPEAKER_GATE_VAD_FRAME - VAD.minSpeechSamples;+ this.head += Math.max(0, end - this.head);+ }+ this.start = -1;+ }+ return this.detected;+ }++ /** Closes an open segment at the end of input. */+ flush(): void {+ if (this.start === -1 || this.tail === this.head) return;+ if (this.tail <= this.start) return;+ this.segments.push([this.start, this.tail]);+ this.head = this.tail;+ this.start = -1;+ }++ private async probability(frame: Float32Array): Promise<number> {+ const out = await this.runner.run('vad', {+ x: { data: frame, dims: [1, SPEAKER_GATE_VAD_FRAME] },+ h: { data: this.h, dims: LSTM_STATE_DIMS },+ c: { data: this.c, dims: LSTM_STATE_DIMS },+ });+ this.h = Float32Array.from(out.new_h.data);+ this.c = Float32Array.from(out.new_c.data);+ return out.prob.data[0];+ }++ private isSpeech(prob: number): boolean {+ const threshold = this.threshold;+ this.currentSample += SPEAKER_GATE_VAD_FRAME;+ if (prob > threshold && this.tempEnd !== 0) this.tempEnd = 0;+ if (prob > threshold && this.tempStart === 0) {+ // Speech must last minSpeechSamples before it counts.+ this.tempStart = this.currentSample;+ return false;+ }+ if (prob > threshold && this.tempStart !== 0 && !this.triggered) {+ if (this.currentSample - this.tempStart < VAD.minSpeechSamples) return false;+ this.triggered = true;+ return true;+ }+ if (prob < threshold && !this.triggered) {+ this.tempStart = 0;+ this.tempEnd = 0;+ return false;+ }+ const negThreshold = Math.max(threshold - 0.15, 0.01);+ if (prob > negThreshold && this.triggered) return true;+ if (prob > threshold && !this.triggered) {+ this.triggered = true;+ return true;+ }+ if (prob < threshold && this.triggered) {+ if (this.tempEnd === 0) this.tempEnd = this.currentSample;+ if (this.currentSample - this.tempEnd < this.minSilenceSamples) return true;+ this.tempStart = 0;+ this.tempEnd = 0;+ this.triggered = false;+ return false;+ }+ return false;+ }+}++/** Speaker embedding of 16 kHz samples, null when the clip is too short. */+export async function computeSpeakerEmbedding(+ runner: SpeakerOnnxRunner,+ samples: Float32Array,+): Promise<Float32Array | null> {+ const features = computeKaldiFbank(samples);+ if (features.numFrames === 0) return null;+ subtractFbankMean(features);+ const out = await runner.run('embedding', {+ x: { data: features.data, dims: [1, features.numFrames, KALDI_FBANK_DIM] },+ });+ return Float32Array.from(out.embedding.data);+}++/** Gate engine for one dictation run; each run owns its VAD state. */+export function createOnnxSpeakerGateEngine(runner: SpeakerOnnxRunner): SpeakerGateEngine {+ const vad = new SileroVadDetector(runner);+ return {+ resetVad: async () => vad.reset(),+ detectSpeech: async (samples) => {+ const frames = Math.floor(samples.length / SPEAKER_GATE_VAD_FRAME);+ const flags: boolean[] = [];+ for (let i = 0; i < frames; i += 1) {+ flags.push(await vad.push(samples.subarray(i * SPEAKER_GATE_VAD_FRAME, (i + 1) * SPEAKER_GATE_VAD_FRAME)));+ // Only the per-frame flag is used; finished segments would pile up.+ vad.takeSegments();+ }+ return flags;+ },+ embed: (samples) => computeSpeakerEmbedding(runner, samples),+ };+}++export function createOnnxSpeakerEnrollmentEngine(runner: SpeakerOnnxRunner): SpeakerEnrollmentEngine {+ return {+ extractSpeech: (samples) => extractSpeech(runner, samples),+ embed: (samples) => computeSpeakerEmbedding(runner, samples),+ };+}++/** Speech-only samples of a clip: VAD segments joined, silence dropped. */+export async function extractSpeech(runner: SpeakerOnnxRunner, samples: Float32Array): Promise<Float32Array> {+ const vad = new SileroVadDetector(runner);+ const segments: Array<[number, number]> = [];+ const frames = Math.floor(samples.length / SPEAKER_GATE_VAD_FRAME);+ for (let i = 0; i < frames; i += 1) {+ await vad.push(samples.subarray(i * SPEAKER_GATE_VAD_FRAME, (i + 1) * SPEAKER_GATE_VAD_FRAME));+ segments.push(...vad.takeSegments());+ }+ vad.flush();+ segments.push(...vad.takeSegments());+ const total = segments.reduce((sum, [from, to]) => sum + Math.max(0, to - from), 0);+ const out = new Float32Array(total);+ let offset = 0;+ for (const [from, to] of segments) {+ if (to <= from) continue;+ out.set(samples.subarray(from, to), offset);+ offset += to - from;+ }+ return out;+}diff --git a/packages/voice-input-core/src/speakerEnrollment.ts b/packages/voice-input-core/src/speakerEnrollment.tsnew file mode 100644index 0000000000..c0973004e0--- /dev/null+++ b/packages/voice-input-core/src/speakerEnrollment.ts@@ -0,0 +1,97 @@+import { cosineSimilarity, SPEAKER_GATE_SAMPLE_RATE } from './SpeakerGate';++/** Inference needed to enroll a voiceprint. */+export interface SpeakerEnrollmentEngine {+ /** Speech-only samples of a clip (VAD segments joined, silence removed). */+ extractSpeech(samples: Float32Array): Promise<Float32Array>;+ embed(samples: Float32Array): Promise<Float32Array | null>;+}++export type SpeakerEnrollmentFailure = 'too_short' | 'no_embedding' | 'inconsistent';++export type SpeakerEnrollmentResult =+ | {+ ok: true;+ embedding: Float32Array;+ /** Lowest similarity between one clip and the mean of the other clips. */+ selfScore: number;+ speechSec: number;+ }+ | {+ ok: false;+ reason: SpeakerEnrollmentFailure;+ /** Index of the clip that failed, when one clip is to blame. */+ clipIndex?: number;+ speechSec?: number;+ selfScore?: number;+ };++export const SPEAKER_ENROLLMENT_CLIP_COUNT = 3;+export const SPEAKER_ENROLLMENT_MIN_CLIP_SPEECH_SEC = 2;+// Own-voice windows scored 0.77–0.88 in validation; clips of one person that+// disagree this much usually mean a second voice or heavy noise in a clip.+export const SPEAKER_ENROLLMENT_MIN_SELF_SCORE = 0.6;++/**+ * Builds a voiceprint from a few read-aloud clips: the mean of each clip's+ * normalized embedding, normalized again — the same recipe the validation+ * used. Each clip must carry enough speech and agree with the other clips,+ * without its own embedding inflating the consistency score.+ */+export async function buildSpeakerEnrollment(+ engine: SpeakerEnrollmentEngine,+ clips: Float32Array[],+): Promise<SpeakerEnrollmentResult> {+ const embeddings: Float32Array[] = [];+ let speechSamples = 0;+ for (let index = 0; index < clips.length; index += 1) {+ const speech = await engine.extractSpeech(clips[index]);+ const clipSec = speech.length / SPEAKER_GATE_SAMPLE_RATE;+ speechSamples += speech.length;+ if (clipSec < SPEAKER_ENROLLMENT_MIN_CLIP_SPEECH_SEC) {+ return { ok: false, reason: 'too_short', clipIndex: index, speechSec: clipSec };+ }+ const embedding = await engine.embed(speech);+ if (+ !embedding?.length ||+ !embedding.every(Number.isFinite) ||+ !embedding.some((value) => value !== 0) ||+ (embeddings.length > 0 && embedding.length !== embeddings[0].length)+ ) {+ return { ok: false, reason: 'no_embedding', clipIndex: index };+ }+ embeddings.push(normalize(embedding));+ }+ const speechSec = speechSamples / SPEAKER_GATE_SAMPLE_RATE;+ if (embeddings.length === 0) return { ok: false, reason: 'too_short', speechSec };++ const mean = new Float32Array(embeddings[0].length);+ for (const embedding of embeddings) {+ for (let i = 0; i < mean.length; i += 1) mean[i] += embedding[i];+ }+ const voiceprint = normalize(mean);++ let selfScore = 1;+ let worstClip = 0;+ embeddings.forEach((embedding, index) => {+ const otherClips = Float32Array.from(mean, (value, dimension) => value - embedding[dimension]);+ const score = cosineSimilarity(embedding, otherClips);+ if (score < selfScore) {+ selfScore = score;+ worstClip = index;+ }+ });+ if (selfScore < SPEAKER_ENROLLMENT_MIN_SELF_SCORE) {+ return { ok: false, reason: 'inconsistent', clipIndex: worstClip, selfScore, speechSec };+ }+ return { ok: true, embedding: voiceprint, selfScore, speechSec };+}++function normalize(vector: Float32Array): Float32Array {+ let sum = 0;+ for (let i = 0; i < vector.length; i += 1) sum += vector[i] * vector[i];+ const norm = Math.sqrt(sum) || 1;+ const out = new Float32Array(vector.length);+ for (let i = 0; i < vector.length; i += 1) out[i] = vector[i] / norm;+ return out;+}diff --git a/packages/voice-input-core/src/speakerModels.ts b/packages/voice-input-core/src/speakerModels.tsnew file mode 100644index 0000000000..449b4024c3--- /dev/null+++ b/packages/voice-input-core/src/speakerModels.ts@@ -0,0 +1,57 @@+/**+ * Models the speaker gate downloads the first time a user turns it on. Both+ * desktop and mobile fetch the same files from Cindy's CDN, addressed by+ * content hash, and verify the hash before use.+ *+ * Sources (ONNX files as published by the sherpa-onnx project):+ * - Silero VAD (MIT): https://github.com/snakers4/silero-vad+ * - 3D-Speaker CAM++ zh/en "advanced" (Apache-2.0, per its ModelScope card+ * iic/speech_campplus_sv_zh_en_16k-common_advanced):+ * https://github.com/modelscope/3D-Speaker+ *+ * Changing a model means a new hash, so a new CDN object; clients holding the+ * old file simply download the new one. Old files are removed on next check.+ */+export type SpeakerModelAsset = {+ role: 'vad' | 'embedding';+ /** Name kept on disk, also used in logs. */+ fileName: string;+ sha256: string;+ bytes: number;+};++export const SPEAKER_MODEL_ASSETS: readonly SpeakerModelAsset[] = [+ {+ role: 'vad',+ fileName: 'silero_vad.onnx',+ sha256: '9e2449e1087496d8d4caba907f23e0bd3f78d91fa552479bb9c23ac09cbb1fd6',+ bytes: 643_854,+ },+ {+ role: 'embedding',+ fileName: '3dspeaker_campplus_zh_en_16k_advanced.onnx',+ sha256: 'aa3cfc16963a10586a9393f5035d6d6b57e98d358b347f80c2a30bf4f00ceba2',+ bytes: 28_281_164,+ },+];++export const SPEAKER_MODEL_TOTAL_BYTES = SPEAKER_MODEL_ASSETS.reduce(+ (sum, asset) => sum + asset.bytes,+ 0,+);++/** Object path below the region's `cdnBaseUrl`. */+export function speakerModelCdnPath(asset: SpeakerModelAsset): string {+ return `voice-models/${asset.sha256}.onnx`;+}++/** Local file name: the hash keeps an updated model from reusing a stale file. */+export function speakerModelLocalName(asset: SpeakerModelAsset): string {+ return `${asset.sha256.slice(0, 16)}-${asset.fileName}`;+}++export function speakerModelAsset(role: SpeakerModelAsset['role']): SpeakerModelAsset {+ const asset = SPEAKER_MODEL_ASSETS.find((candidate) => candidate.role === role);+ if (!asset) throw new Error(`missing speaker model asset: ${role}`);+ return asset;+}diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 9547b79fa4..b180127921 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -457,6 +457,9 @@ importers:sharp:specifier: ^0.35.0version: 0.35.3(@types/[email protected])+ sherpa-onnx-node:+ specifier: 1.13.8+ version: 1.13.8silk-wasm:specifier: ^3.7.1version: 3.7.1@@ -10171,6 +10174,39 @@ packages:resolution: {integrity: sha512-w1aiOKwKuRgtwAReIIj89puqg+I7GvX4IbLrvmhXbzQsj1+Zwi4VO3+fa6ZF91TWSjIxoEkKnMeHcLEODK5ZXA==}engines: {node: '>= 0.4'}+ resolution: {integrity: sha512-FPNgJMgnWVl/KhRTIhG3KL3A4Om63Rn4YKXc9/uHY7SzLcvqLJLc/h7UBWJwduXvv7K18t5NpxHR6XgXn4sjWw==}+ cpu: [arm64]+ os: [darwin]++ resolution: {integrity: sha512-7BLRpjM6w4f9W46/nmkmq8lEKUayhebvcpslCVQ+6QN2uReYlZEMDZlSpXMjme+hUFrPfRz8P3UNq8ep/4d19g==}+ cpu: [x64]+ os: [darwin]++ resolution: {integrity: sha512-Tlg7a70b/Wge3OF8IgTHF9jhSVCsLyKQKhwc4BsJ5A+dL/SrFtGBjzuHp4XeLhiiOT7afCxX5PdSn/D4c8Lnuw==}+ cpu: [arm64]+ os: [linux]++ resolution: {integrity: sha512-6plnhjagsSeTntCgnlag86hWbs/uZE9Crms1LgOb68/1nKsIQjMd+WG519m+aPwT6TrsBOiEMzrx41t8sL5L5g==}+ cpu: [x64]+ os: [linux]++ resolution: {integrity: sha512-MsDMBdhLFTZ1GwvcGSSQhnS7g/EA8OMH6IYysCVUOM7j8Icty9KRc0E6YT1A5fWBsZwRfKOeh88QC95aRvS8ag==}++ resolution: {integrity: sha512-H0Ojln9hfvM+pxWqW0cnjB/XK8/JPq4/k0IWu2JpY5Z458M3zv+XC3Hu+wmot3AoH/K1Bgt23n/tTKtPV9x8qg==}+ cpu: [ia32]+ os: [win32]++ resolution: {integrity: sha512-oZF1c9VPOKtMwn83Bboc5XSWL+76BRoyB3eUuVnCknBKxwSULZU2Foia9VHWzU+n4I12rPsP6z6H9Rp1hD9o8g==}+ cpu: [x64]+ os: [win32]+resolution: {integrity: sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==}engines: {node: '>= 0.4'}@@ -21803,6 +21839,33 @@ snapshots:+ optional: true++ optional: true++ optional: true++ optional: true++ optionalDependencies:+ sherpa-onnx-darwin-arm64: 1.13.8+ sherpa-onnx-darwin-x64: 1.13.8+ sherpa-onnx-linux-arm64: 1.13.8+ sherpa-onnx-linux-x64: 1.13.8+ sherpa-onnx-win-ia32: 1.13.8+ sherpa-onnx-win-x64: 1.13.8++ optional: true++ optional: true+dependencies:es-errors: 1.3.0diff --git a/scripts/__tests__/third-party-notices.test.mjs b/scripts/__tests__/third-party-notices.test.mjsindex 6152acbc17..6434ca707e 100644--- a/scripts/__tests__/third-party-notices.test.mjs+++ b/scripts/__tests__/third-party-notices.test.mjs@@ -26,6 +26,15 @@ function read(relativePath) {return fs.readFileSync(path.join(repoRoot, relativePath), "utf8");}+test("speaker models and native inference libraries are disclosed on both clients", () => {+ for (const artifact of artifactNames) {+ const notices = read(`docs/legal/notices/${artifact}.txt`);+ assert.ok(notices.includes("Silero VAD (runtime-downloaded model)"));+ assert.ok(notices.includes("3D-Speaker CAM++ zh-en advanced"));+ assert.ok(notices.includes("ONNX Runtime (native inference library)"));+ }+});+test("Windows input helper dependencies participate in Cargo license collection", () => {const source = read("scripts/generate-third-party-notices.mjs");assert.ok(source.includes('"windows-gamepad-helper"'));diff --git a/scripts/generate-third-party-notices.mjs b/scripts/generate-third-party-notices.mjsindex 7747dac762..91b3eec371 100644--- a/scripts/generate-third-party-notices.mjs+++ b/scripts/generate-third-party-notices.mjs@@ -687,6 +687,35 @@ function readBundledLicense(relativePath) {);}+function buildSpeakerModelEntries(apacheText) {+ return [+ bundledComponent({+ name: "Silero VAD (runtime-downloaded model)",+ version: "sha256:9e2449e1087496d8d4caba907f23e0bd3f78d91fa552479bb9c23ac09cbb1fd6",+ license: "MIT",+ url: "https://github.com/snakers4/silero-vad",+ licenseText: MIT_TEXT("Copyright (c) 2020-present Silero Team"),+ }),+ bundledComponent({+ name: "3D-Speaker CAM++ zh-en advanced (runtime-downloaded model)",+ version: "sha256:aa3cfc16963a10586a9393f5035d6d6b57e98d358b347f80c2a30bf4f00ceba2",+ license: "Apache-2.0",+ url: "https://modelscope.cn/models/iic/speech_campplus_sv_zh_en_16k-common_advanced",+ licenseText: apacheText,+ }),+ ];+}++function onnxRuntimeEntry(version) {+ return bundledComponent({+ name: "ONNX Runtime (native inference library)",+ version,+ license: "MIT",+ url: "https://github.com/microsoft/onnxruntime",+ licenseText: MIT_TEXT("Copyright (c) Microsoft Corporation"),+ });+}+/*** 桌面三平台共有的非 npm 分发组件声明(含安装包内资产与运行时受管下载资产)。*@@ -696,7 +725,10 @@ function readBundledLicense(relativePath) {* 的 productName 同样是 x64/arm64 但目前只传 arm64,属既存缺口,记在 issue #452。*/function buildDesktopCommonEntries(apacheText, sharpPackageNames) {- const entries = [];+ const entries = [+ ...buildSpeakerModelEntries(apacheText),+ onnxRuntimeEntry("bundled with sherpa-onnx-node 1.13.8"),+ ];// ripgrep — 随包分发的搜索二进制entries.push(@@ -992,6 +1024,8 @@ function buildWindowsEntries() {function buildMobileEntries(apacheText, platform) {const entries = [+ ...buildSpeakerModelEntries(apacheText),+ onnxRuntimeEntry("1.30.0"),...buildProviderBrandingEntries(),bundledComponent({name: "JetBrains Mono fonts",