Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
build(desktop): use upstream's sherpa-onnx for Windows arm64
Elian Doran8eb5a4346a5d
diff --git a/.claude/skills/working-with-transcription/SKILL.md b/.claude/skills/working-with-transcription/SKILL.mdindex 57ae35b0d1..60bc93ad33 100644--- a/.claude/skills/working-with-transcription/SKILL.md+++ b/.claude/skills/working-with-transcription/SKILL.md@@ -272,7 +272,7 @@ The same 31-minute Romanian meeting (no reference, judged by reading): int8 is o- **The capture window must be `offscreen`**: a hidden window renders no frames without it, and the self-capture that yields system audio times out. `getDisplayMedia()` needs a user gesture, which only `executeJavaScript(…, true)` gives a hidden window.- **Chromium's audio processing is applied during capture**, so the WAV already holds it and no replay can switch it off. The system track runs with echo cancellation, noise suppression and auto gain all off; the microphone keeps echo cancellation, so the meeting played through speakers is not transcribed twice, and its auto gain. Earlier recordings, including the one under "Findings so far", had noise suppression on both tracks and echo cancellation on the system track, so do not compare transcripts across that change.- **A silent system source** usually means the sink's monitor volume is near zero (seen at -66 dB); the per-source peak logged every 5 s shows it.-- **Prebuilds**: `sherpa-onnx-node` has none for win-arm64. `provider: "trt"` exits the process with an offline model.+- **`provider: "trt"`** exits the process with an offline model.## Testsdiff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.ymlindex b2b7c3d568..c70707a45c 100644--- a/.github/workflows/nightly.yml+++ b/.github/workflows/nightly.yml@@ -12,7 +12,6 @@ on:paths:- .github/actions/build-electron/*- .github/workflows/nightly.yml- - .github/workflows/sherpa-onnx-win-arm64.yml- forge.config.tsconcurrency:@@ -32,13 +31,8 @@ permissions:contents: writejobs:- sherpa-onnx-win-arm64:- if: ${{ github.repository == vars.REPO_MAIN }}- uses: ./.github/workflows/sherpa-onnx-win-arm64.ymlnightly-electron:if: ${{ github.repository == vars.REPO_MAIN }}- needs:- - sherpa-onnx-win-arm64name: Deploy nightlystrategy:fail-fast: false@@ -103,15 +97,10 @@ jobs:with:node-version: 24- name: Install dependencies- # The arm64 macOS runner also packages darwin-x64, which needs that architecture's native- # optional dependencies (sherpa-onnx-darwin-x64) beside the host's.- run: pnpm install --frozen-lockfile ${{ matrix.os.name == 'macos' && '--cpu=x64,arm64' || '' }}- - name: Add sherpa-onnx for Windows arm64- if: ${{ matrix.os.name == 'windows' && matrix.arch == 'arm64' }}- uses: actions/download-artifact@v8- with:- name: sherpa-onnx-win-arm64- path: node_modules/sherpa-onnx-win-arm64+ # The macOS and Windows runners each package both architectures, which needs the other+ # architecture's native optional dependencies (sherpa-onnx-darwin-x64,+ # sherpa-onnx-win-arm64) beside the host's.+ run: pnpm install --frozen-lockfile ${{ (matrix.os.name == 'macos' || matrix.os.name == 'windows') && '--cpu=x64,arm64' || '' }}- name: Update nightly versionrun: pnpm run chore:ci-update-nightly-version- name: Run the builddiff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex 90ab34ab3d..4224f38c16 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -31,13 +31,10 @@ jobs:- name: Check version consistencyrun: pnpm tsx ${{ github.workspace }}/scripts/check-version-consistency.ts ${{ github.ref_name }}- sherpa-onnx-win-arm64:- uses: ./.github/workflows/sherpa-onnx-win-arm64.ymlmake-electron:name: Make Electronneeds:- sanity-check- - sherpa-onnx-win-arm64strategy:fail-fast: falsematrix:@@ -86,15 +83,10 @@ jobs:node-version: 24cache: 'pnpm'- name: Install dependencies- # The arm64 macOS runner also packages darwin-x64, which needs that architecture's native- # optional dependencies (sherpa-onnx-darwin-x64) beside the host's.- run: pnpm install --frozen-lockfile ${{ matrix.os.name == 'macos' && '--cpu=x64,arm64' || '' }}- - name: Add sherpa-onnx for Windows arm64- if: ${{ matrix.os.name == 'windows' && matrix.arch == 'arm64' }}- uses: actions/download-artifact@v8- with:- name: sherpa-onnx-win-arm64- path: node_modules/sherpa-onnx-win-arm64+ # The macOS and Windows runners each package both architectures, which needs the other+ # architecture's native optional dependencies (sherpa-onnx-darwin-x64,+ # sherpa-onnx-win-arm64) beside the host's.+ run: pnpm install --frozen-lockfile ${{ (matrix.os.name == 'macos' || matrix.os.name == 'windows') && '--cpu=x64,arm64' || '' }}- name: Run the builduses: ./.github/actions/build-electronwith:diff --git a/.github/workflows/sherpa-onnx-win-arm64.yml b/.github/workflows/sherpa-onnx-win-arm64.ymldeleted file mode 100644index d3ceb0ffb3..0000000000--- a/.github/workflows/sherpa-onnx-win-arm64.yml+++ /dev/null@@ -1,111 +0,0 @@-name: sherpa-onnx for Windows arm64--# sherpa-onnx publishes no Node addon for Windows on arm64 (no `sherpa-onnx-win-arm64` on npm),-# so meeting transcription has nothing to load there. This builds that package from upstream's-# sources at the pinned version, linked against the win-arm64 libraries upstream releases, and-# uploads it as the `sherpa-onnx-win-arm64` artifact for the Windows arm64 desktop build.-# Remove it once upstream publishes the package (k2-fsa/sherpa-onnx, npm-addon-win-arm64.yaml).--on:- workflow_call:--permissions:- contents: read--jobs:- build:- name: Build sherpa-onnx-win-arm64- runs-on: windows-11-arm- defaults:- run:- shell: bash- steps:- - uses: actions/checkout@v7- with:- persist-credentials: false- sparse-checkout: |- apps/desktop/package.json- .github/workflows/sherpa-onnx-win-arm64.yml- sparse-checkout-cone-mode: false-- - name: Read the pinned version- id: version- run: |- version=$(node -p 'require("./apps/desktop/package.json").dependencies["sherpa-onnx-node"]')- echo "version=$version" >> "$GITHUB_OUTPUT"-- - name: Restore a previous build- id: cache- uses: actions/cache@v6- with:- path: out/sherpa-onnx-win-arm64- key: sherpa-onnx-win-arm64-${{ steps.version.outputs.version }}-${{ hashFiles('.github/workflows/sherpa-onnx-win-arm64.yml') }}-- - uses: actions/setup-node@v7- if: steps.cache.outputs.cache-hit != 'true'- with:- node-version: 24-- - name: Build the addon- if: steps.cache.outputs.cache-hit != 'true'- env:- VERSION: ${{ steps.version.outputs.version }}- run: |- set -euo pipefail- test "$(node -p process.arch)" = arm64-- git clone --quiet --depth 1 --branch "v$VERSION" https://github.com/k2-fsa/sherpa-onnx.git sherpa- # The addon's sources are git symlinks, which a checkout without symlink support writes- # as files holding the link target.- cd sherpa- git ls-files -s scripts/node-addon-api | awk '$1 == "120000" { print $4 }' | while read -r link; do- if [ ! -L "$link" ]; then- cp --remove-destination "$(dirname "$link")/$(cat "$link")" "$link"- fi- done- cd ..-- libs="sherpa-onnx-v$VERSION-win-arm64-shared-MD-Release-lib"- curl -sSfL -o libs.tar.bz2 \- "https://github.com/k2-fsa/sherpa-onnx/releases/download/v$VERSION/$libs.tar.bz2"- tar xjf libs.tar.bz2- mkdir -p "$libs/include/sherpa-onnx/c-api"- cp sherpa/sherpa-onnx/c-api/c-api.h "$libs/include/sherpa-onnx/c-api/"- export SHERPA_ONNX_INSTALL_DIR="$PWD/$libs"-- cd sherpa/scripts/node-addon-api- npm install --ignore-scripts --no-audit --no-fund- ./node_modules/.bin/cmake-js compile -A ARM64- cd ../../..-- out=out/sherpa-onnx-win-arm64- mkdir -p "$out"- cp sherpa/scripts/node-addon-api/build/Release/sherpa-onnx.node "$libs"/lib/*.dll "$out/"- cp sherpa/LICENSE "$out/"- cat > "$out/package.json" <<EOF- {- "name": "sherpa-onnx-win-arm64",- "version": "$VERSION",- "license": "Apache-2.0",- "os": [ "win32" ],- "cpu": [ "arm64" ]- }- EOF-- - name: Load the addon- env:- VERSION: ${{ steps.version.outputs.version }}- run: |- node -e '- const addon = require("./out/sherpa-onnx-win-arm64/sherpa-onnx.node");- if (addon.version !== process.env.VERSION) {- throw new Error(`Built ${addon.version}, expected ${process.env.VERSION}`);- }- console.log(`sherpa-onnx ${addon.version}, onnxruntime ${addon.onnxruntimeVersion}`);- '-- - uses: actions/upload-artifact@v7- with:- name: sherpa-onnx-win-arm64- path: out/sherpa-onnx-win-arm64- if-no-files-found: errordiff --git a/apps/desktop/scripts/build.ts b/apps/desktop/scripts/build.tsindex 0343565b03..58610e305b 100644--- a/apps/desktop/scripts/build.ts+++ b/apps/desktop/scripts/build.ts@@ -48,9 +48,7 @@ async function main() {* Copies `sherpa-onnx-node`, which the meeting transcription worker loads, together with the* package holding its native addon for the target platform. That package is only an optional* dependency, so pnpm installs it just for the host's platform; CI installs the others it- * packages for with `--cpu`. Upstream publishes none for Windows on arm64, so CI builds- * `sherpa-onnx-win-arm64` itself (`.github/workflows/sherpa-onnx-win-arm64.yml`) and places it in- * `node_modules`. A target with no such package ships neither.+ * packages for with `--cpu`. A target with no such package ships neither.*/function copySherpaOnnx() {const sherpaDir = join(build.rootDir, "node_modules", "sherpa-onnx-node");@@ -58,12 +56,11 @@ function copySherpaOnnx() {const { optionalDependencies } = JSON.parse(sherpaPackageJson);const platform = process.platform === "win32" ? "win" : process.platform;const platformPackage = `sherpa-onnx-${platform}-${targetArch()}`;- const isInstalled = existsSync(join(build.rootDir, "node_modules", platformPackage));- if (!(platformPackage in optionalDependencies) && !isInstalled) {+ if (!(platformPackage in optionalDependencies)) {console.warn(`sherpa-onnx has no ${platformPackage}; transcription is unavailable there.`);return;}- if (!isInstalled) {+ if (!existsSync(join(build.rootDir, "node_modules", platformPackage))) {throw new Error(`${platformPackage} is not installed. Install the target architecture's `+ `optional dependencies too: pnpm install --cpu=${process.arch},${targetArch()}`);}