Skip to content

armgit / Handy

Public Imported from GitHub
0

A free, open source, and extensible speech-to-text application that works completely offline.

feat: pass custom words as Whisper initial_prompt instead of post-correction (#1035)

Javier Campanini85a8ed77b5ac
diff --git a/src-tauri/src/managers/transcription.rs b/src-tauri/src/managers/transcription.rs
index e9f5484e..2beaea99 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,