Skip to content

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

fix(meeting): anchor live speaker timestamps to the first system chunk

Gabriel Steina221ea46acaf
diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.js
index 24e6d8e41..0c4292df6 100644
--- a/src/helpers/ipcHandlers.js
+++ b/src/helpers/ipcHandlers.js
@@ -6180,58 +6180,71 @@ class IPCHandlers {
}
meetingLiveSpeakerState = null;
- meetingLiveSpeakerStartedAt = Date.now();
- const started = await liveSpeakerIdentifier.start(
- (identification) => {
- if (!win || win.isDestroyed()) {
- return;
- }
+ // Anchored on the first system chunk instead, in sendMeetingAudio.
+ meetingLiveSpeakerStartedAt = null;
+ const started = await liveSpeakerIdentifier
+ .start(
+ (identification) => {
+ if (!win || win.isDestroyed() || meetingLiveSpeakerStartedAt == null) {
+ return;
+ }
- bindOneOnOneAttendeeToSpeaker(identification.speakerId);
+ bindOneOnOneAttendeeToSpeaker(identification.speakerId);
- const displayName = meetingOneOnOneAttendee
- ? meetingOneOnOneAttendee.displayName
- : identification.displayName;
+ const displayName = meetingOneOnOneAttendee
+ ? meetingOneOnOneAttendee.displayName
+ : identification.displayName;
- const startTime = Math.max(
- meetingLiveSpeakerStartedAt || 0,
- (meetingLiveSpeakerStartedAt || 0) + identification.startTime * 1000
- );
- const endTime = Math.max(
- startTime,
- (meetingLiveSpeakerStartedAt || 0) + identification.endTime * 1000
- );
- const enrichedIdentification = {
- ...identification,
- displayName,
- startTime,
- endTime,
- };
+ const startTime = Math.max(
+ meetingLiveSpeakerStartedAt,
+ meetingLiveSpeakerStartedAt + identification.startTime * 1000
+ );
+ const endTime = Math.max(
+ startTime,
+ meetingLiveSpeakerStartedAt + identification.endTime * 1000
+ );
+ const enrichedIdentification = {
+ ...identification,
+ displayName,
+ startTime,
+ endTime,
+ };
- win.webContents.send("meeting-speaker-identified", enrichedIdentification);
-
- for (const seg of meetingDiarizationSegments) {
- if (
- seg.source === "system" &&
- seg.timestamp != null &&
- seg.timestamp >= startTime &&
- seg.timestamp <= endTime &&
- (!seg.speaker || seg.speakerIsPlaceholder)
- ) {
- applyConfirmedSpeaker(seg, {
- speaker: identification.speakerId,
- speakerName: displayName || seg.speakerName,
- speakerIsPlaceholder: false,
- });
+ win.webContents.send("meeting-speaker-identified", enrichedIdentification);
+
+ for (const seg of meetingDiarizationSegments) {
+ if (
+ seg.source === "system" &&
+ seg.timestamp != null &&
+ seg.timestamp >= startTime &&
+ seg.timestamp <= endTime &&
+ (!seg.speaker || seg.speakerIsPlaceholder)
+ ) {
+ applyConfirmedSpeaker(seg, {
+ speaker: identification.speakerId,
+ speakerName: displayName || seg.speakerName,
+ speakerIsPlaceholder: false,
+ });
+ }
}
+ },
+ {
+ getSpeakerProfiles: getLiveSpeakerProfiles,
+ maxSpeakers: resolveSessionMaxSpeakers(),
+ enabled: true,
}
- },
- {
- getSpeakerProfiles: getLiveSpeakerProfiles,
- maxSpeakers: resolveSessionMaxSpeakers(),
- enabled: true,
- }
- );
+ )
+ .catch((error) => {
+ // isAvailable() only stats the model file, so a corrupt model or an
+ // onnxruntime binding that won't load still throws here. Speaker labels
+ // are an enhancement — never let them take the recording down with them.
+ debugLogger.warn(
+ "Live speaker identification start failed",
+ { error: error.message },
+ "speaker"
+ );
+ return false;
+ });
if (started) {
meetingLiveSpeakerActive = true;
@@ -6956,6 +6969,13 @@ class IPCHandlers {
flushPendingMeetingMicChunks();
if (meetingLiveSpeakerActive) {
+ // identification.startTime counts samples from the first chunk the
+ // identifier sees, so the wall-clock anchor has to be the arrival of
+ // that chunk. Stamping it when identification starts is only correct
+ // when capture is already running (the macOS tap); the Windows
+ // loopback helper can take seconds to hand over its first buffer, and
+ // a stale anchor shifts every label earlier by that gap.
+ meetingLiveSpeakerStartedAt ??= receivedAt;
void liveSpeakerIdentifier.feedAudio(outboundBuffer);
}
diff --git a/test/helpers/liveSpeakerIdPolicy.test.js b/test/helpers/liveSpeakerIdPolicy.test.js
index d19ed72fb..58903b193 100644
--- a/test/helpers/liveSpeakerIdPolicy.test.js
+++ b/test/helpers/liveSpeakerIdPolicy.test.js
@@ -41,11 +41,32 @@ test("missing mode never identifies speakers", async () => {
assert.equal(supportsLiveSpeakerIdentification(null, "darwin"), false);
});
+// The sole production call site passes only the mode, so the defaulted platform
+// is the path that actually ships. Asserting it against process.platform would
+// compare the function to itself and pass on CI (Linux) even if the default were
+// deleted, so stub the platform instead.
test("platform defaults to the current process platform", async () => {
const { supportsLiveSpeakerIdentification } = await load();
+ const originalPlatform = Object.getOwnPropertyDescriptor(process, "platform");
- assert.equal(
- supportsLiveSpeakerIdentification("loopback"),
- supportsLiveSpeakerIdentification("loopback", process.platform)
- );
+ const onPlatform = (platform, run) => {
+ Object.defineProperty(process, "platform", { value: platform, configurable: true });
+ try {
+ run();
+ } finally {
+ Object.defineProperty(process, "platform", originalPlatform);
+ }
+ };
+
+ onPlatform("win32", () => {
+ assert.equal(supportsLiveSpeakerIdentification("loopback"), true);
+ assert.equal(supportsLiveSpeakerIdentification("native"), true);
+ });
+ onPlatform("linux", () => {
+ assert.equal(supportsLiveSpeakerIdentification("loopback"), false);
+ assert.equal(supportsLiveSpeakerIdentification("native"), true);
+ });
+ onPlatform("darwin", () => {
+ assert.equal(supportsLiveSpeakerIdentification("loopback"), false);
+ });
});