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
Mode-aware file size validation and large file upload support (#352)
Gabriel Stein2c263dce5868
diff --git a/preload.js b/preload.jsindex f8ece6a88..975d5629d 100644--- a/preload.js+++ b/preload.js@@ -86,6 +86,7 @@ contextBridge.exposeInMainWorld("electronAPI", {// Audio file operationsselectAudioFile: () => ipcRenderer.invoke("select-audio-file"),+ getFileSize: (filePath) => ipcRenderer.invoke("get-file-size", filePath),transcribeAudioFile: (filePath, options) =>ipcRenderer.invoke("transcribe-audio-file", filePath, options),getPathForFile: (file) => webUtils.getPathForFile(file),@@ -351,6 +352,10 @@ contextBridge.exposeInMainWorld("electronAPI", {transcribeAudioFileCloud: (filePath) =>ipcRenderer.invoke("transcribe-audio-file-cloud", filePath),transcribeAudioFileByok: (options) => ipcRenderer.invoke("transcribe-audio-file-byok", options),+ onUploadTranscriptionProgress: registerListener(+ "upload-transcription-progress",+ (callback) => (_event, data) => callback(data)+ ),// Referral statsgetReferralStats: () => ipcRenderer.invoke("get-referral-stats"),diff --git a/src/components/notes/UploadAudioView.tsx b/src/components/notes/UploadAudioView.tsxindex 8165881b8..672b19223 100644--- a/src/components/notes/UploadAudioView.tsx+++ b/src/components/notes/UploadAudioView.tsx@@ -40,6 +40,10 @@ type UploadState = "idle" | "selected" | "transcribing" | "complete" | "error";const SUPPORTED_EXTENSIONS = ["mp3", "wav", "m4a", "webm", "ogg", "flac", "aac"];+const BYOK_MAX_FILE_SIZE = 25 * 1024 * 1024; // 25 MB — hard limit for bring-your-own-key+const CLOUD_FREE_MAX_FILE_SIZE = 25 * 1024 * 1024; // 25 MB — free plan cloud limit+const CLOUD_PRO_MAX_FILE_SIZE = 500 * 1024 * 1024; // 500 MB — pro plan cloud limit+const TITLE_SYSTEM_PROMPT ="Generate a concise 3-8 word title for these transcribed notes. Return ONLY the title text, nothing else — no quotes, no prefix, no explanation.";@@ -57,13 +61,23 @@ interface UploadAudioViewProps {export default function UploadAudioView({ onNoteCreated, onOpenSettings }: UploadAudioViewProps) {const { t } = useTranslation();const [state, setState] = useState<UploadState>("idle");- const [file, setFile] = useState<{ name: string; path: string; size: string } | null>(null);+ const [file, setFile] = useState<{+ name: string;+ path: string;+ size: string;+ sizeBytes: number;+ } | null>(null);const [result, setResult] = useState<string | null>(null);const [noteId, setNoteId] = useState<number | null>(null);const [error, setError] = useState<string | null>(null);const [isDragOver, setIsDragOver] = useState(false);const [progress, setProgress] = useState(0);const progressRef = useRef<ReturnType<typeof setInterval> | null>(null);+ const [chunkProgress, setChunkProgress] = useState<{+ chunksTotal: number;+ chunksCompleted: number;+ } | null>(null);+ const progressCleanupRef = useRef<(() => void) | null>(null);const [folders, setFolders] = useState<FolderItem[]>([]);const [selectedFolderId, setSelectedFolderId] = useState<string>("");@@ -123,6 +137,36 @@ export default function UploadAudioView({ onNoteCreated, onOpenSettings }: Uploaconst showModelPicker = !isSignedIn || cloudTranscriptionMode === "byok" || useLocalWhisper;const shouldCenter = !showSetup && !advancedOpen;+ // Mode detection+ const isByok = !useLocalWhisper && !isOpenWhisprCloud;++ // Mode-aware file size validation+ // Local: no limits at all+ // BYOK: 25 MB hard max regardless of plan+ // Cloud free: 25 MB max (upgrade to Pro for more)+ // Cloud pro: 500 MB max+ let fileTooLarge = false;+ let requiresUpgrade = false;+ let requiresAccount = false;+ let byokTooLarge = false;+ let isLargeFile = false;++ if (file) {+ if (useLocalWhisper) {+ // Local transcription: no file size restrictions+ } else if (isByok) {+ byokTooLarge = file.sizeBytes > BYOK_MAX_FILE_SIZE;+ if (byokTooLarge && !isSignedIn) {+ requiresAccount = true;+ }+ } else {+ // Cloud (OpenWhispr) — user is always signed in here+ fileTooLarge = file.sizeBytes > CLOUD_PRO_MAX_FILE_SIZE;+ requiresUpgrade = !isProUser && file.sizeBytes > CLOUD_FREE_MAX_FILE_SIZE;+ isLargeFile = file.sizeBytes > CLOUD_FREE_MAX_FILE_SIZE;+ }+ }+useEffect(() => {return () => {if (progressRef.current) clearInterval(progressRef.current);@@ -236,7 +280,13 @@ export default function UploadAudioView({ onNoteCreated, onOpenSettings }: Uploaconst res = await window.electronAPI.selectAudioFile();if (!res.canceled && res.filePath) {const name = res.filePath.split(/[/\\]/).pop() || "audio";- setFile({ name, path: res.filePath, size: "" });+ const sizeBytes = (await window.electronAPI.getFileSize?.(res.filePath)) ?? 0;+ setFile({+ name,+ path: res.filePath,+ size: sizeBytes ? formatFileSize(sizeBytes) : "",+ sizeBytes,+ });setState("selected");setError(null);}@@ -251,7 +301,7 @@ export default function UploadAudioView({ onNoteCreated, onOpenSettings }: Uploaif (SUPPORTED_EXTENSIONS.includes(ext)) {const filePath = window.electronAPI.getPathForFile(f);if (!filePath) return;- setFile({ name: f.name, path: filePath, size: formatFileSize(f.size) });+ setFile({ name: f.name, path: filePath, size: formatFileSize(f.size), sizeBytes: f.size });setState("selected");setError(null);}@@ -259,12 +309,15 @@ export default function UploadAudioView({ onNoteCreated, onOpenSettings }: Uploaconst reset = () => {if (progressRef.current) clearInterval(progressRef.current);+ if (progressCleanupRef.current) progressCleanupRef.current();+ progressCleanupRef.current = null;setState("idle");setFile(null);setResult(null);setNoteId(null);setError(null);setProgress(0);+ setChunkProgress(null);const personal = findDefaultFolder(folders);if (personal) setSelectedFolderId(String(personal.id));};@@ -274,16 +327,32 @@ export default function UploadAudioView({ onNoteCreated, onOpenSettings }: UploasetState("transcribing");setError(null);setProgress(0);+ setChunkProgress(null);- progressRef.current = setInterval(() => {- setProgress((prev) => {- if (prev >= 90) {- if (progressRef.current) clearInterval(progressRef.current);- return prev;- }- return prev + Math.random() * 6;- });- }, 500);+ const useChunkProgress = isOpenWhisprCloud && isLargeFile;++ if (useChunkProgress) {+ progressCleanupRef.current =+ window.electronAPI.onUploadTranscriptionProgress?.((data) => {+ if (data.chunksTotal > 0) {+ setChunkProgress({+ chunksTotal: data.chunksTotal,+ chunksCompleted: data.chunksCompleted,+ });+ setProgress((data.chunksCompleted / data.chunksTotal) * 90);+ }+ }) ?? null;+ } else {+ progressRef.current = setInterval(() => {+ setProgress((prev) => {+ if (prev >= 90) {+ if (progressRef.current) clearInterval(progressRef.current);+ return prev;+ }+ return prev + Math.random() * 6;+ });+ }, 500);+ }try {let res: { success: boolean; text?: string; error?: string; code?: string };@@ -313,6 +382,8 @@ export default function UploadAudioView({ onNoteCreated, onOpenSettings }: Uploa}if (progressRef.current) clearInterval(progressRef.current);+ if (progressCleanupRef.current) progressCleanupRef.current();+ progressCleanupRef.current = null;if (res.success && res.text) {setProgress(100);@@ -344,6 +415,8 @@ export default function UploadAudioView({ onNoteCreated, onOpenSettings }: Uploa}} catch (err) {if (progressRef.current) clearInterval(progressRef.current);+ if (progressCleanupRef.current) progressCleanupRef.current();+ progressCleanupRef.current = null;setProgress(0);setError(err instanceof Error ? err.message : t("notes.upload.errorOccurred"));setState("error");@@ -382,6 +455,19 @@ export default function UploadAudioView({ onNoteCreated, onOpenSettings }: Uploa}};+ const handleCreateAccount = () => {+ localStorage.setItem("pendingCloudMigration", "true");+ localStorage.setItem("onboardingCurrentStep", "0");+ localStorage.removeItem("onboardingCompleted");+ window.location.reload();+ };++ const switchToCloud = () => {+ setCloudTranscriptionMode("openwhispr");+ setUseLocalWhisper(false);+ updateTranscriptionSettings({ useLocalWhisper: false });+ };+const getTranscribingLabel = (): string => {if (isOpenWhisprCloud) return t("notes.upload.transcribingCloud");if (useLocalWhisper) return t("notes.upload.transcribingLocal");@@ -520,6 +606,16 @@ export default function UploadAudioView({ onNoteCreated, onOpenSettings }: UploagetActiveModelLabel={getActiveModelLabel}reset={reset}handleTranscribe={handleTranscribe}+ requiresUpgrade={!!requiresUpgrade}+ fileTooLarge={fileTooLarge}+ isLargeFile={isLargeFile}+ isOpenWhisprCloud={isOpenWhisprCloud}+ byokTooLarge={byokTooLarge}+ requiresAccount={requiresAccount}+ isProUser={!!isProUser}+ onUpgrade={() => usage?.openCheckout()}+ onCreateAccount={handleCreateAccount}+ onSwitchToCloud={switchToCloud}/>)}@@ -529,6 +625,7 @@ export default function UploadAudioView({ onNoteCreated, onOpenSettings }: Uploaprogress={progress}getTranscribingLabel={getTranscribingLabel}file={file}+ chunkProgress={chunkProgress}/>)}@@ -616,10 +713,6 @@ export default function UploadAudioView({ onNoteCreated, onOpenSettings }: Uploa);}-/* -------------------------------------------------------------------------- */-/* Private sub-components — one per upload state variant */-/* -------------------------------------------------------------------------- */-interface NoProviderViewProps {t: (key: string, options?: Record<string, unknown>) => string;onOpenSettings: () => void;@@ -775,10 +868,20 @@ function IdleView({interface SelectedViewProps {t: (key: string) => string;- file: { name: string; path: string; size: string };+ file: { name: string; path: string; size: string; sizeBytes: number };getActiveModelLabel: () => string;reset: () => void;handleTranscribe: () => void;+ requiresUpgrade: boolean;+ fileTooLarge: boolean;+ isLargeFile: boolean;+ isOpenWhisprCloud: boolean;+ byokTooLarge: boolean;+ requiresAccount: boolean;+ isProUser: boolean;+ onUpgrade: () => void;+ onCreateAccount: () => void;+ onSwitchToCloud: () => void;}function SelectedView({@@ -787,7 +890,19 @@ function SelectedView({getActiveModelLabel,reset,handleTranscribe,+ requiresUpgrade,+ fileTooLarge,+ isLargeFile,+ isOpenWhisprCloud,+ byokTooLarge,+ requiresAccount,+ isProUser,+ onUpgrade,+ onCreateAccount,+ onSwitchToCloud,}: SelectedViewProps) {+ const canTranscribe = !fileTooLarge && !requiresUpgrade && !byokTooLarge;+return (<div style={{ animation: "float-up 0.3s ease-out" }}><div className="rounded-lg border border-foreground/8 dark:border-white/6 bg-surface-1/40 dark:bg-white/[0.03] backdrop-blur-sm p-4 mb-3">@@ -809,10 +924,102 @@ function SelectedView({</div></div>- <div className="flex items-center gap-2 justify-center">- <Button variant="default" size="sm" onClick={handleTranscribe} className="h-8 text-xs px-5">- {t("notes.upload.transcribe")}- </Button>+ {/* Cloud absolute limit (500 MB) */}+ {fileTooLarge && (+ <div className="rounded-lg border border-destructive/12 dark:border-destructive/15 bg-destructive/[0.03] px-3 py-2.5 mb-3">+ <p className="text-xs text-destructive/60 leading-relaxed">+ {t("notes.upload.fileTooLarge")}+ </p>+ </div>+ )}++ {/* BYOK file too large — shared explanation */}+ {byokTooLarge && (+ <div className="rounded-lg border border-primary/12 dark:border-primary/15 bg-primary/[0.03] px-3 py-2.5 mb-3">+ <p className="text-xs text-foreground/50 leading-relaxed">+ {t("notes.upload.byokTooLarge")}+ </p>+ <p className="text-xs text-foreground/35 leading-relaxed mt-1.5">+ {t("notes.upload.byokTooLargeDetail")}+ </p>+ <p className="text-xs text-foreground/50 leading-relaxed mt-1.5 font-medium">+ {requiresAccount+ ? t("notes.upload.byokTooLargeNeedsAccount")+ : isProUser+ ? t("notes.upload.switchToCloudForLargeFiles")+ : t("notes.upload.byokTooLargeNeedsUpgrade")}+ </p>+ </div>+ )}++ {/* Cloud free user, file > 25 MB → needs paid plan */}+ {requiresUpgrade && !fileTooLarge && (+ <div className="rounded-lg border border-primary/12 dark:border-primary/15 bg-primary/[0.03] px-3 py-2.5 mb-3">+ <p className="text-xs text-foreground/50 leading-relaxed">+ {t("notes.upload.paidPlanRequired")}+ </p>+ </div>+ )}++ {/* Cloud large file info (Pro user, will be chunked) */}+ {isLargeFile && !requiresUpgrade && !fileTooLarge && isOpenWhisprCloud && (+ <p className="text-xs text-foreground/20 text-center mb-3">+ {t("notes.upload.largeFileNote")}+ </p>+ )}++ <div className="flex items-center gap-2 justify-center flex-wrap">+ {/* BYOK too large — not signed in: Create Account */}+ {byokTooLarge && requiresAccount && (+ <Button+ variant="default"+ size="sm"+ onClick={onCreateAccount}+ className="h-8 text-xs px-5"+ >+ {t("notes.upload.createAccount")}+ </Button>+ )}++ {/* BYOK too large — signed in, Pro: Switch to Cloud */}+ {byokTooLarge && !requiresAccount && isProUser && (+ <Button+ variant="default"+ size="sm"+ onClick={onSwitchToCloud}+ className="h-8 text-xs px-5"+ >+ {t("notes.upload.switchToCloud")}+ </Button>+ )}++ {/* BYOK too large — signed in, Free: Upgrade */}+ {byokTooLarge && !requiresAccount && !isProUser && (+ <Button variant="default" size="sm" onClick={onUpgrade} className="h-8 text-xs px-5">+ {t("notes.upload.upgrade")}+ </Button>+ )}++ {/* Cloud requires upgrade */}+ {!byokTooLarge && requiresUpgrade && (+ <Button variant="default" size="sm" onClick={onUpgrade} className="h-8 text-xs px-5">+ {t("notes.upload.upgrade")}+ </Button>+ )}++ {/* Normal: can transcribe */}+ {canTranscribe && (+ <Button+ variant="default"+ size="sm"+ onClick={handleTranscribe}+ className="h-8 text-xs px-5"+ >+ {t("notes.upload.transcribe")}+ </Button>+ )}++ {/* Cancel button — always shown */}<Buttonvariant="ghost"size="sm"@@ -827,13 +1034,22 @@ function SelectedView({}interface TranscribingViewProps {- t: (key: string) => string;+ t: (key: string, options?: Record<string, unknown>) => string;progress: number;getTranscribingLabel: () => string;- file: { name: string; path: string; size: string } | null;+ file: { name: string; path: string; size: string; sizeBytes: number } | null;+ chunkProgress: { chunksTotal: number; chunksCompleted: number } | null;}-function TranscribingView({ t, progress, getTranscribingLabel, file }: TranscribingViewProps) {+function TranscribingView({+ t,+ progress,+ getTranscribingLabel,+ file,+ chunkProgress,+}: TranscribingViewProps) {+ const hasChunkInfo = chunkProgress !== null && chunkProgress.chunksTotal > 0;+return (<div className="flex flex-col items-center" style={{ animation: "float-up 0.3s ease-out" }}><div className="flex items-end justify-center gap-[3px] h-10 mb-5">@@ -858,9 +1074,17 @@ function TranscribingView({ t, progress, getTranscribingLabel, file }: Transcrib</div><p className="text-xs text-foreground/50 font-medium">{getTranscribingLabel()}</p>- {file && (- <p className="text-xs text-foreground/20 mt-1 truncate max-w-[200px]">{file.name}</p>- )}+ {hasChunkInfo ? (+ <p className="text-xs text-foreground/20 mt-1">+ {t("notes.upload.chunkProgress", {+ completed: chunkProgress.chunksCompleted,+ total: chunkProgress.chunksTotal,+ })}+ </p>+ ) : null}+ {!hasChunkInfo && file ? (+ <p className="text-xs text-foreground/20 mt-1 truncate max-w-50">{file.name}</p>+ ) : null}</div>);}diff --git a/src/helpers/ffmpegUtils.js b/src/helpers/ffmpegUtils.jsindex 3b60d5ee8..f6d1c38e0 100644--- a/src/helpers/ffmpegUtils.js+++ b/src/helpers/ffmpegUtils.js@@ -237,6 +237,88 @@ function computeFloat32RMS(float32Buffer) {return Math.sqrt(sumSquares / numSamples);}+function splitAudioFile(inputPath, outputDir, options = {}) {+ const { segmentDuration = 600, audioBitrate = "128k" } = options;++ return new Promise((resolve, reject) => {+ const ffmpegPath = getFFmpegPath();+ if (!ffmpegPath) {+ reject(new Error("FFmpeg not found - required for audio splitting"));+ return;+ }++ const outputPattern = path.join(outputDir, "chunk-%03d.mp3");++ const args = [+ "-i",+ inputPath,+ "-f",+ "segment",+ "-segment_time",+ String(segmentDuration),+ "-c:a",+ "libmp3lame",+ "-b:a",+ audioBitrate,+ "-ar",+ "16000",+ "-ac",+ "1",+ "-y",+ outputPattern,+ ];++ debugLogger.debug("Splitting audio with FFmpeg", {+ input: inputPath,+ outputDir,+ segmentDuration,+ audioBitrate,+ });++ const proc = spawn(ffmpegPath, args, {+ stdio: ["ignore", "pipe", "pipe"],+ windowsHide: true,+ });++ let stderr = "";++ proc.stderr.on("data", (data) => {+ stderr += data.toString();+ });++ proc.on("error", (error) => {+ reject(new Error(`FFmpeg split error: ${error.message}`));+ });++ proc.on("close", (code) => {+ if (code !== 0) {+ const stderrPreview = stderr.slice(-500).trim();+ debugLogger.debug("FFmpeg split failed", { code, stderr: stderrPreview });+ reject(+ new Error(+ `FFmpeg split exited with code ${code}${stderrPreview ? `: ${stderrPreview}` : ""}`+ )+ );+ return;+ }++ const chunks = fs+ .readdirSync(outputDir)+ .filter((f) => f.startsWith("chunk-") && f.endsWith(".mp3"))+ .sort()+ .map((f) => path.join(outputDir, f));++ if (chunks.length === 0) {+ reject(new Error("FFmpeg split produced no output files"));+ return;+ }++ debugLogger.debug("FFmpeg split complete", { chunkCount: chunks.length });+ resolve(chunks);+ });+ });+}+function clearCache() {cachedFFmpegPath = null;}@@ -245,6 +327,7 @@ module.exports = {getFFmpegPath,isWavFormat,convertToWav,+ splitAudioFile,wavToFloat32Samples,computeFloat32RMS,clearCache,diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.jsindex b6f4a95d3..d09463f26 100644--- a/src/helpers/ipcHandlers.js+++ b/src/helpers/ipcHandlers.js@@ -577,6 +577,16 @@ class IPCHandlers {return { canceled: false, filePath: result.filePaths[0] };});+ ipcMain.handle("get-file-size", async (_event, filePath) => {+ const fs = require("fs");+ try {+ const stats = fs.statSync(filePath);+ return stats.size;+ } catch {+ return 0;+ }+ });+ipcMain.handle("transcribe-audio-file", async (event, filePath, options = {}) => {const fs = require("fs");try {@@ -2115,6 +2125,10 @@ class IPCHandlers {ipcMain.handle("transcribe-audio-file-cloud", async (event, filePath) => {const fs = require("fs");+ const os = require("os");+ const { splitAudioFile } = require("./ffmpegUtils");+ const FILE_SIZE_LIMIT = 25 * 1024 * 1024;+ const CONCURRENCY_LIMIT = 5;try {const apiUrl = getApiUrl();if (!apiUrl) throw new Error("OpenWhispr API URL not configured");@@ -2122,6 +2136,126 @@ class IPCHandlers {const cookieHeader = await getSessionCookies(event);if (!cookieHeader) throw new Error("No session cookies available");+ const fileSize = fs.statSync(filePath).size;++ if (fileSize > FILE_SIZE_LIMIT) {+ debugLogger.debug("Large file detected, using client-side chunking", {+ fileSize,+ filePath: path.basename(filePath),+ });++ const chunkDir = path.join(os.tmpdir(), `ow-chunks-${Date.now()}`);+ fs.mkdirSync(chunkDir, { recursive: true });++ try {+ event.sender.send("upload-transcription-progress", {+ stage: "splitting",+ chunksTotal: 0,+ chunksCompleted: 0,+ });++ const chunkPaths = await splitAudioFile(filePath, chunkDir);+ const totalChunks = chunkPaths.length;++ debugLogger.debug("Audio split into chunks", { totalChunks });++ event.sender.send("upload-transcription-progress", {+ stage: "transcribing",+ chunksTotal: totalChunks,+ chunksCompleted: 0,+ });++ const results = new Array(totalChunks).fill(null);+ let completedCount = 0;++ const transcribeChunk = async (index) => {+ const chunkBuffer = fs.readFileSync(chunkPaths[index]);+ const chunkName = path.basename(chunkPaths[index]);++ const { body, boundary } = buildMultipartBody(chunkBuffer, chunkName, "audio/mpeg", {+ source: "file_upload",+ clientType: "desktop",+ appVersion: app.getVersion(),+ clientVersion: app.getVersion(),+ sessionId: this.sessionId,+ });++ const url = new URL(`${apiUrl}/api/transcribe`);+ const data = await postMultipart(url, body, boundary, { Cookie: cookieHeader });++ if (data.statusCode === 401) {+ throw Object.assign(new Error("Session expired"), { code: "AUTH_EXPIRED" });+ }+ if (data.statusCode === 429) {+ throw Object.assign(new Error("Daily word limit reached"), {+ code: "LIMIT_REACHED",+ ...data.data,+ });+ }+ if (data.statusCode !== 200) {+ throw new Error(data.data?.error || `API error: ${data.statusCode}`);+ }++ results[index] = data.data;+ completedCount++;++ event.sender.send("upload-transcription-progress", {+ stage: "transcribing",+ chunksTotal: totalChunks,+ chunksCompleted: completedCount,+ });+ };++ const indices = Array.from({ length: totalChunks }, (_, i) => i);+ const executing = new Set();++ for (const index of indices) {+ const p = transcribeChunk(index).then(+ () => executing.delete(p),+ (err) => {+ executing.delete(p);+ if (err.code === "AUTH_EXPIRED" || err.code === "LIMIT_REACHED") throw err;+ debugLogger.warn(`Chunk ${index} failed`, { error: err.message });+ }+ );+ executing.add(p);+ if (executing.size >= CONCURRENCY_LIMIT) {+ await Promise.race(executing);+ }+ }+ await Promise.all(executing);++ const succeeded = results.filter((r) => r !== null);+ if (succeeded.length === 0) {+ throw new Error("All chunks failed to transcribe");+ }++ const fullText = results+ .filter((r) => r !== null)+ .map((r) => r.text)+ .join(" ")+ .replace(/\s+/g, " ")+ .trim();++ const failed = results.filter((r) => r === null).length;+ if (failed > 0) {+ debugLogger.warn("Some chunks failed", { failed, total: totalChunks });+ }++ return {+ success: true,+ text: fullText,+ ...(failed > 0 ? { warning: `${failed} of ${totalChunks} chunks failed` } : {}),+ };+ } finally {+ try {+ fs.rmSync(chunkDir, { recursive: true, force: true });+ } catch (cleanupErr) {+ debugLogger.warn("Failed to cleanup chunk dir", { error: cleanupErr.message });+ }+ }+ }+const audioBuffer = fs.readFileSync(filePath);const ext = path.extname(filePath).toLowerCase().replace(".", "");const contentType = AUDIO_MIME_TYPES[ext] || "audio/mpeg";@@ -2156,6 +2290,9 @@ class IPCHandlers {return { success: true, text: data.data.text };} catch (error) {debugLogger.error("Cloud audio file transcription error", { error: error.message });+ if (error.code === "AUTH_EXPIRED" || error.code === "LIMIT_REACHED") {+ return { success: false, error: error.message, code: error.code, ...error };+ }return { success: false, error: error.message };}});@@ -2164,10 +2301,19 @@ class IPCHandlers {"transcribe-audio-file-byok",async (event, { filePath, apiKey, baseUrl, model }) => {const fs = require("fs");+ const BYOK_FILE_SIZE_LIMIT = 25 * 1024 * 1024; // 25 MBtry {if (!apiKey) throw new Error("No API key configured. Add your key in Settings.");if (!baseUrl) throw new Error("No transcription endpoint configured.");+ const fileSize = fs.statSync(filePath).size;+ if (fileSize > BYOK_FILE_SIZE_LIMIT) {+ return {+ success: false,+ error: "File too large. Maximum size for bring-your-own-key is 25 MB.",+ };+ }+const audioBuffer = fs.readFileSync(filePath);const ext = path.extname(filePath).toLowerCase().replace(".", "");const contentType = AUDIO_MIME_TYPES[ext] || "audio/mpeg";diff --git a/src/locales/de/translation.json b/src/locales/de/translation.jsonindex ccb8c98b6..07d819961 100644--- a/src/locales/de/translation.json+++ b/src/locales/de/translation.json@@ -1392,7 +1392,10 @@"errorOccurred": "Ein Fehler ist aufgetreten","noProviderTitle": "Kein Transkriptionsanbieter eingerichtet","noProviderDescription": "Fügen Sie einen API-Schlüssel hinzu oder laden Sie ein lokales Modell herunter, um mit der Transkription zu beginnen.",- "noProviderAction": "Transkriptionseinstellungen öffnen"+ "noProviderAction": "Transkriptionseinstellungen öffnen",+ "fileTooLarge": "Diese Datei überschreitet das Limit von 500 MB.",+ "largeFileNote": "Große Dateien werden aufgeteilt und parallel transkribiert.",+ "chunkProgress": "Transkribiere Teil {{completed}} von {{total}}..."},"meeting": {"title": "Besprechungsnotizen",diff --git a/src/locales/en/translation.json b/src/locales/en/translation.jsonindex 76575b4b9..cd2922bc0 100644--- a/src/locales/en/translation.json+++ b/src/locales/en/translation.json@@ -1428,7 +1428,19 @@"errorOccurred": "An error occurred","noProviderTitle": "No transcription provider set up","noProviderDescription": "Add an API key or download a local model to start transcribing.",- "noProviderAction": "Open Transcription Settings"+ "noProviderAction": "Open Transcription Settings",+ "fileTooLarge": "This file exceeds the 500 MB limit.",+ "paidPlanRequired": "Cloud transcription for files over 25 MB requires a paid plan. Large files are processed with OpenWhispr Cloud for reliable, high-quality results.",+ "largeFileNote": "Large files are split and transcribed in parallel.",+ "chunkProgress": "Transcribing part {{completed}} of {{total}}...",+ "byokTooLarge": "Third-party API keys only support files up to 25 MB.",+ "byokTooLargeDetail": "For files over 25 MB, OpenWhispr Cloud handles splitting, parallel processing, and reassembly — so you get reliable results without depending on third-party provider limits.",+ "byokTooLargeNeedsAccount": "Create an account and upgrade to a paid plan to transcribe larger files with OpenWhispr Cloud.",+ "byokTooLargeNeedsUpgrade": "Upgrade to a paid plan to transcribe larger files with OpenWhispr Cloud.",+ "switchToCloudForLargeFiles": "Switch to OpenWhispr Cloud to transcribe this file.",+ "createAccount": "Create Account",+ "upgrade": "Upgrade",+ "switchToCloud": "OpenWhispr Cloud"},"meeting": {"title": "Meeting Notes",diff --git a/src/locales/es/translation.json b/src/locales/es/translation.jsonindex 87823acc5..0e28a9fa0 100644--- a/src/locales/es/translation.json+++ b/src/locales/es/translation.json@@ -1396,7 +1396,10 @@"errorOccurred": "Se produjo un error","noProviderTitle": "No se ha configurado un proveedor de transcripción","noProviderDescription": "Agrega una clave API o descarga un modelo local para comenzar a transcribir.",- "noProviderAction": "Abrir configuración de transcripción"+ "noProviderAction": "Abrir configuración de transcripción",+ "fileTooLarge": "Este archivo supera el límite de 500 MB.",+ "largeFileNote": "Los archivos grandes se dividen y transcriben en paralelo.",+ "chunkProgress": "Transcribiendo parte {{completed}} de {{total}}..."},"meeting": {"title": "Notas de reunión",diff --git a/src/locales/fr/translation.json b/src/locales/fr/translation.jsonindex 4f4ac241f..76bdbde5c 100644--- a/src/locales/fr/translation.json+++ b/src/locales/fr/translation.json@@ -1432,7 +1432,10 @@"errorOccurred": "Une erreur est survenue","noProviderTitle": "Aucun fournisseur de transcription configuré","noProviderDescription": "Ajoutez une clé API ou téléchargez un modèle local pour commencer à transcrire.",- "noProviderAction": "Ouvrir les paramètres de transcription"+ "noProviderAction": "Ouvrir les paramètres de transcription",+ "fileTooLarge": "Ce fichier dépasse la limite de 500 MB.",+ "largeFileNote": "Les fichiers volumineux sont découpés et transcrits en parallèle.",+ "chunkProgress": "Transcription de la partie {{completed}} sur {{total}}..."},"meeting": {"title": "Notes de réunion",diff --git a/src/locales/it/translation.json b/src/locales/it/translation.jsonindex 4adb7483f..005973bbc 100644--- a/src/locales/it/translation.json+++ b/src/locales/it/translation.json@@ -1396,7 +1396,10 @@"errorOccurred": "Si è verificato un errore","noProviderTitle": "Nessun provider di trascrizione configurato","noProviderDescription": "Aggiungi una chiave API o scarica un modello locale per iniziare a trascrivere.",- "noProviderAction": "Apri impostazioni di trascrizione"+ "noProviderAction": "Apri impostazioni di trascrizione",+ "fileTooLarge": "Questo file supera il limite di 500 MB.",+ "largeFileNote": "I file di grandi dimensioni vengono suddivisi e trascritti in parallelo.",+ "chunkProgress": "Trascrizione parte {{completed}} di {{total}}..."},"meeting": {"title": "Note delle riunioni",diff --git a/src/locales/ja/translation.json b/src/locales/ja/translation.jsonindex 954907a36..9e05fe70c 100644--- a/src/locales/ja/translation.json+++ b/src/locales/ja/translation.json@@ -1371,7 +1371,10 @@"errorOccurred": "エラーが発生しました","noProviderTitle": "文字起こしプロバイダーが設定されていません","noProviderDescription": "API キーを追加するか、ローカルモデルをダウンロードして文字起こしを開始してください。",- "noProviderAction": "文字起こし設定を開く"+ "noProviderAction": "文字起こし設定を開く",+ "fileTooLarge": "このファイルは 500 MB の制限を超えています。",+ "largeFileNote": "大容量ファイルは分割され、並列で文字起こしされます。",+ "chunkProgress": "パート {{completed}} / {{total}} を文字起こし中..."},"meeting": {"title": "議事録",diff --git a/src/locales/pt/translation.json b/src/locales/pt/translation.jsonindex c235827b6..f54526f5f 100644--- a/src/locales/pt/translation.json+++ b/src/locales/pt/translation.json@@ -1396,7 +1396,10 @@"errorOccurred": "Ocorreu um erro","noProviderTitle": "Nenhum provedor de transcrição configurado","noProviderDescription": "Adicione uma chave API ou baixe um modelo local para começar a transcrever.",- "noProviderAction": "Abrir configurações de transcrição"+ "noProviderAction": "Abrir configurações de transcrição",+ "fileTooLarge": "Este arquivo excede o limite de 500 MB.",+ "largeFileNote": "Arquivos grandes são divididos e transcritos em paralelo.",+ "chunkProgress": "Transcrevendo parte {{completed}} de {{total}}..."},"meeting": {"title": "Notas de reunião",diff --git a/src/locales/ru/translation.json b/src/locales/ru/translation.jsonindex 49d16a807..bc46e9cb2 100644--- a/src/locales/ru/translation.json+++ b/src/locales/ru/translation.json@@ -1396,7 +1396,10 @@"errorOccurred": "Произошла ошибка","noProviderTitle": "Провайдер транскрипции не настроен","noProviderDescription": "Добавьте API-ключ или скачайте локальную модель, чтобы начать транскрипцию.",- "noProviderAction": "Открыть настройки транскрипции"+ "noProviderAction": "Открыть настройки транскрипции",+ "fileTooLarge": "Этот файл превышает ограничение в 500 MB.",+ "largeFileNote": "Большие файлы разделяются и транскрибируются параллельно.",+ "chunkProgress": "Транскрибирование части {{completed}} из {{total}}..."},"meeting": {"title": "Заметки со встреч",diff --git a/src/locales/zh-CN/translation.json b/src/locales/zh-CN/translation.jsonindex dd8aa221a..473d9a57a 100644--- a/src/locales/zh-CN/translation.json+++ b/src/locales/zh-CN/translation.json@@ -1392,7 +1392,10 @@"errorOccurred": "发生错误","noProviderTitle": "尚未设置转录服务商","noProviderDescription": "添加 API Key 或下载本地模型以开始转录。",- "noProviderAction": "打开转录设置"+ "noProviderAction": "打开转录设置",+ "fileTooLarge": "此文件超过了 500 MB 的大小限制。",+ "largeFileNote": "大文件将被分割并平行转录。",+ "chunkProgress": "正在转录第 {{completed}} 部分,共 {{total}} 部分..."},"meeting": {"title": "会议笔记",diff --git a/src/locales/zh-TW/translation.json b/src/locales/zh-TW/translation.jsonindex 35679159d..d38c29ae0 100644--- a/src/locales/zh-TW/translation.json+++ b/src/locales/zh-TW/translation.json@@ -1392,7 +1392,10 @@"errorOccurred": "發生錯誤","noProviderTitle": "尚未設定轉錄服務供應商","noProviderDescription": "新增 API Key 或下載本機模型以開始轉錄。",- "noProviderAction": "開啟轉錄設定"+ "noProviderAction": "開啟轉錄設定",+ "fileTooLarge": "此檔案超過 500 MB 的大小限制。",+ "largeFileNote": "大型檔案將被分割並平行轉錄。",+ "chunkProgress": "正在轉錄第 {{completed}} 部分,共 {{total}} 部分..."},"meeting": {"title": "會議筆記",diff --git a/src/types/electron.ts b/src/types/electron.tsindex f6e26ace8..51dcba4df 100644--- a/src/types/electron.ts+++ b/src/types/electron.ts@@ -362,6 +362,7 @@ declare global {// Audio file operationsselectAudioFile: () => Promise<{ canceled: boolean; filePath?: string }>;+ getFileSize?: (filePath: string) => Promise<number>;transcribeAudioFile: (filePath: string,options?: {@@ -770,6 +771,10 @@ declare global {code?: string;}>;+ onUploadTranscriptionProgress?: (+ callback: (data: { stage: string; chunksTotal: number; chunksCompleted: number }) => void+ ) => () => void;+// BYOK audio file transcriptiontranscribeAudioFileByok?: (options: {filePath: string;