diff --git a/src/libse/AudioToText/AudioToTextPostProcessor.cs b/src/libse/AudioToText/AudioToTextPostProcessor.cs index 6f70f93c3..0528e5914 100644 --- a/src/libse/AudioToText/AudioToTextPostProcessor.cs +++ b/src/libse/AudioToText/AudioToTextPostProcessor.cs @@ -17,7 +17,7 @@ namespace Nikse.SubtitleEdit.Core.AudioToText public double SetPeriodIfDistanceToNextIsMoreThan { get; set; } = 300; public double SetPeriodIfDistanceToNextIsMoreThanAlways { get; set; } = 500; - public int ParagraphMaxChars { get; set; } = 86; + public int ParagraphMaxChars { get; set; } public string TwoLetterLanguageCode { get; } @@ -25,6 +25,12 @@ namespace Nikse.SubtitleEdit.Core.AudioToText public AudioToTextPostProcessor(string twoLetterLanguageCode) { TwoLetterLanguageCode = twoLetterLanguageCode; + + ParagraphMaxChars = Configuration.Settings.Tools.AudioToTextLineMaxChars; + if (ParagraphMaxChars < 10 || ParagraphMaxChars > 1_000_000) + { + ParagraphMaxChars = 86; + } } public Subtitle Generate(List resultTexts, bool usePostProcessing, bool addPeriods, bool mergeLines, bool fixCasing, bool fixShortDuration) @@ -146,12 +152,12 @@ namespace Nikse.SubtitleEdit.Core.AudioToText if (language == "jp") { - ParagraphMaxChars = 13; + ParagraphMaxChars = Configuration.Settings.Tools.AudioToTextLineMaxCharsJp; } if (language == "cn") { - ParagraphMaxChars = 16; + ParagraphMaxChars = Configuration.Settings.Tools.AudioToTextLineMaxCharsCn; } var mergedSubtitle = new Subtitle(); diff --git a/src/libse/Common/Settings.cs b/src/libse/Common/Settings.cs index 96b5622e6..6bcd6ef0d 100644 --- a/src/libse/Common/Settings.cs +++ b/src/libse/Common/Settings.cs @@ -400,6 +400,9 @@ namespace Nikse.SubtitleEdit.Core.Common public bool GenVideoNonAssaFixRtlUnicode { get; set; } public bool VoskPostProcessing { get; set; } public string VoskModel { get; set; } + public int AudioToTextLineMaxChars { get; set; } + public int AudioToTextLineMaxCharsJp { get; set; } + public int AudioToTextLineMaxCharsCn { get; set; } public ToolsSettings() { @@ -589,6 +592,9 @@ namespace Nikse.SubtitleEdit.Core.Common GenVideoFontSizePercentOfHeight = 0.078f; GenVideoNonAssaBox = true; VoskPostProcessing = true; + AudioToTextLineMaxChars = 86; + AudioToTextLineMaxCharsJp = 32; + AudioToTextLineMaxCharsCn = 36; } } @@ -5981,6 +5987,25 @@ $HorzAlign = Center settings.Tools.VoskModel = subNode.InnerText; } + subNode = node.SelectSingleNode("AudioToTextLineMaxChars"); + if (subNode != null) + { + settings.Tools.AudioToTextLineMaxChars = Convert.ToInt32(subNode.InnerText, CultureInfo.InvariantCulture); + } + + subNode = node.SelectSingleNode("AudioToTextLineMaxCharsJp"); + if (subNode != null) + { + settings.Tools.AudioToTextLineMaxCharsJp = Convert.ToInt32(subNode.InnerText, CultureInfo.InvariantCulture); + } + + subNode = node.SelectSingleNode("AudioToTextLineMaxCharsCn"); + if (subNode != null) + { + settings.Tools.AudioToTextLineMaxCharsCn = Convert.ToInt32(subNode.InnerText, CultureInfo.InvariantCulture); + } + + subNode = node.SelectSingleNode("FindHistory"); if (subNode != null) { @@ -10096,6 +10121,9 @@ $HorzAlign = Center textWriter.WriteElementString("GenVideoNonAssaFixRtlUnicode", settings.Tools.GenVideoNonAssaFixRtlUnicode.ToString(CultureInfo.InvariantCulture)); textWriter.WriteElementString("VoskPostProcessing", settings.Tools.VoskPostProcessing.ToString(CultureInfo.InvariantCulture)); textWriter.WriteElementString("VoskModel", settings.Tools.VoskModel); + textWriter.WriteElementString("VoskModel", settings.Tools.AudioToTextLineMaxChars.ToString(CultureInfo.InvariantCulture)); + textWriter.WriteElementString("AudioToTextLineMaxCharsJp", settings.Tools.AudioToTextLineMaxCharsJp.ToString(CultureInfo.InvariantCulture)); + textWriter.WriteElementString("AudioToTextLineMaxCharsCn", settings.Tools.AudioToTextLineMaxCharsCn.ToString(CultureInfo.InvariantCulture)); if (settings.Tools.FindHistory != null && settings.Tools.FindHistory.Count > 0) {