From 8810ecd9500f959810848921c162d1e3eda2433a Mon Sep 17 00:00:00 2001 From: Nikolaj Olsson Date: Sat, 15 Jun 2024 17:58:21 +0200 Subject: [PATCH] Fix crash in Vosk audio to text on selected lines - thx MediaExpres :) Fix #8530 Fix crash when Vosk is not installed --- src/ui/Forms/Main.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/ui/Forms/Main.cs b/src/ui/Forms/Main.cs index 9df26a569..694ec8e56 100644 --- a/src/ui/Forms/Main.cs +++ b/src/ui/Forms/Main.cs @@ -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)