Skip to content

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

fix(upload): Clarify model and speaker detection failures (#1991)

Chad Pihaa4c914c91a18
diff --git a/src/components/notes/BatchQueueView.tsx b/src/components/notes/BatchQueueView.tsx
index c5d26ae0c..ccc414aae 100644
--- a/src/components/notes/BatchQueueView.tsx
+++ b/src/components/notes/BatchQueueView.tsx
@@ -1,3 +1,4 @@
+import type { JSX } from "react";
import { useTranslation } from "react-i18next";
import { AlertTriangle, Check, X, Loader2, Clock, Trash2 } from "lucide-react";
import { Button } from "../ui/button";
@@ -30,6 +31,30 @@ function StatusIcon({ status }: { status: QueueItem["status"] }) {
}
}
+interface BatchWarningIndicatorProps {
+ transcriptionWarning: boolean;
+ diarizationWarning: boolean;
+ t: (key: string) => string;
+}
+
+export function BatchWarningIndicator({
+ transcriptionWarning,
+ diarizationWarning,
+ t,
+}: BatchWarningIndicatorProps): JSX.Element | null {
+ const messages: string[] = [];
+ if (transcriptionWarning) messages.push(t("notes.upload.partialWarning"));
+ if (diarizationWarning) messages.push(t("notes.upload.diarizationWarning"));
+ if (messages.length === 0) return null;
+
+ const label = messages.join(" ");
+ return (
+ <span className="flex shrink-0" role="img" title={label} aria-label={label}>
+ <AlertTriangle size={11} className="text-warning" />
+ </span>
+ );
+}
+
export default function BatchQueueView({
queue,
byokMaxFileSizeMb,
@@ -110,10 +135,12 @@ export default function BatchQueueView({
</div>
)}
- {item.status === "done" && item.warning && (
- <span className="flex shrink-0" title={t("notes.upload.partialWarning")}>
- <AlertTriangle size={11} className="text-amber-500/60" />
- </span>
+ {item.status === "done" && (
+ <BatchWarningIndicator
+ transcriptionWarning={!!item.warning}
+ diarizationWarning={!!item.diarizationWarning}
+ t={t}
+ />
)}
{item.status === "done" && item.noteId && onOpenNote && (
diff --git a/src/components/notes/UploadAudioFeedback.tsx b/src/components/notes/UploadAudioFeedback.tsx
new file mode 100644
index 000000000..e5086743c
--- /dev/null
+++ b/src/components/notes/UploadAudioFeedback.tsx
@@ -0,0 +1,73 @@
+import React from "react";
+import { cn } from "../lib/utils";
+
+// Both completion warnings sit under the transcript preview and share its
+// column, so they share one recipe; only the tone differs.
+const COMPLETION_WARNING = "text-xs max-w-[240px] text-center mb-4 -mt-2";
+
+interface UploadModelSettingsButtonProps {
+ label: string;
+ actionLabel: string;
+ onOpenSettings?: (section: string) => void;
+ className?: string;
+}
+
+export function UploadModelSettingsButton({
+ label,
+ actionLabel,
+ onOpenSettings,
+ className,
+}: UploadModelSettingsButtonProps): React.JSX.Element {
+ return (
+ <button
+ type="button"
+ onClick={() => onOpenSettings?.("uploadTranscription")}
+ // WCAG 2.5.3: keep the visible label inside the accessible name, so the
+ // model stays announced and voice control can still target the button.
+ aria-label={`${label}, ${actionLabel}`}
+ title={actionLabel}
+ disabled={!onOpenSettings}
+ className={cn(
+ "rounded-sm underline underline-offset-2 decoration-foreground/30 transition-colors",
+ "hover:text-foreground hover:decoration-foreground/50 active:text-foreground/50",
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/30 focus-visible:ring-offset-1",
+ "disabled:pointer-events-none disabled:no-underline disabled:opacity-50",
+ className
+ )}
+ >
+ {label}
+ </button>
+ );
+}
+
+interface UploadCompleteWarningsProps {
+ partialWarning: { failed: number; total: number } | null;
+ diarizationWarning: boolean;
+ t: (key: string, options?: Record<string, unknown>) => string;
+}
+
+export function UploadCompleteWarnings({
+ partialWarning,
+ diarizationWarning,
+ t,
+}: UploadCompleteWarningsProps): React.JSX.Element | null {
+ if (!partialWarning && !diarizationWarning) return null;
+
+ return (
+ <>
+ {partialWarning && (
+ <p className={cn(COMPLETION_WARNING, "text-destructive/50")}>
+ {t("notes.upload.partialWarningCount", {
+ failed: partialWarning.failed,
+ total: partialWarning.total,
+ })}
+ </p>
+ )}
+ {diarizationWarning && (
+ <p className={cn(COMPLETION_WARNING, "text-warning")} role="status" aria-live="polite">
+ {t("notes.upload.diarizationWarning")}
+ </p>
+ )}
+ </>
+ );
+}
diff --git a/src/components/notes/UploadAudioView.tsx b/src/components/notes/UploadAudioView.tsx
index 61fd2c066..65bd9f809 100644
--- a/src/components/notes/UploadAudioView.tsx
+++ b/src/components/notes/UploadAudioView.tsx
@@ -53,6 +53,7 @@ import { useBatchQueue } from "../../stores/batchQueueStore";
import type { TranscribeOptions } from "../../stores/batchQueueStore";
import {
transcribeFileWithSpeakers,
+ resolveDiarizationSettings,
shouldUseByokDiarize,
getTranscriptionApiKey,
} from "../../services/fileTranscription";
@@ -70,6 +71,7 @@ import { usePolicyStore } from "../../stores/policyStore";
import { usePolicySnapshot, useTranscriptionContextAllowed } from "../../hooks/usePolicy";
import { byokFileSizeLimit, resolveTranscriptionRoute } from "../../helpers/transcriptionRoute";
import { saveUploadNote, uploadTitleFallback } from "../../services/uploadNotes";
+import { UploadCompleteWarnings, UploadModelSettingsButton } from "./UploadAudioFeedback";
type UploadState = "idle" | "selected" | "downloading" | "transcribing" | "complete" | "error";
@@ -148,6 +150,7 @@ export default function UploadAudioView({ onNoteCreated, onOpenSettings }: Uploa
const [partialWarning, setPartialWarning] = useState<{ failed: number; total: number } | null>(
null
);
+ const [diarizationWarning, setDiarizationWarning] = useState(false);
const [noteId, setNoteId] = useState<number | null>(null);
const [error, setError] = useState<string | null>(null);
const [isDragOver, setIsDragOver] = useState(false);
@@ -197,23 +200,38 @@ export default function UploadAudioView({ onNoteCreated, onOpenSettings }: Uploa
localStorage.setItem("uploadDiarizationNumSpeakers", diarizationNumSpeakers);
}, [diarizationNumSpeakers]);
- const diarizationDownloadRef = useRef(false);
- const ensureDiarizationModels = async (): Promise<boolean> => {
- if (diarizationDownloadRef.current) return false;
- diarizationDownloadRef.current = true;
+ const diarizationDownloadRef = useRef<Promise<boolean> | null>(null);
+ // Callers share one in-flight download: a transcribe started while the
+ // mount-time heal is still fetching has to wait for it, not give up and
+ // report that speaker detection couldn't be applied.
+ const ensureDiarizationModels = (): Promise<boolean> => {
+ if (diarizationDownloadRef.current) return diarizationDownloadRef.current;
setDiarizationDownloading(true);
- try {
- await window.electronAPI.downloadDiarizationModels?.();
- const status = await window.electronAPI.getDiarizationModelStatus?.();
- const ready = status?.modelsDownloaded ?? false;
- setDiarizationModelsReady(ready);
- return ready;
- } finally {
- diarizationDownloadRef.current = false;
- setDiarizationDownloading(false);
- }
+ const pending = (async () => {
+ try {
+ await window.electronAPI.downloadDiarizationModels?.();
+ const status = await window.electronAPI.getDiarizationModelStatus?.();
+ const ready = status?.modelsDownloaded ?? false;
+ setDiarizationModelsReady(ready);
+ return ready;
+ } finally {
+ diarizationDownloadRef.current = null;
+ setDiarizationDownloading(false);
+ }
+ })();
+ diarizationDownloadRef.current = pending;
+ return pending;
};
+ const buildDiarizationSettings = (): Promise<DiarizationSettings> =>
+ resolveDiarizationSettings({
+ enabled: diarizationEnabled,
+ modelsReady: !!diarizationModelsReady,
+ numSpeakers: diarizationNumSpeakers ? Number(diarizationNumSpeakers) : null,
+ config: buildTranscriptionConfig(),
+ ensureModels: ensureDiarizationModels,
+ });
+
useEffect(() => {
window.electronAPI.getDiarizationModelStatus?.().then((status) => {
const ready = status?.modelsDownloaded ?? false;
@@ -586,6 +604,7 @@ export default function UploadAudioView({ onNoteCreated, onOpenSettings }: Uploa
setFile(null);
setResult(null);
setPartialWarning(null);
+ setDiarizationWarning(false);
setNoteId(null);
setError(null);
setProgress(0);
@@ -622,6 +641,7 @@ export default function UploadAudioView({ onNoteCreated, onOpenSettings }: Uploa
setError(null);
setProgress(0);
setChunkProgress(null);
+ setDiarizationWarning(false);
const useChunkProgress = isOpenWhisprCloud && isLargeFile;
@@ -649,11 +669,7 @@ export default function UploadAudioView({ onNoteCreated, onOpenSettings }: Uploa
}
try {
- const diarization: DiarizationSettings = {
- enabled: diarizationEnabled,
- localModelsReady: !!diarizationModelsReady,
- numSpeakers: diarizationNumSpeakers ? Number(diarizationNumSpeakers) : null,
- };
+ const diarization = await buildDiarizationSettings();
const res: FileTranscriptionResult = await transcribeFileWithSpeakers(
currentFile.path,
buildTranscriptionConfig(),
@@ -678,6 +694,7 @@ export default function UploadAudioView({ onNoteCreated, onOpenSettings }: Uploa
? { failed: res.failedChunks, total: res.totalChunks }
: null
);
+ setDiarizationWarning(!!res.diarizationWarning);
let title: string;
if (currentFile.fromUrl) {
@@ -845,7 +862,7 @@ export default function UploadAudioView({ onNoteCreated, onOpenSettings }: Uploa
setBatchUrlNotice(skipped > 0 ? t("notes.upload.urlsSkipped", { n: skipped }) : null);
};
- const startBatchProcessing = () => {
+ const startBatchProcessing = async () => {
if (state === "downloading" || state === "transcribing") return;
if (!isTranscriptionContextAllowed(usePolicyStore.getState(), getSettings(), "upload")) {
setBatchUrlNotice(t("common.managedByOrg"));
@@ -860,13 +877,7 @@ export default function UploadAudioView({ onNoteCreated, onOpenSettings }: Uploa
generateTitle: async (text) => (await generateTitle(text)) || null,
};
- const diarization: DiarizationSettings = {
- enabled: diarizationEnabled,
- localModelsReady: !!diarizationModelsReady,
- numSpeakers: diarizationNumSpeakers ? Number(diarizationNumSpeakers) : null,
- };
-
- batch.processQueue(transcribeOpts, diarization);
+ batch.processQueue(transcribeOpts, await buildDiarizationSettings());
};
const handleCreateFolder = async () => {
@@ -935,6 +946,7 @@ export default function UploadAudioView({ onNoteCreated, onOpenSettings }: Uploa
handleBrowse={handleBrowse}
isDragOver={isDragOver}
setIsDragOver={setIsDragOver}
+ onOpenSettings={onOpenSettings}
/>
<div className="flex items-center gap-3 my-3">
@@ -1115,6 +1127,7 @@ export default function UploadAudioView({ onNoteCreated, onOpenSettings }: Uploa
onUpgrade={() => usage?.openCheckout()}
onCreateAccount={handleCreateAccount}
onSwitchToCloud={switchToCloud}
+ onOpenSettings={onOpenSettings}
/>
)}
@@ -1194,6 +1207,7 @@ export default function UploadAudioView({ onNoteCreated, onOpenSettings }: Uploa
t={t}
result={result}
partialWarning={partialWarning}
+ diarizationWarning={diarizationWarning}
folders={folders}
selectedFolderId={selectedFolderId}
handleFolderChange={handleFolderChange}
@@ -1413,6 +1427,7 @@ interface IdleViewProps {
handleBrowse: () => void;
isDragOver: boolean;
setIsDragOver: (v: boolean) => void;
+ onOpenSettings?: (section: string) => void;
}
function IdleView({
@@ -1422,6 +1437,7 @@ function IdleView({
handleBrowse,
isDragOver,
setIsDragOver,
+ onOpenSettings,
}: IdleViewProps) {
const fileInputRef = useRef<HTMLInputElement>(null);
@@ -1453,9 +1469,12 @@ function IdleView({
/>
</div>
<h2 className="text-xs font-semibold text-foreground mb-1">{t("notes.upload.title")}</h2>
- <p className="text-xs text-foreground/25">
- {t("notes.upload.using", { model: getActiveModelLabel() })}
- </p>
+ <UploadModelSettingsButton
+ label={t("notes.upload.using", { model: getActiveModelLabel() })}
+ actionLabel={t("notes.upload.noProviderAction")}
+ onOpenSettings={onOpenSettings}
+ className="text-xs text-foreground/70"
+ />
</div>
<input
@@ -1544,6 +1563,7 @@ interface SelectedViewProps {
onUpgrade: () => void;
onCreateAccount: () => void;
onSwitchToCloud: () => void;
+ onOpenSettings?: (section: string) => void;
}
function SelectedView({
@@ -1564,6 +1584,7 @@ function SelectedView({
onUpgrade,
onCreateAccount,
onSwitchToCloud,
+ onOpenSettings,
}: SelectedViewProps) {
const canTranscribe = !fileTooLarge && !requiresUpgrade && !byokTooLarge;
@@ -1577,7 +1598,12 @@ function SelectedView({
<div className="min-w-0 flex-1">
<p className="text-xs text-foreground/70 truncate font-medium">{file.name}</p>
{file.size && <p className="text-xs text-foreground/25 mt-0.5">{file.size}</p>}
- <p className="text-xs text-foreground/20 mt-0.5">{getActiveModelLabel()}</p>
+ <UploadModelSettingsButton
+ label={getActiveModelLabel()}
+ actionLabel={t("notes.upload.noProviderAction")}
+ onOpenSettings={onOpenSettings}
+ className="block max-w-full truncate text-left text-xs text-foreground/70 mt-0.5"
+ />
</div>
<button
onClick={reset}
@@ -1830,6 +1856,7 @@ interface CompleteViewProps {
t: (key: string, options?: Record<string, unknown>) => string;
result: string;
partialWarning: { failed: number; total: number } | null;
+ diarizationWarning: boolean;
folders: FolderItem[];
selectedFolderId: string;
handleFolderChange: (val: string) => void;
@@ -1842,6 +1869,7 @@ function CompleteView({
t,
result,
partialWarning,
+ diarizationWarning,
folders,
selectedFolderId,
handleFolderChange,
@@ -1896,14 +1924,11 @@ function CompleteView({
{result.slice(0, 150)}
</p>
- {partialWarning && (
- <p className="text-xs text-destructive/50 max-w-[240px] text-center mb-4 -mt-2">
- {t("notes.upload.partialWarningCount", {
- failed: partialWarning.failed,
- total: partialWarning.total,
- })}
- </p>
- )}
+ <UploadCompleteWarnings
+ partialWarning={partialWarning}
+ diarizationWarning={diarizationWarning}
+ t={t}
+ />
{folders.length > 0 && (
<FolderSelect
diff --git a/src/locales/de/translation.json b/src/locales/de/translation.json
index 643b57434..f3f73f763 100644
--- a/src/locales/de/translation.json
+++ b/src/locales/de/translation.json
@@ -3107,6 +3107,7 @@
"transcriptionComplete": "Transkription abgeschlossen",
"partialWarning": "Ein Teil der Audiodatei konnte nicht transkribiert werden.",
"partialWarningCount": "{{failed}} von {{total}} Audioabschnitten konnten nicht transkribiert werden.",
+ "diarizationWarning": "Die Sprechererkennung konnte nicht angewendet werden. Das Transkript wurde ohne Sprecherkennzeichnungen gespeichert.",
"chunkLossExceeded": "Wegen eines Netzwerkproblems ging zu viel Audio verloren. Prüfen Sie Ihre Verbindung und versuchen Sie es erneut.",
"openNote": "Notiz öffnen",
"uploadAnother": "Weitere hochladen",
diff --git a/src/locales/en/translation.json b/src/locales/en/translation.json
index 1c8cf0d03..4be582f55 100644
--- a/src/locales/en/translation.json
+++ b/src/locales/en/translation.json
@@ -3107,6 +3107,7 @@
"transcriptionComplete": "Transcription complete",
"partialWarning": "Part of the audio couldn't be transcribed.",
"partialWarningCount": "{{failed}} of {{total}} audio sections couldn't be transcribed.",
+ "diarizationWarning": "Speaker identification couldn't be applied. The transcript was saved without speaker labels.",
"chunkLossExceeded": "Too much of the audio was lost to a network problem. Check your connection and try again.",
"openNote": "Open Note",
"uploadAnother": "Upload Another",
diff --git a/src/locales/es/translation.json b/src/locales/es/translation.json
index b2ea829a8..c6ce109b7 100644
--- a/src/locales/es/translation.json
+++ b/src/locales/es/translation.json
@@ -2944,6 +2944,7 @@
"transcriptionComplete": "Transcripción completada",
"partialWarning": "No se pudo transcribir una parte del audio.",
"partialWarningCount": "No se pudieron transcribir {{failed}} de {{total}} secciones del audio.",
+ "diarizationWarning": "No se pudo aplicar la identificación de hablantes. La transcripción se guardó sin etiquetas de hablante.",
"chunkLossExceeded": "Se perdió demasiado audio por un problema de red. Comprueba tu conexión e inténtalo de nuevo.",
"openNote": "Abrir nota",
"uploadAnother": "Subir otro",
diff --git a/src/locales/fr/translation.json b/src/locales/fr/translation.json
index 6d56b1320..141c6ba59 100644
--- a/src/locales/fr/translation.json
+++ b/src/locales/fr/translation.json
@@ -3107,6 +3107,7 @@
"transcriptionComplete": "Transcription terminée",
"partialWarning": "Une partie de l'audio n'a pas pu être transcrite.",
"partialWarningCount": "{{failed}} sections audio sur {{total}} n'ont pas pu être transcrites.",
+ "diarizationWarning": "L’identification des intervenants n’a pas pu être appliquée. La transcription a été enregistrée sans étiquettes d’intervenant.",
"chunkLossExceeded": "Une trop grande partie de l'audio a été perdue à cause d'un problème réseau. Vérifiez votre connexion et réessayez.",
"openNote": "Ouvrir la note",
"uploadAnother": "Téléverser un autre fichier",
diff --git a/src/locales/it/translation.json b/src/locales/it/translation.json
index 3b30649f4..e405834c9 100644
--- a/src/locales/it/translation.json
+++ b/src/locales/it/translation.json
@@ -2896,6 +2896,7 @@
"transcriptionComplete": "Trascrizione completata",
"partialWarning": "Non è stato possibile trascrivere una parte dell'audio.",
"partialWarningCount": "Non è stato possibile trascrivere {{failed}} sezioni audio su {{total}}.",
+ "diarizationWarning": "Non è stato possibile applicare l'identificazione dei parlanti. La trascrizione è stata salvata senza etichette dei parlanti.",
"chunkLossExceeded": "Troppo audio è andato perso a causa di un problema di rete. Controlla la connessione e riprova.",
"openNote": "Apri nota",
"uploadAnother": "Carica un altro",
diff --git a/src/locales/ja/translation.json b/src/locales/ja/translation.json
index 793324443..c420e05c6 100644
--- a/src/locales/ja/translation.json
+++ b/src/locales/ja/translation.json
@@ -2880,6 +2880,7 @@
"transcriptionComplete": "文字起こし完了",
"partialWarning": "音声の一部を文字起こしできませんでした。",
"partialWarningCount": "{{total}}個の音声セクションのうち{{failed}}個を文字起こしできませんでした。",
+ "diarizationWarning": "話者識別を適用できませんでした。文字起こしは話者ラベルなしで保存されました。",
"chunkLossExceeded": "ネットワークの問題で音声の大部分が失われました。接続を確認してもう一度お試しください。",
"openNote": "ノートを開く",
"uploadAnother": "別のファイルをアップロード",
diff --git a/src/locales/pt/translation.json b/src/locales/pt/translation.json
index a2d456470..b14654509 100644
--- a/src/locales/pt/translation.json
+++ b/src/locales/pt/translation.json
@@ -2896,6 +2896,7 @@
"transcriptionComplete": "Transcrição concluída",
"partialWarning": "Não foi possível transcrever parte do áudio.",
"partialWarningCount": "Não foi possível transcrever {{failed}} de {{total}} seções do áudio.",
+ "diarizationWarning": "Não foi possível aplicar a identificação de falantes. A transcrição foi salva sem rótulos de falante.",
"chunkLossExceeded": "Muito áudio foi perdido devido a um problema de rede. Verifique sua conexão e tente novamente.",
"openNote": "Abrir nota",
"uploadAnother": "Enviar outro",
diff --git a/src/locales/ru/translation.json b/src/locales/ru/translation.json
index 204ad2665..ca94eb036 100644
--- a/src/locales/ru/translation.json
+++ b/src/locales/ru/translation.json
@@ -2918,6 +2918,7 @@
"transcriptionComplete": "Транскрибирование завершено",
"partialWarning": "Не удалось транскрибировать часть аудио.",
"partialWarningCount": "Не удалось транскрибировать {{failed}} из {{total}} фрагментов аудио.",
+ "diarizationWarning": "Не удалось применить распознавание говорящих. Расшифровка сохранена без меток говорящих.",
"chunkLossExceeded": "Из-за проблемы с сетью потеряно слишком много аудио. Проверьте подключение и попробуйте снова.",
"openNote": "Открыть заметку",
"uploadAnother": "Загрузить ещё",
diff --git a/src/locales/zh-CN/translation.json b/src/locales/zh-CN/translation.json
index 93a22b1b9..e5083efbc 100644
--- a/src/locales/zh-CN/translation.json
+++ b/src/locales/zh-CN/translation.json
@@ -2896,6 +2896,7 @@
"transcriptionComplete": "转录完成",
"partialWarning": "部分音频内容无法转录。",
"partialWarningCount": "{{total}}个音频片段中有{{failed}}个无法转写。",
+ "diarizationWarning": "无法应用说话人识别。转写已保存,但不包含说话人标签。",
"chunkLossExceeded": "由于网络问题丢失了过多音频。请检查网络连接后重试。",
"openNote": "打开笔记",
"uploadAnother": "上传另一个",
diff --git a/src/locales/zh-TW/translation.json b/src/locales/zh-TW/translation.json
index 9d62156b6..9eeefc9ff 100644
--- a/src/locales/zh-TW/translation.json
+++ b/src/locales/zh-TW/translation.json
@@ -2896,6 +2896,7 @@
"transcriptionComplete": "轉錄完成",
"partialWarning": "部分音訊內容無法轉錄。",
"partialWarningCount": "{{total}}個音訊片段中有{{failed}}個無法轉錄。",
+ "diarizationWarning": "無法套用說話者識別。轉錄已儲存,但不包含說話者標籤。",
"chunkLossExceeded": "由於網路問題遺失了過多音訊。請檢查網路連線後重試。",
"openNote": "開啟筆記",
"uploadAnother": "上傳另一個",
diff --git a/src/services/fileTranscription.ts b/src/services/fileTranscription.ts
index daa160922..1820e46cf 100644
--- a/src/services/fileTranscription.ts
+++ b/src/services/fileTranscription.ts
@@ -9,6 +9,8 @@ export interface FileTranscriptionResult {
error?: string;
code?: string;
diarized?: boolean;
+ // The transcript succeeded, but requested speaker labels could not be applied.
+ diarizationWarning?: boolean;
warning?: string;
// Set alongside `warning` by the chunked cloud path: how much audio was lost.
failedChunks?: number;
@@ -172,6 +174,33 @@ export function shouldUseByokDiarize(
);
}
+interface DiarizationSettingsRequest {
+ enabled: boolean;
+ modelsReady: boolean;
+ numSpeakers: number | null;
+ config: FileTranscriptionConfig;
+ ensureModels: () => Promise<boolean>;
+}
+
+// Speaker detection is opt-in but its local models download lazily, so a run
+// started before they land would report "couldn't be applied" without the
+// diarizer ever being invoked. Fetch them first; only the routes that diarize
+// server-side can skip the download.
+export async function resolveDiarizationSettings({
+ enabled,
+ modelsReady,
+ numSpeakers,
+ config,
+ ensureModels,
+}: DiarizationSettingsRequest): Promise<DiarizationSettings> {
+ const needsLocalModels = enabled && !modelsReady && !shouldUseByokDiarize(config, enabled);
+ return {
+ enabled,
+ localModelsReady: needsLocalModels ? await ensureModels() : modelsReady,
+ numSpeakers,
+ };
+}
+
// Transcribe and diarize in parallel, then merge speaker labels into the text.
// Shared by the single-file flow and the batch queue. `durationSeconds` (when the
// source knows it, e.g. URL downloads) beats inferring duration from segments.
@@ -203,8 +232,10 @@ export async function transcribeFileWithSpeakers(
const measuredDuration = durationSeconds || (diar?.success && diar.durationSeconds) || null;
const result = { ...transcribed, durationSeconds: measuredDuration };
- if (!result.success || !result.text || result.diarized) return result;
- if (!diar?.success || !diar.segments?.length) return result;
+ if (!result.success || !result.text || !diarization.enabled || result.diarized) return result;
+ if (!diar?.success || !diar.segments?.length) {
+ return { ...result, diarizationWarning: true };
+ }
try {
const merged = await window.electronAPI.mergeSpeakerText?.(
@@ -216,5 +247,5 @@ export async function transcribeFileWithSpeakers(
} catch {
// Merge failure falls back to the plain transcript.
}
- return result;
+ return { ...result, diarizationWarning: true };
}
diff --git a/src/stores/batchQueueStore.ts b/src/stores/batchQueueStore.ts
index fd4ea69ec..b123a9e28 100644
--- a/src/stores/batchQueueStore.ts
+++ b/src/stores/batchQueueStore.ts
@@ -21,6 +21,8 @@ export interface QueueItem {
error?: string;
// Transcription completed but parts of the audio failed (e.g. failed chunks).
warning?: boolean;
+ // Transcription completed, but requested speaker labels could not be applied.
+ diarizationWarning?: boolean;
noteId?: number;
tempPath?: string;
}
@@ -244,6 +246,7 @@ export function processBatchQueue(
status: "done",
progress: 100,
warning: !!transcriptionResult.warning,
+ diarizationWarning: !!transcriptionResult.diarizationWarning,
noteId: noteRes.note.id,
});
} else {
diff --git a/test/components/uploadAudioFeedback.test.js b/test/components/uploadAudioFeedback.test.js
new file mode 100644
index 000000000..16f03fa68
--- /dev/null
+++ b/test/components/uploadAudioFeedback.test.js
@@ -0,0 +1,158 @@
+const test = require("node:test");
+const assert = require("node:assert/strict");
+const { createElement } = require("react");
+const { renderToStaticMarkup } = require("react-dom/server");
+const { createRendererServer, installBrowserGlobals } = require("../lib/rendererTestHarness");
+
+async function loadFeedback(t) {
+ installBrowserGlobals(t);
+ const vite = await createRendererServer(t, {
+ cachePrefix: "openwhispr-upload-audio-feedback-test-",
+ });
+ return vite.ssrLoadModule("/components/notes/UploadAudioFeedback.tsx");
+}
+
+async function loadBatchQueueView(t) {
+ installBrowserGlobals(t);
+ const vite = await createRendererServer(t, {
+ cachePrefix: "openwhispr-batch-warning-indicator-test-",
+ });
+ return vite.ssrLoadModule("/components/notes/BatchQueueView.tsx");
+}
+
+test("the model button announces the model it names, not just the action", async (t) => {
+ const { UploadModelSettingsButton } = await loadFeedback(t);
+
+ const markup = renderToStaticMarkup(
+ createElement(UploadModelSettingsButton, {
+ label: "Using Whisper · base",
+ actionLabel: "Open Transcription Settings",
+ onOpenSettings: () => {},
+ })
+ );
+
+ // WCAG 2.5.3: the accessible name must contain the visible label, or voice
+ // control cannot target the button and screen readers never hear the model.
+ const ariaLabel = markup.match(/aria-label="([^"]*)"/)?.[1];
+ assert.ok(ariaLabel, "expected an aria-label");
+ assert.ok(
+ ariaLabel.includes("Using Whisper · base"),
+ `accessible name "${ariaLabel}" must contain the visible label`
+ );
+ assert.ok(ariaLabel.includes("Open Transcription Settings"));
+});
+
+test("the model button opens the upload-scoped transcription settings", async (t) => {
+ const { UploadModelSettingsButton } = await loadFeedback(t);
+
+ const openedSections = [];
+ const element = UploadModelSettingsButton({
+ label: "Using Whisper · base",
+ actionLabel: "Open Transcription Settings",
+ onOpenSettings: (section) => openedSections.push(section),
+ });
+ element.props.onClick();
+
+ assert.deepEqual(openedSections, ["uploadTranscription"]);
+ assert.equal(element.props.type, "button");
+});
+
+test("the batch warning indicator renders nothing when neither warning is set", async (t) => {
+ const { BatchWarningIndicator } = await loadBatchQueueView(t);
+
+ const markup = renderToStaticMarkup(
+ createElement(BatchWarningIndicator, {
+ transcriptionWarning: false,
+ diarizationWarning: false,
+ t: (key) => key,
+ })
+ );
+
+ assert.equal(markup, "");
+});
+
+test("the batch warning indicator combines both warnings into one label", async (t) => {
+ const { BatchWarningIndicator } = await loadBatchQueueView(t);
+
+ const markup = renderToStaticMarkup(
+ createElement(BatchWarningIndicator, {
+ transcriptionWarning: true,
+ diarizationWarning: true,
+ t: (key) => key,
+ })
+ );
+
+ const ariaLabel = markup.match(/aria-label="([^"]*)"/)?.[1];
+ assert.equal(ariaLabel, "notes.upload.partialWarning notes.upload.diarizationWarning");
+ assert.match(markup, /text-warning/);
+ // A non-widget span in the tab order is a dead stop: `title` tooltips do not
+ // open on keyboard focus, so there is nothing to read once you land there.
+ assert.doesNotMatch(markup, /tabindex/i);
+});
+
+test("the batch warning indicator reports a transcription-only warning", async (t) => {
+ const { BatchWarningIndicator } = await loadBatchQueueView(t);
+
+ const markup = renderToStaticMarkup(
+ createElement(BatchWarningIndicator, {
+ transcriptionWarning: true,
+ diarizationWarning: false,
+ t: (key) => key,
+ })
+ );
+
+ assert.match(markup, /aria-label="notes\.upload\.partialWarning"/);
+});
+
+test("the completed upload stays quiet when nothing went wrong", async (t) => {
+ const { UploadCompleteWarnings } = await loadFeedback(t);
+
+ const markup = renderToStaticMarkup(
+ createElement(UploadCompleteWarnings, {
+ partialWarning: null,
+ diarizationWarning: false,
+ t: (key) => key,
+ })
+ );
+
+ assert.equal(markup, "");
+});
+
+test("the completed upload shows the diarization warning only when it is flagged", async (t) => {
+ const { UploadCompleteWarnings } = await loadFeedback(t);
+
+ const warned = renderToStaticMarkup(
+ createElement(UploadCompleteWarnings, {
+ partialWarning: null,
+ diarizationWarning: true,
+ t: (key) => key,
+ })
+ );
+ assert.match(warned, /notes\.upload\.diarizationWarning/);
+ assert.match(warned, /text-warning/);
+ assert.doesNotMatch(warned, /amber/, "use the --color-warning token, not a hand-rolled amber");
+
+ const quiet = renderToStaticMarkup(
+ createElement(UploadCompleteWarnings, {
+ partialWarning: null,
+ diarizationWarning: false,
+ t: (key) => key,
+ })
+ );
+ assert.doesNotMatch(quiet, /notes\.upload\.diarizationWarning/);
+});
+
+test("a chunk loss and a diarization failure are reported together", async (t) => {
+ const { UploadCompleteWarnings } = await loadFeedback(t);
+
+ const markup = renderToStaticMarkup(
+ createElement(UploadCompleteWarnings, {
+ partialWarning: { failed: 2, total: 9 },
+ diarizationWarning: true,
+ t: (key) => key,
+ })
+ );
+
+ assert.match(markup, /notes\.upload\.partialWarningCount/);
+ assert.match(markup, /notes\.upload\.diarizationWarning/);
+});
diff --git a/test/services/fileTranscriptionDiarizationWarning.test.js b/test/services/fileTranscriptionDiarizationWarning.test.js
new file mode 100644
index 000000000..ff6dd3aa2
--- /dev/null
+++ b/test/services/fileTranscriptionDiarizationWarning.test.js
@@ -0,0 +1,223 @@
+const test = require("node:test");
+const assert = require("node:assert/strict");
+const { createRendererServer, installBrowserGlobals } = require("../lib/rendererTestHarness");
+
+function localConfig() {
+ return {
+ useLocalWhisper: true,
+ localTranscriptionProvider: "nvidia",
+ whisperModel: "base",
+ parakeetModel: "parakeet-tdt-0.6b-v3",
+ cohereModel: "command-a-transcribe",
+ isOpenWhisprCloud: false,
+ getApiKey: () => "",
+ cloudTranscriptionProvider: "openai",
+ cloudTranscriptionBaseUrl: "",
+ cloudTranscriptionModel: "whisper-1",
+ language: "en",
+ transcriptionMode: "providers",
+ };
+}
+
+async function loadFileTranscription(t) {
+ const { window } = installBrowserGlobals(t);
+ const vite = await createRendererServer(t, {
+ cachePrefix: "openwhispr-file-diarization-warning-test-",
+ mockModules: {
+ "/lib/auth": "export const withSessionRefresh = (fn) => fn();",
+ },
+ });
+ const mod = await vite.ssrLoadModule("/services/fileTranscription.ts");
+ window.electronAPI.transcribeAudioFile = async () => ({
+ success: true,
+ text: "Plain transcript",
+ });
+ return { window, ...mod };
+}
+
+test("keeps the transcript and warns when local speaker identification fails", async (t) => {
+ const { window, transcribeFileWithSpeakers } = await loadFileTranscription(t);
+ window.electronAPI.diarizeAudioFile = async () => ({
+ success: false,
+ error: "Speaker identification failed",
+ });
+
+ const result = await transcribeFileWithSpeakers("/tmp/audio.wav", localConfig(), {
+ enabled: true,
+ localModelsReady: true,
+ numSpeakers: null,
+ });
+
+ assert.equal(result.success, true);
+ assert.equal(result.text, "Plain transcript");
+ assert.equal(result.diarizationWarning, true);
+});
+
+test("keeps the transcript and warns when speaker labels cannot be merged", async (t) => {
+ const { window, transcribeFileWithSpeakers } = await loadFileTranscription(t);
+ window.electronAPI.diarizeAudioFile = async () => ({
+ success: true,
+ segments: [{ speaker: "speaker_00", start: 0, end: 2 }],
+ });
+ window.electronAPI.mergeSpeakerText = async () => ({
+ success: false,
+ error: "Merge failed",
+ });
+
+ const result = await transcribeFileWithSpeakers("/tmp/audio.wav", localConfig(), {
+ enabled: true,
+ localModelsReady: true,
+ numSpeakers: null,
+ });
+
+ assert.equal(result.success, true);
+ assert.equal(result.text, "Plain transcript");
+ assert.equal(result.diarizationWarning, true);
+});
+
+test("does not warn when speaker labels are merged", async (t) => {
+ const { window, transcribeFileWithSpeakers } = await loadFileTranscription(t);
+ window.electronAPI.diarizeAudioFile = async () => ({
+ success: true,
+ segments: [{ speaker: "speaker_00", start: 0, end: 2 }],
+ });
+ window.electronAPI.mergeSpeakerText = async () => ({
+ success: true,
+ text: "Speaker 1: Plain transcript",
+ });
+
+ const result = await transcribeFileWithSpeakers("/tmp/audio.wav", localConfig(), {
+ enabled: true,
+ localModelsReady: true,
+ numSpeakers: null,
+ });
+
+ assert.equal(result.text, "Speaker 1: Plain transcript");
+ assert.equal(result.diarizationWarning, undefined);
+});
+
+test("does not warn when speaker detection is off", async (t) => {
+ const { window, transcribeFileWithSpeakers } = await loadFileTranscription(t);
+ let diarizeCalls = 0;
+ window.electronAPI.diarizeAudioFile = async () => {
+ diarizeCalls += 1;
+ return { success: false };
+ };
+
+ const result = await transcribeFileWithSpeakers("/tmp/audio.wav", localConfig(), {
+ enabled: false,
+ localModelsReady: true,
+ numSpeakers: null,
+ });
+
+ assert.equal(diarizeCalls, 0);
+ assert.equal(result.diarizationWarning, undefined);
+});
+
+test("does not warn when the provider applied its own speaker labels", async (t) => {
+ const { window, transcribeFileWithSpeakers } = await loadFileTranscription(t);
+ window.electronAPI.transcribeAudioFile = async () => ({
+ success: true,
+ text: "[Speaker 1] Hola",
+ diarized: true,
+ });
+
+ const result = await transcribeFileWithSpeakers("/tmp/audio.wav", localConfig(), {
+ enabled: true,
+ localModelsReady: true,
+ numSpeakers: null,
+ });
+
+ assert.equal(result.diarizationWarning, undefined);
+});
+
+test("keeps the transcript and warns when the merge throws", async (t) => {
+ const { window, transcribeFileWithSpeakers } = await loadFileTranscription(t);
+ window.electronAPI.diarizeAudioFile = async () => ({
+ success: true,
+ segments: [{ speaker: "speaker_00", start: 0, end: 2 }],
+ });
+ window.electronAPI.mergeSpeakerText = async () => {
+ throw new Error("merge crashed");
+ };
+
+ const result = await transcribeFileWithSpeakers("/tmp/audio.wav", localConfig(), {
+ enabled: true,
+ localModelsReady: true,
+ numSpeakers: null,
+ });
+
+ assert.equal(result.text, "Plain transcript");
+ assert.equal(result.diarizationWarning, true);
+});
+
+test("fetches the local speaker models before a run that needs them", async (t) => {
+ const { resolveDiarizationSettings } = await loadFileTranscription(t);
+ let ensureCalls = 0;
+
+ const settings = await resolveDiarizationSettings({
+ enabled: true,
+ modelsReady: false,
+ numSpeakers: null,
+ config: localConfig(),
+ ensureModels: async () => {
+ ensureCalls += 1;
+ return true;
+ },
+ });
+
+ assert.equal(ensureCalls, 1);
+ assert.deepEqual(settings, { enabled: true, localModelsReady: true, numSpeakers: null });
+});
+
+test("does not fetch local models when the provider diarizes server-side", async (t) => {
+ const { resolveDiarizationSettings } = await loadFileTranscription(t);
+ let ensureCalls = 0;
+
+ const settings = await resolveDiarizationSettings({
+ enabled: true,
+ modelsReady: false,
+ numSpeakers: 2,
+ config: { ...localConfig(), useLocalWhisper: false, cloudTranscriptionProvider: "openai" },
+ ensureModels: async () => {
+ ensureCalls += 1;
+ return true;
+ },
+ });
+
+ assert.equal(ensureCalls, 0);
+ assert.deepEqual(settings, { enabled: true, localModelsReady: false, numSpeakers: 2 });
+});
+
+test("does not fetch local models when speaker detection is off", async (t) => {
+ const { resolveDiarizationSettings } = await loadFileTranscription(t);
+ let ensureCalls = 0;
+
+ const settings = await resolveDiarizationSettings({
+ enabled: false,
+ modelsReady: false,
+ numSpeakers: null,
+ config: localConfig(),
+ ensureModels: async () => {
+ ensureCalls += 1;
+ return true;
+ },
+ });
+
+ assert.equal(ensureCalls, 0);
+ assert.equal(settings.enabled, false);
+});
+
+test("reports models unavailable when the download fails", async (t) => {
+ const { resolveDiarizationSettings } = await loadFileTranscription(t);
+
+ const settings = await resolveDiarizationSettings({
+ enabled: true,
+ modelsReady: false,
+ numSpeakers: null,
+ config: localConfig(),
+ ensureModels: async () => false,
+ });
+
+ assert.equal(settings.localModelsReady, false);
+});
diff --git a/test/stores/batchQueueDiarizationWarning.test.js b/test/stores/batchQueueDiarizationWarning.test.js
new file mode 100644
index 000000000..f72b84a6f
--- /dev/null
+++ b/test/stores/batchQueueDiarizationWarning.test.js
@@ -0,0 +1,80 @@
+const test = require("node:test");
+const assert = require("node:assert/strict");
+const { createRendererServer, installBrowserGlobals } = require("../lib/rendererTestHarness");
+
+async function waitForQueueCompletion(useBatchQueueStore) {
+ for (let attempt = 0; attempt < 20; attempt += 1) {
+ if (!useBatchQueueStore.getState().isProcessing) return;
+ await new Promise((resolve) => setImmediate(resolve));
+ }
+ throw new Error("Batch queue did not finish");
+}
+
+test("batch uploads retain diarization warnings separately from transcription warnings", async (t) => {
+ installBrowserGlobals(t);
+ globalThis.__batchDiarizationResult = {
+ success: true,
+ text: "Plain transcript",
+ diarizationWarning: true,
+ };
+ t.after(() => {
+ delete globalThis.__batchDiarizationResult;
+ });
+
+ const vite = await createRendererServer(t, {
+ cachePrefix: "openwhispr-batch-diarization-warning-test-",
+ mockModules: {
+ "/services/fileTranscription": `
+ export async function transcribeFileWithSpeakers() {
+ return globalThis.__batchDiarizationResult;
+ }
+ `,
+ "/components/notes/shared": `
+ export const DOWNLOAD_ERROR_KEYS = {};
+ export function transcriptionErrorKey() { return null; }
+ `,
+ "/services/uploadNotes": `
+ export async function saveUploadNote() {
+ return { success: true, note: { id: 42 } };
+ }
+ export function uploadTitleFallback() { return "Uploaded note"; }
+ `,
+ "/stores/settingsStore": "export function getSettings() { return {}; }",
+ "/stores/policyRules": "export function isTranscriptionContextAllowed() { return true; }",
+ "/stores/policyStore": `
+ export const usePolicyStore = { getState() { return {}; } };
+ `,
+ },
+ });
+ const { addFiles, processBatchQueue, useBatchQueueStore } = await vite.ssrLoadModule(
+ "/stores/batchQueueStore.ts"
+ );
+
+ addFiles([{ name: "interview.wav", path: "/tmp/interview.wav", sizeBytes: 1024 }]);
+ processBatchQueue(
+ {
+ transcription: {
+ useLocalWhisper: true,
+ localTranscriptionProvider: "nvidia",
+ whisperModel: "base",
+ parakeetModel: "parakeet-tdt-0.6b-v3",
+ cohereModel: "command-a-transcribe",
+ isOpenWhisprCloud: false,
+ getApiKey: () => "",
+ cloudTranscriptionProvider: "openai",
+ cloudTranscriptionBaseUrl: "",
+ cloudTranscriptionModel: "whisper-1",
+ language: "en",
+ },
+ folderId: null,
+ },
+ { enabled: true, localModelsReady: true, numSpeakers: null }
+ );
+ await waitForQueueCompletion(useBatchQueueStore);
+
+ const [item] = useBatchQueueStore.getState().queue;
+ assert.equal(item.status, "done");
+ assert.equal(item.warning, false);
+ assert.equal(item.diarizationWarning, true);
+ assert.equal(item.noteId, 42);
+});