Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.
JavaScript aianthropiccross-platformgeminigroqlinuxmacosnvidiaopen-sourceopenaiparakeetspeech-to-texttranscribewhisperwindows
chore(transcription): update sherpa-onnx to 1.13.8 (#1951)
Emanuele Tonelloecd94591213b
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 8c46fcbb5..4bcf61fd9 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -63,6 +63,7 @@ A follow-up to 1.10.0 built from everything that landed since. Notes open straig### Transcription+- **Local transcription now uses sherpa-onnx 1.13.8.** Cohere Transcribe now returns an empty result for silent audio instead of hallucinating a sentence; the bundled ONNX Runtime also moves to 1.28.2. (#1951, thanks @emanuelet)- **Long local dictations transcribe faster.** Parakeet and Orukeet decode audio in 15-second segments, and the app sent them to the local server one after another even though the server decodes on three threads. Segments now decode side by side, one per server thread and sized to the machine's cores, so a one-minute dictation no longer waits on four serial passes. Dictations under 15 seconds are unchanged. (#2178)- **Local dictation skips a decode step after you stop.** The app records in compressed WebM/Opus and used to hand that to FFmpeg to unpack before Parakeet, Orukeet, Cohere Transcribe or whisper.cpp could start, about half a second on Windows and a few milliseconds on macOS. The microphone now also keeps a raw 16 kHz copy from the moment it opens, pre-roll included, and the local engine decodes that directly. The WebM is still saved to history and remains what cloud providers, very long recordings and any fallback receive. Transcripts are unchanged: on the real engine, raw and Opus-decoded audio differed in about one word in a hundred, in the raw copy's favour. whisper.cpp also no longer needs FFmpeg present for a ready WAV. (#2179)- **Your own Deepgram key works again.** Every Deepgram connection failed with `Unexpected server response: 401`, even though the same key tested fine in Settings and worked against Deepgram directly. Deepgram accepts a raw API key only under its `Token` authorization scheme and reserves `Bearer` for the short-lived tokens OpenWhispr Cloud mints on your behalf — and the app was presenting your key as a `Bearer`. This broke bring-your-own-key dictation as well as Note Recording. (#2140, thanks @nikhilmaddirala)diff --git a/scripts/download-sherpa-onnx.js b/scripts/download-sherpa-onnx.jsindex 0f47b68d8..a3dc81ce8 100644--- a/scripts/download-sherpa-onnx.js+++ b/scripts/download-sherpa-onnx.js@@ -17,7 +17,7 @@ const {} = require("../src/helpers/parakeetCapability");const { renameImportedModule } = require("./lib/pe-imports");-const SHERPA_ONNX_VERSION = "1.13.4";+const SHERPA_ONNX_VERSION = "1.13.8";const GITHUB_RELEASE_URL = `https://github.com/k2-fsa/sherpa-onnx/releases/download/v${SHERPA_ONNX_VERSION}`;// Windows 11 ships an older onnxruntime.dll in System32, and on some machines@@ -37,10 +37,10 @@ const WINDOWS_ONNXRUNTIME_PRIVATE_NAME = "ow-onnxrt.dll";// cmake/onnxruntime-osx-arm64.cmake pins). On macOS hosts we swap that slice// in and keep the x86_64 slice, so the file stays universal2.const MACOS_ARM64_ONNXRUNTIME = {- url: "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.27.0/onnxruntime-osx-arm64-1.27.0.zip",- sha256: "5f05b2653eb0af852dab46c85778f0e012c514ed2e71a6dbb9c9550434b0a514",- libraryName: "libonnxruntime.1.27.0.dylib",- marker: "arm64-1.27.0", // recorded in the install marker so older installs re-extract+ url: "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.28.2/onnxruntime-osx-arm64-1.28.2.zip",+ sha256: "d9e5c0c79929e201f5b8eb095e6809a91ce78be9866a1bca0dfab7e20b40ae40",+ libraryName: "libonnxruntime.dylib",+ marker: "arm64-1.28.2", // recorded in the install marker so older installs re-extract};// Binary configurations for each platform@@ -176,7 +176,7 @@ function validateMacosDeploymentTargets(targets) {}for (const target of targets) {- if (compareVersions(target.minimumVersion, PARAKEET_MINIMUM_MACOS_VERSION) !== 0) {+ if (compareVersions(target.minimumVersion, PARAKEET_MINIMUM_MACOS_VERSION) > 0) {throw new Error(`${target.architecture} requires macOS ${target.minimumVersion}, but the Parakeet capability gate is ${PARAKEET_MINIMUM_MACOS_VERSION}`);@@ -198,17 +198,11 @@ function verifyPackagedMacosParakeet(} = {}) {const binDirectory = path.join(appPath, "Contents", "Resources", "bin");- const libraries = readDirectory(binDirectory).filter((fileName) =>- /^libonnxruntime\.\d+(?:\.\d+)*\.dylib$/.test(fileName)- );-- if (libraries.length !== 1) {- throw new Error(- `Expected one versioned ONNX Runtime library in ${binDirectory}, found ${libraries.length}`- );+ if (!readDirectory(binDirectory).includes(MACOS_ARM64_ONNXRUNTIME.libraryName)) {+ throw new Error(`Expected ${MACOS_ARM64_ONNXRUNTIME.libraryName} in ${binDirectory}`);}- const libraryPath = path.join(binDirectory, libraries[0]);+ const libraryPath = path.join(binDirectory, MACOS_ARM64_ONNXRUNTIME.libraryName);const targets = parseMacosDeploymentTargets(runVtool(libraryPath));return { ...validateMacosDeploymentTargets(targets), libraryPath };}@@ -289,25 +283,39 @@ function privatizeWindowsOnnxRuntime({ binDir, binaryPaths, libraryNames }) {return shippedLibraries;}+function readInstallMarker(markerPath) {+ try {+ return JSON.parse(fs.readFileSync(markerPath, "utf8"));+ } catch {+ return null;+ }+}++function findObsoleteLibraries(previousLibraries, installedLibraries, directoryEntries) {+ const previous = new Set(previousLibraries);+ const installed = new Set(installedLibraries);+ return directoryEntries.filter((file) => previous.has(file) && !installed.has(file));+}+function isCompleteInstall(markerPath, binaryPaths, { platformArch, binDir = BIN_DIR }) {if (binaryPaths.some((binaryPath) => !fs.existsSync(binaryPath))) return false;- try {- const marker = JSON.parse(fs.readFileSync(markerPath, "utf8"));- if (marker.version !== SHERPA_ONNX_VERSION || !Array.isArray(marker.libraries)) return false;- if (marker.libraries.some((lib) => !fs.existsSync(path.join(binDir, lib)))) return false;- // A win32 marker without this field predates the rename: the exes on disk- // still import onnxruntime.dll and must be re-extracted.- if (platformArch.startsWith("win32")) {- return marker.onnxRuntime === WINDOWS_ONNXRUNTIME_PRIVATE_NAME;- }- // A macOS marker without this field still holds the slow universal2 slice.- return (- !isMacosHostTarget(platformArch) || marker.onnxRuntime === MACOS_ARM64_ONNXRUNTIME.marker- );- } catch {+ const marker = readInstallMarker(markerPath);+ if (marker?.version !== SHERPA_ONNX_VERSION || !Array.isArray(marker?.libraries)) return false;+ if (+ marker.libraries.some(+ (library) => typeof library !== "string" || !fs.existsSync(path.join(binDir, library))+ )+ ) {return false;}+ // A win32 marker without this field predates the rename: the exes on disk+ // still import onnxruntime.dll and must be re-extracted.+ if (platformArch.startsWith("win32")) {+ return marker.onnxRuntime === WINDOWS_ONNXRUNTIME_PRIVATE_NAME;+ }+ // A macOS marker without this field still holds the slow universal2 slice.+ return !isMacosHostTarget(platformArch) || marker.onnxRuntime === MACOS_ARM64_ONNXRUNTIME.marker;}async function downloadBinary(platformArch, config, isForce = false) {@@ -320,6 +328,10 @@ async function downloadBinary(platformArch, config, isForce = false) {const onlineOutputPath = path.join(BIN_DIR, config.onlineOutputName);const diarizeOutputPath = path.join(BIN_DIR, config.diarizeOutputName);const installMarkerPath = path.join(BIN_DIR, `.sherpa-onnx-${platformArch}.json`);+ const previousInstall = readInstallMarker(installMarkerPath);+ const previousLibraries = Array.isArray(previousInstall?.libraries)+ ? previousInstall.libraries+ : [];if (!isForce &&@@ -330,8 +342,8 @@ async function downloadBinary(platformArch, config, isForce = false) {console.log(` ${platformArch}: Already exists (use --force to re-download)`);return true;}- // A failed repair must not leave a previous marker certifying partially patched binaries.- if (fs.existsSync(installMarkerPath)) fs.unlinkSync(installMarkerPath);+ // Retain cleanup ownership across retries without certifying a partially repaired install.+ fs.writeFileSync(installMarkerPath, JSON.stringify({ libraries: previousLibraries }));const url = getDownloadUrl(config.archiveName);console.log(` ${platformArch}: Downloading from ${url}`);@@ -377,7 +389,7 @@ async function downloadBinary(platformArch, config, isForce = false) {fs.rmSync(destPath, { force: true });fs.copyFileSync(libPath, destPath);setExecutable(destPath);- if (isMacosHostTarget(platformArch) && versionMatch?.[1] === "libonnxruntime") {+ if (isMacosHostTarget(platformArch) && libName === MACOS_ARM64_ONNXRUNTIME.libraryName) {await replaceMacosArm64OnnxRuntime(destPath, platformArch);}adhocSign(destPath, platformArch);@@ -385,6 +397,15 @@ async function downloadBinary(platformArch, config, isForce = false) {console.log(` ${platformArch}: Copied library ${libName}`);}+ for (const file of findObsoleteLibraries(+ previousLibraries,+ copiedLibraries,+ fs.readdirSync(BIN_DIR)+ )) {+ fs.rmSync(path.join(BIN_DIR, file), { force: true });+ console.log(` ${platformArch}: Removed stale ${file}`);+ }+// Replace unversioned copies with symlinks to versioned ones (macOS/Linux only)if (process.platform !== "win32") {for (const [baseName, versionedName] of versionedLibs) {@@ -506,6 +527,7 @@ module.exports = {WINDOWS_ONNXRUNTIME_UPSTREAM_NAME,getDownloadUrl,extractTarBz2,+ findObsoleteLibraries,isCompleteInstall,parseMacosDeploymentTargets,privatizeWindowsOnnxRuntime,diff --git a/test/helpers/parakeetDeploymentTarget.test.js b/test/helpers/parakeetDeploymentTarget.test.jsindex 9f1fa0c7b..028683a1a 100644--- a/test/helpers/parakeetDeploymentTarget.test.js+++ b/test/helpers/parakeetDeploymentTarget.test.js@@ -4,17 +4,17 @@ const assert = require("node:assert/strict");const sherpaDownloader = require("../../scripts/download-sherpa-onnx");const UNIVERSAL_VTOOL_OUTPUT = `-/tmp/libonnxruntime.1.27.0.dylib (architecture x86_64):+/tmp/libonnxruntime.dylib (architecture x86_64):Load command 10cmd LC_BUILD_VERSIONplatform MACOS- minos 15.5+ minos 10.15sdk 15.5-/tmp/libonnxruntime.1.27.0.dylib (architecture arm64):+/tmp/libonnxruntime.dylib (architecture arm64):Load command 10cmd LC_BUILD_VERSIONplatform MACOS- minos 15.5+ minos 11.0sdk 15.5`;@@ -22,8 +22,8 @@ test("parses deployment targets for both ONNX Runtime architecture slices", () =const targets = sherpaDownloader.parseMacosDeploymentTargets?.(UNIVERSAL_VTOOL_OUTPUT);assert.deepEqual(targets, [- { architecture: "x86_64", minimumVersion: "15.5" },- { architecture: "arm64", minimumVersion: "15.5" },+ { architecture: "x86_64", minimumVersion: "10.15" },+ { architecture: "arm64", minimumVersion: "11.0" },]);});@@ -60,22 +60,22 @@ test("rejects a packaged ONNX Runtime library missing a universal architecture s);});-test("validates the versioned ONNX Runtime library from a packaged app", () => {+test("validates the ONNX Runtime library the sherpa binaries load", () => {const appPath = "/tmp/OpenWhispr.app";const result = sherpaDownloader.verifyPackagedMacosParakeet?.(appPath, {readDirectory(directory) {assert.equal(directory, `${appPath}/Contents/Resources/bin`);- return ["libonnxruntime.dylib", "libonnxruntime.1.27.0.dylib"];+ return ["libonnxruntime.dylib"];},runVtool(libraryPath) {- assert.equal(libraryPath, `${appPath}/Contents/Resources/bin/libonnxruntime.1.27.0.dylib`);+ assert.equal(libraryPath, `${appPath}/Contents/Resources/bin/libonnxruntime.dylib`);return UNIVERSAL_VTOOL_OUTPUT;},});assert.deepEqual(result, {architectures: ["x86_64", "arm64"],- libraryPath: `${appPath}/Contents/Resources/bin/libonnxruntime.1.27.0.dylib`,+ libraryPath: `${appPath}/Contents/Resources/bin/libonnxruntime.dylib`,minimumVersion: "15.5",});});diff --git a/test/scripts/downloadSherpaOnnx.test.js b/test/scripts/downloadSherpaOnnx.test.jsindex fb655b844..b4fe1c2ad 100644--- a/test/scripts/downloadSherpaOnnx.test.js+++ b/test/scripts/downloadSherpaOnnx.test.js@@ -15,6 +15,7 @@ const {WINDOWS_ONNXRUNTIME_PRIVATE_NAME,WINDOWS_ONNXRUNTIME_UPSTREAM_NAME,extractTarBz2,+ findObsoleteLibraries,isCompleteInstall,privatizeWindowsOnnxRuntime,} = require("../../scripts/download-sherpa-onnx");@@ -25,6 +26,16 @@ const EXE_NAMES = ["sherpa-onnx-diarize-win32-x64.exe",];+test("removes only libraries from the previous sherpa-onnx install", () => {+ const obsolete = findObsoleteLibraries(+ ["libonnxruntime.1.27.0.dylib", "libonnxruntime.dylib", "libsherpa-onnx-c-api.dylib"],+ ["libonnxruntime.dylib", "libsherpa-onnx-c-api.dylib"],+ ["libonnxruntime.1.27.0.dylib", "libonnxruntime.dylib", "libllama.dylib"]+ );++ assert.deepEqual(obsolete, ["libonnxruntime.1.27.0.dylib"]);+});+function makeBinDir(t) {const dir = fs.mkdtempSync(path.join(os.tmpdir(), "sherpa-win32-"));t.after(() => fs.rmSync(dir, { recursive: true, force: true }));@@ -194,6 +205,19 @@ test("Linux markers do not need the onnxRuntime field", (t) => {);});+test("a malformed marker is not a complete install", (t) => {+ const dir = makeBinDir(t);+ const binary = path.join(dir, "sherpa-onnx-ws-linux-x64");+ const marker = path.join(dir, ".sherpa-onnx-linux-x64.json");+ fs.writeFileSync(binary, "");+ fs.writeFileSync(marker, JSON.stringify({ version: SHERPA_ONNX_VERSION, libraries: [null] }));++ assert.equal(+ isCompleteInstall(marker, [binary], { platformArch: "linux-x64", binDir: dir }),+ false+ );+});+test("a macOS marker written before the arm64 ONNX Runtime slice is not a complete install",{ skip: process.platform !== "darwin" && "the slice is only replaced on macOS hosts" },@@ -219,6 +243,86 @@ test(});+test("a failed macOS upgrade still removes obsolete libraries when retried", async (t) => {+ const root = makeBinDir(t);+ const binDir = path.join(root, "resources", "bin");+ fs.mkdirSync(binDir, { recursive: true });+ const config = BINARIES["darwin-arm64"];+ const binaryPaths = [config.outputName, config.onlineOutputName, config.diarizeOutputName].map(+ (name) => path.join(binDir, name)+ );+ const markerPath = path.join(binDir, ".sherpa-onnx-darwin-arm64.json");+ const obsoleteLibrary = path.join(binDir, "libonnxruntime.1.27.0.dylib");+ fs.writeFileSync(obsoleteLibrary, "old runtime");+ fs.copyFileSync(obsoleteLibrary, path.join(binDir, "libonnxruntime.dylib"));+ fs.writeFileSync(path.join(binDir, "libllama.dylib"), "unrelated runtime");+ for (const binaryPath of binaryPaths) fs.writeFileSync(binaryPath, "old binary");+ fs.writeFileSync(+ markerPath,+ JSON.stringify({+ version: "1.13.4",+ libraries: ["libonnxruntime.1.27.0.dylib", "libonnxruntime.dylib"],+ onnxRuntime: "arm64-1.27.0",+ })+ );++ const sourcePath = require.resolve("../../scripts/download-sherpa-onnx");+ const requireFromDownloader = createRequire(sourcePath);+ let failDownload = true;+ const downloadBinary = vm.runInNewContext(+ `${fs.readFileSync(sourcePath, "utf8")}\ndownloadBinary;`,+ {+ __dirname: path.join(root, "scripts"),+ module: { exports: {} },+ // Stub network and native extraction; marker and library operations use the filesystem.+ process: { ...process, platform: "linux" },+ console,+ require(name) {+ if (name === "./lib/download-utils") {+ return {+ ...requireFromDownloader(name),+ async downloadFile(_url, destination) {+ if (failDownload) throw new Error("simulated download failure");+ fs.writeFileSync(destination, "fixture archive");+ },+ };+ }+ if (name === "child_process") {+ return {+ execFileSync(command, args, { cwd }) {+ assert.equal(command, "tar");+ const extractDir = path.resolve(cwd, args[args.indexOf("-C") + 1]);+ for (const name of [+ config.binaryPath,+ config.onlineBinaryPath,+ config.diarizeBinaryPath,+ ]) {+ fs.writeFileSync(path.join(extractDir, name), "new binary");+ }+ fs.writeFileSync(path.join(extractDir, "libonnxruntime.dylib"), "new runtime");+ },+ };+ }+ return requireFromDownloader(name);+ },+ },+ { filename: sourcePath }+ );++ assert.equal(await downloadBinary("darwin-arm64", config), false);+ assert.equal(await downloadBinary("darwin-arm64", config), false);+ assert.equal(+ isCompleteInstall(markerPath, binaryPaths, { platformArch: "darwin-arm64", binDir }),+ false+ );++ failDownload = false;+ assert.equal(await downloadBinary("darwin-arm64", config), true);+ assert.equal(fs.existsSync(obsoleteLibrary), false);+ assert.equal(fs.readFileSync(path.join(binDir, "libonnxruntime.dylib"), "utf8"), "new runtime");+ assert.equal(fs.readFileSync(path.join(binDir, "libllama.dylib"), "utf8"), "unrelated runtime");+});+test("a failed automatic Windows repair stays incomplete and retries DLL patching", async (t) => {const root = makeBinDir(t);const binDir = path.join(root, "resources", "bin");@@ -298,7 +402,6 @@ test("a failed automatic Windows repair stays incomplete and retries DLL patchinassert.equal(patchFailureInjected, true);assert.ok(listImportedModules(fs.readFileSync(binaryPaths[1])).includes("onnxruntime.dll"));assert.equal(fs.existsSync(path.join(binDir, "onnxruntime.dll")), false);- assert.equal(fs.existsSync(markerPath), false);assert.equal(isCompleteInstall(markerPath, binaryPaths, options), false);failPatch = false;