From 7e362d1d957da60daf65a8b62c6396c2ee857d83 Mon Sep 17 00:00:00 2001 From: Nikolaj Olsson Date: Thu, 4 Apr 2024 15:13:45 +0200 Subject: [PATCH] Improve validation for Whisper English only models - thx Purfview :) --- src/ui/Forms/AudioToText/WhisperAudioToText.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ui/Forms/AudioToText/WhisperAudioToText.cs b/src/ui/Forms/AudioToText/WhisperAudioToText.cs index ce1cab557..84d66dee7 100644 --- a/src/ui/Forms/AudioToText/WhisperAudioToText.cs +++ b/src/ui/Forms/AudioToText/WhisperAudioToText.cs @@ -387,7 +387,7 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText _languageCode = GetLanguage(comboBoxLanguages.Text); if (comboBoxModels.Items[comboBoxModels.SelectedIndex] is WhisperModel model && - _languageCode != "en" && model.Name.EndsWith(".en", StringComparison.InvariantCulture)) + _languageCode != "en" && IsModelEnglishOnly(model)) { var result = MessageBox.Show("English model should only be used with English language." + Environment.NewLine + "Continue anyway?", Text, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning); @@ -514,6 +514,13 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText DialogResult = DialogResult.OK; } + private static bool IsModelEnglishOnly(WhisperModel model) + { + return model.Name.EndsWith(".en", StringComparison.InvariantCulture) || + model.Name == "distil-large-v2" || + model.Name == "distil-large-v3"; + } + private void ShowProgressBar() { progressBar1.Maximum = 100;