Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.
JavaScript aianthropiccross-platformgeminigroqlinuxmacosnvidiaopen-sourceopenaiparakeetspeech-to-texttranscribewhisperwindows
fix(upload): honor self-hosted transcription mode for audio uploads (#1180)
Gabriel Steinc18706f388f8
diff --git a/src/components/notes/UploadAudioView.tsx b/src/components/notes/UploadAudioView.tsxindex 09724d239..40ebdd01d 100644--- a/src/components/notes/UploadAudioView.tsx+++ b/src/components/notes/UploadAudioView.tsx@@ -102,8 +102,12 @@ export default function UploadAudioView({ onNoteCreated, onOpenSettings }: UploacloudTranscriptionModel,cloudTranscriptionBaseUrl,cloudTranscriptionMode,+ transcriptionMode,} = useSettingsStore(useShallow(selectResolvedUploadTranscription));+ const remoteTranscriptionUrl = useSettingsStore((s) => s.remoteTranscriptionUrl);+ const remoteTranscriptionModel = useSettingsStore((s) => s.remoteTranscriptionModel);+const setUploadTranscriptionMode = useSettingsStore((s) => s.setUploadTranscriptionMode);const setUploadCloudTranscriptionMode = useSettingsStore((s) => s.setUploadCloudTranscriptionMode@@ -125,6 +129,7 @@ export default function UploadAudioView({ onNoteCreated, onOpenSettings }: UploaisSignedIn && cloudTranscriptionMode === "openwhispr" && !useLocalWhisper;// Mode detection+ const isSelfHosted = transcriptionMode === "self-hosted" && !useLocalWhisper;const isByok = !useLocalWhisper && !isOpenWhisprCloud;// Mode-aware file size validation@@ -141,8 +146,8 @@ export default function UploadAudioView({ onNoteCreated, onOpenSettings }: Uploaif (file) {if (useLocalWhisper) {// Local transcription: no file size restrictions- } else if (cloudTranscriptionProvider === "custom") {- // Custom endpoints (e.g. local whisper.cpp): no file size restrictions+ } else if (isSelfHosted || cloudTranscriptionProvider === "custom") {+ // Self-hosted / custom endpoints (e.g. local whisper.cpp): no file size restrictions} else if (isByok) {byokTooLarge = file.sizeBytes > BYOK_MAX_FILE_SIZE;if (byokTooLarge && !isSignedIn) {@@ -178,7 +183,9 @@ export default function UploadAudioView({ onNoteCreated, onOpenSettings }: Uploareturn;}if (!useLocalWhisper) {- if (cloudTranscriptionProvider === "custom") {+ if (isSelfHosted) {+ if (!cancelled) setProviderReady(!!remoteTranscriptionUrl?.trim());+ } else if (cloudTranscriptionProvider === "custom") {// Custom providers only need a base URL; API key is truly optionalif (!cancelled) setProviderReady(!!cloudTranscriptionBaseUrl?.trim());} else if (cloudTranscriptionProvider === "corti") {@@ -220,6 +227,8 @@ export default function UploadAudioView({ onNoteCreated, onOpenSettings }: Uploa};}, [isOpenWhisprCloud,+ isSelfHosted,+ remoteTranscriptionUrl,useLocalWhisper,localTranscriptionProvider,cloudTranscriptionProvider,@@ -241,6 +250,10 @@ export default function UploadAudioView({ onNoteCreated, onOpenSettings }: Uploareturn `Parakeet · ${parakeetModel || "default"}`;return `Whisper · ${whisperModel || "base"}`;}+ if (isSelfHosted) {+ const name = t("settingsPage.transcription.modes.selfHosted");+ return remoteTranscriptionModel ? `${name} · ${remoteTranscriptionModel}` : name;+ }const name =cloudTranscriptionProvider === "custom"? t("notes.upload.custom")@@ -380,6 +393,8 @@ export default function UploadAudioView({ onNoteCreated, onOpenSettings }: Uploamodel: localTranscriptionProvider === "nvidia" ? parakeetModel : whisperModel,});} else {+ // Self-hosted fields make the handler route to the configured server+ // (fail-closed on misconfiguration) instead of stale BYOK settings.res = await window.electronAPI.transcribeAudioFileByok!({filePath: file.path,apiKey: getActiveApiKey(),@@ -389,6 +404,9 @@ export default function UploadAudioView({ onNoteCreated, onOpenSettings }: Uploalanguage: getBaseLanguageCode(preferredLanguage) || "en",environment: cortiEnvironment,tenant: cortiTenant,+ transcriptionMode,+ remoteTranscriptionUrl,+ remoteTranscriptionModel,});}@@ -481,6 +499,11 @@ export default function UploadAudioView({ onNoteCreated, onOpenSettings }: Uploaconst getTranscribingLabel = (): string => {if (isOpenWhisprCloud) return t("notes.upload.transcribingCloud");if (useLocalWhisper) return t("notes.upload.transcribingLocal");+ if (isSelfHosted) {+ return t("notes.upload.transcribingProvider", {+ provider: t("settingsPage.transcription.modes.selfHosted"),+ });+ }return t("notes.upload.transcribingProvider", { provider: cloudTranscriptionProvider });};diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.jsindex 1d18e2763..b242f4926 100644--- a/src/helpers/ipcHandlers.js+++ b/src/helpers/ipcHandlers.js@@ -6976,11 +6976,55 @@ class IPCHandlers {"transcribe-audio-file-byok",async (event,- { filePath, apiKey, baseUrl, model, provider, language, environment, tenant }+ {+ filePath,+ apiKey,+ baseUrl,+ model,+ provider,+ language,+ environment,+ tenant,+ transcriptionMode,+ remoteTranscriptionUrl,+ remoteTranscriptionModel,+ }) => {const fs = require("fs");const BYOK_FILE_SIZE_LIMIT = 25 * 1024 * 1024; // 25 MBtry {+ const { resolveSelfHostedRetryRoute } = await import("./retryTranscriptionRouting.js");+ const selfHostedRoute = resolveSelfHostedRetryRoute({+ transcriptionMode,+ remoteTranscriptionUrl,+ remoteTranscriptionModel,+ });++ // Fail closed: a misconfigured self-hosted setup must never fall through to BYOK.+ if (selfHostedRoute?.kind === "configuration-error") {+ return { success: false, error: selfHostedRoute.error };+ }++ if (selfHostedRoute?.kind === "self-hosted") {+ // User's own server, so the 25 MB third-party cap does not apply.+ const ext = path.extname(filePath).toLowerCase().replace(".", "");+ const { body, boundary } = buildMultipartBody(+ fs.readFileSync(filePath),+ path.basename(filePath),+ AUDIO_MIME_TYPES[ext] || "audio/mpeg",+ { model: selfHostedRoute.model, language }+ );+ const data = await postMultipart(new URL(selfHostedRoute.endpoint), body, boundary);+ if (data.statusCode !== 200) {+ throw new Error(+ data.data?.error?.message ||+ data.data?.error ||+ `Self-hosted API Error: ${data.statusCode}`+ );+ }+ return { success: true, text: data.data.text };+ }+const fileSize = fs.statSync(filePath).size;if (fileSize > BYOK_FILE_SIZE_LIMIT) {return {diff --git a/src/types/electron.ts b/src/types/electron.tsindex 55bbaae64..0a9b6eef1 100644--- a/src/types/electron.ts+++ b/src/types/electron.ts@@ -1320,6 +1320,9 @@ declare global {language?: string;environment?: string;tenant?: string;+ transcriptionMode?: string;+ remoteTranscriptionUrl?: string;+ remoteTranscriptionModel?: string;}) => Promise<{success: boolean;text?: string;