Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

fix: degrade live speaker ID gracefully when onnxruntime binding is missing

Chadpiha8fb5cfa871ef
diff --git a/src/helpers/liveSpeakerIdentifier.js b/src/helpers/liveSpeakerIdentifier.js
index 4a02fb237..fffb97bbd 100644
--- a/src/helpers/liveSpeakerIdentifier.js
+++ b/src/helpers/liveSpeakerIdentifier.js
@@ -11,6 +11,25 @@ function clampMaxSpeakers(value) {
return Math.max(1, Math.min(MAX_SPEAKER_COUNT, Math.floor(n)));
}
+// onnxruntime-node ships no darwin/x64 prebuilt binding since 1.24, so the
+// require throws on Intel Macs (#1500). A missing binding must degrade live
+// speaker identification, never fail the meeting start that triggers it.
+let ortLoadFailed = false;
+
+function loadOnnxRuntime() {
+ if (ortLoadFailed) return null;
+ try {
+ return require("onnxruntime-node");
+ } catch (error) {
+ ortLoadFailed = true;
+ debugLogger.warn(
+ "onnxruntime-node binding failed to load — live speaker identification disabled",
+ { error: error.message, platform: process.platform, arch: process.arch }
+ );
+ return null;
+ }
+}
+
const SAMPLE_RATE = 16000;
const VAD_WINDOW_SIZE = 512;
const MIN_SEGMENT_SECONDS = 1.5;
@@ -148,7 +167,11 @@ class LiveSpeakerIdentifier {
}
isAvailable() {
- return this._diarizationManager?.isVadModelDownloaded() && speakerEmbeddings.isAvailable();
+ return (
+ this._diarizationManager?.isVadModelDownloaded() &&
+ speakerEmbeddings.isAvailable() &&
+ loadOnnxRuntime() !== null
+ );
}
getTransientState() {
@@ -377,7 +400,9 @@ class LiveSpeakerIdentifier {
return;
}
- const ort = require("onnxruntime-node");
+ const ort = loadOnnxRuntime();
+ if (!ort) return;
+
this.session = await ort.InferenceSession.create(vadModelPath);
this.vadStateInputs = (this.session.inputNames || []).filter((name) => /state|h|c/i.test(name));
this.vadStateOutputs = (this.session.outputNames || []).filter((name) =>
@@ -482,7 +507,8 @@ class LiveSpeakerIdentifier {
async _getVadProbability(window) {
if (!this.session) return 0;
- const ort = require("onnxruntime-node");
+ const ort = loadOnnxRuntime();
+ if (!ort) return 0;
const feeds = {};
const audioInputName = (this.session.inputNames || []).find(
(name) => !this.vadStateInputs.includes(name) && !/sr|sample.?rate/i.test(name)
diff --git a/test/helpers/liveSpeakerIdentifier.test.js b/test/helpers/liveSpeakerIdentifier.test.js
index 0b4ef762d..e4ca9a1d9 100644
--- a/test/helpers/liveSpeakerIdentifier.test.js
+++ b/test/helpers/liveSpeakerIdentifier.test.js
@@ -18,9 +18,10 @@ function cosineSimilarity(a, b) {
return denom === 0 ? 0 : dot / denom;
}
-function loadIdentifier() {
+function loadIdentifier(options = {}) {
delete require.cache[identifierModulePath];
const warnings = [];
+ const interceptsOrt = "ort" in options;
Module._load = function loadWithMocks(request, parent, isMain) {
if (request === "./debugLogger") {
@@ -41,14 +42,23 @@ function loadIdentifier() {
extractEmbeddingFromSamples: async () => null,
};
}
+ if (interceptsOrt && request === "onnxruntime-node") {
+ return options.ort();
+ }
return originalLoad.call(this, request, parent, isMain);
};
+ const restore = () => {
+ Module._load = originalLoad;
+ };
+
try {
const { LiveSpeakerIdentifier } = require(identifierModulePath);
- return { LiveSpeakerIdentifier, warnings };
+ return { LiveSpeakerIdentifier, warnings, restore };
} finally {
- Module._load = originalLoad;
+ // The ort hook must outlive module load: the identifier requires
+ // onnxruntime-node lazily, from inside the test body.
+ if (!interceptsOrt) restore();
}
}
@@ -245,6 +255,67 @@ test("an at-cap fold never steals the cluster's identity for a profile-matched v
assert.equal(aliceAgain.displayName, "Alice", "Alice's cluster must still be hers");
});
+// onnxruntime-node ships no darwin/x64 prebuilt binding since 1.24, so on Intel
+// Macs the lazy require throws MODULE_NOT_FOUND (#1500). Speaker identification
+// must degrade to "unavailable" — never take the whole meeting start down.
+function missingBindingRequire() {
+ const error = new Error(
+ "Cannot find module '../bin/napi-v6/darwin/x64/onnxruntime_binding.node'"
+ );
+ error.code = "MODULE_NOT_FOUND";
+ throw error;
+}
+
+function stubDownloadedModels(identifier) {
+ identifier.setDiarizationManager({
+ isVadModelDownloaded: () => true,
+ getVadModelPath: () => __filename,
+ });
+}
+
+test("isAvailable() is false when the onnxruntime binding cannot load", (t) => {
+ const { LiveSpeakerIdentifier, restore } = loadIdentifier({ ort: missingBindingRequire });
+ t.after(restore);
+ const identifier = new LiveSpeakerIdentifier();
+ stubDownloadedModels(identifier);
+
+ assert.equal(identifier.isAvailable(), false);
+});
+
+test("start() resolves false instead of rejecting when the binding is missing", async (t) => {
+ const { LiveSpeakerIdentifier, restore } = loadIdentifier({ ort: missingBindingRequire });
+ t.after(restore);
+ const identifier = new LiveSpeakerIdentifier();
+ stubDownloadedModels(identifier);
+
+ const started = await identifier.start(() => {}, {});
+ assert.equal(started, false, "a missing native binding must not fail meeting start");
+});
+
+test("the binding failure is logged once, not on every availability check", (t) => {
+ const { LiveSpeakerIdentifier, warnings, restore } = loadIdentifier({
+ ort: missingBindingRequire,
+ });
+ t.after(restore);
+ const identifier = new LiveSpeakerIdentifier();
+ stubDownloadedModels(identifier);
+
+ identifier.isAvailable();
+ identifier.isAvailable();
+
+ const bindingWarnings = warnings.filter((w) => /onnxruntime/i.test(w.message));
+ assert.equal(bindingWarnings.length, 1, "repeated checks must not spam the logs");
+});
+
+test("isAvailable() stays true when the binding loads", (t) => {
+ const { LiveSpeakerIdentifier, restore } = loadIdentifier({ ort: () => ({}) });
+ t.after(restore);
+ const identifier = new LiveSpeakerIdentifier();
+ stubDownloadedModels(identifier);
+
+ assert.equal(Boolean(identifier.isAvailable()), true);
+});
+
test("distinct voices are folded into one cluster when the session cap is 1", () => {
const { LiveSpeakerIdentifier } = loadIdentifier();
const identifier = new LiveSpeakerIdentifier();