diff --git a/LanguageBaseEnglish.xml b/LanguageBaseEnglish.xml index 2662d5908..c90ae8168 100644 --- a/LanguageBaseEnglish.xml +++ b/LanguageBaseEnglish.xml @@ -980,9 +980,11 @@ We leverage the intrinsic rhythm of the image. Note: Advanced SubStation Alpha styling will be used :) "{0}" generated with burned-in subtitle in {1}. Time remaining: {0} minutes + Time remaining: One minute Time remaining: {0} seconds Time remaining: A few seconds Time remaining: {0} minutes and {1} seconds + Time remaining: One minute and {0} seconds Target file name: {0} Target file size (requires 2 pass encoding) File size in MB diff --git a/src/Test/Logic/ProgressHelperTest.cs b/src/Test/Logic/ProgressHelperTest.cs new file mode 100644 index 000000000..ab8952d4b --- /dev/null +++ b/src/Test/Logic/ProgressHelperTest.cs @@ -0,0 +1,38 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Nikse.SubtitleEdit.Core.Common; +using Nikse.SubtitleEdit.Logic; + +namespace Test.Logic +{ + [TestClass] + public class ProgressHelperTest + { + [TestMethod] + public void TestOneMinute() + { + var result = ProgressHelper.ToProgressTime(new TimeCode(0, 1, 0, 0).TotalMilliseconds); + Assert.AreEqual("Time remaining: One minute", result); + } + + [TestMethod] + public void TestOneMinuteAndTwoSeconds() + { + var result = ProgressHelper.ToProgressTime(new TimeCode(0, 1, 2, 0).TotalMilliseconds); + Assert.AreEqual("Time remaining: One minute and 2 seconds", result); + } + + [TestMethod] + public void TestTwoMinuteAndTwoSeconds() + { + var result = ProgressHelper.ToProgressTime(new TimeCode(0, 2, 2, 0).TotalMilliseconds); + Assert.AreEqual("Time remaining: 2 minutes and 2 seconds", result); + } + + [TestMethod] + public void TestOneSecond() + { + var result = ProgressHelper.ToProgressTime(new TimeCode(0, 0, 1, 0).TotalMilliseconds); + Assert.AreEqual("Time remaining: A few seconds", result); + } + } +} diff --git a/src/Test/Test.csproj b/src/Test/Test.csproj index 022c74ecc..f0d14b19e 100644 --- a/src/Test/Test.csproj +++ b/src/Test/Test.csproj @@ -105,6 +105,7 @@ + diff --git a/src/ui/Forms/AudioToText/WhisperAudioToText.cs b/src/ui/Forms/AudioToText/WhisperAudioToText.cs index 0405fc48f..af047a5bd 100644 --- a/src/ui/Forms/AudioToText/WhisperAudioToText.cs +++ b/src/ui/Forms/AudioToText/WhisperAudioToText.cs @@ -253,6 +253,7 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText private void ButtonGenerate_Click(object sender, EventArgs e) { + _cancel = false; if (comboBoxModels.Items.Count == 0) { buttonDownload_Click(null, null); @@ -1761,17 +1762,31 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText private void contextMenuStripWhisperAdvanced_Opening(object sender, System.ComponentModel.CancelEventArgs e) { - if (!string.IsNullOrEmpty(Configuration.Settings.Tools.WhisperCppModelLocation) && - Directory.Exists(Configuration.Settings.Tools.WhisperCppModelLocation)) + runOnlyPostProcessingToolStripMenuItem.Visible = buttonGenerate.Enabled; + toolStripSeparatorRunOnlyPostprocessing.Visible = buttonGenerate.Enabled; + + if (Configuration.Settings.Tools.WhisperChoice == WhisperChoice.Cpp || + Configuration.Settings.Tools.WhisperChoice == WhisperChoice.ConstMe) { - setCPPConstmeModelsFolderToolStripMenuItem.Text = $"{LanguageSettings.Current.AudioToText.SetCppConstMeFolder} [{Configuration.Settings.Tools.WhisperCppModelLocation}]"; + if (!string.IsNullOrEmpty(Configuration.Settings.Tools.WhisperCppModelLocation) && + Directory.Exists(Configuration.Settings.Tools.WhisperCppModelLocation)) + { + setCPPConstmeModelsFolderToolStripMenuItem.Text = $"{LanguageSettings.Current.AudioToText.SetCppConstMeFolder} [{Configuration.Settings.Tools.WhisperCppModelLocation}]"; + } + else + { + setCPPConstmeModelsFolderToolStripMenuItem.Text = LanguageSettings.Current.AudioToText.SetCppConstMeFolder; + } + setCPPConstmeModelsFolderToolStripMenuItem.Visible = true; } else { - setCPPConstmeModelsFolderToolStripMenuItem.Text = LanguageSettings.Current.AudioToText.SetCppConstMeFolder; + setCPPConstmeModelsFolderToolStripMenuItem.Visible = false; } - downloadCUDAForPerfviewsWhisperFasterToolStripMenuItem.Visible = Configuration.Settings.Tools.WhisperChoice == WhisperChoice.PurfviewFasterWhisper; + downloadCUDAForPerfviewsWhisperFasterToolStripMenuItem.Visible = + buttonGenerate.Enabled && + Configuration.Settings.Tools.WhisperChoice == WhisperChoice.PurfviewFasterWhisper; var whisperLogFile = SeLogger.GetWhisperLogFilePath(); if (File.Exists(whisperLogFile)) @@ -1789,6 +1804,8 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText { try { + labelProgress.Text = LanguageSettings.Current.AudioToText.PostProcessing; + _languageCode = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle); var postProcessor = new AudioToTextPostProcessor(_languageCode) { diff --git a/src/ui/Logic/Language.cs b/src/ui/Logic/Language.cs index 9164acfd2..4335ebf08 100644 --- a/src/ui/Logic/Language.cs +++ b/src/ui/Logic/Language.cs @@ -1231,9 +1231,11 @@ namespace Nikse.SubtitleEdit.Logic InfoAssaOn = "Note: Advanced SubStation Alpha styling will be used :)", XGeneratedWithBurnedInSubsInX = "\"{0}\" generated with burned-in subtitle in {1}.", TimeRemainingMinutes = "Time remaining: {0} minutes", + TimeRemainingOneMinute = "Time remaining: One minute", TimeRemainingSeconds = "Time remaining: {0} seconds", TimeRemainingAFewSeconds = "Time remaining: A few seconds", TimeRemainingMinutesAndSeconds = "Time remaining: {0} minutes and {1} seconds", + TimeRemainingOneMinuteAndSeconds = "Time remaining: One minute and {0} seconds", TargetFileName = "Target file name: {0}", TargetFileSize = "Target file size (requires 2 pass encoding)", FileSizeMb = "File size in MB", diff --git a/src/ui/Logic/LanguageDeserializer.cs b/src/ui/Logic/LanguageDeserializer.cs index ebdded3ea..7fc077fbd 100644 --- a/src/ui/Logic/LanguageDeserializer.cs +++ b/src/ui/Logic/LanguageDeserializer.cs @@ -2581,6 +2581,9 @@ namespace Nikse.SubtitleEdit.Logic case "GenerateVideoWithBurnedInSubs/TimeRemainingMinutes": language.GenerateVideoWithBurnedInSubs.TimeRemainingMinutes = reader.Value; break; + case "GenerateVideoWithBurnedInSubs/TimeRemainingOneMinute": + language.GenerateVideoWithBurnedInSubs.TimeRemainingOneMinute = reader.Value; + break; case "GenerateVideoWithBurnedInSubs/TimeRemainingSeconds": language.GenerateVideoWithBurnedInSubs.TimeRemainingSeconds = reader.Value; break; @@ -2590,6 +2593,9 @@ namespace Nikse.SubtitleEdit.Logic case "GenerateVideoWithBurnedInSubs/TimeRemainingMinutesAndSeconds": language.GenerateVideoWithBurnedInSubs.TimeRemainingMinutesAndSeconds = reader.Value; break; + case "GenerateVideoWithBurnedInSubs/TimeRemainingOneMinuteAndSeconds": + language.GenerateVideoWithBurnedInSubs.TimeRemainingOneMinuteAndSeconds = reader.Value; + break; case "GenerateVideoWithBurnedInSubs/TargetFileName": language.GenerateVideoWithBurnedInSubs.TargetFileName = reader.Value; break; diff --git a/src/ui/Logic/LanguageStructure.cs b/src/ui/Logic/LanguageStructure.cs index 3d7437150..485c54164 100644 --- a/src/ui/Logic/LanguageStructure.cs +++ b/src/ui/Logic/LanguageStructure.cs @@ -1055,9 +1055,11 @@ public string InfoAssaOn { get; set; } public string XGeneratedWithBurnedInSubsInX { get; set; } public string TimeRemainingMinutes { get; set; } + public string TimeRemainingOneMinute { get; set; } public string TimeRemainingSeconds { get; set; } public string TimeRemainingAFewSeconds { get; set; } public string TimeRemainingMinutesAndSeconds { get; set; } + public string TimeRemainingOneMinuteAndSeconds { get; set; } public string TargetFileName { get; set; } public string TargetFileSize { get; set; } public string FileSizeMb { get; set; } diff --git a/src/ui/Logic/ProgressHelper.cs b/src/ui/Logic/ProgressHelper.cs index 4399552ec..df3a4119e 100644 --- a/src/ui/Logic/ProgressHelper.cs +++ b/src/ui/Logic/ProgressHelper.cs @@ -7,20 +7,38 @@ namespace Nikse.SubtitleEdit.Logic { public static string ToProgressTime(double estimatedTotalMs) { - var totalSeconds = (int)Math.Round(estimatedTotalMs / 1000.0); + var totalSeconds = (int)Math.Round(estimatedTotalMs / 1000.0, MidpointRounding.AwayFromZero); if (totalSeconds < 60) { - return totalSeconds < 3 - ? string.Format(LanguageSettings.Current.GenerateVideoWithBurnedInSubs.TimeRemainingAFewSeconds) - : string.Format(LanguageSettings.Current.GenerateVideoWithBurnedInSubs.TimeRemainingSeconds, totalSeconds); + if (totalSeconds < 3) + { + return string.Format(LanguageSettings.Current.GenerateVideoWithBurnedInSubs.TimeRemainingAFewSeconds); + } + + return string.Format(LanguageSettings.Current.GenerateVideoWithBurnedInSubs.TimeRemainingSeconds, totalSeconds); } if (totalSeconds / 60 > 5) { - return string.Format(LanguageSettings.Current.GenerateVideoWithBurnedInSubs.TimeRemainingMinutes, (int)Math.Round(totalSeconds / 60.0)); + return string.Format(LanguageSettings.Current.GenerateVideoWithBurnedInSubs.TimeRemainingMinutes, (int)Math.Round(totalSeconds / 60.0, MidpointRounding.AwayFromZero)); } var timeCode = new TimeCode(estimatedTotalMs); + if (timeCode.Seconds == 0 && timeCode.Minutes > 0) + { + if (timeCode.Minutes == 1) + { + return string.Format(LanguageSettings.Current.GenerateVideoWithBurnedInSubs.TimeRemainingOneMinute); + } + + return string.Format(LanguageSettings.Current.GenerateVideoWithBurnedInSubs.TimeRemainingMinutes, timeCode.Minutes); + } + + if (timeCode.Hours == 0 && timeCode.Minutes == 1) + { + return string.Format(LanguageSettings.Current.GenerateVideoWithBurnedInSubs.TimeRemainingOneMinuteAndSeconds, timeCode.Seconds); + } + return string.Format(LanguageSettings.Current.GenerateVideoWithBurnedInSubs.TimeRemainingMinutesAndSeconds, timeCode.Minutes + timeCode.Hours * 60, timeCode.Seconds); } }