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
feat(transcription): turn speaker identification off in the settings
Elian Doran531cf6374f87
diff --git a/.claude/skills/working-with-transcription/SKILL.md b/.claude/skills/working-with-transcription/SKILL.mdindex c5738c77bc..5cdfe09876 100644--- a/.claude/skills/working-with-transcription/SKILL.md+++ b/.claude/skills/working-with-transcription/SKILL.md@@ -55,7 +55,7 @@ Nothing the transcription process imports may reach `@triliumnext/core` or `@tri## The model-Users choose the recognizer under Options → Transcription: the non-synced option `transcriptionModel` holds a key of `TRANSCRIPTION_MODELS` (commons `transcript.ts`), `parakeet-int8` (the default, "Standard") or `parakeet-fp32` ("High accuracy"), each naming its resource and precision; an unknown value reads as the default (`getTranscriptionModel()`). The launcher calls `requireResources(getTranscriptionResources(<option>))` before it creates the meeting note, which shows the download dialog for those missing, and `startRecording()` resolves the same option through `getModelPaths()`. The models are resources of the resource manager (`apps/server/src/services/resources.ts`), each in `<data dir>/resources/<id>-<hash>/` and checked against the SHA-256 in `model.ts`: `transcription.parakeet` (int8, 670 MB), `transcription.parakeet-fp32` (2.5 GB, pinned to a Hugging Face revision), `transcription.silero-vad` (0.6 MB) and `transcription.titanet` (40 MB). The hash in the directory name covers every file's path and SHA-256, so changing a file of one model downloads that model alone again, into a new directory. A recording needs Parakeet and Silero; without TitaNet it labels no speakers.+Users choose the recognizer under Options → Transcription: the non-synced option `transcriptionModel` holds a key of `TRANSCRIPTION_MODELS` (commons `transcript.ts`), `parakeet-int8` (the default, "Standard") or `parakeet-fp32` ("High accuracy"), each naming its resource and precision; an unknown value reads as the default (`getTranscriptionModel()`). The synced option `transcriptionSpeakersEnabled` (the "Identify speakers" switch, default on) decides whether a recording labels speakers. The launcher calls `requireResources(getTranscriptionResources(<model>, <speakers>))` before it creates the meeting note, which shows the download dialog for those missing (TitaNet only while the switch is on), and `startRecording()` resolves the same two options through `getModelPaths()`, which passes `speaker: null` while the switch is off. The models are resources of the resource manager (`apps/server/src/services/resources.ts`), each in `<data dir>/resources/<id>-<hash>/` and checked against the SHA-256 in `model.ts`: `transcription.parakeet` (int8, 670 MB), `transcription.parakeet-fp32` (2.5 GB, pinned to a Hugging Face revision), `transcription.silero-vad` (0.6 MB) and `transcription.titanet` (40 MB). The hash in the directory name covers every file's path and SHA-256, so changing a file of one model downloads that model alone again, into a new directory. A recording needs Parakeet and Silero; without TitaNet it labels no speakers.A directory installed by hand, `<data dir>/transcription-model` (`LOCAL_MODEL_DIR`), takes precedence over the downloads, each model for itself, when it holds that model's files (each Parakeet precision when every one of its files is there, Silero when `silero_vad.onnx` is, TitaNet when `speaker/nemo_en_titanet_small.onnx` is); for `pnpm desktop:start` that is `apps/desktop/data/transcription-model`, which the scripts below read. `ModelPaths.recognizer` carries the precision with the directory, and `loadSherpaEngine()` loads that precision's files; it records it as `precision` in the engine settings and applies `blankPenalty` to int8 only (see "Findings so far").diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex bc90595c6d..978f662346 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -4629,6 +4629,8 @@"european_languages": "European languages","european_languages_description": "Parakeet TDT 0.6B v3 by NVIDIA recognizes 25 European languages and works out which one is spoken. High accuracy makes fewer mistakes, but it is a 2.4 GB download instead of 0.6 GB and needs about 1.6 GB more memory while recording. A model that is not downloaded yet is downloaded when you start a recording.","model_standard": "Standard",- "model_high_accuracy": "High accuracy"+ "model_high_accuracy": "High accuracy",+ "identify_speakers": "Identify speakers",+ "identify_speakers_description": "Tells the other participants apart and labels each of their utterances with its speaker; what you say into your microphone is always yours. Turn it off if it mixes up voices, or to save the processing it takes during a recording. It applies from the next recording."}}diff --git a/apps/client/src/widgets/launch_bar/RecordMeetingButton.spec.tsx b/apps/client/src/widgets/launch_bar/RecordMeetingButton.spec.tsxindex 0ea8060998..693b2b9575 100644--- a/apps/client/src/widgets/launch_bar/RecordMeetingButton.spec.tsx+++ b/apps/client/src/widgets/launch_bar/RecordMeetingButton.spec.tsx@@ -10,7 +10,8 @@ const mocks = vi.hoisted(() => ({createNote: vi.fn(),showError: vi.fn(),requireResources: vi.fn(),- transcriptionModel: null as string | null+ transcriptionModel: null as string | null,+ speakersEnabled: true}));vi.mock("../../services/date_notes", () => ({@@ -23,7 +24,10 @@ vi.mock("../../services/dialog", () => ({requireResources: mocks.requireResources}));vi.mock("../../services/options", () => ({- default: { get: (name: string) => name === "transcriptionModel" ? mocks.transcriptionModel : null }+ default: {+ get: (name: string) => name === "transcriptionModel" ? mocks.transcriptionModel : null,+ is: (name: string) => name === "transcriptionSpeakersEnabled" && mocks.speakersEnabled+ }}));vi.mock("../../services/toast", () => ({default: { showError: mocks.showError }@@ -43,6 +47,7 @@ import RecordMeetingButton, { createMeetingNote, toggleRecording } from "./RecorbeforeEach(() => {vi.clearAllMocks();mocks.transcriptionModel = null;+ mocks.speakersEnabled = true;vi.useFakeTimers({ now: new Date(2026, 9, 13, 14, 30), toFake: [ "Date" ] });});@@ -122,6 +127,13 @@ describe("toggleRecording", () => {[ "transcription.parakeet-fp32", "transcription.silero-vad", "transcription.titanet" ]);});+ it("leaves the speaker model out while speaker identification is off", async () => {+ mocks.speakersEnabled = false;+ await toggleRecording("idle");+ expect(mocks.requireResources).toHaveBeenCalledExactlyOnceWith(+ [ "transcription.parakeet", "transcription.silero-vad" ]);+ });+it("starts nothing when no meeting note could be created", async () => {mocks.getInboxNote.mockResolvedValue(null);vi.spyOn(console, "warn").mockImplementation(() => {});diff --git a/apps/client/src/widgets/launch_bar/RecordMeetingButton.tsx b/apps/client/src/widgets/launch_bar/RecordMeetingButton.tsxindex 0d4d435739..83866bfc80 100644--- a/apps/client/src/widgets/launch_bar/RecordMeetingButton.tsx+++ b/apps/client/src/widgets/launch_bar/RecordMeetingButton.tsx@@ -105,7 +105,9 @@ export async function toggleRecording(status: TranscriptionStatus) {if (status !== "idle") {return;}- if (!await requireResources(getTranscriptionResources(options.get("transcriptionModel")))) {+ const resources = getTranscriptionResources(+ options.get("transcriptionModel"), options.is("transcriptionSpeakersEnabled"));+ if (!await requireResources(resources)) {return;}diff --git a/apps/client/src/widgets/type_widgets/options/transcription.spec.tsx b/apps/client/src/widgets/type_widgets/options/transcription.spec.tsxindex 769bfd43ba..869c2fbe2c 100644--- a/apps/client/src/widgets/type_widgets/options/transcription.spec.tsx+++ b/apps/client/src/widgets/type_widgets/options/transcription.spec.tsx@@ -5,7 +5,9 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";const mocks = vi.hoisted(() => ({electron: true,stored: "" as string,- saved: [] as string[]+ saved: [] as string[],+ speakersEnabled: true,+ savedSpeakers: [] as boolean[]}));vi.mock("../../../services/utils", async (importOriginal) => ({@@ -20,6 +22,10 @@ vi.mock("../../react/hooks", async (importOriginal) => ({useTriliumOption: (name: string) => [name === "transcriptionModel" ? mocks.stored : "",(value: string) => void mocks.saved.push(value)+ ],+ useTriliumOptionBool: (name: string) => [+ name === "transcriptionSpeakersEnabled" && mocks.speakersEnabled,+ (value: boolean) => void mocks.savedSpeakers.push(value)]}));@@ -33,6 +39,8 @@ beforeEach(() => {mocks.electron = true;mocks.stored = "parakeet-fp32";mocks.saved = [];+ mocks.speakersEnabled = true;+ mocks.savedSpeakers = [];host = document.body.appendChild(document.createElement("div"));});@@ -67,6 +75,21 @@ describe("TranscriptionSettings", () => {expect(mocks.saved).toEqual([ "parakeet-int8" ]);});+ it("turns speaker identification off", () => {+ open();+ const toggle = host.querySelector<HTMLInputElement>("input.switch-toggle[id^='identify-speakers-']");+ if (!toggle) {+ throw new Error("The speaker switch is missing.");+ }+ expect(toggle.checked).toBe(true);++ act(() => {+ toggle.checked = false;+ toggle.dispatchEvent(new Event("input", { bubbles: true }));+ });+ expect(mocks.savedSpeakers).toEqual([ false ]);+ });+it("shows the default model for a value it does not know", () => {mocks.stored = "whisper";expect(open()?.value).toBe("parakeet-int8");diff --git a/apps/client/src/widgets/type_widgets/options/transcription.tsx b/apps/client/src/widgets/type_widgets/options/transcription.tsxindex b78fa0f5e5..d25243e3b2 100644--- a/apps/client/src/widgets/type_widgets/options/transcription.tsx+++ b/apps/client/src/widgets/type_widgets/options/transcription.tsx@@ -4,7 +4,8 @@ import { t } from "../../../services/i18n";import { isElectron } from "../../../services/utils";import { Card, OptionCardSection } from "../../react/Card";import FormSelect from "../../react/FormSelect";-import { useTriliumOption } from "../../react/hooks";+import FormToggle from "../../react/FormToggle";+import { useTriliumOption, useTriliumOptionBool } from "../../react/hooks";import NoItems from "../../react/NoItems";import OptionsPageHeader from "./components/OptionsPageHeader";@@ -28,6 +29,7 @@ export default function TranscriptionSettings() {function RecognitionSettings() {const [ model, setModel ] = useTriliumOption("transcriptionModel");+ const [ speakersEnabled, setSpeakersEnabled ] = useTriliumOptionBool("transcriptionSpeakersEnabled");const labels: Record<TranscriptionModelId, string> = {"parakeet-int8": t("transcription_options.model_standard"),"parakeet-fp32": t("transcription_options.model_high_accuracy")@@ -49,6 +51,14 @@ function RecognitionSettings() {values={Object.values(TRANSCRIPTION_MODELS).map(({ id }) => ({ id, label: labels[id] }))}/></OptionCardSection>++ <OptionCardSection+ name="identify-speakers"+ label={t("transcription_options.identify_speakers")}+ description={t("transcription_options.identify_speakers_description")}+ >+ <FormToggle currentValue={speakersEnabled} onChange={setSpeakersEnabled} />+ </OptionCardSection></Card>);}diff --git a/apps/desktop/src/services/transcription/index.spec.ts b/apps/desktop/src/services/transcription/index.spec.tsindex 7ad6223b15..2c9ca98d39 100644--- a/apps/desktop/src/services/transcription/index.spec.ts+++ b/apps/desktop/src/services/transcription/index.spec.ts@@ -17,6 +17,7 @@ const h = vi.hoisted(() => ({isDev: false,installedResources: [] as string[],transcriptionModel: null as string | null,+ speakersEnabled: true,registerResource: vi.fn(),log: { info: vi.fn(), error: vi.fn() },listeners: null as WorkerListeners | null,@@ -63,7 +64,8 @@ vi.mock("@triliumnext/core", () => ({},getLog: () => h.log,options: {- getOptionOrNull: (name: string) => name === "transcriptionModel" ? h.transcriptionModel : null+ getOptionOrNull: (name: string) => name === "transcriptionModel" ? h.transcriptionModel : null,+ getOptionBool: (name: string) => name === "transcriptionSpeakersEnabled" && h.speakersEnabled},protected_session: { isProtectedSessionAvailable: () => h.isProtectedSessionAvailable },utils: { isDev: () => h.isDev }@@ -134,6 +136,7 @@ beforeEach(() => {h.broadcast.length = 0;h.isDev = false;h.transcriptionModel = null;+ h.speakersEnabled = true;h.installedResources = ["transcription.parakeet", "transcription.silero-vad", "transcription.titanet"];@@ -353,6 +356,13 @@ describe("transcription IPC", () => {expect(h.worker.start.mock.calls[0][0].models.speaker).toBeNull();});+ it("records without the speaker model while speaker identification is off", async () => {+ const invoke = await loadService();+ h.speakersEnabled = false;+ expect(await invoke("transcription-start", "meeting")).toBe("");+ expect(h.worker.start.mock.calls[0][0].models.speaker).toBeNull();+ });+it("records with the model the option selects, refusing while it is not downloaded", async () => {const invoke = await loadService();h.transcriptionModel = "parakeet-fp32";diff --git a/apps/desktop/src/services/transcription/index.ts b/apps/desktop/src/services/transcription/index.tsindex 8afa740192..5b04aa81ed 100644--- a/apps/desktop/src/services/transcription/index.ts+++ b/apps/desktop/src/services/transcription/index.ts@@ -62,7 +62,10 @@ export async function startRecording(noteId: unknown): Promise<string> {if (typeof noteId !== "string" || !becca.getNote(noteId)) {return t("transcription.note-not-found");}- const models = getModelPaths(options.getOptionOrNull("transcriptionModel"));+ const models = getModelPaths(+ options.getOptionOrNull("transcriptionModel"),+ options.getOptionBool("transcriptionSpeakersEnabled")+ );if (!models) {return t("transcription.model-not-downloaded");}diff --git a/apps/desktop/src/services/transcription/model.ts b/apps/desktop/src/services/transcription/model.tsindex 74160c944f..c01506d4af 100644--- a/apps/desktop/src/services/transcription/model.ts+++ b/apps/desktop/src/services/transcription/model.ts@@ -131,13 +131,14 @@ export const TRANSCRIPTION_MODELS = [ ...RECOGNIZER_MODELS, VAD_MODEL, SPEAKER_M/*** Returns where the installed models are for a recording with the model `modelId` (a key of* `TRANSCRIPTION_MODELS` in commons), or `null` while its recognizer or the VAD is missing.- * Without the speaker model, the transcript labels no speakers.+ * The speaker model is left out unless `identifySpeakers` holds and it is installed; without it,+ * the transcript labels no speakers.*/-export function getModelPaths(modelId: string | null): ModelPaths | null {+export function getModelPaths(modelId: string | null, identifySpeakers: boolean): ModelPaths | null {const model = getTranscriptionModel(modelId);const recognizer = resources.getPath(model.resourceId);const vad = resources.getPath(VAD_MODEL.id);- const speaker = resources.getPath(SPEAKER_MODEL.id);+ const speaker = identifySpeakers ? resources.getPath(SPEAKER_MODEL.id) : null;if (!recognizer || !vad) {return null;}diff --git a/packages/commons/src/lib/options_interface.ts b/packages/commons/src/lib/options_interface.tsindex aa533a61d6..1cd07e700e 100644--- a/packages/commons/src/lib/options_interface.ts+++ b/packages/commons/src/lib/options_interface.ts@@ -209,6 +209,8 @@ export interface OptionDefinitions extends KeyboardShortcutsOptions<KeyboardActi* each device downloads and runs its own.*/transcriptionModel: string;+ /** Whether a recording tells the other participants apart, labeling each utterance with its speaker. */+ transcriptionSpeakersEnabled: boolean;leftPaneVisible: boolean;rightPaneVisible: boolean;nativeTitleBarVisible: boolean;diff --git a/packages/commons/src/lib/transcript.spec.ts b/packages/commons/src/lib/transcript.spec.tsindex 58f99e2a66..b18cffbe8f 100644--- a/packages/commons/src/lib/transcript.spec.ts+++ b/packages/commons/src/lib/transcript.spec.ts@@ -95,10 +95,12 @@ describe("transcription models", () => {expect(getTranscriptionModel("toString").id).toBe("parakeet-int8");});- it("needs the selected recognizer, the VAD and the speaker model to record", () => {- expect(getTranscriptionResources("parakeet-fp32"))+ it("needs the selected recognizer, the VAD and, to identify speakers, the speaker model", () => {+ expect(getTranscriptionResources("parakeet-fp32", true)).toEqual([ "transcription.parakeet-fp32", "transcription.silero-vad", "transcription.titanet" ]);- expect(getTranscriptionResources(undefined))+ expect(getTranscriptionResources(undefined, true)).toEqual([ "transcription.parakeet", "transcription.silero-vad", "transcription.titanet" ]);+ expect(getTranscriptionResources("parakeet-int8", false))+ .toEqual([ "transcription.parakeet", "transcription.silero-vad" ]);});});diff --git a/packages/commons/src/lib/transcript.ts b/packages/commons/src/lib/transcript.tsindex 60db8b3e1a..d924e680ba 100644--- a/packages/commons/src/lib/transcript.ts+++ b/packages/commons/src/lib/transcript.ts@@ -74,9 +74,16 @@ export function getTranscriptionModel(id: string | null | undefined): Transcript: TRANSCRIPTION_MODELS[DEFAULT_TRANSCRIPTION_MODEL];}-/** Returns the resources a recording with the model `modelId` needs. */-export function getTranscriptionResources(modelId: string | null | undefined) {- return [ getTranscriptionModel(modelId).resourceId, ...Object.values(TRANSCRIPTION_RESOURCES) ];+/**+ * Returns the resources a recording with the model `modelId` needs: the speaker model only when it+ * identifies speakers.+ */+export function getTranscriptionResources(modelId: string | null | undefined, identifySpeakers: boolean) {+ return [+ getTranscriptionModel(modelId).resourceId,+ TRANSCRIPTION_RESOURCES.vad,+ ...(identifySpeakers ? [ TRANSCRIPTION_RESOURCES.speaker ] : [])+ ];}/** Reads a transcript attachment's content, or returns `null` for content of another shape. */diff --git a/packages/trilium-core/src/routes/api/options.ts b/packages/trilium-core/src/routes/api/options.tsindex 93ca6adaeb..99a19b3aab 100644--- a/packages/trilium-core/src/routes/api/options.ts+++ b/packages/trilium-core/src/routes/api/options.ts@@ -65,6 +65,7 @@ const ALLOWED_OPTIONS = new Set<OptionNames>(["codeLineWrapEnabled","transcriptCleanupEnabled","transcriptionModel",+ "transcriptionSpeakersEnabled","codeNotesMimeTypes","contentManagerSortOrder","contentManagerViewMode",diff --git a/packages/trilium-core/src/services/options_init.ts b/packages/trilium-core/src/services/options_init.tsindex ffc9ed8830..0bcaebce7b 100644--- a/packages/trilium-core/src/services/options_init.ts+++ b/packages/trilium-core/src/services/options_init.ts@@ -185,6 +185,7 @@ const defaultOptions: DefaultOption[] = [{ name: "codeLineWrapEnabled", value: "true", isSynced: false },{ name: "transcriptCleanupEnabled", value: "true", isSynced: true },{ name: "transcriptionModel", value: DEFAULT_TRANSCRIPTION_MODEL, isSynced: false },+ { name: "transcriptionSpeakersEnabled", value: "true", isSynced: true },{ name: "codeNoteTabWidth", value: "4", isSynced: true },{ name: "codeNoteIndentWithTabs", value: "false", isSynced: true },{