Skip to content

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

feat(uploads): persist segment timestamps from BYOK cloud transcriptions for SRT export — fixes #1095

Gabriel Steinaada0217ea86
diff --git a/src/components/notes/UploadAudioView.tsx b/src/components/notes/UploadAudioView.tsx
index c4333171c..e0c90530e 100644
--- a/src/components/notes/UploadAudioView.tsx
+++ b/src/components/notes/UploadAudioView.tsx
@@ -651,7 +651,7 @@ export default function UploadAudioView({ onNoteCreated, onOpenSettings }: Uploa
buildTranscriptionConfig(),
diarization,
currentFile.durationSeconds,
- { requestId }
+ { requestId, timestamps: true }
).finally(() => {
if (activeRequestIdRef.current === requestId) activeRequestIdRef.current = null;
});
@@ -687,6 +687,7 @@ export default function UploadAudioView({ onNoteCreated, onOpenSettings }: Uploa
folderId: selectedFolderId ? Number(selectedFolderId) : null,
diarization,
durationSeconds: res.durationSeconds,
+ segments: res.segments,
});
if (runId !== runIdRef.current) return;
if (noteRes.success && noteRes.note) setNoteId(noteRes.note.id);
diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.js
index 00df09ea5..0bb1c3f1b 100644
--- a/src/helpers/ipcHandlers.js
+++ b/src/helpers/ipcHandlers.js
@@ -207,6 +207,7 @@ const {
mergeSpeakersWithText,
formatSpeakerTranscript,
} = require("./speakerMerge");
+const { timestampRequestFields, mapVerboseSegments } = require("./uploadTimestamps");
// Canonicalize allowed dirs so realpath'd inputs match on macOS (/var -> /private/var).
// Deliberately narrow: user-picked paths anywhere else are approved individually via
@@ -8286,6 +8287,7 @@ class IPCHandlers {
baseUrl,
model,
diarize,
+ timestamps,
provider,
language,
environment,
@@ -8431,6 +8433,11 @@ class IPCHandlers {
{ provider: route.provider, endpoint: route.endpoint }
);
}
+ } else if (timestamps) {
+ // Providers/models that don't support the request keep the
+ // plain-text request untouched (helper returns null).
+ const fields = timestampRequestFields(route.provider, route.model);
+ if (fields) Object.assign(multipartFields, fields);
}
const { body, boundary } = buildMultipartBody(
@@ -8476,26 +8483,30 @@ class IPCHandlers {
`[${s.speaker}] ${formatDiarTime(s.start)} - ${formatDiarTime(s.end)}\n${s.text}`
)
.join("\n\n");
- return { success: true, text: formatted, diarized: true };
+ return { success: true, text: formatted, diarized: true, segments };
}
if (diarize && data.data?.segments) {
- const segments = data.data.segments || [];
+ const segments = (data.data.segments || []).map((s) => ({
+ speaker: s.speaker || "Speaker ?",
+ text: s.text || "",
+ start: s.start || 0,
+ end: s.end || 0,
+ }));
const formatted = segments
- .map((s) => {
- const speaker = s.speaker || "Speaker ?";
- const start = formatDiarTime(s.start || 0);
- const end = formatDiarTime(s.end || 0);
- return `[${speaker}] ${start} - ${end}\n${s.text || ""}`;
- })
+ .map(
+ (s) =>
+ `[${s.speaker}] ${formatDiarTime(s.start)} - ${formatDiarTime(s.end)}\n${s.text}`
+ )
.join("\n\n");
- return { success: true, text: formatted, diarized: true };
+ return { success: true, text: formatted, diarized: true, segments };
}
if (diarize) {
debugLogger.warn("BYOK diarization requested but provider returned no speaker data");
}
- return { success: true, text: data.data.text };
+ const segments = timestamps ? mapVerboseSegments(data.data) : null;
+ return { success: true, text: data.data.text, ...(segments ? { segments } : {}) };
} catch (error) {
debugLogger.error("BYOK audio file transcription error", { error: error.message });
return { success: false, error: error.message };
diff --git a/src/helpers/transcriptFormatter.js b/src/helpers/transcriptFormatter.js
index 3ee5374ce..76bc66bf4 100644
--- a/src/helpers/transcriptFormatter.js
+++ b/src/helpers/transcriptFormatter.js
@@ -140,13 +140,19 @@ function formatTxt(note, segments, speakerMappings) {
function formatSrt(segments, speakerMappings, note = {}) {
const merged = mergeSegments(normalizeSegmentTimestamps(segments, note));
+ // Upload transcripts carry no speaker identity at all; prefixing every cue
+ // with "Unknown Speaker:" would defeat the subtitle use case. Meeting
+ // segments always serialize a source, so they keep their labels.
+ const hasSpeakerIdentity = merged.some((seg) => seg.speaker || seg.speakerName || seg.source);
const entries = [];
for (let i = 0; i < merged.length; i++) {
const seg = merged[i];
const nextTs = i + 1 < merged.length ? merged[i + 1].timestamp : seg.endTimestamp + 3;
entries.push(`${i + 1}`);
entries.push(`${formatSrtTimestamp(seg.timestamp)} --> ${formatSrtTimestamp(nextTs)}`);
- entries.push(`${resolveSpeaker(seg, speakerMappings)}: ${seg.text}`);
+ entries.push(
+ hasSpeakerIdentity ? `${resolveSpeaker(seg, speakerMappings)}: ${seg.text}` : seg.text
+ );
entries.push("");
}
return entries.join("\n");
diff --git a/src/helpers/uploadTimestamps.js b/src/helpers/uploadTimestamps.js
new file mode 100644
index 000000000..c768dd710
--- /dev/null
+++ b/src/helpers/uploadTimestamps.js
@@ -0,0 +1,40 @@
+// Which extra multipart fields ask a BYOK transcription provider for
+// segment-level timestamps, and how its verbose response maps back to
+// segments. Gated per provider/model because unsupported combinations
+// (gpt-4o-transcribe rejects verbose_json; custom/self-hosted servers may
+// 400 on unknown fields) must keep the plain-text request untouched — a
+// missing timestamp is a degraded export, never a failed upload.
+function timestampRequestFields(provider, model) {
+ if (provider === "openai" && model === "whisper-1") {
+ return { response_format: "verbose_json" };
+ }
+ if (provider === "groq") {
+ return { response_format: "verbose_json" };
+ }
+ if (provider === "mistral") {
+ return { timestamp_granularities: "segment" };
+ }
+ return null;
+}
+
+// verbose_json (OpenAI/Groq) and Mistral's segment granularity both carry
+// `segments: [{ text, start, end }]`. Null when the response has nothing
+// usable, so callers fall back to the plain transcript.
+function mapVerboseSegments(responseData) {
+ const segments = responseData?.segments;
+ if (!Array.isArray(segments)) return null;
+
+ const mapped = [];
+ for (const seg of segments) {
+ const text = typeof seg?.text === "string" ? seg.text.trim() : "";
+ if (!text || !Number.isFinite(seg.start)) continue;
+ mapped.push({
+ text,
+ start: seg.start,
+ end: Number.isFinite(seg.end) ? seg.end : seg.start,
+ });
+ }
+ return mapped.length ? mapped : null;
+}
+
+module.exports = { timestampRequestFields, mapVerboseSegments };
diff --git a/src/services/fileTranscription.ts b/src/services/fileTranscription.ts
index 9e2024765..4198a3383 100644
--- a/src/services/fileTranscription.ts
+++ b/src/services/fileTranscription.ts
@@ -15,6 +15,9 @@ export interface FileTranscriptionResult {
// Measured duration of the source audio, for persisting as
// audio_duration_seconds. Only transcribeFileWithSpeakers sets it.
durationSeconds?: number | null;
+ // Segment-level timing from BYOK providers that support it (opts.timestamps
+ // or BYOK diarization). Absent whenever the provider returned text only.
+ segments?: Array<{ text: string; start: number; end: number; speaker?: string }>;
}
export interface DiarizationSettings {
@@ -76,7 +79,7 @@ export async function transcribeFile(
filePath: string,
cfg: FileTranscriptionConfig,
diarize: boolean,
- opts: { requestId?: string } = {}
+ opts: { requestId?: string; timestamps?: boolean } = {}
): Promise<FileTranscriptionResult> {
if (cfg.isOpenWhisprCloud) {
return withSessionRefresh(async () => {
@@ -127,6 +130,7 @@ export async function transcribeFile(
baseUrl: cfg.cloudTranscriptionBaseUrl,
model: cfg.cloudTranscriptionModel,
diarize: diarize || undefined,
+ timestamps: opts.timestamps || undefined,
provider: cfg.cloudTranscriptionProvider,
language: cfg.language,
environment: cfg.cortiEnvironment,
@@ -161,7 +165,7 @@ export async function transcribeFileWithSpeakers(
cfg: FileTranscriptionConfig,
diarization: DiarizationSettings,
durationSeconds?: number | null,
- opts: { requestId?: string } = {}
+ opts: { requestId?: string; timestamps?: boolean } = {}
): Promise<FileTranscriptionResult> {
const byokDiarize = shouldUseByokDiarize(cfg, diarization.enabled);
const diarizePromise =
diff --git a/src/services/uploadNotes.ts b/src/services/uploadNotes.ts
index 31a0b5e44..cfa55c576 100644
--- a/src/services/uploadNotes.ts
+++ b/src/services/uploadNotes.ts
@@ -11,6 +11,31 @@ function normalizeSpeakerCount(value: number | null | undefined): number | null
return Math.min(count, MAX_SPEAKER_COUNT);
}
+export interface UploadSegment {
+ text: string;
+ start: number;
+ end?: number;
+ speaker?: string;
+}
+
+// Serializes provider timing segments into the note.transcript JSON the
+// meeting path already stores, unlocking the Transcript tab and the
+// SRT/TXT/JSON/MD export for upload notes. Timestamps stay in relative
+// seconds — normalizeSegmentTimestamps only rebases epoch-ms values.
+// Undefined when there is nothing usable, so plain-text uploads stay exactly
+// as they were.
+export function buildUploadTranscript(segments?: UploadSegment[] | null): string | undefined {
+ if (!segments?.length) return undefined;
+ const stored = segments
+ .filter((seg) => seg.text?.trim() && Number.isFinite(seg.start))
+ .map((seg) => ({
+ text: seg.text.trim(),
+ timestamp: seg.start,
+ ...(seg.speaker ? { speakerName: seg.speaker } : {}),
+ }));
+ return stored.length ? JSON.stringify(stored) : undefined;
+}
+
// What an upload persists onto the note row about the diarizer invocation,
// matching the meeting path's write semantics: the columns are written only
// when diarization ran. A null diarization_enabled means "user never chose" and
@@ -22,19 +47,28 @@ function normalizeSpeakerCount(value: number | null | undefined): number | null
// explicit choice.
export function buildUploadNoteMetadata(
diarization: DiarizationSettings,
- durationSeconds?: number | null
+ durationSeconds?: number | null,
+ segments?: UploadSegment[] | null
) {
+ const transcript = buildUploadTranscript(segments);
+ const noteUpdates: Record<string, unknown> | null =
+ diarization.enabled || transcript
+ ? {
+ ...(diarization.enabled
+ ? {
+ diarization_enabled: 1,
+ expected_speaker_count: normalizeSpeakerCount(diarization.numSpeakers),
+ }
+ : {}),
+ ...(transcript ? { transcript } : {}),
+ }
+ : null;
return {
audioDurationSeconds:
typeof durationSeconds === "number" && Number.isFinite(durationSeconds) && durationSeconds > 0
? durationSeconds
: null,
- noteUpdates: diarization.enabled
- ? {
- diarization_enabled: 1,
- expected_speaker_count: normalizeSpeakerCount(diarization.numSpeakers),
- }
- : null,
+ noteUpdates,
};
}
@@ -45,12 +79,14 @@ interface SaveUploadNoteParams {
folderId: number | null;
diarization: DiarizationSettings;
durationSeconds?: number | null;
+ segments?: UploadSegment[] | null;
}
// The one save path for upload and URL-ingest notes, shared by the single-file
// flow and the batch queue: the duration goes in the insert (updateNote does
-// not whitelist audio_duration_seconds), and the diarization columns follow
-// through updateNote — the same route the meeting path writes them through.
+// not whitelist audio_duration_seconds), and the diarization columns and the
+// timestamped transcript follow through updateNote — the same route the
+// meeting path writes them through.
export async function saveUploadNote({
title,
text,
@@ -58,10 +94,12 @@ export async function saveUploadNote({
folderId,
diarization,
durationSeconds,
+ segments,
}: SaveUploadNoteParams) {
const { audioDurationSeconds, noteUpdates } = buildUploadNoteMetadata(
diarization,
- durationSeconds
+ durationSeconds,
+ segments
);
const res = await window.electronAPI.saveNote(
title,
diff --git a/src/stores/batchQueueStore.ts b/src/stores/batchQueueStore.ts
index dac4b3da9..c1ee50ea4 100644
--- a/src/stores/batchQueueStore.ts
+++ b/src/stores/batchQueueStore.ts
@@ -198,7 +198,7 @@ export function processBatchQueue(
transcription,
diarization,
durationSeconds,
- { requestId }
+ { requestId, timestamps: true }
).finally(() => {
if (activeUploadRequestId === requestId) activeUploadRequestId = null;
});
@@ -235,6 +235,7 @@ export function processBatchQueue(
folderId: transcribeOpts.folderId,
diarization,
durationSeconds: transcriptionResult.durationSeconds,
+ segments: transcriptionResult.segments,
});
if (noteRes.success && noteRes.note) {
diff --git a/src/types/electron.ts b/src/types/electron.ts
index 771ef09bb..48a71d06e 100644
--- a/src/types/electron.ts
+++ b/src/types/electron.ts
@@ -1990,6 +1990,7 @@ declare global {
baseUrl: string;
model: string;
diarize?: boolean;
+ timestamps?: boolean;
provider?: string;
language?: string;
environment?: string;
@@ -2002,6 +2003,7 @@ declare global {
text?: string;
error?: string;
diarized?: boolean;
+ segments?: Array<{ text: string; start: number; end: number; speaker?: string }>;
}>;
// Usage limit events
diff --git a/test/helpers/transcriptFormatter.test.js b/test/helpers/transcriptFormatter.test.js
index 03bfc7787..9246b1c16 100644
--- a/test/helpers/transcriptFormatter.test.js
+++ b/test/helpers/transcriptFormatter.test.js
@@ -133,12 +133,13 @@ test("consecutive speaker-less segments within 2s merge across SRT, TXT and Mark
{ timestamp: 5, text: "Later sentence." },
];
+ // SRT cues from a fully speaker-less transcript (a timestamped upload)
+ // carry bare text — an "Unknown Speaker:" prefix on every subtitle would
+ // defeat the format's purpose.
const srtOutput = formatSrt(segments, {});
- assert.match(
- srtOutput,
- /^1\n00:00:00,000 --> 00:00:05,000\nUnknown Speaker: Hello world, this is a test\./
- );
- assert.match(srtOutput, /\n2\n00:00:05,000 --> 00:00:08,000\nUnknown Speaker: Later sentence\./);
+ assert.match(srtOutput, /^1\n00:00:00,000 --> 00:00:05,000\nHello world, this is a test\./);
+ assert.match(srtOutput, /\n2\n00:00:05,000 --> 00:00:08,000\nLater sentence\./);
+ assert.doesNotMatch(srtOutput, /Unknown Speaker/);
const txtOutput = formatTxt(
{ title: "Test Note", created_at: "2026-01-01T00:00:00Z" },
@@ -157,6 +158,32 @@ test("consecutive speaker-less segments within 2s merge across SRT, TXT and Mark
assert.ok(mdOutput.includes("**Unknown Speaker** `00:00:05`\nLater sentence."));
});
+test("a single segment with speaker identity keeps the prefix on every SRT cue", () => {
+ const output = formatSrt(
+ [
+ { timestamp: 0, text: "No identity here." },
+ { speakerName: "Ada", timestamp: 5, text: "Named reply." },
+ ],
+ {}
+ );
+
+ assert.match(output, /^1\n00:00:00,000 --> 00:00:05,000\nUnknown Speaker: No identity here\./);
+ assert.match(output, /\n2\n00:00:05,000 --> 00:00:08,000\nAda: Named reply\./);
+});
+
+test("meeting segments identified only by source keep their SRT speaker labels", () => {
+ const output = formatSrt(
+ [
+ { source: "mic", timestamp: 0, text: "Me talking." },
+ { source: "system", timestamp: 5, text: "Them talking." },
+ ],
+ {}
+ );
+
+ assert.match(output, /^1\n00:00:00,000 --> 00:00:05,000\nYou: Me talking\./);
+ assert.match(output, /\n2\n00:00:05,000 --> 00:00:08,000\nOthers: Them talking\./);
+});
+
test("a manually named segment does not absorb the adjacent un-named one", () => {
const segments = [
{
diff --git a/test/helpers/uploadTimestamps.test.js b/test/helpers/uploadTimestamps.test.js
new file mode 100644
index 000000000..030e5f50b
--- /dev/null
+++ b/test/helpers/uploadTimestamps.test.js
@@ -0,0 +1,77 @@
+const test = require("node:test");
+const assert = require("node:assert/strict");
+
+const {
+ timestampRequestFields,
+ mapVerboseSegments,
+} = require("../../src/helpers/uploadTimestamps");
+
+test("timestamp fields are requested only from providers/models that accept them", () => {
+ assert.deepEqual(timestampRequestFields("openai", "whisper-1"), {
+ response_format: "verbose_json",
+ });
+ assert.deepEqual(timestampRequestFields("groq", "whisper-large-v3"), {
+ response_format: "verbose_json",
+ });
+ assert.deepEqual(timestampRequestFields("groq", "whisper-large-v3-turbo"), {
+ response_format: "verbose_json",
+ });
+ assert.deepEqual(timestampRequestFields("mistral", "voxtral-mini-latest"), {
+ timestamp_granularities: "segment",
+ });
+
+ // gpt-4o transcribe models reject verbose_json outright.
+ assert.equal(timestampRequestFields("openai", "gpt-4o-transcribe"), null);
+ assert.equal(timestampRequestFields("openai", "gpt-4o-mini-transcribe"), null);
+
+ // Everything else fails safe to a plain-text request: a custom or
+ // self-hosted server may 400 on fields it doesn't know.
+ assert.equal(timestampRequestFields("custom", "whisper-1"), null);
+ assert.equal(timestampRequestFields("self-hosted", "whisper-large-v3"), null);
+ assert.equal(timestampRequestFields("xai", "grok-stt"), null);
+ assert.equal(timestampRequestFields(undefined, undefined), null);
+});
+
+test("verbose segments map to {text, start, end}", () => {
+ assert.deepEqual(
+ mapVerboseSegments({
+ text: "Hello world. Goodbye.",
+ segments: [
+ { id: 0, seek: 0, start: 0, end: 4.2, text: " Hello world." },
+ { id: 1, seek: 400, start: 4.2, end: 7.5, text: " Goodbye." },
+ ],
+ }),
+ [
+ { text: "Hello world.", start: 0, end: 4.2 },
+ { text: "Goodbye.", start: 4.2, end: 7.5 },
+ ]
+ );
+});
+
+test("malformed verbose segments are dropped, never thrown", () => {
+ const mapped = mapVerboseSegments({
+ segments: [
+ { start: 0, end: 1, text: " " },
+ { start: NaN, end: 2, text: "no start" },
+ { start: "1", end: 2, text: "string start" },
+ { end: 2, text: "missing start" },
+ null,
+ { start: 3, end: "x", text: "bad end falls back to start" },
+ { start: 5, text: "missing end falls back to start" },
+ ],
+ });
+
+ assert.deepEqual(mapped, [
+ { text: "bad end falls back to start", start: 3, end: 3 },
+ { text: "missing end falls back to start", start: 5, end: 5 },
+ ]);
+});
+
+test("responses without usable segments map to null", () => {
+ assert.equal(mapVerboseSegments({ text: "plain json response" }), null);
+ assert.equal(mapVerboseSegments({ segments: "not-an-array" }), null);
+ assert.equal(mapVerboseSegments({ segments: [] }), null);
+ assert.equal(mapVerboseSegments({ segments: [{ start: NaN, text: "" }] }), null);
+ assert.equal(mapVerboseSegments(null), null);
+ assert.equal(mapVerboseSegments(undefined), null);
+});
diff --git a/test/services/fileTranscriptionTimestamps.test.js b/test/services/fileTranscriptionTimestamps.test.js
new file mode 100644
index 000000000..f46b3470f
--- /dev/null
+++ b/test/services/fileTranscriptionTimestamps.test.js
@@ -0,0 +1,64 @@
+const test = require("node:test");
+const assert = require("node:assert/strict");
+const { createRendererServer, installBrowserGlobals } = require("../lib/rendererTestHarness");
+
+// The upload flows opt into segment timestamps (issue #1095): the flag must
+// reach the BYOK IPC call, and the segments the handler returns must survive
+// transcribeFileWithSpeakers' result spread so saveUploadNote can persist them.
+
+function byokConfig() {
+ return {
+ useLocalWhisper: false,
+ localTranscriptionProvider: "whisper",
+ whisperModel: "base",
+ parakeetModel: "parakeet-tdt-0.6b-v3",
+ isOpenWhisprCloud: false,
+ getApiKey: () => "sk-test",
+ cloudTranscriptionProvider: "openai",
+ cloudTranscriptionBaseUrl: "",
+ cloudTranscriptionModel: "whisper-1",
+ language: "en",
+ transcriptionMode: "providers",
+ };
+}
+
+test("timestamps opt-in reaches the BYOK IPC call and segments flow back", async (t) => {
+ const { window } = installBrowserGlobals(t);
+ const vite = await createRendererServer(t, {
+ cachePrefix: "openwhispr-file-timestamps-test-",
+ mockModules: {
+ "/lib/auth": "export const withSessionRefresh = (fn) => fn();",
+ },
+ });
+ const { transcribeFile, transcribeFileWithSpeakers } = await vite.ssrLoadModule(
+ "/services/fileTranscription.ts"
+ );
+
+ const segments = [{ text: "Hello.", start: 0, end: 2.5 }];
+ let receivedOptions = null;
+ window.electronAPI.transcribeAudioFileByok = async (options) => {
+ receivedOptions = options;
+ return { success: true, text: "Hello.", segments };
+ };
+
+ const direct = await transcribeFile("/tmp/audio.webm", byokConfig(), false, {
+ timestamps: true,
+ });
+ assert.equal(receivedOptions.timestamps, true);
+ assert.deepEqual(direct.segments, segments);
+
+ // Without the opt-in the request stays exactly as before.
+ await transcribeFile("/tmp/audio.webm", byokConfig(), false);
+ assert.equal(receivedOptions.timestamps, undefined);
+
+ const withSpeakers = await transcribeFileWithSpeakers(
+ "/tmp/audio.webm",
+ byokConfig(),
+ { enabled: false, localModelsReady: false, numSpeakers: null },
+ 120,
+ { timestamps: true }
+ );
+ assert.equal(receivedOptions.timestamps, true);
+ assert.deepEqual(withSpeakers.segments, segments);
+ assert.equal(withSpeakers.durationSeconds, 120);
+});
diff --git a/test/services/uploadNotes.test.js b/test/services/uploadNotes.test.js
index 7251be5dd..c6b0435a8 100644
--- a/test/services/uploadNotes.test.js
+++ b/test/services/uploadNotes.test.js
@@ -75,6 +75,67 @@ test("unusable durations degrade to null", async () => {
}
});
+test("provider segments serialize into the meeting-path transcript shape", async () => {
+ const { buildUploadTranscript } = await load();
+
+ const transcript = buildUploadTranscript([
+ { text: " Hello world. ", start: 0, end: 4.2 },
+ { text: "Named part.", start: 4.2, end: 7.5, speaker: "Speaker 1" },
+ ]);
+
+ // Relative seconds are stored as-is: normalizeSegmentTimestamps only
+ // rebases epoch-millisecond values, so export math stays correct.
+ assert.deepEqual(JSON.parse(transcript), [
+ { text: "Hello world.", timestamp: 0 },
+ { text: "Named part.", timestamp: 4.2, speakerName: "Speaker 1" },
+ ]);
+});
+
+test("unusable segments produce no transcript at all", async () => {
+ const { buildUploadTranscript } = await load();
+
+ assert.equal(buildUploadTranscript(undefined), undefined);
+ assert.equal(buildUploadTranscript(null), undefined);
+ assert.equal(buildUploadTranscript([]), undefined);
+ assert.equal(
+ buildUploadTranscript([
+ { text: " ", start: 0 },
+ { text: "no start", start: NaN },
+ ]),
+ undefined
+ );
+});
+
+test("segments persist the transcript even when diarization is off", async () => {
+ const { buildUploadNoteMetadata } = await load();
+
+ const { noteUpdates } = buildUploadNoteMetadata(
+ { enabled: false, localModelsReady: false, numSpeakers: null },
+ 60,
+ [{ text: "Hello.", start: 0, end: 2 }]
+ );
+
+ // The transcript must not drag the diarization columns along: a null
+ // diarization_enabled still defers to the global speaker setting.
+ assert.deepEqual(noteUpdates, { transcript: JSON.stringify([{ text: "Hello.", timestamp: 0 }]) });
+});
+
+test("segments and diarization metadata share one noteUpdates write", async () => {
+ const { buildUploadNoteMetadata } = await load();
+
+ const { noteUpdates } = buildUploadNoteMetadata(
+ { enabled: true, localModelsReady: true, numSpeakers: 2 },
+ 60,
+ [{ text: "Hi.", start: 1, speaker: "Speaker 1" }]
+ );
+
+ assert.deepEqual(noteUpdates, {
+ diarization_enabled: 1,
+ expected_speaker_count: 2,
+ transcript: JSON.stringify([{ text: "Hi.", timestamp: 1, speakerName: "Speaker 1" }]),
+ });
+});
+
test("upload titles fall back to the transcript, then the file name", async () => {
const { uploadTitleFallback } = await load();