From 85a8ed77b5ac1f894d5c9acb8313e43b6e957542 Mon Sep 17 00:00:00 2001 From: Javier Campanini Date: Fri, 13 Mar 2026 21:37:46 -0400 Subject: [PATCH] feat: pass custom words as Whisper initial_prompt instead of post-correction (#1035) Whisper supports an `initial_prompt` parameter that biases the model's vocabulary during transcription. For Whisper models, we now join the user's custom words list into a comma-separated string and pass it as the initial_prompt. This guides the model to prefer those spellings during decoding rather than relying solely on fuzzy post-correction. For non-Whisper engines (Parakeet, Moonshine, SenseVoice, GigaAM), the existing apply_custom_words post-correction continues to apply since those engines don't support prompt-based vocabulary biasing. Co-authored-by: Claude Opus 4.6 --- src-tauri/src/managers/transcription.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src-tauri/src/managers/transcription.rs b/src-tauri/src/managers/transcription.rs index e9f5484..2beaea9 100644 --- a/src-tauri/src/managers/transcription.rs +++ b/src-tauri/src/managers/transcription.rs @@ -501,6 +501,11 @@ impl TranscriptionManager { let params = WhisperInferenceParams { language: whisper_language, translate: settings.translate_to_english, + initial_prompt: if settings.custom_words.is_empty() { + None + } else { + Some(settings.custom_words.join(", ")) + }, ..Default::default() }; @@ -602,8 +607,15 @@ impl TranscriptionManager { } }; - // Apply word correction if custom words are configured - let corrected_result = if !settings.custom_words.is_empty() { + // Apply word correction if custom words are configured. + // Skip for Whisper models since custom words are already passed as initial_prompt. + let is_whisper = self + .model_manager + .get_model_info(&settings.selected_model) + .map(|info| matches!(info.engine_type, EngineType::Whisper)) + .unwrap_or(false); + + let corrected_result = if !settings.custom_words.is_empty() && !is_whisper { apply_custom_words( &result.text, &settings.custom_words,