From 8fc7e65aaee40e74566be9b8260fbf8a2f9c8658 Mon Sep 17 00:00:00 2001 From: Kelvin Amoaba <97001695+AmoabaKelvin@users.noreply.github.com> Date: Mon, 9 Nov 2026 04:16:25 +0000 Subject: [PATCH] fix(speech): reload the warm speech model when Use GPU changes A loaded recognizer kept the GPU choice it started with, so turning Use GPU off left the next dictations on the GPU until the model unloaded. --- src/main/speech/speech-model-warmup.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/speech/speech-model-warmup.ts b/src/main/speech/speech-model-warmup.ts index 347e4e8c7ca..988d4a9c737 100644 --- a/src/main/speech/speech-model-warmup.ts +++ b/src/main/speech/speech-model-warmup.ts @@ -12,6 +12,7 @@ type SpeechWarmupStore = { * does not wait for it. Returns a call that re-warms it when the user is likely to dictate. */ export function startSpeechModelWarmup(store: SpeechWarmupStore): () => void { + let speechGpu = store.getSettings().voice?.speechGpu // A settings change retries a model that failed to load; a window focus does not. const sync = (retryFailed: boolean): void => { const voice = store.getSettings().voice @@ -22,7 +23,12 @@ export function startSpeechModelWarmup(store: SpeechWarmupStore): () => void { try { const stt = getSpeechSttService(store) stt.setIdleUnloadDelay(voiceModelUnloadDelayMs(voice)) - void stt.prewarm(voice.sttModel, voice.dictationLanguage, retryFailed) + // A loaded recognizer keeps the GPU choice it started with, so reload it for the new one. + const gpuChanged = voice.speechGpu !== speechGpu + speechGpu = voice.speechGpu + const reloaded = gpuChanged ? stt.unloadIdleModel() : Promise.resolve() + const { sttModel, dictationLanguage } = voice + void reloaded.then(() => stt.prewarm(sttModel, dictationLanguage, retryFailed)) } catch (error) { // Runs inside settings writes; an unusable models folder must not fail the write. console.warn('[speech] Could not pre-warm the speech model:', error)