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
refactor: clean up unified provider layout — fix self-hosted defaults, DRY radio cards
Gabriel Steina7aba67317f4
diff --git a/preload.js b/preload.jsindex 0e4821544..503c43379 100644--- a/preload.js+++ b/preload.js@@ -207,10 +207,6 @@ contextBridge.exposeInMainWorld("electronAPI", {checkFFmpegAvailability: () => ipcRenderer.invoke("check-ffmpeg-availability"),getAudioDiagnostics: () => ipcRenderer.invoke("get-audio-diagnostics"),- // LAN Whisper transcription (remote whisper-server on local network)- transcribeLanWhisper: (audioBlob, options) =>- ipcRenderer.invoke("transcribe-lan-whisper", audioBlob, options),-// Whisper server functions (faster repeated transcriptions)whisperServerStart: (modelName) => ipcRenderer.invoke("whisper-server-start", modelName),whisperServerStop: () => ipcRenderer.invoke("whisper-server-stop"),diff --git a/src/components/SettingsPage.tsx b/src/components/SettingsPage.tsxindex c8a82713f..d60a6b284 100644--- a/src/components/SettingsPage.tsx+++ b/src/components/SettingsPage.tsx@@ -118,6 +118,8 @@ const UI_LANGUAGE_OPTIONS: import("./ui/LanguageSelector").LanguageOption[] = [{ value: "zh-TW", label: "繁體中文", flag: "🇹🇼" },];+const noop = () => {};+function SettingsPanel({children,className = "",@@ -159,6 +161,79 @@ function SectionHeader({ title, description }: { title: string; description?: st);}+interface InferenceModeOption {+ id: InferenceMode;+ label: string;+ description: string;+ icon: React.ReactNode;+}++function InferenceModeSelector({+ modes,+ activeMode,+ onSelect,+}: {+ modes: InferenceModeOption[];+ activeMode: InferenceMode;+ onSelect: (mode: InferenceMode) => void;+}) {+ const { t } = useTranslation();++ return (+ <SettingsPanel>+ {modes.map((mode) => {+ const isActive = activeMode === mode.id;+ return (+ <SettingsPanelRow key={mode.id}>+ <button+ onClick={() => onSelect(mode.id)}+ className="w-full flex items-center gap-3 text-left cursor-pointer group"+ >+ <div+ className={`w-8 h-8 rounded-md flex items-center justify-center shrink-0 transition-colors ${+ isActive+ ? "bg-primary/10 dark:bg-primary/15"+ : "bg-muted/60 dark:bg-surface-raised group-hover:bg-muted dark:group-hover:bg-surface-3"+ }`}+ >+ <div+ className={`transition-colors ${isActive ? "text-primary" : "text-muted-foreground"}`}+ >+ {mode.icon}+ </div>+ </div>+ <div className="flex-1 min-w-0">+ <div className="flex items-center gap-2">+ <span className="text-xs font-medium text-foreground">{mode.label}</span>+ {isActive && (+ <span className="text-xs font-medium text-primary bg-primary/10 dark:bg-primary/15 px-1.5 py-px rounded-sm">+ {t("common.active")}+ </span>+ )}+ </div>+ <p className="text-xs text-muted-foreground/80 mt-0.5">{mode.description}</p>+ </div>+ <div+ className={`w-4 h-4 rounded-full border-2 shrink-0 transition-colors ${+ isActive+ ? "border-primary bg-primary"+ : "border-border-hover dark:border-border-subtle"+ }`}+ >+ {isActive && (+ <div className="w-full h-full flex items-center justify-center">+ <div className="w-1.5 h-1.5 rounded-full bg-primary-foreground" />+ </div>+ )}+ </div>+ </button>+ </SettingsPanelRow>+ );+ })}+ </SettingsPanel>+ );+}+interface TranscriptionSectionProps {isSignedIn: boolean;cloudTranscriptionMode: string;@@ -310,7 +385,7 @@ function TranscriptionSection({useLocalWhisper={mode === "local" || (!mode && useLocalWhisper)}onModeChange={mode- ? () => {}+ ? noop: (isLocal) => {setUseLocalWhisper(isLocal);updateTranscriptionSettings({ useLocalWhisper: isLocal });@@ -341,57 +416,11 @@ function TranscriptionSection({{isSignedIn ? (<>- <SettingsPanel>- {transcriptionModes.map((mode) => {- const isActive = transcriptionMode === mode.id;- return (- <SettingsPanelRow key={mode.id}>- <button- onClick={() => handleTranscriptionModeSelect(mode.id)}- className="w-full flex items-center gap-3 text-left cursor-pointer group"- >- <div- className={`w-8 h-8 rounded-md flex items-center justify-center shrink-0 transition-colors ${- isActive- ? "bg-primary/10 dark:bg-primary/15"- : "bg-muted/60 dark:bg-surface-raised group-hover:bg-muted dark:group-hover:bg-surface-3"- }`}- >- <div- className={`transition-colors ${isActive ? "text-primary" : "text-muted-foreground"}`}- >- {mode.icon}- </div>- </div>- <div className="flex-1 min-w-0">- <div className="flex items-center gap-2">- <span className="text-xs font-medium text-foreground">{mode.label}</span>- {isActive && (- <span className="text-xs font-medium text-primary bg-primary/10 dark:bg-primary/15 px-1.5 py-px rounded-sm">- {t("common.active")}- </span>- )}- </div>- <p className="text-xs text-muted-foreground/80 mt-0.5">{mode.description}</p>- </div>- <div- className={`w-4 h-4 rounded-full border-2 shrink-0 transition-colors ${- isActive- ? "border-primary bg-primary"- : "border-border-hover dark:border-border-subtle"- }`}- >- {isActive && (- <div className="w-full h-full flex items-center justify-center">- <div className="w-1.5 h-1.5 rounded-full bg-primary-foreground" />- </div>- )}- </div>- </button>- </SettingsPanelRow>- );- })}- </SettingsPanel>+ <InferenceModeSelector+ modes={transcriptionModes}+ activeMode={transcriptionMode}+ onSelect={handleTranscriptionModeSelect}+ />{transcriptionMode === "providers" && renderTranscriptionPicker("cloud")}{transcriptionMode === "local" && renderTranscriptionPicker("local")}@@ -575,61 +604,11 @@ function AiModelsSection({<>{isSignedIn ? (<>- <SettingsPanel>- {aiModes.map((mode) => {- const isActive = reasoningMode === mode.id;- return (- <SettingsPanelRow key={mode.id}>- <button- onClick={() => handleReasoningModeSelect(mode.id)}- className="w-full flex items-center gap-3 text-left cursor-pointer group"- >- <div- className={`w-8 h-8 rounded-md flex items-center justify-center shrink-0 transition-colors ${- isActive- ? "bg-primary/10 dark:bg-primary/15"- : "bg-muted/60 dark:bg-surface-raised group-hover:bg-muted dark:group-hover:bg-surface-3"- }`}- >- <div- className={`transition-colors ${isActive ? "text-primary" : "text-muted-foreground"}`}- >- {mode.icon}- </div>- </div>- <div className="flex-1 min-w-0">- <div className="flex items-center gap-2">- <span className="text-xs font-medium text-foreground">- {mode.label}- </span>- {isActive && (- <span className="text-xs font-medium text-primary bg-primary/10 dark:bg-primary/15 px-1.5 py-px rounded-sm">- {t("common.active")}- </span>- )}- </div>- <p className="text-xs text-muted-foreground/80 mt-0.5">- {mode.description}- </p>- </div>- <div- className={`w-4 h-4 rounded-full border-2 shrink-0 transition-colors ${- isActive- ? "border-primary bg-primary"- : "border-border-hover dark:border-border-subtle"- }`}- >- {isActive && (- <div className="w-full h-full flex items-center justify-center">- <div className="w-1.5 h-1.5 rounded-full bg-primary-foreground" />- </div>- )}- </div>- </button>- </SettingsPanelRow>- );- })}- </SettingsPanel>+ <InferenceModeSelector+ modes={aiModes}+ activeMode={reasoningMode}+ onSelect={handleReasoningModeSelect}+ />{reasoningMode === "providers" && renderReasoningSelector("cloud")}{reasoningMode === "local" && renderReasoningSelector("local")}diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.jsindex ee1052e6d..25c2d6577 100644--- a/src/helpers/ipcHandlers.js+++ b/src/helpers/ipcHandlers.js@@ -1201,48 +1201,6 @@ class IPCHandlers {return this.whisperManager.getServerStatus();});- ipcMain.handle("transcribe-lan-whisper", async (event, audioBlob, options = {}) => {- debugLogger.log("transcribe-lan-whisper called", {- audioBlobSize: audioBlob?.byteLength || audioBlob?.length || 0,- url: options.url,- });-- if (!options.url) {- return {- success: false,- error: "lan_url_missing",- message: "LAN server URL not configured",- };- }-- try {- const result = await this.whisperManager.transcribeViaLan(audioBlob, options.url, options);-- debugLogger.log("LAN Whisper result", {- success: result.success,- hasText: !!result.text,- });-- if (!result.success && result.message === "No audio detected") {- event.sender.send("no-audio-detected");- }-- return result;- } catch (error) {- debugLogger.error("LAN Whisper transcription error", { error: error.message });-- if (error.message.includes("unreachable")) {- return {- success: false,- error: "lan_unreachable",- message: "LAN whisper-server is unreachable. Check the URL and network connection.",- };- }-- return { success: false, error: "lan_error", message: error.message };- }- });-ipcMain.handle("detect-gpu", async () => {const { detectNvidiaGpu } = require("../utils/gpuDetection");return detectNvidiaGpu();diff --git a/src/services/ReasoningService.ts b/src/services/ReasoningService.tsindex 537f8bb8e..1304e36a1 100644--- a/src/services/ReasoningService.ts+++ b/src/services/ReasoningService.ts@@ -40,6 +40,15 @@ class ReasoningService extends BaseReasoningService {}}+ private isLanReasoningMode(): boolean {+ const settings = getSettings();+ return (+ settings.reasoningMode === "self-hosted" &&+ settings.remoteReasoningType === "lan" &&+ !!settings.remoteReasoningUrl+ );+ }+private getConfiguredOpenAIBase(): string {if (typeof window === "undefined") {return API_ENDPOINTS.OPENAI_BASE;@@ -437,16 +446,12 @@ class ReasoningService extends BaseReasoningService {let result: string;const startTime = Date.now();- const settings = getSettings();- const isLanReasoning =- settings.reasoningMode === "self-hosted" &&- settings.remoteReasoningType === "lan" &&- settings.remoteReasoningUrl;+ const isLanReasoning = this.isLanReasoningMode();logger.logReasoning("ROUTING_TO_PROVIDER", {provider,model,- isLanReasoning: !!isLanReasoning,+ isLanReasoning,});if (isLanReasoning) {@@ -1201,10 +1206,7 @@ class ReasoningService extends BaseReasoningService {const isLocalProvider = !cloudProviders.includes(provider);const settings = getSettings();- const isLanReasoning =- settings.reasoningMode === "self-hosted" &&- settings.remoteReasoningType === "lan" &&- settings.remoteReasoningUrl;+ const isLanReasoning = this.isLanReasoningMode();let endpoint: string;let apiKey = "";@@ -1392,10 +1394,7 @@ class ReasoningService extends BaseReasoningService {const isLocalProvider = !cloudProviders.includes(provider);const settings = getSettings();- const isLanReasoning =- settings.reasoningMode === "self-hosted" &&- settings.remoteReasoningType === "lan" &&- settings.remoteReasoningUrl;+ const isLanReasoning = this.isLanReasoningMode();if ((isLocalProvider || isLanReasoning) && !tools) {const contentGen = this.processTextStreaming(messages, model, provider, config);@@ -1662,16 +1661,12 @@ class ReasoningService extends BaseReasoningService {return true;}- const settings = getSettings();- if (- settings.reasoningMode === "self-hosted" &&- settings.remoteReasoningType === "lan" &&- settings.remoteReasoningUrl?.trim()- ) {+ if (this.isLanReasoningMode()) {logger.logReasoning("API_KEY_CHECK", { lanReasoning: true });return true;}+ const settings = getSettings();if (settings.reasoningProvider === "custom" && settings.cloudReasoningBaseUrl?.trim()) {logger.logReasoning("API_KEY_CHECK", {customProvider: true,diff --git a/src/stores/settingsStore.ts b/src/stores/settingsStore.tsindex 392535f42..38e76e046 100644--- a/src/stores/settingsStore.ts+++ b/src/stores/settingsStore.ts@@ -386,8 +386,8 @@ export const useSettingsStore = create<SettingsState>()((set, get) => ({return "openwhispr" as InferenceMode;})(),remoteTranscriptionType: (() => {- const v = readString("remoteTranscriptionType", "openai-compatible");- return v === "lan" ? "lan" : ("openai-compatible" as SelfHostedType);+ const v = readString("remoteTranscriptionType", "lan");+ return v === "openai-compatible" ? "openai-compatible" : ("lan" as SelfHostedType);})(),remoteTranscriptionUrl: readString("remoteTranscriptionUrl", ""),reasoningMode: (() => {@@ -396,8 +396,8 @@ export const useSettingsStore = create<SettingsState>()((set, get) => ({return "openwhispr" as InferenceMode;})(),remoteReasoningType: (() => {- const v = readString("remoteReasoningType", "openai-compatible");- return v === "lan" ? "lan" : ("openai-compatible" as SelfHostedType);+ const v = readString("remoteReasoningType", "lan");+ return v === "openai-compatible" ? "openai-compatible" : ("lan" as SelfHostedType);})(),remoteReasoningUrl: readString("remoteReasoningUrl", ""),diff --git a/src/types/electron.ts b/src/types/electron.tsindex 5ad4ebdda..e068b760b 100644--- a/src/types/electron.ts+++ b/src/types/electron.ts@@ -518,10 +518,6 @@ declare global {// Whisper operations (whisper.cpp)transcribeLocalWhisper: (audioBlob: Blob | ArrayBuffer, options?: any) => Promise<any>;- transcribeLanWhisper: (- audioBlob: Blob | ArrayBuffer,- options?: { url: string; language?: string; initialPrompt?: string }- ) => Promise<any>;checkWhisperInstallation: () => Promise<WhisperCheckResult>;downloadWhisperModel: (modelName: string) => Promise<WhisperModelResult>;onWhisperDownloadProgress: (