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
Add per-GPU device selector for transcription and intelligence
Alcahestb7eaccfcaa37
diff --git a/preload.js b/preload.jsindex 144f922f7..64329fb7e 100644--- a/preload.js+++ b/preload.js@@ -195,6 +195,9 @@ contextBridge.exposeInMainWorld("electronAPI", {whisperServerStatus: () => ipcRenderer.invoke("whisper-server-status"),// CUDA GPU acceleration+ listGpus: () => ipcRenderer.invoke("list-gpus"),+ setGpuDeviceIndex: (purpose, index) => ipcRenderer.invoke("set-gpu-device-index", purpose, index),+ getGpuDeviceIndex: (purpose) => ipcRenderer.invoke("get-gpu-device-index", purpose),detectGpu: () => ipcRenderer.invoke("detect-gpu"),getCudaWhisperStatus: () => ipcRenderer.invoke("get-cuda-whisper-status"),downloadCudaWhisperBinary: () => ipcRenderer.invoke("download-cuda-whisper-binary"),diff --git a/src/components/SettingsPage.tsx b/src/components/SettingsPage.tsxindex 4a06bb1f9..fb05c89f2 100644--- a/src/components/SettingsPage.tsx+++ b/src/components/SettingsPage.tsx@@ -392,6 +392,7 @@ function TranscriptionSection({variant="settings"/>)}+ <GpuDeviceSelector purpose="transcription" /></div>);}@@ -619,12 +620,61 @@ function AiModelsSection({setCustomReasoningApiKey={setCustomReasoningApiKey}/>)}+ <GpuDeviceSelector purpose="intelligence" /></>)}</div>);}+function GpuDeviceSelector({ purpose }: { purpose: "transcription" | "intelligence" }) {+ const { t } = useTranslation();+ const [gpus, setGpus] = useState<Array<{ index: number; name: string; vramMb: number }>>([]);+ const [selectedIndex, setSelectedIndex] = useState("0");+ const [loaded, setLoaded] = useState(false);++ useEffect(() => {+ Promise.all([+ window.electronAPI?.listGpus?.() ?? Promise.resolve([]),+ window.electronAPI?.getGpuDeviceIndex?.(purpose) ?? Promise.resolve("0"),+ ]).then(([gpuList, idx]) => {+ setGpus(gpuList);+ setSelectedIndex(idx);+ setLoaded(true);+ });+ }, [purpose]);++ if (!loaded || gpus.length < 2) return null;++ return (+ <div className="border-t border-border/40 pt-4 mt-4">+ <SectionHeader+ title={t(`settingsPage.${purpose}.gpuDevice.title`)}+ description={t(`settingsPage.${purpose}.gpuDevice.description`)}+ />+ <SettingsPanel>+ <SettingsPanelRow>+ <select+ value={selectedIndex}+ onChange={async (e) => {+ const idx = e.target.value;+ setSelectedIndex(idx);+ await window.electronAPI?.setGpuDeviceIndex?.(purpose, Number(idx));+ }}+ className="w-full rounded-md border border-border bg-background px-3 py-2 text-sm"+ >+ {gpus.map((gpu) => (+ <option key={gpu.index} value={String(gpu.index)}>+ GPU {gpu.index}: {gpu.name} ({Math.round(gpu.vramMb / 1024)}GB)+ </option>+ ))}+ </select>+ </SettingsPanelRow>+ </SettingsPanel>+ </div>+ );+}+export default function SettingsPage({ activeSection = "general" }: SettingsPageProps) {const {confirmDialog,@@ -2770,6 +2820,7 @@ EOF`,})()}</div>)}+</div>);@@ -3397,6 +3448,7 @@ EOF`,</div>)}</div>+</div>);diff --git a/src/helpers/environment.js b/src/helpers/environment.jsindex 05c04880e..eb2ece92b 100644--- a/src/helpers/environment.js+++ b/src/helpers/environment.js@@ -27,6 +27,8 @@ const PERSISTED_KEYS = ["START_MINIMIZED","UI_LANGUAGE","WHISPER_CUDA_ENABLED",+ "TRANSCRIPTION_GPU_INDEX",+ "INTELLIGENCE_GPU_INDEX",];class EnvironmentManager {diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.jsindex 4d7311928..9c4a3bbe2 100644--- a/src/helpers/ipcHandlers.js+++ b/src/helpers/ipcHandlers.js@@ -119,6 +119,7 @@ class IPCHandlers {this._audioCleanupInterval = null;this._setupTextEditMonitor();this._setupAudioCleanup();+ this._logDetectedGpus();this.setupHandlers();if (this.whisperManager?.serverManager) {@@ -164,6 +165,16 @@ class IPCHandlers {}}+ async _logDetectedGpus() {+ const { listNvidiaGpus } = require("../utils/gpuDetection");+ const gpus = await listNvidiaGpus();+ if (gpus.length > 0) {+ debugLogger.info("NVIDIA GPUs detected", { count: gpus.length, devices: gpus.map(g => `${g.name} (${g.vramMb}MB)`) }, "gpu");+ } else {+ debugLogger.debug("No NVIDIA GPUs detected", {}, "gpu");+ }+ }+_setupAudioCleanup() {const DEFAULT_RETENTION_DAYS = 30;const SIX_HOURS_MS = 6 * 60 * 60 * 1000;@@ -985,6 +996,57 @@ class IPCHandlers {return detectNvidiaGpu();});+ ipcMain.handle("list-gpus", async () => {+ const { listNvidiaGpus } = require("../utils/gpuDetection");+ const gpus = await listNvidiaGpus();+ debugLogger.info("GPU devices detected", { count: gpus.length, gpus }, "gpu");+ return gpus;+ });++ ipcMain.handle("set-gpu-device-index", async (_event, purpose, index) => {+ const idx = String(parseInt(index, 10));+ if (isNaN(parseInt(index, 10)) || parseInt(index, 10) < 0) {+ return { success: false };+ }+ const key = purpose === "intelligence" ? "INTELLIGENCE_GPU_INDEX" : "TRANSCRIPTION_GPU_INDEX";+ const oldIdx = process.env[key] || "0";+ process.env[key] = idx;+ this.environmentManager.saveAllKeysToEnvFile().catch(() => {});++ if (oldIdx !== idx) {+ try {+ if (purpose === "transcription" && this.whisperManager?.process) {+ debugLogger.info("Restarting whisper-server for GPU change", { from: oldIdx, to: idx }, "gpu");+ const modelPath = this.whisperManager.modelPath;+ await this.whisperManager.stop();+ if (modelPath) {+ await this.whisperManager.start(modelPath, { useCuda: !!process.env.WHISPER_CUDA_ENABLED });+ }+ }+ if (purpose === "intelligence") {+ const modelManager = require("./modelManagerBridge").default;+ if (modelManager.serverManager?.process) {+ debugLogger.info("Restarting llama-server for GPU change", { from: oldIdx, to: idx }, "gpu");+ const modelPath = modelManager.serverManager.modelPath;+ await modelManager.serverManager.stop();+ if (modelPath) {+ await modelManager.serverManager.start(modelPath);+ }+ }+ }+ } catch (err) {+ debugLogger.error("Failed to restart server after GPU change", { error: err.message, purpose }, "gpu");+ }+ }++ return { success: true };+ });++ ipcMain.handle("get-gpu-device-index", async (_event, purpose) => {+ const key = purpose === "intelligence" ? "INTELLIGENCE_GPU_INDEX" : "TRANSCRIPTION_GPU_INDEX";+ return process.env[key] || "0";+ });+ipcMain.handle("get-cuda-whisper-status", async () => {const { detectNvidiaGpu } = require("../utils/gpuDetection");const gpuInfo = await detectNvidiaGpu();diff --git a/src/helpers/llamaServer.js b/src/helpers/llamaServer.jsindex 381b36d62..511df30fd 100644--- a/src/helpers/llamaServer.js+++ b/src/helpers/llamaServer.js@@ -215,6 +215,10 @@ class LlamaServerManager {env.PATH = binDir + (env.PATH ? `;${env.PATH}` : "");}+ if (process.env.INTELLIGENCE_GPU_INDEX) {+ env.CUDA_VISIBLE_DEVICES = process.env.INTELLIGENCE_GPU_INDEX;+ }+return env;}diff --git a/src/helpers/whisperServer.js b/src/helpers/whisperServer.jsindex d12d1d522..5d46a5e45 100644--- a/src/helpers/whisperServer.js+++ b/src/helpers/whisperServer.js@@ -234,6 +234,10 @@ class WhisperServerManager extends EventEmitter {const serverBinaryDir = path.dirname(serverBinary);spawnEnv.PATH = serverBinaryDir + pathSep + (process.env.PATH || "");+ if (usingCuda && process.env.TRANSCRIPTION_GPU_INDEX) {+ spawnEnv.CUDA_VISIBLE_DEVICES = process.env.TRANSCRIPTION_GPU_INDEX;+ }+const args = ["--model", modelPath, "--host", "127.0.0.1", "--port", String(this.port)];// FFmpeg is required for pre-converting audio to 16kHz mono WAVdiff --git a/src/locales/de/translation.json b/src/locales/de/translation.jsonindex 9134726f4..5708f7791 100644--- a/src/locales/de/translation.json+++ b/src/locales/de/translation.json@@ -1385,6 +1385,16 @@"description": "Konfigurieren Sie Ihren eigenen Anbieter und API-Schlüssel.","title": "Zu benutzerdefinierter Einrichtung gewechselt"}+ },+ "gpuDevice": {+ "title": "Transkriptions-GPU",+ "description": "GPU für lokale Spracherkennung"+ }+ },+ "intelligence": {+ "gpuDevice": {+ "title": "GPU-Gerät",+ "description": "GPU für lokale Transkription und KI-Verarbeitung auswählen"}}},diff --git a/src/locales/en/translation.json b/src/locales/en/translation.jsonindex ec47cd742..dcee21bc1 100644--- a/src/locales/en/translation.json+++ b/src/locales/en/translation.json@@ -1433,6 +1433,16 @@"description": "Configure your own provider and API key.","title": "Switched to Custom Setup"}+ },+ "gpuDevice": {+ "title": "Transcription GPU",+ "description": "GPU used for local speech-to-text"+ }+ },+ "intelligence": {+ "gpuDevice": {+ "title": "GPU Device",+ "description": "Select which GPU to use for local transcription and AI processing"}}},diff --git a/src/locales/es/translation.json b/src/locales/es/translation.jsonindex 91f60ea1c..97537ce54 100644--- a/src/locales/es/translation.json+++ b/src/locales/es/translation.json@@ -1385,6 +1385,16 @@"description": "Configura tu propio proveedor y clave API.","title": "Cambiado a configuración personalizada"}+ },+ "gpuDevice": {+ "title": "GPU de transcripción",+ "description": "GPU usada para transcripción local"+ }+ },+ "intelligence": {+ "gpuDevice": {+ "title": "Dispositivo GPU",+ "description": "Seleccionar qué GPU usar para transcripción local y procesamiento IA"}}},diff --git a/src/locales/fr/translation.json b/src/locales/fr/translation.jsonindex 36c6f02db..085fc07bc 100644--- a/src/locales/fr/translation.json+++ b/src/locales/fr/translation.json@@ -1385,6 +1385,16 @@"description": "Configurez votre propre fournisseur et clé API.","title": "Basculé vers la configuration personnalisée"}+ },+ "gpuDevice": {+ "title": "GPU de transcription",+ "description": "GPU pour la transcription locale"+ }+ },+ "intelligence": {+ "gpuDevice": {+ "title": "Périphérique GPU",+ "description": "Sélectionner le GPU pour la transcription locale et le traitement IA"}}},diff --git a/src/locales/it/translation.json b/src/locales/it/translation.jsonindex 9b0d20064..0a08b91df 100644--- a/src/locales/it/translation.json+++ b/src/locales/it/translation.json@@ -1385,6 +1385,16 @@"description": "Configura il tuo provider e la tua chiave API.","title": "Passato a configurazione personalizzata"}+ },+ "gpuDevice": {+ "title": "GPU trascrizione",+ "description": "GPU usata per la trascrizione locale"+ }+ },+ "intelligence": {+ "gpuDevice": {+ "title": "Dispositivo GPU",+ "description": "Seleziona quale GPU usare per la trascrizione locale e l'elaborazione IA"}}},diff --git a/src/locales/ja/translation.json b/src/locales/ja/translation.jsonindex e05ed8811..a46eca0fa 100644--- a/src/locales/ja/translation.json+++ b/src/locales/ja/translation.json@@ -1385,6 +1385,16 @@"description": "独自のプロバイダーと API キーを設定してください。","title": "カスタム設定に切り替えました"}+ },+ "gpuDevice": {+ "title": "文字起こしGPU",+ "description": "ローカル音声認識に使用するGPU"+ }+ },+ "intelligence": {+ "gpuDevice": {+ "title": "GPUデバイス",+ "description": "ローカル文字起こしとAI処理に使用するGPUを選択"}}},diff --git a/src/locales/pt/translation.json b/src/locales/pt/translation.jsonindex f032757a0..ea6c65fc8 100644--- a/src/locales/pt/translation.json+++ b/src/locales/pt/translation.json@@ -1357,6 +1357,16 @@"description": "Configure seu próprio provedor e chave API.","title": "Mudou para configuração personalizada"}+ },+ "gpuDevice": {+ "title": "GPU de transcrição",+ "description": "GPU usada para transcrição local"+ }+ },+ "intelligence": {+ "gpuDevice": {+ "title": "Dispositivo GPU",+ "description": "Selecionar qual GPU usar para transcrição local e processamento IA"}}},diff --git a/src/locales/ru/translation.json b/src/locales/ru/translation.jsonindex 7d11631f9..264814175 100644--- a/src/locales/ru/translation.json+++ b/src/locales/ru/translation.json@@ -1385,6 +1385,16 @@"description": "Настройте собственного провайдера и API-ключ.","title": "Переключено на пользовательскую настройку"}+ },+ "gpuDevice": {+ "title": "GPU транскрипции",+ "description": "GPU для локального распознавания речи"+ }+ },+ "intelligence": {+ "gpuDevice": {+ "title": "Устройство GPU",+ "description": "Выберите GPU для локальной транскрипции и обработки ИИ"}}},diff --git a/src/locales/zh-CN/translation.json b/src/locales/zh-CN/translation.jsonindex 188a5c885..0d9f1461a 100644--- a/src/locales/zh-CN/translation.json+++ b/src/locales/zh-CN/translation.json@@ -1385,6 +1385,16 @@"description": "请配置你的服务商和 API Key。","title": "已切换到自定义设置"}+ },+ "gpuDevice": {+ "title": "转录 GPU",+ "description": "用于本地语音识别的 GPU"+ }+ },+ "intelligence": {+ "gpuDevice": {+ "title": "GPU 设备",+ "description": "选择用于本地转录和 AI 处理的 GPU"}}},diff --git a/src/locales/zh-TW/translation.json b/src/locales/zh-TW/translation.jsonindex 9fe0164ed..32da9a6ea 100644--- a/src/locales/zh-TW/translation.json+++ b/src/locales/zh-TW/translation.json@@ -1385,6 +1385,16 @@"description": "設定你自己的供應商和 API Key。","title": "已切換至自訂設定"}+ },+ "gpuDevice": {+ "title": "轉錄 GPU",+ "description": "用於本機語音辨識的 GPU"+ }+ },+ "intelligence": {+ "gpuDevice": {+ "title": "GPU 裝置",+ "description": "選擇用於本機轉錄和 AI 處理的 GPU"}}},diff --git a/src/types/electron.ts b/src/types/electron.tsindex 2a288cf70..f2904914a 100644--- a/src/types/electron.ts+++ b/src/types/electron.ts@@ -55,6 +55,12 @@ export interface ActionItem {updated_at: string;}+export interface GpuDevice {+ index: number;+ name: string;+ vramMb: number;+}+export interface GpuInfo {hasNvidiaGpu: boolean;gpuName?: string;@@ -496,6 +502,9 @@ declare global {}>;// CUDA GPU acceleration+ listGpus?: () => Promise<GpuDevice[]>;+ setGpuDeviceIndex?: (purpose: "transcription" | "intelligence", index: number) => Promise<{ success: boolean }>;+ getGpuDeviceIndex?: (purpose: "transcription" | "intelligence") => Promise<string>;detectGpu: () => Promise<GpuInfo>;getCudaWhisperStatus: () => Promise<CudaWhisperStatus>;downloadCudaWhisperBinary: () => Promise<{ success: boolean; error?: string }>;diff --git a/src/utils/gpuDetection.js b/src/utils/gpuDetection.jsindex d35e3babf..f0437825f 100644--- a/src/utils/gpuDetection.js+++ b/src/utils/gpuDetection.js@@ -44,4 +44,45 @@ function detectNvidiaGpu() {});}-module.exports = { detectNvidiaGpu };+let cachedGpuList = null;++function listNvidiaGpus() {+ if (cachedGpuList) return Promise.resolve(cachedGpuList);++ if (process.platform === "darwin") {+ cachedGpuList = [];+ return Promise.resolve(cachedGpuList);+ }++ return new Promise((resolve) => {+ execFile(+ "nvidia-smi",+ ["--query-gpu=index,name,memory.total", "--format=csv,noheader,nounits"],+ { timeout: 5000 },+ (error, stdout) => {+ if (error || !stdout) {+ cachedGpuList = [];+ resolve(cachedGpuList);+ return;+ }++ cachedGpuList = stdout+ .trim()+ .split("\n")+ .map((line) => {+ const parts = line.split(",").map((s) => s.trim());+ return {+ index: parseInt(parts[0], 10),+ name: parts[1] || "Unknown GPU",+ vramMb: parseInt(parts[2], 10) || 0,+ };+ })+ .filter((g) => !isNaN(g.index));++ resolve(cachedGpuList);+ }+ );+ });+}++module.exports = { detectNvidiaGpu, listNvidiaGpus };