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 <noreply@anthropic.com>
This commit is contained in:
parent
6ad588cba0
commit
85a8ed77b5
1 changed files with 14 additions and 2 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue