Fix crash in Vosk audio to text on selected lines - thx MediaExpres :)

Fix #8530
Fix crash when Vosk is not installed
This commit is contained in:
Nikolaj Olsson 2024-06-15 17:58:21 +02:00
parent 37d821130c
commit 8810ecd950

View File

@ -9832,6 +9832,28 @@ namespace Nikse.SubtitleEdit.Forms
return;
}
var voskFolder = Path.Combine(Configuration.DataDirectory, "Vosk");
if (!Directory.Exists(voskFolder))
{
Directory.CreateDirectory(voskFolder);
}
if (Configuration.IsRunningOnWindows && !HasCurrentVosk(voskFolder))
{
if (MessageBox.Show(string.Format(LanguageSettings.Current.Settings.DownloadX, "libvosk"), "Subtitle Edit", MessageBoxButtons.YesNoCancel) != DialogResult.Yes)
{
return;
}
using (var form = new DownloadVosk())
{
if (form.ShowDialog(this) != DialogResult.OK)
{
return;
}
}
}
var audioClips = GetAudioClips();
if (audioClips.Count == 1 && audioClips[0].Paragraph.DurationTotalMilliseconds > 10_000)