From 22173fb253a8fb36b4f2a78bb15003e486687cd8 Mon Sep 17 00:00:00 2001 From: Nikolaj Olsson Date: Fri, 15 Mar 2024 21:06:41 +0100 Subject: [PATCH] Fix minor whisper cmd setting UI issue --- .../Forms/AudioToText/WhisperAudioToText.cs | 30 +++++++++++-------- .../WhisperAudioToTextSelectedLines.cs | 3 ++ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/ui/Forms/AudioToText/WhisperAudioToText.cs b/src/ui/Forms/AudioToText/WhisperAudioToText.cs index c90a52343..ae717b79e 100644 --- a/src/ui/Forms/AudioToText/WhisperAudioToText.cs +++ b/src/ui/Forms/AudioToText/WhisperAudioToText.cs @@ -137,6 +137,7 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText Init(); InitializeWhisperEngines(comboBoxWhisperEngine); + FixPurfviewWhisperStandardArgument(labelAdvanced, comboBoxWhisperEngine.Text); } public static void InitializeWhisperEngines(NikseComboBox cb) @@ -1993,18 +1994,7 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText private void comboBoxWhisperEngine_SelectedIndexChanged(object sender, EventArgs e) { - if (comboBoxWhisperEngine.Text != WhisperChoice.PurfviewFasterWhisper && Configuration.Settings.Tools.WhisperExtraSettings.Contains("--standard", StringComparison.Ordinal)) - { - Configuration.Settings.Tools.WhisperExtraSettings = Configuration.Settings.Tools.WhisperExtraSettings.Replace("--standard", string.Empty).Trim(); - labelAdvanced.Text = Configuration.Settings.Tools.WhisperExtraSettings; - } - else if (comboBoxWhisperEngine.Text == WhisperChoice.PurfviewFasterWhisper && - !Configuration.Settings.Tools.WhisperExtraSettings.Contains("--standard", StringComparison.Ordinal) && - Configuration.Settings.Tools.WhisperPurfviewFasterWhisperDefaultCmd == "--standard") - { - Configuration.Settings.Tools.WhisperExtraSettings = Configuration.Settings.Tools.WhisperPurfviewFasterWhisperDefaultCmd; - labelAdvanced.Text = Configuration.Settings.Tools.WhisperExtraSettings; - } + FixPurfviewWhisperStandardArgument(labelAdvanced, comboBoxWhisperEngine.Text); if (comboBoxWhisperEngine.Text == Configuration.Settings.Tools.WhisperChoice) { @@ -2077,6 +2067,22 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText } } + internal static void FixPurfviewWhisperStandardArgument(Label label, string engine) + { + if (engine != WhisperChoice.PurfviewFasterWhisper && Configuration.Settings.Tools.WhisperExtraSettings.Contains("--standard", StringComparison.Ordinal)) + { + Configuration.Settings.Tools.WhisperExtraSettings = Configuration.Settings.Tools.WhisperExtraSettings.Replace("--standard", string.Empty).Trim(); + } + else if (engine == WhisperChoice.PurfviewFasterWhisper && + !Configuration.Settings.Tools.WhisperExtraSettings.Contains("--standard", StringComparison.Ordinal) && + Configuration.Settings.Tools.WhisperPurfviewFasterWhisperDefaultCmd == "--standard") + { + Configuration.Settings.Tools.WhisperExtraSettings = Configuration.Settings.Tools.WhisperPurfviewFasterWhisperDefaultCmd; + } + + label.Text = Configuration.Settings.Tools.WhisperExtraSettings; + } + private void setCPPConstMeModelsFolderToolStripMenuItem_Click(object sender, EventArgs e) { using (var folderBrowserDialog1 = new FolderBrowserDialog()) diff --git a/src/ui/Forms/AudioToText/WhisperAudioToTextSelectedLines.cs b/src/ui/Forms/AudioToText/WhisperAudioToTextSelectedLines.cs index 8e0d43e1e..94ffdf984 100644 --- a/src/ui/Forms/AudioToText/WhisperAudioToTextSelectedLines.cs +++ b/src/ui/Forms/AudioToText/WhisperAudioToTextSelectedLines.cs @@ -77,6 +77,7 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText } WhisperAudioToText.InitializeWhisperEngines(comboBoxWhisperEngine); + WhisperAudioToText.FixPurfviewWhisperStandardArgument(labelAdvanced, comboBoxWhisperEngine.Text); } private void Init() @@ -667,6 +668,8 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText private void comboBoxWhisperEngine_SelectedIndexChanged(object sender, EventArgs e) { + WhisperAudioToText.FixPurfviewWhisperStandardArgument(labelAdvanced, comboBoxWhisperEngine.Text); + if (comboBoxWhisperEngine.Text == Configuration.Settings.Tools.WhisperChoice) { return;