Skip to content

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

feat: initial diarization implementation

Gabriel Steinb187f3a1460c
diff --git a/main.js b/main.js
index 368655a6e..cc944cbe9 100644
--- a/main.js
+++ b/main.js
@@ -194,6 +194,7 @@ const DatabaseManager = require("./src/helpers/database");
const ClipboardManager = require("./src/helpers/clipboard");
const WhisperManager = require("./src/helpers/whisper");
const ParakeetManager = require("./src/helpers/parakeet");
+const DiarizationManager = require("./src/helpers/diarization");
const TrayManager = require("./src/helpers/tray");
const IPCHandlers = require("./src/helpers/ipcHandlers");
const UpdateManager = require("./src/updater");
@@ -219,6 +220,7 @@ let databaseManager = null;
let clipboardManager = null;
let whisperManager = null;
let parakeetManager = null;
+let diarizationManager = null;
let trayManager = null;
let updateManager = null;
let globeKeyManager = null;
@@ -292,6 +294,7 @@ function initializeCoreManagers() {
whisperCudaManager = new WhisperCudaManager();
}
parakeetManager = new ParakeetManager();
+ diarizationManager = new DiarizationManager();
googleCalendarManager = new GoogleCalendarManager(databaseManager, windowManager);
meetingDetectionEngine = new MeetingDetectionEngine(
googleCalendarManager,
@@ -315,6 +318,7 @@ function initializeCoreManagers() {
clipboardManager,
whisperManager,
parakeetManager,
+ diarizationManager,
windowManager,
updateManager,
windowsKeyManager,
@@ -1184,6 +1188,9 @@ if (gotSingleInstanceLock) {
if (parakeetManager) {
parakeetManager.stopServer().catch(() => {});
}
+ if (diarizationManager) {
+ diarizationManager.shutdown().catch(() => {});
+ }
// Stop llama-server if running
const modelManager = require("./src/helpers/modelManagerBridge").default;
modelManager.stopServer().catch(() => {});
diff --git a/package.json b/package.json
index 76f9d5927..9851c0703 100644
--- a/package.json
+++ b/package.json
@@ -58,6 +58,7 @@
"download:qdrant": "node scripts/download-qdrant.js --current",
"download:qdrant:all": "node scripts/download-qdrant.js --all",
"download:embedding-model": "node scripts/download-minilm.js",
+ "download:diarization-models": "node scripts/download-diarization-models.js",
"format:js": "eslint . --fix && cd src && eslint . --fix && prettier --write \"**/*.{js,jsx,ts,tsx,json,css,md}\"",
"format": "npm run format:js",
"format:check": "eslint . && cd src && eslint . && prettier --check \"**/*.{js,jsx,ts,tsx,json,css,md}\"",
diff --git a/preload.js b/preload.js
index 3d09ad5d7..8f48dcce4 100644
--- a/preload.js
+++ b/preload.js
@@ -249,6 +249,20 @@ contextBridge.exposeInMainWorld("electronAPI", {
parakeetServerStop: () => ipcRenderer.invoke("parakeet-server-stop"),
parakeetServerStatus: () => ipcRenderer.invoke("parakeet-server-status"),
+ // Diarization (speaker identification) functions
+ downloadDiarizationModels: () => ipcRenderer.invoke("download-diarization-models"),
+ getDiarizationModelStatus: () => ipcRenderer.invoke("get-diarization-model-status"),
+ deleteDiarizationModels: () => ipcRenderer.invoke("delete-diarization-models"),
+ cancelDiarizationDownload: () => ipcRenderer.invoke("cancel-diarization-download"),
+ onDiarizationDownloadProgress: registerListener(
+ "diarization-download-progress",
+ (callback) => (_event, data) => callback(data)
+ ),
+ onMeetingDiarizationComplete: registerListener(
+ "meeting-diarization-complete",
+ (callback) => (_event, data) => callback(data)
+ ),
+
// Window control functions
windowMinimize: () => ipcRenderer.invoke("window-minimize"),
windowMaximize: () => ipcRenderer.invoke("window-maximize"),
diff --git a/scripts/download-diarization-models.js b/scripts/download-diarization-models.js
new file mode 100644
index 000000000..b19c029c2
--- /dev/null
+++ b/scripts/download-diarization-models.js
@@ -0,0 +1,108 @@
+#!/usr/bin/env node
+const fs = require("fs");
+const os = require("os");
+const path = require("path");
+const { execFileSync } = require("child_process");
+const { downloadFile, parseArgs } = require("./lib/download-utils");
+
+const MODEL_DIR = path.join(os.homedir(), ".cache", "openwhispr", "diarization-models");
+
+const SEGMENTATION_URL =
+ "https://github.com/k2-fsa/sherpa-onnx/releases/download/speaker-segmentation-models/sherpa-onnx-pyannote-segmentation-3-0.tar.bz2";
+const SEGMENTATION_DIR = "sherpa-onnx-pyannote-segmentation-3-0";
+const SEGMENTATION_FILE = "model.onnx";
+
+const EMBEDDING_URL =
+ "https://github.com/k2-fsa/sherpa-onnx/releases/download/speaker-recongition-models/3dspeaker_speech_campplus_sv_en_voxceleb_16k.onnx";
+const EMBEDDING_FILE = "3dspeaker_speech_campplus_sv_en_voxceleb_16k.onnx";
+
+function extractTarBz2(archivePath, destDir) {
+ fs.mkdirSync(destDir, { recursive: true });
+ const cwd = path.dirname(archivePath);
+ execFileSync("tar", ["-xjf", path.basename(archivePath), "-C", path.relative(cwd, destDir)], {
+ stdio: "inherit",
+ cwd,
+ });
+}
+
+async function main() {
+ console.log("\n[diarization-models] Downloading diarization models...\n");
+
+ const args = parseArgs();
+
+ const segModelPath = path.join(MODEL_DIR, SEGMENTATION_DIR, SEGMENTATION_FILE);
+ const embModelPath = path.join(MODEL_DIR, EMBEDDING_FILE);
+
+ const allExist = fs.existsSync(segModelPath) && fs.existsSync(embModelPath);
+ if (allExist && !args.isForce) {
+ console.log("[diarization-models] Model files already exist (use --force to re-download)\n");
+ return;
+ }
+
+ fs.mkdirSync(MODEL_DIR, { recursive: true });
+
+ // Download segmentation model (tar.bz2 archive)
+ if (!fs.existsSync(segModelPath) || args.isForce) {
+ console.log(`[diarization-models] Downloading segmentation model from ${SEGMENTATION_URL}`);
+
+ const archivePath = path.join(MODEL_DIR, `${SEGMENTATION_DIR}.tar.bz2`);
+
+ try {
+ await downloadFile(SEGMENTATION_URL, archivePath);
+
+ const extractDir = path.join(MODEL_DIR, "temp-segmentation");
+ fs.mkdirSync(extractDir, { recursive: true });
+ extractTarBz2(archivePath, extractDir);
+
+ // Find model.onnx inside the extracted directory
+ const extractedModelPath = path.join(extractDir, SEGMENTATION_DIR, SEGMENTATION_FILE);
+ if (!fs.existsSync(extractedModelPath)) {
+ console.error(`[diarization-models] ${SEGMENTATION_FILE} not found in archive`);
+ process.exitCode = 1;
+ return;
+ }
+
+ const destDir = path.join(MODEL_DIR, SEGMENTATION_DIR);
+ fs.mkdirSync(destDir, { recursive: true });
+ fs.copyFileSync(extractedModelPath, segModelPath);
+
+ const stats = fs.statSync(segModelPath);
+ const sizeMB = (stats.size / 1024 / 1024).toFixed(1);
+ console.log(`[diarization-models] Segmentation model downloaded (${sizeMB}MB)`);
+
+ // Cleanup
+ fs.rmSync(extractDir, { recursive: true, force: true });
+ if (fs.existsSync(archivePath)) fs.unlinkSync(archivePath);
+ } catch (error) {
+ console.error(`[diarization-models] Failed to download segmentation model: ${error.message}`);
+ if (fs.existsSync(archivePath)) fs.unlinkSync(archivePath);
+ process.exitCode = 1;
+ return;
+ }
+ } else {
+ console.log(`[diarization-models] Segmentation model already exists, skipping`);
+ }
+
+ // Download embedding model (direct .onnx file)
+ if (!fs.existsSync(embModelPath) || args.isForce) {
+ console.log(`[diarization-models] Downloading embedding model from ${EMBEDDING_URL}`);
+
+ try {
+ await downloadFile(EMBEDDING_URL, embModelPath);
+ const stats = fs.statSync(embModelPath);
+ const sizeMB = (stats.size / 1024 / 1024).toFixed(1);
+ console.log(`[diarization-models] Embedding model downloaded (${sizeMB}MB)`);
+ } catch (error) {
+ console.error(`[diarization-models] Failed to download embedding model: ${error.message}`);
+ if (fs.existsSync(embModelPath)) fs.unlinkSync(embModelPath);
+ process.exitCode = 1;
+ return;
+ }
+ } else {
+ console.log(`[diarization-models] Embedding model already exists, skipping`);
+ }
+
+ console.log(`\n[diarization-models] Models ready at ${MODEL_DIR}\n`);
+}
+
+main().catch(console.error);
diff --git a/scripts/download-sherpa-onnx.js b/scripts/download-sherpa-onnx.js
index 01b62b7b3..37e0c5169 100644
--- a/scripts/download-sherpa-onnx.js
+++ b/scripts/download-sherpa-onnx.js
@@ -7,7 +7,6 @@ const {
findBinaryInDir,
parseArgs,
setExecutable,
- cleanupFiles,
} = require("./lib/download-utils");
const SHERPA_ONNX_VERSION = "1.12.23";
@@ -20,24 +19,32 @@ const BINARIES = {
archiveName: `sherpa-onnx-v${SHERPA_ONNX_VERSION}-osx-universal2-shared.tar.bz2`,
binaryPath: "sherpa-onnx-offline-websocket-server",
outputName: "sherpa-onnx-ws-darwin-arm64",
+ diarizeBinaryPath: "sherpa-onnx-offline-speaker-diarization",
+ diarizeOutputName: "sherpa-onnx-diarize-darwin-arm64",
libPattern: "*.dylib",
},
"darwin-x64": {
archiveName: `sherpa-onnx-v${SHERPA_ONNX_VERSION}-osx-universal2-shared.tar.bz2`,
binaryPath: "sherpa-onnx-offline-websocket-server",
outputName: "sherpa-onnx-ws-darwin-x64",
+ diarizeBinaryPath: "sherpa-onnx-offline-speaker-diarization",
+ diarizeOutputName: "sherpa-onnx-diarize-darwin-x64",
libPattern: "*.dylib",
},
"win32-x64": {
archiveName: `sherpa-onnx-v${SHERPA_ONNX_VERSION}-win-x64-shared.tar.bz2`,
binaryPath: "sherpa-onnx-offline-websocket-server.exe",
outputName: "sherpa-onnx-ws-win32-x64.exe",
+ diarizeBinaryPath: "sherpa-onnx-offline-speaker-diarization.exe",
+ diarizeOutputName: "sherpa-onnx-diarize-win32-x64.exe",
libPattern: "*.dll",
},
"linux-x64": {
archiveName: `sherpa-onnx-v${SHERPA_ONNX_VERSION}-linux-x64-shared.tar.bz2`,
binaryPath: "sherpa-onnx-offline-websocket-server",
outputName: "sherpa-onnx-ws-linux-x64",
+ diarizeBinaryPath: "sherpa-onnx-offline-speaker-diarization",
+ diarizeOutputName: "sherpa-onnx-diarize-linux-x64",
libPattern: "*.so*",
},
};
@@ -100,8 +107,9 @@ async function downloadBinary(platformArch, config, isForce = false) {
}
const outputPath = path.join(BIN_DIR, config.outputName);
+ const diarizeOutputPath = path.join(BIN_DIR, config.diarizeOutputName);
- if (fs.existsSync(outputPath) && !isForce) {
+ if (fs.existsSync(outputPath) && fs.existsSync(diarizeOutputPath) && !isForce) {
console.log(` ${platformArch}: Already exists (use --force to re-download)`);
return true;
}
@@ -118,7 +126,7 @@ async function downloadBinary(platformArch, config, isForce = false) {
fs.mkdirSync(extractDir, { recursive: true });
extractTarBz2(archivePath, extractDir);
- // Find the binary (may be in a subdirectory)
+ // Find the WebSocket server binary (may be in a subdirectory)
const binaryName = path.basename(config.binaryPath);
let binaryPath = findBinaryInDir(extractDir, binaryName);
@@ -126,51 +134,64 @@ async function downloadBinary(platformArch, config, isForce = false) {
fs.copyFileSync(binaryPath, outputPath);
setExecutable(outputPath);
console.log(` ${platformArch}: Extracted to ${config.outputName}`);
+ } else {
+ console.error(` ${platformArch}: Binary '${binaryName}' not found in archive`);
+ return false;
+ }
- // Copy shared libraries
- if (config.libPattern) {
- const libraries = findLibrariesInDir(extractDir, config.libPattern);
+ // Find the diarization binary from the same archive
+ const diarizeBinaryName = path.basename(config.diarizeBinaryPath);
+ let diarizeBinaryPath = findBinaryInDir(extractDir, diarizeBinaryName);
- // Separate versioned and unversioned libraries to create symlinks where possible
- // e.g. libonnxruntime.dylib -> libonnxruntime.1.23.2.dylib (saves ~71MB)
- const versionedLibs = new Map(); // base name -> versioned file name
+ if (diarizeBinaryPath && fs.existsSync(diarizeBinaryPath)) {
+ fs.copyFileSync(diarizeBinaryPath, diarizeOutputPath);
+ setExecutable(diarizeOutputPath);
+ console.log(` ${platformArch}: Extracted to ${config.diarizeOutputName}`);
+ } else {
+ console.error(` ${platformArch}: Diarization binary '${diarizeBinaryName}' not found in archive`);
+ return false;
+ }
- for (const libPath of libraries) {
- const libName = path.basename(libPath);
- const destPath = path.join(BIN_DIR, libName);
+ // Copy shared libraries
+ if (config.libPattern) {
+ const libraries = findLibrariesInDir(extractDir, config.libPattern);
- // Detect versioned dylib pattern: libFoo.X.Y.Z.dylib
- const versionMatch = libName.match(/^(lib.+?)\.(\d+\.\d+\.\d+)\.(dylib|so|dll)$/);
- if (versionMatch) {
- const baseName = `${versionMatch[1]}.${versionMatch[3]}`; // e.g. libonnxruntime.dylib
- versionedLibs.set(baseName, libName);
- }
+ // Separate versioned and unversioned libraries to create symlinks where possible
+ // e.g. libonnxruntime.dylib -> libonnxruntime.1.23.2.dylib (saves ~71MB)
+ const versionedLibs = new Map(); // base name -> versioned file name
- fs.copyFileSync(libPath, destPath);
- setExecutable(destPath);
- console.log(` ${platformArch}: Copied library ${libName}`);
+ for (const libPath of libraries) {
+ const libName = path.basename(libPath);
+ const destPath = path.join(BIN_DIR, libName);
+
+ // Detect versioned dylib pattern: libFoo.X.Y.Z.dylib
+ const versionMatch = libName.match(/^(lib.+?)\.(\d+\.\d+\.\d+)\.(dylib|so|dll)$/);
+ if (versionMatch) {
+ const baseName = `${versionMatch[1]}.${versionMatch[3]}`; // e.g. libonnxruntime.dylib
+ versionedLibs.set(baseName, libName);
}
- // Replace unversioned copies with symlinks to versioned ones (macOS/Linux only)
- if (process.platform !== "win32") {
- for (const [baseName, versionedName] of versionedLibs) {
- const basePath = path.join(BIN_DIR, baseName);
- const versionedPath = path.join(BIN_DIR, versionedName);
- if (
- fs.existsSync(basePath) &&
- fs.existsSync(versionedPath) &&
- !fs.lstatSync(basePath).isSymbolicLink()
- ) {
- fs.unlinkSync(basePath);
- fs.symlinkSync(versionedName, basePath);
- console.log(` ${platformArch}: Symlinked ${baseName} -> ${versionedName}`);
- }
+ fs.copyFileSync(libPath, destPath);
+ setExecutable(destPath);
+ console.log(` ${platformArch}: Copied library ${libName}`);
+ }
+
+ // Replace unversioned copies with symlinks to versioned ones (macOS/Linux only)
+ if (process.platform !== "win32") {
+ for (const [baseName, versionedName] of versionedLibs) {
+ const basePath = path.join(BIN_DIR, baseName);
+ const versionedPath = path.join(BIN_DIR, versionedName);
+ if (
+ fs.existsSync(basePath) &&
+ fs.existsSync(versionedPath) &&
+ !fs.lstatSync(basePath).isSymbolicLink()
+ ) {
+ fs.unlinkSync(basePath);
+ fs.symlinkSync(versionedName, basePath);
+ console.log(` ${platformArch}: Symlinked ${baseName} -> ${versionedName}`);
}
}
}
- } else {
- console.error(` ${platformArch}: Binary '${binaryName}' not found in archive`);
- return false;
}
// Cleanup
@@ -217,7 +238,16 @@ async function main() {
}
if (args.shouldCleanup) {
- cleanupFiles(BIN_DIR, "sherpa-onnx", `sherpa-onnx-ws-${args.platformArch}`);
+ const wsPrefix = `sherpa-onnx-ws-${args.platformArch}`;
+ const diarizePrefix = `sherpa-onnx-diarize-${args.platformArch}`;
+ const files = fs.readdirSync(BIN_DIR).filter((f) => f.startsWith("sherpa-onnx"));
+ files.forEach((file) => {
+ if (!file.startsWith(wsPrefix) && !file.startsWith(diarizePrefix)) {
+ const filePath = path.join(BIN_DIR, file);
+ console.log(`Removing old binary: ${file}`);
+ fs.unlinkSync(filePath);
+ }
+ });
}
} else {
console.log("Downloading binaries for all platforms:");
diff --git a/src/components/SettingsPage.tsx b/src/components/SettingsPage.tsx
index 226621e35..0ad79972e 100644
--- a/src/components/SettingsPage.tsx
+++ b/src/components/SettingsPage.tsx
@@ -398,6 +398,151 @@ function TranscriptionSection({
/>
)}
<GpuDeviceSelector purpose="transcription" />
+ <DiarizationSection />
+ </div>
+ );
+}
+
+function DiarizationSection() {
+ const { t } = useTranslation();
+
+ const [modelsDownloaded, setModelsDownloaded] = useState(false);
+ const [isDownloading, setIsDownloading] = useState(false);
+ const [downloadProgress, setDownloadProgress] = useState(0);
+ const [isChecking, setIsChecking] = useState(true);
+
+ const checkModelStatus = useCallback(async () => {
+ try {
+ const status = await window.electronAPI?.getDiarizationModelStatus?.();
+ if (status) {
+ setModelsDownloaded(status.modelsDownloaded);
+ }
+ } catch {
+ // ignore
+ } finally {
+ setIsChecking(false);
+ }
+ }, []);
+
+ useEffect(() => {
+ checkModelStatus();
+ }, [checkModelStatus]);
+
+ useEffect(() => {
+ const unsubscribe = window.electronAPI?.onDiarizationDownloadProgress?.((data: any) => {
+ if (data.type === "complete") {
+ setIsDownloading(false);
+ setModelsDownloaded(true);
+ setDownloadProgress(100);
+ } else if (data.percentage !== undefined) {
+ setDownloadProgress(Math.round(data.percentage));
+ }
+ });
+ return () => {
+ unsubscribe?.();
+ };
+ }, []);
+
+ const handleDownload = async () => {
+ setIsDownloading(true);
+ setDownloadProgress(0);
+ try {
+ const result = await window.electronAPI?.downloadDiarizationModels?.();
+ if (result?.success) {
+ setModelsDownloaded(true);
+ }
+ } catch {
+ // ignore
+ } finally {
+ setIsDownloading(false);
+ }
+ };
+
+ const handleDelete = async () => {
+ try {
+ await window.electronAPI?.deleteDiarizationModels?.();
+ setModelsDownloaded(false);
+ } catch {
+ // ignore
+ }
+ };
+
+ if (isChecking) return null;
+
+ return (
+ <div>
+ <SectionHeader
+ title={t("settingsPage.transcription.diarization.title")}
+ description={t("settingsPage.transcription.diarization.description")}
+ />
+ <SettingsPanel>
+ {modelsDownloaded ? (
+ <SettingsPanelRow>
+ <SettingsRow
+ label={t("settingsPage.transcription.diarization.modelsReady")}
+ >
+ <div className="flex items-center gap-2">
+ <div className="flex items-center gap-1.5 text-xs text-success">
+ <Check size={14} />
+ <span>{t("settingsPage.transcription.diarization.modelsReady")}</span>
+ </div>
+ <Button
+ variant="ghost"
+ size="sm"
+ className="h-6 w-6 p-0 text-muted-foreground/40 hover:text-destructive"
+ onClick={handleDelete}
+ >
+ <Trash2 size={12} />
+ </Button>
+ </div>
+ </SettingsRow>
+ </SettingsPanelRow>
+ ) : isDownloading ? (
+ <SettingsPanelRow>
+ <div className="space-y-2">
+ <div className="flex items-center justify-between">
+ <span className="text-xs font-medium text-foreground">
+ {t("settingsPage.transcription.diarization.downloading")}
+ </span>
+ <span className="text-xs text-muted-foreground tabular-nums">
+ {downloadProgress}%
+ </span>
+ </div>
+ <div
+ className="w-full rounded-full overflow-hidden bg-white/5 dark:bg-white/3"
+ style={{ height: 4 }}
+ >
+ <div
+ className="bg-primary shadow-[0_0_8px_oklch(0.62_0.22_260/0.4)]"
+ style={{
+ height: "100%",
+ width: `${Math.min(downloadProgress, 100)}%`,
+ borderRadius: 9999,
+ transition: "width 300ms ease-out",
+ }}
+ />
+ </div>
+ </div>
+ </SettingsPanelRow>
+ ) : (
+ <SettingsPanelRow>
+ <SettingsRow
+ label={t("settingsPage.transcription.diarization.toggle")}
+ description={t("settingsPage.transcription.diarization.requiresModels")}
+ >
+ <Button
+ variant="outline"
+ size="sm"
+ className="h-7 text-xs gap-1.5"
+ onClick={handleDownload}
+ >
+ <Download size={12} />
+ {t("settingsPage.transcription.diarization.downloadModelsSize")}
+ </Button>
+ </SettingsRow>
+ </SettingsPanelRow>
+ )}
+ </SettingsPanel>
</div>
);
}
diff --git a/src/components/notes/MeetingTranscriptChat.tsx b/src/components/notes/MeetingTranscriptChat.tsx
index 5eae1dc92..21eaae9bd 100644
--- a/src/components/notes/MeetingTranscriptChat.tsx
+++ b/src/components/notes/MeetingTranscriptChat.tsx
@@ -18,6 +18,36 @@ const BUBBLE_STYLES = {
},
} as const;
+const SPEAKER_COLORS = [
+ "text-blue-400",
+ "text-green-400",
+ "text-purple-400",
+ "text-orange-400",
+ "text-pink-400",
+ "text-cyan-400",
+ "text-yellow-400",
+ "text-red-400",
+];
+
+const SPEAKER_BORDER_COLORS = [
+ "border-l-blue-400/50",
+ "border-l-green-400/50",
+ "border-l-purple-400/50",
+ "border-l-orange-400/50",
+ "border-l-pink-400/50",
+ "border-l-cyan-400/50",
+ "border-l-yellow-400/50",
+ "border-l-red-400/50",
+];
+
+const getSpeakerKey = (segment: TranscriptSegment) =>
+ segment.speaker || segment.source;
+
+const getSpeakerColorIndex = (speaker: string): number => {
+ const match = speaker.match(/speaker_(\d+)/);
+ return match ? Number(match[1]) % SPEAKER_COLORS.length : 0;
+};
+
function PartialBubble({ text, source }: { text: string; source: "mic" | "system" }) {
const s = BUBBLE_STYLES[source];
return (
@@ -87,18 +117,46 @@ export function MeetingTranscriptChat({
{segments.map((segment, i) => {
const isMic = segment.source === "mic";
const prevSegment = i > 0 ? segments[i - 1] : null;
- const sameSpeaker = prevSegment?.source === segment.source;
+ const sameSpeaker = prevSegment
+ ? getSpeakerKey(prevSegment) === getSpeakerKey(segment)
+ : false;
+
+ const hasSpeaker = !!segment.speaker;
+ const isYou = segment.speaker === "you";
+ const isSystemSpeaker = hasSpeaker && !isYou;
+ const colorIdx = isSystemSpeaker ? getSpeakerColorIndex(segment.speaker!) : 0;
+
+ let speakerLabel: string | null = null;
+ if (hasSpeaker && !sameSpeaker) {
+ if (isYou) {
+ speakerLabel = t("notes.speaker.you");
+ } else {
+ const match = segment.speaker!.match(/speaker_(\d+)/);
+ const n = match ? Number(match[1]) + 1 : 1;
+ speakerLabel = t("notes.speaker.label", { n });
+ }
+ }
return (
<div
key={segment.id}
className={cn(
- "flex",
- isMic ? "justify-start" : "justify-end",
+ "flex flex-col",
+ isMic ? "items-start" : "items-end",
!sameSpeaker && i > 0 && "mt-2"
)}
style={{ animation: "agent-message-in 200ms ease-out both" }}
>
+ {speakerLabel && (
+ <span
+ className={cn(
+ "text-[11px] font-medium mb-0.5 px-1",
+ isYou ? "text-primary/60" : SPEAKER_COLORS[colorIdx]
+ )}
+ >
+ {speakerLabel}
+ </span>
+ )}
<div
className={cn(
"max-w-[80%] px-3 py-1.5",
@@ -110,7 +168,8 @@ export function MeetingTranscriptChat({
)
: cn(
"bg-surface-2 border border-border/30 text-foreground",
- sameSpeaker ? "rounded-lg rounded-tr-sm" : "rounded-lg rounded-br-sm"
+ sameSpeaker ? "rounded-lg rounded-tr-sm" : "rounded-lg rounded-br-sm",
+ isSystemSpeaker && cn("border-l-2", SPEAKER_BORDER_COLORS[colorIdx])
)
)}
>
diff --git a/src/components/notes/NoteEditor.tsx b/src/components/notes/NoteEditor.tsx
index db3f1c6d4..9793cd9ec 100644
--- a/src/components/notes/NoteEditor.tsx
+++ b/src/components/notes/NoteEditor.tsx
@@ -124,6 +124,8 @@ export default function NoteEditor({
const [folderSearch, setFolderSearch] = useState("");
const [isCreatingFolder, setIsCreatingFolder] = useState(false);
const [newFolderName, setNewFolderName] = useState("");
+ const [isDiarizing, setIsDiarizing] = useState(false);
+ const [diarizedSegments, setDiarizedSegments] = useState<TranscriptSegment[] | null>(null);
const editorRef = useRef<Editor | null>(null);
const embeddedChat = useEmbeddedChat({
@@ -152,9 +154,10 @@ export default function NoteEditor({
);
const displaySegments = useMemo<TranscriptSegment[]>(() => {
+ if (diarizedSegments && diarizedSegments.length > 0) return diarizedSegments;
if (meetingSegments && meetingSegments.length > 0) return meetingSegments;
return parseTranscriptSegments(note.transcript || "");
- }, [meetingSegments, note.transcript]);
+ }, [diarizedSegments, meetingSegments, note.transcript]);
const hasChatSegments = displaySegments.length > 0;
@@ -207,6 +210,8 @@ export default function NoteEditor({
prevNoteIdRef.current = note.id;
autoShowDoneRef.current = false;
setChatMode("hidden");
+ setDiarizedSegments(null);
+ setIsDiarizing(false);
if (!isMeetingRecording) {
setViewMode("raw");
}
@@ -235,6 +240,52 @@ export default function NoteEditor({
}
}, [note.title]);
+ // Track meeting recording stop to activate diarization loading state
+ const prevMeetingRecordingRef = useRef(false);
+ const diarizationNoteIdRef = useRef<number | null>(null);
+ useEffect(() => {
+ if (prevMeetingRecordingRef.current && !isMeetingRecording) {
+ diarizationNoteIdRef.current = note.id;
+ setIsDiarizing(true);
+ }
+ prevMeetingRecordingRef.current = !!isMeetingRecording;
+ }, [isMeetingRecording, note.id]);
+
+ // Listen for diarization results from main process
+ useEffect(() => {
+ const cleanup = window.electronAPI?.onMeetingDiarizationComplete?.((data) => {
+ // Ignore if user navigated away from the recording note
+ if (diarizationNoteIdRef.current !== note.id) {
+ setIsDiarizing(false);
+ diarizationNoteIdRef.current = null;
+ return;
+ }
+
+ diarizationNoteIdRef.current = null;
+ setIsDiarizing(false);
+
+ if (!data?.segments?.length) return;
+
+ const enriched = data.segments.map((s: any, i: number) => ({
+ ...s,
+ id: s.id || `diarized-${i}`,
+ }));
+ setDiarizedSegments(enriched);
+
+ // Persist enriched transcript to the note
+ const serialized = JSON.stringify(
+ enriched.map((s: TranscriptSegment) => ({
+ text: s.text,
+ source: s.source,
+ timestamp: s.timestamp,
+ speaker: s.speaker,
+ }))
+ );
+ window.electronAPI.updateNote(note.id, { transcript: serialized });
+ });
+ return () => cleanup?.();
+ }, [note.id]);
+
const handleTitleInput = useCallback(() => {
if (titleRef.current) {
const text = titleRef.current.textContent || "";
@@ -539,11 +590,21 @@ export default function NoteEditor({
<div className="flex-1 relative min-h-0">
<div className="h-full overflow-y-auto">
{viewMode === "transcript" && (hasChatSegments || isMeetingRecording) ? (
- <MeetingTranscriptChat
- segments={displaySegments}
- micPartial={isMeetingRecording ? meetingMicPartial : undefined}
- systemPartial={isMeetingRecording ? meetingSystemPartial : undefined}
- />
+ <>
+ <MeetingTranscriptChat
+ segments={displaySegments}
+ micPartial={isMeetingRecording ? meetingMicPartial : undefined}
+ systemPartial={isMeetingRecording ? meetingSystemPartial : undefined}
+ />
+ {isDiarizing && (
+ <div className="flex items-center justify-center gap-1.5 py-2">
+ <Loader2 size={10} className="animate-spin text-foreground/30" />
+ <span className="text-[11px] text-foreground/30">
+ {t("notes.speaker.identifyingSpeakers")}
+ </span>
+ </div>
+ )}
+ </>
) : viewMode === "transcript" && hasMeetingTranscript ? (
<RichTextEditor value={effectiveTranscript} disabled />
) : viewMode === "enhanced" && enhancement ? (
diff --git a/src/helpers/diarization.js b/src/helpers/diarization.js
new file mode 100644
index 000000000..59f40d948
--- /dev/null
+++ b/src/helpers/diarization.js
@@ -0,0 +1,454 @@
+const fs = require("fs");
+const fsPromises = require("fs").promises;
+const path = require("path");
+const { spawn } = require("child_process");
+const debugLogger = require("./debugLogger");
+const { downloadFile, createDownloadSignal, checkDiskSpace } = require("./downloadUtils");
+const { resolveBinaryPath, gracefulStopProcess } = require("../utils/serverUtils");
+const { getModelsDirForService } = require("./modelDirUtils");
+const { convertToWav } = require("./ffmpegUtils");
+const { getSafeTempDir } = require("./safeTempDir");
+
+const DIARIZATION_TIMEOUT_MS = 300000; // 5 minutes
+
+const SEGMENTATION_MODEL_URL =
+ "https://github.com/k2-fsa/sherpa-onnx/releases/download/speaker-segmentation-models/sherpa-onnx-pyannote-segmentation-3-0.tar.bz2";
+const EMBEDDING_MODEL_URL =
+ "https://github.com/k2-fsa/sherpa-onnx/releases/download/speaker-recongition-models/3dspeaker_speech_campplus_sv_en_voxceleb_16k.onnx";
+
+const SEGMENTATION_DIR = "sherpa-onnx-pyannote-segmentation-3-0";
+const SEGMENTATION_ONNX = path.join(SEGMENTATION_DIR, "model.onnx");
+const EMBEDDING_ONNX = "3dspeaker_speech_campplus_sv_en_voxceleb_16k.onnx";
+
+class DiarizationManager {
+ constructor() {
+ this._process = null;
+ this.currentDownloadProcess = null;
+ this.cachedBinaryPath = null;
+ }
+
+ getBinaryPath() {
+ if (this.cachedBinaryPath) return this.cachedBinaryPath;
+
+ const platformArch = `${process.platform}-${process.arch}`;
+ const binaryName =
+ process.platform === "win32"
+ ? `sherpa-onnx-diarize-${platformArch}.exe`
+ : `sherpa-onnx-diarize-${platformArch}`;
+
+ const resolved = resolveBinaryPath(binaryName);
+ if (resolved) this.cachedBinaryPath = resolved;
+ return resolved;
+ }
+
+ isAvailable() {
+ return this.getBinaryPath() !== null && this.isModelDownloaded();
+ }
+
+ getModelsDir() {
+ return getModelsDirForService("diarization");
+ }
+
+ isModelDownloaded() {
+ const modelsDir = this.getModelsDir();
+ const segPath = path.join(modelsDir, SEGMENTATION_ONNX);
+ const embPath = path.join(modelsDir, EMBEDDING_ONNX);
+ return fs.existsSync(segPath) && fs.existsSync(embPath);
+ }
+
+ async downloadModels(progressCallback = null) {
+ const modelsDir = this.getModelsDir();
+ await fsPromises.mkdir(modelsDir, { recursive: true });
+
+ if (this.isModelDownloaded()) {
+ return { success: true, path: modelsDir };
+ }
+
+ const requiredBytes = 35 * 1_000_000; // ~35MB total
+ const spaceCheck = await checkDiskSpace(modelsDir, requiredBytes * 2.5);
+ if (!spaceCheck.ok) {
+ throw new Error(
+ `Not enough disk space. Need ~${Math.round((requiredBytes * 2.5) / 1_000_000)}MB, ` +
+ `only ${Math.round(spaceCheck.availableBytes / 1_000_000)}MB available.`
+ );
+ }
+
+ const { signal, abort } = createDownloadSignal();
+ this.currentDownloadProcess = { abort };
+
+ try {
+ // Download segmentation model (tar.bz2)
+ const segArchivePath = path.join(modelsDir, `${SEGMENTATION_DIR}.tar.bz2`);
+ const segModelPath = path.join(modelsDir, SEGMENTATION_ONNX);
+
+ if (!fs.existsSync(segModelPath)) {
+ await downloadFile(SEGMENTATION_MODEL_URL, segArchivePath, {
+ timeout: 600000,
+ signal,
+ onProgress: (downloadedBytes, totalBytes) => {
+ if (progressCallback) {
+ progressCallback({
+ type: "progress",
+ stage: "segmentation",
+ downloaded_bytes: downloadedBytes,
+ total_bytes: totalBytes,
+ percentage: totalBytes > 0 ? Math.round((downloadedBytes / totalBytes) * 100) : 0,
+ });
+ }
+ },
+ });
+
+ // Extract tar.bz2
+ if (progressCallback) {
+ progressCallback({ type: "progress", stage: "extracting", percentage: 100 });
+ }
+
+ await this._extractTarBz2(segArchivePath, modelsDir);
+ await fsPromises.unlink(segArchivePath).catch(() => {});
+
+ if (!fs.existsSync(segModelPath)) {
+ throw new Error("Segmentation model extraction failed: model.onnx not found");
+ }
+ }
+
+ // Download embedding model (.onnx directly)
+ const embModelPath = path.join(modelsDir, EMBEDDING_ONNX);
+
+ if (!fs.existsSync(embModelPath)) {
+ await downloadFile(EMBEDDING_MODEL_URL, embModelPath, {
+ timeout: 600000,
+ signal,
+ onProgress: (downloadedBytes, totalBytes) => {
+ if (progressCallback) {
+ progressCallback({
+ type: "progress",
+ stage: "embedding",
+ downloaded_bytes: downloadedBytes,
+ total_bytes: totalBytes,
+ percentage: totalBytes > 0 ? Math.round((downloadedBytes / totalBytes) * 100) : 0,
+ });
+ }
+ },
+ });
+ }
+
+ if (progressCallback) {
+ progressCallback({ type: "complete", percentage: 100 });
+ }
+
+ debugLogger.info("Diarization models downloaded", { modelsDir });
+ return { success: true, path: modelsDir };
+ } catch (error) {
+ if (error.isAbort) {
+ throw new Error("Download interrupted by user");
+ }
+ if (progressCallback) {
+ progressCallback({ type: "error", error: error.message });
+ }
+ throw error;
+ } finally {
+ this.currentDownloadProcess = null;
+ }
+ }
+
+ async _extractTarBz2(archivePath, destDir) {
+ try {
+ await this._runSystemTar(archivePath, destDir);
+ return;
+ } catch (err) {
+ debugLogger.debug("System tar failed, falling back to JS extraction", {
+ error: err.message,
+ });
+ }
+
+ const unbzip2 = require("unbzip2-stream");
+ const tar = require("tar");
+ const { pipeline } = require("stream/promises");
+ await pipeline(fs.createReadStream(archivePath), unbzip2(), tar.x({ cwd: destDir }));
+ }
+
+ _runSystemTar(archivePath, destDir) {
+ return new Promise((resolve, reject) => {
+ // Use relative paths from archive dir as cwd so neither -f nor -C args
+ // contain Windows drive letter colons (GNU tar treats C: as remote host)
+ const cwd = path.dirname(archivePath);
+ const tarProcess = spawn(
+ "tar",
+ ["-xjf", path.basename(archivePath), "-C", path.relative(cwd, destDir)],
+ { stdio: ["ignore", "pipe", "pipe"], cwd }
+ );
+
+ let stderr = "";
+
+ tarProcess.stderr.on("data", (data) => {
+ stderr += data.toString();
+ });
+
+ tarProcess.on("close", (code) => {
+ if (code === 0) {
+ resolve();
+ } else {
+ reject(new Error(`tar extraction failed with code ${code}: ${stderr}`));
+ }
+ });
+
+ tarProcess.on("error", (err) => {
+ reject(new Error(`Failed to start tar process: ${err.message}`));
+ });
+ });
+ }
+
+ async cancelDownload() {
+ if (this.currentDownloadProcess) {
+ this.currentDownloadProcess.abort();
+ this.currentDownloadProcess = null;
+ return { success: true, message: "Download cancelled" };
+ }
+ return { success: false, error: "No active download to cancel" };
+ }
+
+ async diarize(wavPath, options = {}) {
+ const { numSpeakers = -1, threshold = 0.5 } = options;
+
+ const binaryPath = this.getBinaryPath();
+ if (!binaryPath) {
+ debugLogger.warn("Diarization binary not found");
+ return [];
+ }
+
+ if (!this.isModelDownloaded()) {
+ debugLogger.warn("Diarization models not downloaded");
+ return [];
+ }
+
+ if (!fs.existsSync(wavPath)) {
+ debugLogger.warn("Diarization input file not found", { wavPath });
+ return [];
+ }
+
+ const modelsDir = this.getModelsDir();
+ const segPath = path.join(modelsDir, SEGMENTATION_ONNX);
+ const embPath = path.join(modelsDir, EMBEDDING_ONNX);
+
+ const args = [
+ `--segmentation.pyannote-model=${segPath}`,
+ `--embedding.model=${embPath}`,
+ `--clustering.num-clusters=${numSpeakers}`,
+ `--clustering.cluster-threshold=${threshold}`,
+ "--min-duration-on=0.2",
+ "--min-duration-off=0.5",
+ wavPath,
+ ];
+
+ debugLogger.info("Starting diarization", {
+ binaryPath,
+ numSpeakers,
+ threshold,
+ wavPath,
+ });
+
+ return new Promise((resolve) => {
+ let stdout = "";
+ let stderr = "";
+
+ const proc = spawn(binaryPath, args, {
+ stdio: ["ignore", "pipe", "pipe"],
+ windowsHide: true,
+ });
+
+ this._process = proc;
+
+ const timeout = setTimeout(() => {
+ debugLogger.warn("Diarization timed out", { timeoutMs: DIARIZATION_TIMEOUT_MS });
+ gracefulStopProcess(proc);
+ this._process = null;
+ resolve([]);
+ }, DIARIZATION_TIMEOUT_MS);
+
+ proc.stdout.on("data", (data) => {
+ stdout += data.toString();
+ });
+
+ proc.stderr.on("data", (data) => {
+ stderr += data.toString();
+ });
+
+ proc.on("close", (code) => {
+ clearTimeout(timeout);
+ this._process = null;
+
+ if (code !== 0) {
+ debugLogger.warn("Diarization process exited with error", {
+ code,
+ stderr: stderr.slice(-500).trim(),
+ });
+ resolve([]);
+ return;
+ }
+
+ const segments = this._parseOutput(stdout);
+ debugLogger.info("Diarization complete", { segmentCount: segments.length });
+ resolve(segments);
+ });
+
+ proc.on("error", (err) => {
+ clearTimeout(timeout);
+ this._process = null;
+ debugLogger.warn("Diarization process error", { error: err.message });
+ resolve([]);
+ });
+ });
+ }
+
+ _parseOutput(stdout) {
+ const segments = [];
+ const lineRegex = /^(\d+\.?\d*)\s+--\s+(\d+\.?\d*)\s+(speaker_\d+)$/;
+
+ for (const line of stdout.split("\n")) {
+ const trimmed = line.trim();
+ if (!trimmed) continue;
+ const match = trimmed.match(lineRegex);
+ if (match) {
+ segments.push({
+ start: parseFloat(match[1]),
+ end: parseFloat(match[2]),
+ speaker: match[3],
+ });
+ }
+ }
+
+ return segments;
+ }
+
+ mergeWithTranscript(transcriptSegments, diarizationSegments) {
+ if (!transcriptSegments || transcriptSegments.length === 0) return [];
+ if (!diarizationSegments || diarizationSegments.length === 0) {
+ return transcriptSegments.map((seg) => ({ ...seg }));
+ }
+
+ // Build speaker renumbering map (e.g., speaker_00 → speaker_0)
+ const speakerSet = new Set(diarizationSegments.map((d) => d.speaker));
+ const speakerMap = new Map();
+ let idx = 0;
+ for (const sp of speakerSet) {
+ speakerMap.set(sp, `speaker_${idx}`);
+ idx++;
+ }
+
+ return transcriptSegments.map((seg) => {
+ const enriched = { ...seg };
+
+ if (seg.source === "mic") {
+ enriched.speaker = "you";
+ return enriched;
+ }
+
+ if (seg.source === "system" && seg.timestamp != null) {
+ const ts = seg.timestamp;
+ let bestSpeaker = null;
+ let bestOverlap = 0;
+
+ for (const dSeg of diarizationSegments) {
+ if (ts >= dSeg.start && ts <= dSeg.end) {
+ const overlap = dSeg.end - dSeg.start;
+ if (overlap > bestOverlap) {
+ bestOverlap = overlap;
+ bestSpeaker = dSeg.speaker;
+ }
+ }
+ }
+
+ if (bestSpeaker) {
+ enriched.speaker = speakerMap.get(bestSpeaker) || bestSpeaker;
+ }
+ }
+
+ return enriched;
+ });
+ }
+
+ async convertRawPcmToWav(rawPcmPath, inputSampleRate) {
+ const stat = await fsPromises.stat(rawPcmPath);
+ if (stat.size === 0) {
+ throw new Error("Raw PCM file is empty");
+ }
+
+ const tempDir = getSafeTempDir();
+ const timestamp = Date.now();
+ const inputWavPath = path.join(tempDir, `ow-diarize-${timestamp}-input.wav`);
+ const wavPath = path.join(tempDir, `ow-diarize-${timestamp}.wav`);
+
+ // Stream: write 44-byte WAV header, then pipe raw PCM — avoids loading entire file into memory
+ const header = this._createWavHeader(stat.size, inputSampleRate, 1);
+ await new Promise((resolve, reject) => {
+ const out = fs.createWriteStream(inputWavPath);
+ out.write(header);
+ const pcmStream = fs.createReadStream(rawPcmPath);
+ pcmStream.pipe(out);
+ out.on("finish", resolve);
+ out.on("error", reject);
+ pcmStream.on("error", reject);
+ });
+
+ try {
+ await convertToWav(inputWavPath, wavPath, { sampleRate: 16000, channels: 1 });
+ } finally {
+ await fsPromises.unlink(inputWavPath).catch(() => {});
+ }
+
+ debugLogger.debug("Raw PCM converted to WAV for diarization", {
+ wavPath,
+ rawPcmBytes: stat.size,
+ });
+
+ return wavPath;
+ }
+
+ _createWavHeader(dataSize, sampleRate, channels) {
+ const bytesPerSample = 2;
+ const blockAlign = channels * bytesPerSample;
+ const byteRate = sampleRate * blockAlign;
+ const header = Buffer.alloc(44);
+
+ header.write("RIFF", 0);
+ header.writeUInt32LE(36 + dataSize, 4);
+ header.write("WAVE", 8);
+ header.write("fmt ", 12);
+ header.writeUInt32LE(16, 16);
+ header.writeUInt16LE(1, 20);
+ header.writeUInt16LE(channels, 22);
+ header.writeUInt32LE(sampleRate, 24);
+ header.writeUInt32LE(byteRate, 28);
+ header.writeUInt16LE(blockAlign, 32);
+ header.writeUInt16LE(bytesPerSample * 8, 34);
+ header.write("data", 36);
+ header.writeUInt32LE(dataSize, 40);
+
+ return header;
+ }
+
+ async deleteModels() {
+ const modelsDir = this.getModelsDir();
+ const segDir = path.join(modelsDir, SEGMENTATION_DIR);
+ const embPath = path.join(modelsDir, EMBEDDING_ONNX);
+
+ if (fs.existsSync(segDir)) {
+ await fsPromises.rm(segDir, { recursive: true, force: true });
+ }
+ if (fs.existsSync(embPath)) {
+ await fsPromises.unlink(embPath);
+ }
+
+ debugLogger.info("Diarization models deleted", { modelsDir });
+ return { success: true };
+ }
+
+ async shutdown() {
+ if (this._process) {
+ await gracefulStopProcess(this._process);
+ this._process = null;
+ }
+ }
+}
+
+module.exports = DiarizationManager;
diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.js
index 4bd0cb29b..c4ff7836a 100644
--- a/src/helpers/ipcHandlers.js
+++ b/src/helpers/ipcHandlers.js
@@ -95,6 +95,7 @@ class IPCHandlers {
this.clipboardManager = managers.clipboardManager;
this.whisperManager = managers.whisperManager;
this.parakeetManager = managers.parakeetManager;
+ this.diarizationManager = managers.diarizationManager;
this.windowManager = managers.windowManager;
this.updateManager = managers.updateManager;
this.windowsKeyManager = managers.windowsKeyManager;
@@ -1461,6 +1462,52 @@ class IPCHandlers {
return this.parakeetManager.getServerStatus();
});
+ // Diarization model management
+ ipcMain.handle("download-diarization-models", async (event) => {
+ try {
+ const result = await this.diarizationManager.downloadModels((progressData) => {
+ if (!event.sender.isDestroyed()) {
+ event.sender.send("diarization-download-progress", progressData);
+ }
+ });
+ return result;
+ } catch (error) {
+ if (!event.sender.isDestroyed()) {
+ event.sender.send("diarization-download-progress", {
+ type: "error",
+ error: error.message,
+ code: error.code || "DOWNLOAD_FAILED",
+ });
+ }
+ return {
+ success: false,
+ error: error.message,
+ code: error.code || "DOWNLOAD_FAILED",
+ };
+ }
+ });
+
+ ipcMain.handle("get-diarization-model-status", async () => {
+ return {
+ available: this.diarizationManager?.isAvailable() ?? false,
+ modelsDownloaded: this.diarizationManager?.isModelDownloaded() ?? false,
+ };
+ });
+
+ ipcMain.handle("delete-diarization-models", async () => {
+ try {
+ await this.diarizationManager.deleteModels();
+ return { success: true };
+ } catch (error) {
+ debugLogger.error("Failed to delete diarization models", { error: error.message });
+ return { success: false, error: error.message };
+ }
+ });
+
+ ipcMain.handle("cancel-diarization-download", async () => {
+ return this.diarizationManager.cancelDownload();
+ });
+
ipcMain.handle("cleanup-app", async (event) => {
const fs = require("fs");
const os = require("os");
@@ -2778,6 +2825,7 @@ class IPCHandlers {
text: latestSegment.slice(0, 80),
segmentCount: segments.length,
});
+ meetingDiarizationSegments.push({ text: latestSegment, source, timestamp });
send("meeting-transcription-segment", {
text: latestSegment,
source,
@@ -2922,6 +2970,10 @@ class IPCHandlers {
return Buffer.concat([header, pcmBuffer]);
};
+ let meetingDiarizationStream = null; // WriteStream for system audio PCM (disk spooling)
+ let meetingDiarizationPath = null; // temp file path for spooled PCM
+ let meetingDiarizationSegments = []; // final transcript segments for post-recording speaker merge
+
let meetingLocalMode = false;
let meetingLocalBuffers = { mic: [], system: [] };
let meetingLocalTimer = null;
@@ -2968,12 +3020,15 @@ class IPCHandlers {
const text = result.text.trim();
meetingLocalTranscript += (meetingLocalTranscript ? " " : "") + text;
+ const segTimestamp = Date.now();
+ meetingDiarizationSegments.push({ text, source, timestamp: segTimestamp });
+
if (meetingLocalWin && !meetingLocalWin.isDestroyed()) {
meetingLocalWin.webContents.send("meeting-transcription-segment", {
text,
source,
type: "final",
- timestamp: Date.now(),
+ timestamp: segTimestamp,
});
}
}
@@ -3006,6 +3061,15 @@ class IPCHandlers {
}
meetingLocalMode = false;
meetingLocalBuffers = { mic: [], system: [] };
+ if (meetingDiarizationStream) {
+ meetingDiarizationStream.end();
+ meetingDiarizationStream = null;
+ }
+ if (meetingDiarizationPath) {
+ fs.unlink(meetingDiarizationPath, () => {});
+ meetingDiarizationPath = null;
+ }
+ meetingDiarizationSegments = [];
meetingLocalWin = null;
meetingLocalTranscript = "";
meetingLocalProvider = null;
@@ -3176,6 +3240,17 @@ class IPCHandlers {
});
const sendMeetingAudio = (audioBuffer, source) => {
+ if (source === "system") {
+ if (!meetingDiarizationStream) {
+ const os = require("os");
+ meetingDiarizationPath = path.join(os.tmpdir(), `ow-diarize-raw-${Date.now()}.pcm`);
+ meetingDiarizationStream = fs.createWriteStream(meetingDiarizationPath);
+ }
+ meetingDiarizationStream.write(
+ Buffer.isBuffer(audioBuffer) ? audioBuffer : Buffer.from(audioBuffer)
+ );
+ }
+
if (meetingLocalMode) {
const buf = Buffer.isBuffer(audioBuffer) ? audioBuffer : Buffer.from(audioBuffer);
meetingLocalBuffers[source].push(buf);
@@ -3228,6 +3303,17 @@ class IPCHandlers {
await this.audioTapManager.stop();
}
+ // Capture diarization state before any reset
+ const diarizationPcmPath = meetingDiarizationPath;
+ const diarizationSegments = meetingDiarizationSegments;
+ if (meetingDiarizationStream) {
+ await new Promise((resolve) => meetingDiarizationStream.end(resolve));
+ meetingDiarizationStream = null;
+ }
+ meetingDiarizationPath = null;
+ meetingDiarizationSegments = [];
+ const diarizationWin = meetingLocalWin || this.windowManager.controlPanelWindow;
+
if (meetingLocalMode) {
if (meetingLocalTimer) {
clearInterval(meetingLocalTimer);
@@ -3240,14 +3326,22 @@ class IPCHandlers {
}
const transcript = meetingLocalTranscript;
resetMeetingLocalState();
+
+ // Fire-and-forget background diarization (or notify skip)
+ this._startOrSkipDiarization(diarizationPcmPath, diarizationSegments, diarizationWin);
+
return { success: true, transcript };
}
const results = await disconnectMeetingStreaming();
+ const transcript = [results[0]?.text, results[1]?.text].filter(Boolean).join(" ");
+
+ // Fire-and-forget background diarization (or notify skip)
+ this._startOrSkipDiarization(diarizationPcmPath, diarizationSegments, diarizationWin);
return {
success: true,
- transcript: [results[0]?.text, results[1]?.text].filter(Boolean).join(" "),
+ transcript,
};
} catch (error) {
debugLogger.error("Meeting transcription stop error", { error: error.message });
@@ -4994,6 +5088,60 @@ class IPCHandlers {
});
}
+ _startOrSkipDiarization(rawPcmPath, transcriptSegments, win) {
+ const canRun = this.diarizationManager?.isAvailable() && rawPcmPath;
+
+ if (!canRun) {
+ if (win && !win.isDestroyed()) {
+ win.webContents.send("meeting-diarization-complete", { segments: [] });
+ }
+ return;
+ }
+
+ const fs = require("fs");
+
+ (async () => {
+ let tmpWav = null;
+ try {
+ tmpWav = await this.diarizationManager.convertRawPcmToWav(rawPcmPath, 24000);
+
+ const diarizationSegments = await this.diarizationManager.diarize(tmpWav);
+
+ const startMs = transcriptSegments[0]?.timestamp || 0;
+ const isEpochMs = startMs > 1e9;
+ const normalized = transcriptSegments.map((seg) => ({
+ ...seg,
+ timestamp:
+ seg.timestamp != null
+ ? isEpochMs
+ ? (seg.timestamp - startMs) / 1000
+ : seg.timestamp
+ : undefined,
+ }));
+
+ const enrichedSegments = this.diarizationManager.mergeWithTranscript(
+ normalized,
+ diarizationSegments
+ );
+
+ if (win && !win.isDestroyed()) {
+ win.webContents.send("meeting-diarization-complete", { segments: enrichedSegments });
+ }
+ } catch (err) {
+ debugLogger.warn("Background diarization failed", { error: err.message });
+ if (win && !win.isDestroyed()) {
+ win.webContents.send("meeting-diarization-complete", { segments: [] });
+ }
+ } finally {
+ // Clean up both the raw PCM spool file and the converted WAV
+ try { fs.unlinkSync(rawPcmPath); } catch (_) {}
+ if (tmpWav) {
+ try { fs.unlinkSync(tmpWav); } catch (_) {}
+ }
+ }
+ })();
+ }
+
broadcastToWindows(channel, payload) {
const windows = BrowserWindow.getAllWindows();
windows.forEach((win) => {
diff --git a/src/hooks/useMeetingTranscription.ts b/src/hooks/useMeetingTranscription.ts
index 719e3466b..dcce4810c 100644
--- a/src/hooks/useMeetingTranscription.ts
+++ b/src/hooks/useMeetingTranscription.ts
@@ -8,6 +8,7 @@ export interface TranscriptSegment {
text: string;
source: "mic" | "system";
timestamp?: number;
+ speaker?: string;
}
interface UseMeetingTranscriptionReturn {
diff --git a/src/locales/de/translation.json b/src/locales/de/translation.json
index af3dd25ce..5888c6ef1 100644
--- a/src/locales/de/translation.json
+++ b/src/locales/de/translation.json
@@ -1398,6 +1398,17 @@
"gpuDevice": {
"title": "Transkriptions-GPU",
"description": "GPU für lokale Spracherkennung"
+ },
+ "diarization": {
+ "title": "Speaker Identification",
+ "description": "Identify individual speakers in meeting recordings",
+ "toggle": "Identify speakers in meetings",
+ "downloadModels": "Download Models",
+ "downloadModelsSize": "Download Models (~35 MB)",
+ "modelsReady": "Models Ready",
+ "downloading": "Downloading...",
+ "deleteModels": "Delete Models",
+ "requiresModels": "Download speaker identification models to enable this feature"
}
},
"intelligence": {
@@ -1477,6 +1488,10 @@
"gemma_gemma_4_e2b_it_q4_k_m": "Kompaktes Gemma 4 von Google, schnell und effizient",
"gemma_gemma_3_12b_it_q4_k_m": "Googles Mittelklasse-Modell, starkes Reasoning",
"gemma_gemma_3_1b_it_q4_k_m": "Ultraschnelles Google-Modell, ideal für kurze Diktat-Bereinigung"
+ },
+ "diarization": {
+ "segmentation": "Speech boundary detection for speaker diarization",
+ "embedding_en": "Speaker voice fingerprinting for identification"
}
}
},
@@ -1742,7 +1757,10 @@
},
"speaker": {
"you": "Du",
- "them": "Gegenüber"
+ "them": "Gegenüber",
+ "label": "Sprecher {{n}}",
+ "identifyingSpeakers": "Sprecher werden identifiziert...",
+ "speakersIdentified": "Speakers identified"
}
},
"dictionary": {
diff --git a/src/locales/en/translation.json b/src/locales/en/translation.json
index 3c4727925..60588d36e 100644
--- a/src/locales/en/translation.json
+++ b/src/locales/en/translation.json
@@ -1446,6 +1446,17 @@
"gpuDevice": {
"title": "Transcription GPU",
"description": "GPU used for local speech-to-text"
+ },
+ "diarization": {
+ "title": "Speaker Identification",
+ "description": "Identify individual speakers in meeting recordings",
+ "toggle": "Identify speakers in meetings",
+ "downloadModels": "Download Models",
+ "downloadModelsSize": "Download Models (~35 MB)",
+ "modelsReady": "Models Ready",
+ "downloading": "Downloading...",
+ "deleteModels": "Delete Models",
+ "requiresModels": "Download speaker identification models to enable this feature"
}
},
"intelligence": {
@@ -1460,6 +1471,10 @@
"parakeet": {
"parakeet_tdt_0_6b_v3": "Fast multilingual ASR with auto language detection (25 languages)"
},
+ "diarization": {
+ "segmentation": "Speech boundary detection for speaker diarization",
+ "embedding_en": "Speaker voice fingerprinting for identification"
+ },
"whisper": {
"tiny": "Fastest, lower quality",
"base": "Good balance",
@@ -1851,7 +1866,10 @@
},
"speaker": {
"you": "You",
- "them": "Them"
+ "them": "Them",
+ "label": "Speaker {{n}}",
+ "identifyingSpeakers": "Identifying speakers...",
+ "speakersIdentified": "Speakers identified"
}
},
"dictionary": {
diff --git a/src/locales/es/translation.json b/src/locales/es/translation.json
index 4936e700d..bc6fa741b 100644
--- a/src/locales/es/translation.json
+++ b/src/locales/es/translation.json
@@ -1398,6 +1398,17 @@
"gpuDevice": {
"title": "GPU de transcripción",
"description": "GPU usada para transcripción local"
+ },
+ "diarization": {
+ "title": "Speaker Identification",
+ "description": "Identify individual speakers in meeting recordings",
+ "toggle": "Identify speakers in meetings",
+ "downloadModels": "Download Models",
+ "downloadModelsSize": "Download Models (~35 MB)",
+ "modelsReady": "Models Ready",
+ "downloading": "Downloading...",
+ "deleteModels": "Delete Models",
+ "requiresModels": "Download speaker identification models to enable this feature"
}
},
"intelligence": {
@@ -1477,6 +1488,10 @@
"gemma_gemma_4_e2b_it_q4_k_m": "Gemma 4 compacto de Google, rápido y eficiente",
"gemma_gemma_3_12b_it_q4_k_m": "Modelo de gama media de Google, razonamiento sólido",
"gemma_gemma_3_1b_it_q4_k_m": "Modelo Google ultrarrápido, ideal para limpieza de dictado corto"
+ },
+ "diarization": {
+ "segmentation": "Speech boundary detection for speaker diarization",
+ "embedding_en": "Speaker voice fingerprinting for identification"
}
}
},
@@ -1742,7 +1757,10 @@
},
"speaker": {
"you": "Tú",
- "them": "Ellos"
+ "them": "Ellos",
+ "label": "Participante {{n}}",
+ "identifyingSpeakers": "Identificando participantes...",
+ "speakersIdentified": "Speakers identified"
}
},
"dictionary": {
diff --git a/src/locales/fr/translation.json b/src/locales/fr/translation.json
index ac6397a6d..fcdea2e57 100644
--- a/src/locales/fr/translation.json
+++ b/src/locales/fr/translation.json
@@ -1398,6 +1398,17 @@
"gpuDevice": {
"title": "GPU de transcription",
"description": "GPU pour la transcription locale"
+ },
+ "diarization": {
+ "title": "Speaker Identification",
+ "description": "Identify individual speakers in meeting recordings",
+ "toggle": "Identify speakers in meetings",
+ "downloadModels": "Download Models",
+ "downloadModelsSize": "Download Models (~35 MB)",
+ "modelsReady": "Models Ready",
+ "downloading": "Downloading...",
+ "deleteModels": "Delete Models",
+ "requiresModels": "Download speaker identification models to enable this feature"
}
},
"intelligence": {
@@ -1477,6 +1488,10 @@
"gemma_gemma_4_e2b_it_q4_k_m": "Gemma 4 compact de Google, rapide et efficace",
"gemma_gemma_3_12b_it_q4_k_m": "Modèle milieu de gamme de Google, raisonnement solide",
"gemma_gemma_3_1b_it_q4_k_m": "Modèle Google ultra-rapide, idéal pour le nettoyage de courtes dictées"
+ },
+ "diarization": {
+ "segmentation": "Speech boundary detection for speaker diarization",
+ "embedding_en": "Speaker voice fingerprinting for identification"
}
}
},
@@ -1803,7 +1818,10 @@
},
"speaker": {
"you": "Vous",
- "them": "Eux"
+ "them": "Eux",
+ "label": "Intervenant {{n}}",
+ "identifyingSpeakers": "Identification des intervenants...",
+ "speakersIdentified": "Speakers identified"
}
},
"dictionary": {
diff --git a/src/locales/it/translation.json b/src/locales/it/translation.json
index b75496318..c0f2da3a4 100644
--- a/src/locales/it/translation.json
+++ b/src/locales/it/translation.json
@@ -1398,6 +1398,17 @@
"gpuDevice": {
"title": "GPU trascrizione",
"description": "GPU usata per la trascrizione locale"
+ },
+ "diarization": {
+ "title": "Speaker Identification",
+ "description": "Identify individual speakers in meeting recordings",
+ "toggle": "Identify speakers in meetings",
+ "downloadModels": "Download Models",
+ "downloadModelsSize": "Download Models (~35 MB)",
+ "modelsReady": "Models Ready",
+ "downloading": "Downloading...",
+ "deleteModels": "Delete Models",
+ "requiresModels": "Download speaker identification models to enable this feature"
}
},
"intelligence": {
@@ -1477,6 +1488,10 @@
"gemma_gemma_4_e2b_it_q4_k_m": "Gemma 4 compatto di Google, veloce ed efficiente",
"gemma_gemma_3_12b_it_q4_k_m": "Modello di fascia media di Google, ragionamento solido",
"gemma_gemma_3_1b_it_q4_k_m": "Modello Google ultraveloce, ideale per la pulizia di brevi dettature"
+ },
+ "diarization": {
+ "segmentation": "Speech boundary detection for speaker diarization",
+ "embedding_en": "Speaker voice fingerprinting for identification"
}
}
},
@@ -1742,7 +1757,10 @@
},
"speaker": {
"you": "Tu",
- "them": "Loro"
+ "them": "Loro",
+ "label": "Partecipante {{n}}",
+ "identifyingSpeakers": "Identificazione dei partecipanti...",
+ "speakersIdentified": "Speakers identified"
}
},
"dictionary": {
diff --git a/src/locales/ja/translation.json b/src/locales/ja/translation.json
index 9a59b864d..61b93259c 100644
--- a/src/locales/ja/translation.json
+++ b/src/locales/ja/translation.json
@@ -1398,6 +1398,17 @@
"gpuDevice": {
"title": "文字起こしGPU",
"description": "ローカル音声認識に使用するGPU"
+ },
+ "diarization": {
+ "title": "Speaker Identification",
+ "description": "Identify individual speakers in meeting recordings",
+ "toggle": "Identify speakers in meetings",
+ "downloadModels": "Download Models",
+ "downloadModelsSize": "Download Models (~35 MB)",
+ "modelsReady": "Models Ready",
+ "downloading": "Downloading...",
+ "deleteModels": "Delete Models",
+ "requiresModels": "Download speaker identification models to enable this feature"
}
},
"intelligence": {
@@ -1477,6 +1488,10 @@
"gemma_gemma_4_e2b_it_q4_k_m": "Google のコンパクトな Gemma 4、高速で効率的",
"gemma_gemma_3_12b_it_q4_k_m": "Google の中型モデル、強力な推論",
"gemma_gemma_3_1b_it_q4_k_m": "超高速 Google モデル、短い口述のクリーンアップに最適"
+ },
+ "diarization": {
+ "segmentation": "Speech boundary detection for speaker diarization",
+ "embedding_en": "Speaker voice fingerprinting for identification"
}
}
},
@@ -1670,7 +1685,10 @@
},
"speaker": {
"you": "あなた",
- "them": "相手"
+ "them": "相手",
+ "label": "話者 {{n}}",
+ "identifyingSpeakers": "話者を識別中...",
+ "speakersIdentified": "Speakers identified"
}
},
"dictionary": {
diff --git a/src/locales/pt/translation.json b/src/locales/pt/translation.json
index 8010a616c..86611c305 100644
--- a/src/locales/pt/translation.json
+++ b/src/locales/pt/translation.json
@@ -1370,6 +1370,17 @@
"gpuDevice": {
"title": "GPU de transcrição",
"description": "GPU usada para transcrição local"
+ },
+ "diarization": {
+ "title": "Speaker Identification",
+ "description": "Identify individual speakers in meeting recordings",
+ "toggle": "Identify speakers in meetings",
+ "downloadModels": "Download Models",
+ "downloadModelsSize": "Download Models (~35 MB)",
+ "modelsReady": "Models Ready",
+ "downloading": "Downloading...",
+ "deleteModels": "Delete Models",
+ "requiresModels": "Download speaker identification models to enable this feature"
}
},
"intelligence": {
@@ -1449,6 +1460,10 @@
"gemma_gemma_4_e2b_it_q4_k_m": "Gemma 4 compacto do Google, rápido e eficiente",
"gemma_gemma_3_12b_it_q4_k_m": "Modelo intermediário do Google, raciocínio sólido",
"gemma_gemma_3_1b_it_q4_k_m": "Modelo Google ultrarrápido, ideal para limpeza de ditados curtos"
+ },
+ "diarization": {
+ "segmentation": "Speech boundary detection for speaker diarization",
+ "embedding_en": "Speaker voice fingerprinting for identification"
}
}
},
@@ -1742,7 +1757,10 @@
},
"speaker": {
"you": "Você",
- "them": "Outro"
+ "them": "Outro",
+ "label": "Participante {{n}}",
+ "identifyingSpeakers": "Identificando participantes...",
+ "speakersIdentified": "Speakers identified"
}
},
"dictionary": {
diff --git a/src/locales/ru/translation.json b/src/locales/ru/translation.json
index 857a867c6..522230b8d 100644
--- a/src/locales/ru/translation.json
+++ b/src/locales/ru/translation.json
@@ -1398,6 +1398,17 @@
"gpuDevice": {
"title": "GPU транскрипции",
"description": "GPU для локального распознавания речи"
+ },
+ "diarization": {
+ "title": "Speaker Identification",
+ "description": "Identify individual speakers in meeting recordings",
+ "toggle": "Identify speakers in meetings",
+ "downloadModels": "Download Models",
+ "downloadModelsSize": "Download Models (~35 MB)",
+ "modelsReady": "Models Ready",
+ "downloading": "Downloading...",
+ "deleteModels": "Delete Models",
+ "requiresModels": "Download speaker identification models to enable this feature"
}
},
"intelligence": {
@@ -1477,6 +1488,10 @@
"gemma_gemma_4_e2b_it_q4_k_m": "Компактная Gemma 4 от Google, быстрая и эффективная",
"gemma_gemma_3_12b_it_q4_k_m": "Средняя модель Google, сильное рассуждение",
"gemma_gemma_3_1b_it_q4_k_m": "Сверхбыстрая модель Google, лучшая для очистки коротких диктовок"
+ },
+ "diarization": {
+ "segmentation": "Speech boundary detection for speaker diarization",
+ "embedding_en": "Speaker voice fingerprinting for identification"
}
}
},
@@ -1742,7 +1757,10 @@
},
"speaker": {
"you": "Вы",
- "them": "Собеседник"
+ "them": "Собеседник",
+ "label": "Участник {{n}}",
+ "identifyingSpeakers": "Определение участников...",
+ "speakersIdentified": "Speakers identified"
}
},
"dictionary": {
diff --git a/src/locales/zh-CN/translation.json b/src/locales/zh-CN/translation.json
index 4dabe6a69..bf7516f1d 100644
--- a/src/locales/zh-CN/translation.json
+++ b/src/locales/zh-CN/translation.json
@@ -1001,7 +1001,12 @@
"annualEquivalent": "$16.67",
"includesPrefix": "所有 Pro 功能 +",
"badge": "最受欢迎",
- "features": ["无限会议录制", "代理模式", "与您的数据对话(即将推出)", "优先支持"],
+ "features": [
+ "无限会议录制",
+ "代理模式",
+ "与您的数据对话(即将推出)",
+ "优先支持"
+ ],
"cta": "开始使用",
"switchToAnnual": "切换为年付"
},
@@ -1393,6 +1398,17 @@
"gpuDevice": {
"title": "转录 GPU",
"description": "用于本地语音识别的 GPU"
+ },
+ "diarization": {
+ "title": "Speaker Identification",
+ "description": "Identify individual speakers in meeting recordings",
+ "toggle": "Identify speakers in meetings",
+ "downloadModels": "Download Models",
+ "downloadModelsSize": "Download Models (~35 MB)",
+ "modelsReady": "Models Ready",
+ "downloading": "Downloading...",
+ "deleteModels": "Delete Models",
+ "requiresModels": "Download speaker identification models to enable this feature"
}
},
"intelligence": {
@@ -1472,6 +1488,10 @@
"gemma_gemma_4_e2b_it_q4_k_m": "Google 紧凑型 Gemma 4,快速高效",
"gemma_gemma_3_12b_it_q4_k_m": "Google 中型模型,强推理能力",
"gemma_gemma_3_1b_it_q4_k_m": "超快谷歌模型,最适合短听写清理"
+ },
+ "diarization": {
+ "segmentation": "Speech boundary detection for speaker diarization",
+ "embedding_en": "Speaker voice fingerprinting for identification"
}
}
},
@@ -1737,7 +1757,10 @@
},
"speaker": {
"you": "你",
- "them": "对方"
+ "them": "对方",
+ "label": "发言者 {{n}}",
+ "identifyingSpeakers": "正在识别发言者...",
+ "speakersIdentified": "Speakers identified"
}
},
"dictionary": {
diff --git a/src/locales/zh-TW/translation.json b/src/locales/zh-TW/translation.json
index 49c54fb59..8137ebf05 100644
--- a/src/locales/zh-TW/translation.json
+++ b/src/locales/zh-TW/translation.json
@@ -1001,7 +1001,12 @@
"annualEquivalent": "$16.67",
"includesPrefix": "所有 Pro 功能 +",
"badge": "最熱門",
- "features": ["無限會議錄製", "代理模式", "與您的資料對話(即將推出)", "優先支援"],
+ "features": [
+ "無限會議錄製",
+ "代理模式",
+ "與您的資料對話(即將推出)",
+ "優先支援"
+ ],
"cta": "開始使用",
"switchToAnnual": "切換為年付"
},
@@ -1393,6 +1398,17 @@
"gpuDevice": {
"title": "轉錄 GPU",
"description": "用於本機語音辨識的 GPU"
+ },
+ "diarization": {
+ "title": "Speaker Identification",
+ "description": "Identify individual speakers in meeting recordings",
+ "toggle": "Identify speakers in meetings",
+ "downloadModels": "Download Models",
+ "downloadModelsSize": "Download Models (~35 MB)",
+ "modelsReady": "Models Ready",
+ "downloading": "Downloading...",
+ "deleteModels": "Delete Models",
+ "requiresModels": "Download speaker identification models to enable this feature"
}
},
"intelligence": {
@@ -1472,6 +1488,10 @@
"gemma_gemma_4_e2b_it_q4_k_m": "Google 緊湊型 Gemma 4,快速高效",
"gemma_gemma_3_12b_it_q4_k_m": "Google 中型模型,強推理能力",
"gemma_gemma_3_1b_it_q4_k_m": "超快 Google 模型,最適合短語音清理"
+ },
+ "diarization": {
+ "segmentation": "Speech boundary detection for speaker diarization",
+ "embedding_en": "Speaker voice fingerprinting for identification"
}
}
},
@@ -1737,7 +1757,10 @@
},
"speaker": {
"you": "你",
- "them": "對方"
+ "them": "對方",
+ "label": "發言者 {{n}}",
+ "identifyingSpeakers": "正在辨識發言者...",
+ "speakersIdentified": "Speakers identified"
}
},
"dictionary": {
diff --git a/src/models/modelRegistryData.json b/src/models/modelRegistryData.json
index e241bc6af..6fa5b6736 100644
--- a/src/models/modelRegistryData.json
+++ b/src/models/modelRegistryData.json
@@ -39,6 +39,26 @@
"descriptionKey": "models.descriptions.parakeet.parakeet_tdt_0_6b_v3"
}
},
+ "diarizationModels": {
+ "sherpa-onnx-pyannote-segmentation-3-0": {
+ "name": "Pyannote Segmentation 3.0",
+ "description": "Speech boundary detection for speaker diarization",
+ "size": "6.6 MB",
+ "sizeMb": 6.6,
+ "downloadUrl": "https://github.com/k2-fsa/sherpa-onnx/releases/download/speaker-segmentation-models/sherpa-onnx-pyannote-segmentation-3-0.tar.bz2",
+ "extractDir": "sherpa-onnx-pyannote-segmentation-3-0",
+ "descriptionKey": "models.descriptions.diarization.segmentation"
+ },
+ "3dspeaker-campplus-en": {
+ "name": "CAM++ Speaker Embedding (English)",
+ "description": "Speaker voice fingerprinting for identification",
+ "size": "28.2 MB",
+ "sizeMb": 28.2,
+ "downloadUrl": "https://github.com/k2-fsa/sherpa-onnx/releases/download/speaker-recongition-models/3dspeaker_speech_campplus_sv_en_voxceleb_16k.onnx",
+ "fileName": "3dspeaker_speech_campplus_sv_en_voxceleb_16k.onnx",
+ "descriptionKey": "models.descriptions.diarization.embedding_en"
+ }
+ },
"whisperModels": {
"tiny": {
"name": "Tiny",
diff --git a/src/types/electron.ts b/src/types/electron.ts
index b8dd63072..a316a1640 100644
--- a/src/types/electron.ts
+++ b/src/types/electron.ts
@@ -1307,6 +1307,27 @@ declare global {
) => () => void;
onMeetingTranscriptionError?: (callback: (error: string) => void) => () => void;
+ // Speaker diarization
+ downloadDiarizationModels?: () => Promise<{ success: boolean; error?: string }>;
+ getDiarizationModelStatus?: () => Promise<{
+ available: boolean;
+ modelsDownloaded: boolean;
+ }>;
+ deleteDiarizationModels?: () => Promise<{ success: boolean }>;
+ cancelDiarizationDownload?: () => Promise<{ success: boolean; message?: string; error?: string }>;
+ onDiarizationDownloadProgress?: (callback: (data: any) => void) => () => void;
+ onMeetingDiarizationComplete?: (
+ callback: (data: {
+ segments: Array<{
+ id: string;
+ text: string;
+ source: "mic" | "system";
+ timestamp?: number;
+ speaker?: string;
+ }>;
+ }) => void
+ ) => () => void;
+
// Dictation realtime streaming
dictationRealtimeWarmup?: (options: {
model?: string;
diff --git a/src/utils/parseTranscriptSegments.ts b/src/utils/parseTranscriptSegments.ts
index 4be7d851b..e9ffce1ff 100644
--- a/src/utils/parseTranscriptSegments.ts
+++ b/src/utils/parseTranscriptSegments.ts
@@ -7,12 +7,14 @@ export function parseTranscriptSegments(raw: string): TranscriptSegment[] {
text: string;
source: "mic" | "system";
timestamp?: number;
+ speaker?: string;
}>;
return parsed.map((s, i) => ({
id: `stored-${i}`,
text: s.text,
source: s.source,
timestamp: s.timestamp,
+ speaker: s.speaker,
}));
} catch (e) {
logger.warn("Failed to parse transcript segments", e);