diff --git a/src/libse/AutoTranslate/ChatGptTranslate.cs b/src/libse/AutoTranslate/ChatGptTranslate.cs index a94efa353..0a3959624 100644 --- a/src/libse/AutoTranslate/ChatGptTranslate.cs +++ b/src/libse/AutoTranslate/ChatGptTranslate.cs @@ -44,9 +44,14 @@ namespace Nikse.SubtitleEdit.Core.AutoTranslate var content = new StringContent(input, Encoding.UTF8); content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json"); var result = _httpClient.PostAsync(string.Empty, content).Result; - result.EnsureSuccessStatusCode(); var bytes = await result.Content.ReadAsByteArrayAsync(); var json = Encoding.UTF8.GetString(bytes).Trim(); + if (!result.IsSuccessStatusCode) + { + SeLogger.Error("ChatGptTranslate failed calling API: Status code=" + result.StatusCode + Environment.NewLine + json); + } + + result.EnsureSuccessStatusCode(); var parser = new SeJsonParser(); var resultText = parser.GetFirstObject(json, "content"); diff --git a/src/libse/Common/Settings.cs b/src/libse/Common/Settings.cs index e46354ed7..ca0d4bb4f 100644 --- a/src/libse/Common/Settings.cs +++ b/src/libse/Common/Settings.cs @@ -323,6 +323,7 @@ namespace Nikse.SubtitleEdit.Core.Common public int BinEditRightMargin { get; set; } public string BinEditStartPosition { get; set; } public string BinEditStartSize { get; set; } + public bool BinEditShowColumnGap { get; set; } public bool FixCommonErrorsFixOverlapAllowEqualEndStart { get; set; } public bool FixCommonErrorsSkipStepOne { get; set; } public string ImportTextSplitting { get; set; } @@ -6094,6 +6095,12 @@ $HorzAlign = Center settings.Tools.ExportPenLineJoin = subNode.InnerText; } + subNode = node.SelectSingleNode("BinEditShowColumnGap"); + if (subNode != null) + { + settings.Tools.BinEditShowColumnGap = Convert.ToBoolean(subNode.InnerText, CultureInfo.InvariantCulture); + } + subNode = node.SelectSingleNode("FixCommonErrorsFixOverlapAllowEqualEndStart"); if (subNode != null) { @@ -11713,6 +11720,7 @@ $HorzAlign = Center textWriter.WriteElementString("ExportFullFrame", settings.Tools.ExportFullFrame.ToString(CultureInfo.InvariantCulture)); textWriter.WriteElementString("ExportFcpFullPathUrl", settings.Tools.ExportFcpFullPathUrl.ToString(CultureInfo.InvariantCulture)); textWriter.WriteElementString("ExportPenLineJoin", settings.Tools.ExportPenLineJoin); + textWriter.WriteElementString("BinEditShowColumnGap", settings.Tools.BinEditShowColumnGap.ToString(CultureInfo.InvariantCulture)); textWriter.WriteElementString("FixCommonErrorsFixOverlapAllowEqualEndStart", settings.Tools.FixCommonErrorsFixOverlapAllowEqualEndStart.ToString(CultureInfo.InvariantCulture)); textWriter.WriteElementString("FixCommonErrorsSkipStepOne", settings.Tools.FixCommonErrorsSkipStepOne.ToString(CultureInfo.InvariantCulture)); textWriter.WriteElementString("ImportTextSplitting", settings.Tools.ImportTextSplitting); diff --git a/src/libse/SubtitleFormats/SmpteTt2052.cs b/src/libse/SubtitleFormats/SmpteTt2052.cs index 974c0eaa3..7e0f439b8 100644 --- a/src/libse/SubtitleFormats/SmpteTt2052.cs +++ b/src/libse/SubtitleFormats/SmpteTt2052.cs @@ -120,6 +120,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats + @@ -149,8 +150,9 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats } } var div = xml.DocumentElement.SelectSingleNode("//ttml:body", nsmgr).SelectSingleNode("ttml:div", nsmgr); - bool hasBottomCenterRegion = false; - bool hasTopCenterRegion = false; + var hasBottomCenterRegion = false; + var hasTopCenterRegion = false; + var hasMiddleRegion = false; foreach (XmlNode node in xml.DocumentElement.SelectNodes("//ttml:head/ttml:layout/ttml:region", nsmgr)) { string id = null; @@ -172,6 +174,11 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats { hasTopCenterRegion = true; } + + if (id != null && (id == "centerCenter" || id == "center")) + { + hasMiddleRegion = true; + } } foreach (var p in subtitle.Paragraphs) @@ -204,6 +211,11 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats paragraph.Attributes.Append(regionP); } } + else if (hasMiddleRegion && (text.StartsWith("{\\an5}", StringComparison.Ordinal) || text.StartsWith("{\\an6}", StringComparison.Ordinal) || text.StartsWith("{\\an7}", StringComparison.Ordinal))) + { + regionP.InnerText = "centerCenter"; + paragraph.Attributes.Append(regionP); + } else if (hasBottomCenterRegion) { regionP.InnerText = "bottom"; diff --git a/src/libse/SubtitleFormats/TimedText10.cs b/src/libse/SubtitleFormats/TimedText10.cs index 7c7751013..eec9bcdb6 100644 --- a/src/libse/SubtitleFormats/TimedText10.cs +++ b/src/libse/SubtitleFormats/TimedText10.cs @@ -201,7 +201,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats " " + Environment.NewLine + // Middle column " " + Environment.NewLine + - " " + Environment.NewLine + + " " + Environment.NewLine + " " + Environment.NewLine + // Right column " " + Environment.NewLine + @@ -448,7 +448,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats region = "centerLeft"; } - if (text.StartsWith("{\\an5}", StringComparison.Ordinal) && AddDefaultRegionIfNotExists(xml, "centerСenter")) + if (text.StartsWith("{\\an5}", StringComparison.Ordinal) && AddDefaultRegionIfNotExists(xml, "centerCenter")) { region = "centerСenter"; } @@ -882,7 +882,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats new KeyValuePair("bottomCenter", "{\\an2}"), new KeyValuePair("bottomRight", "{\\an3}"), new KeyValuePair("centerLeft", "{\\an4}"), - new KeyValuePair("centerСenter", "{\\an5}"), + new KeyValuePair("centerCenter", "{\\an5}"), new KeyValuePair("centerRight", "{\\an6}"), new KeyValuePair("topLeft", "{\\an7}"), new KeyValuePair("topCenter", "{\\an8}"), diff --git a/src/ui/Forms/AudioToText/VoskAudioToText.cs b/src/ui/Forms/AudioToText/VoskAudioToText.cs index db1ba3c69..1cbc1dec6 100644 --- a/src/ui/Forms/AudioToText/VoskAudioToText.cs +++ b/src/ui/Forms/AudioToText/VoskAudioToText.cs @@ -33,6 +33,7 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText private bool _useCenterChannelOnly; private Model _model; private int _initialWidth = 725; + private readonly List _outputBatchFileNames = new List(); public Subtitle TranscribedSubtitle { get; private set; } @@ -236,7 +237,8 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText MessageBox.Show($"{errorCount} error(s)!{Environment.NewLine}{errors}"); } - MessageBox.Show(string.Format(LanguageSettings.Current.AudioToText.XFilesSavedToVideoSourceFolder, listViewInputFiles.Items.Count - errorCount)); + var fileList = Environment.NewLine + Environment.NewLine + string.Join(Environment.NewLine, _outputBatchFileNames); + MessageBox.Show(string.Format(LanguageSettings.Current.AudioToText.XFilesSavedToVideoSourceFolder, listViewInputFiles.Items.Count - errorCount) + fileList); groupBoxInputFiles.Enabled = true; buttonGenerate.Enabled = true; @@ -253,11 +255,12 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText var fileName = Path.Combine(Utilities.GetPathAndFileNameWithoutExtension(videoFileName)) + format.Extension; if (File.Exists(fileName)) { - fileName = $"{Path.Combine(Utilities.GetPathAndFileNameWithoutExtension(videoFileName))}.{Guid.NewGuid().ToByteArray()}.{format.Extension}"; + fileName = $"{Path.Combine(Utilities.GetPathAndFileNameWithoutExtension(videoFileName))}.{Guid.NewGuid().ToString()}.{format.Extension}"; } File.WriteAllText(fileName, text, Encoding.UTF8); textBoxLog.AppendText("Subtitle written to : " + fileName + Environment.NewLine); + _outputBatchFileNames.Add(fileName); } internal static string GetLanguage(string text) diff --git a/src/ui/Forms/AudioToText/WhisperAudioToText.cs b/src/ui/Forms/AudioToText/WhisperAudioToText.cs index 975e6bfe3..6c0639e13 100644 --- a/src/ui/Forms/AudioToText/WhisperAudioToText.cs +++ b/src/ui/Forms/AudioToText/WhisperAudioToText.cs @@ -44,6 +44,8 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText private double _lastEstimatedMs = double.MaxValue; private VideoInfo _videoInfo; private readonly WavePeakData _wavePeaks; + private readonly List _outputBatchFileNames = new List(); + public bool UnknownArgument { get; set; } public bool RunningOnCuda { get; set; } public bool IncompleteModel { get; set; } @@ -575,7 +577,8 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText MessageBox.Show(this, $"{errorCount} error(s)!{Environment.NewLine}{errors}", Text, MessageBoxButtons.OK); } - MessageBox.Show(this, string.Format(LanguageSettings.Current.AudioToText.XFilesSavedToVideoSourceFolder, listViewInputFiles.Items.Count - errorCount), Text, MessageBoxButtons.OK); + var fileList = Environment.NewLine + Environment.NewLine + string.Join(Environment.NewLine, _outputBatchFileNames); + MessageBox.Show(this, string.Format(LanguageSettings.Current.AudioToText.XFilesSavedToVideoSourceFolder, listViewInputFiles.Items.Count - errorCount) + fileList, Text, MessageBoxButtons.OK); groupBoxInputFiles.Enabled = true; buttonGenerate.Enabled = true; @@ -671,11 +674,12 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText var fileName = Path.Combine(Utilities.GetPathAndFileNameWithoutExtension(videoFileName)) + format.Extension; if (File.Exists(fileName)) { - fileName = $"{Path.Combine(Utilities.GetPathAndFileNameWithoutExtension(videoFileName))}.{Guid.NewGuid().ToByteArray()}.{format.Extension}"; + fileName = $"{Path.Combine(Utilities.GetPathAndFileNameWithoutExtension(videoFileName))}.{Guid.NewGuid().ToString()}.{format.Extension}"; } File.WriteAllText(fileName, text, Encoding.UTF8); _outputText.Add("Subtitle written to : " + fileName); + _outputBatchFileNames.Add(fileName); } internal static string GetLanguage(string name) diff --git a/src/ui/Forms/BinaryEdit/BinEdit.cs b/src/ui/Forms/BinaryEdit/BinEdit.cs index 1bb58d177..3c5437fca 100644 --- a/src/ui/Forms/BinaryEdit/BinEdit.cs +++ b/src/ui/Forms/BinaryEdit/BinEdit.cs @@ -373,6 +373,12 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit videoPlayerContainer1.TryLoadGfx(); videoPlayerContainer1.HidePlayerName(); + + if (Configuration.Settings.Tools.BinEditShowColumnGap) + { + _columnIndexGap = 0; + UpdateListViewColumns(); + } } private void OpenBinSubtitle(string fileName) @@ -616,7 +622,7 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit var paragraph = subtitle.Paragraphs[index]; var item = new ListViewItem { UseItemStyleForSubItems = false, Checked = extra.IsForced && _columnIndexForced >= 0 }; - int count = startIndex; + var count = startIndex; if (_columnIndexNumber >= 0) { count = AddListViewSubItem(item, count, (index + 1).ToString(CultureInfo.InvariantCulture)); @@ -2895,6 +2901,8 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine + Configuration.Settings.Tools.BinEditStartSize = WindowState == FormWindowState.Maximized ? "Maximized" : Width + ";" + Height; } + Configuration.Settings.Tools.BinEditShowColumnGap = _columnIndexGap >= 0; + CloseVideo(); CleanUp();