From 258d108f59daab690ca61c2e50ea45401696e9cd Mon Sep 17 00:00:00 2001 From: Moepchi Date: Thu, 17 Sep 2026 18:12:52 +0000 Subject: [PATCH] Add opt-in WASM AEC3 echo canceller for speaker+mic setups Off-by-default toggle in the recording options (Aufnahmeoptionen), using @ennuicastr/webrtcaec3.js (Google WebRTC's AEC3, compiled to WASM) as a stronger supplement to native browser echo cancellation - addresses the speaker+studio-mic (no headset) case from issue #2. Native echoCancellation is turned off while this is enabled since running both fights the same signal. Assets are synced from node_modules into public/vendor/ at dev/build time rather than committed, since the module's glue code needs its .wasm co-located under an exact, unhashed filename. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU --- .gitignore | 3 + web/package-lock.json | 103 +++---------------------------- web/package.json | 3 + web/scripts/sync-aec3-assets.mjs | 20 ++++++ web/src/App.tsx | 64 ++++++++++++++++++- web/src/aec3.ts | 58 +++++++++++++++++ web/src/locales/de.json | 1 + web/src/locales/en.json | 1 + web/src/voice.ts | 52 +++++++++++++++- 9 files changed, 207 insertions(+), 98 deletions(-) create mode 100644 web/scripts/sync-aec3-assets.mjs create mode 100644 web/src/aec3.ts diff --git a/.gitignore b/.gitignore index 41f0697..b7b8b5e 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,6 @@ CLAUDE.md # TLS material for local HTTPS - a private key never belongs in the repo. gateway/certs/ + +# Prebuilt WASM assets synced from node_modules by scripts/sync-aec3-assets.mjs +web/public/vendor/ diff --git a/web/package-lock.json b/web/package-lock.json index 1e0a19b..b63658b 100644 --- a/web/package-lock.json +++ b/web/package-lock.json @@ -8,6 +8,7 @@ "name": "webspeak3-web", "version": "0.0.0", "dependencies": { + "@ennuicastr/webrtcaec3.js": "^0.3.0", "fflate": "^0.8.3", "react": "^19.2.7", "react-dom": "^19.2.7" @@ -1619,6 +1620,12 @@ "tslib": "^2.4.0" } }, + "node_modules/@ennuicastr/webrtcaec3.js": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@ennuicastr/webrtcaec3.js/-/webrtcaec3.js-0.3.0.tgz", + "integrity": "sha512-ZfijX3Pzqr2zY2nTBE+APGB4X8q3up5vqQgmuolCvC2WTYYWvivf3GGVFZnTr6n/kZa9w3Y5P4ugwcrOmsqXZQ==", + "license": "BSD-3-Clause" + }, "node_modules/@isaacs/cliui": { "version": "9.0.0", "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-9.0.0.tgz", @@ -1698,9 +1705,6 @@ "x64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1869,9 +1873,6 @@ "arm64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1889,9 +1890,6 @@ "arm64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -1909,9 +1907,6 @@ "ppc64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1929,9 +1924,6 @@ "riscv64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1949,9 +1941,6 @@ "riscv64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -1969,9 +1958,6 @@ "s390x" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1989,9 +1975,6 @@ "x64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2009,9 +1992,6 @@ "x64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -2182,9 +2162,6 @@ "arm64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2202,9 +2179,6 @@ "arm64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -2222,9 +2196,6 @@ "ppc64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2242,9 +2213,6 @@ "s390x" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2262,9 +2230,6 @@ "x64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2282,9 +2247,6 @@ "x64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -2617,9 +2579,6 @@ "arm" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2634,9 +2593,6 @@ "arm" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -2651,9 +2607,6 @@ "arm64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2668,9 +2621,6 @@ "arm64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -2685,9 +2635,6 @@ "loong64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2702,9 +2649,6 @@ "loong64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -2719,9 +2663,6 @@ "ppc64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2736,9 +2677,6 @@ "ppc64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -2753,9 +2691,6 @@ "riscv64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2770,9 +2705,6 @@ "riscv64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -2787,9 +2719,6 @@ "s390x" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2804,9 +2733,6 @@ "x64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2821,9 +2747,6 @@ "x64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -4891,9 +4814,6 @@ "arm64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MPL-2.0", "optional": true, "os": [ @@ -4915,9 +4835,6 @@ "arm64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MPL-2.0", "optional": true, "os": [ @@ -4939,9 +4856,6 @@ "x64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MPL-2.0", "optional": true, "os": [ @@ -4963,9 +4877,6 @@ "x64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MPL-2.0", "optional": true, "os": [ diff --git a/web/package.json b/web/package.json index beddd7e..7aff46e 100644 --- a/web/package.json +++ b/web/package.json @@ -4,12 +4,15 @@ "version": "0.0.0", "type": "module", "scripts": { + "predev": "node scripts/sync-aec3-assets.mjs", "dev": "vite", + "prebuild": "node scripts/sync-aec3-assets.mjs", "build": "tsc -b && vite build", "lint": "oxlint", "preview": "vite preview" }, "dependencies": { + "@ennuicastr/webrtcaec3.js": "^0.3.0", "fflate": "^0.8.3", "react": "^19.2.7", "react-dom": "^19.2.7" diff --git a/web/scripts/sync-aec3-assets.mjs b/web/scripts/sync-aec3-assets.mjs new file mode 100644 index 0000000..b3aedb8 --- /dev/null +++ b/web/scripts/sync-aec3-assets.mjs @@ -0,0 +1,20 @@ +// Copies the AEC3 WASM module's prebuilt assets into public/vendor/ so they're +// served unhashed, at the exact filenames the module's own glue code expects +// (it resolves its .wasm next to its own