diff --git a/src/libse/Common/Settings.cs b/src/libse/Common/Settings.cs index c91e7fccb..55ae86ea8 100644 --- a/src/libse/Common/Settings.cs +++ b/src/libse/Common/Settings.cs @@ -176,7 +176,7 @@ namespace Nikse.SubtitleEdit.Core.Common public string ChatGptUrl { get; set; } public string ChatGptApiKey { get; set; } public string ChatGptModel { get; set; } - public int ChatGptDelaySeconds { get; set; } + public int AutoTranslateDelaySeconds { get; set; } public string GeminiProApiKey { get; set; } public bool DisableVidoInfoViaLabel { get; set; } public bool ListViewSyntaxColorDurationSmall { get; set; } @@ -5336,10 +5336,10 @@ $HorzAlign = Center settings.Tools.ChatGptModel = subNode.InnerText; } - subNode = node.SelectSingleNode("ChatGptDelaySeconds"); + subNode = node.SelectSingleNode("AutoTranslateDelaySeconds"); if (subNode != null) { - settings.Tools.ChatGptDelaySeconds = Convert.ToInt32(subNode.InnerText, CultureInfo.InvariantCulture); + settings.Tools.AutoTranslateDelaySeconds = Convert.ToInt32(subNode.InnerText, CultureInfo.InvariantCulture); } subNode = node.SelectSingleNode("GeminiProApiKey"); @@ -11811,7 +11811,7 @@ $HorzAlign = Center textWriter.WriteElementString("ChatGptUrl", settings.Tools.ChatGptUrl); textWriter.WriteElementString("ChatGptApiKey", settings.Tools.ChatGptApiKey); textWriter.WriteElementString("ChatGptModel", settings.Tools.ChatGptModel); - textWriter.WriteElementString("ChatGptDelaySeconds", settings.Tools.ChatGptDelaySeconds.ToString(CultureInfo.InvariantCulture)); + textWriter.WriteElementString("AutoTranslateDelaySeconds", settings.Tools.AutoTranslateDelaySeconds.ToString(CultureInfo.InvariantCulture)); textWriter.WriteElementString("GeminiProApiKey", settings.Tools.GeminiProApiKey); textWriter.WriteElementString("DisableVidoInfoViaLabel", settings.Tools.DisableVidoInfoViaLabel.ToString(CultureInfo.InvariantCulture)); textWriter.WriteElementString("ListViewSyntaxColorDurationSmall", settings.Tools.ListViewSyntaxColorDurationSmall.ToString(CultureInfo.InvariantCulture)); diff --git a/src/libse/SubtitleFormats/Smil30.cs b/src/libse/SubtitleFormats/Smil30.cs new file mode 100644 index 000000000..2170e360f --- /dev/null +++ b/src/libse/SubtitleFormats/Smil30.cs @@ -0,0 +1,120 @@ +using Nikse.SubtitleEdit.Core.Common; +using System; +using System.Collections.Generic; +using System.Text; +using System.Xml; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class Smil30 : SubtitleFormat + { + public override string Extension => ".xml"; + + public override string Name => "SMIL 3.0"; + + private static string ToTimeCode(TimeCode tc) + { + return tc.ToString(false).Replace(',', '.'); + } + + private static TimeCode DecodeTimeCode(string s) + { + var parts = s.Split(new[] { ';', ':', '.', ',' }, StringSplitOptions.RemoveEmptyEntries); + return DecodeTimeCodeFramesFourParts(parts); + } + + public override string ToText(Subtitle subtitle, string title) + { + var xml = new XmlDocument(); + xml.LoadXml(""); + + const string ns = "http://www.w3.org/ns/SMIL"; + var nsmgr = new XmlNamespaceManager(xml.NameTable); + nsmgr.AddNamespace("smil", ns); + nsmgr.AddNamespace("epub", "http://www.idpf.org/2007/ops"); + + XmlNode bodyNode = xml.SelectSingleNode("//smil:body", nsmgr); + var count = 1; + foreach (var p in subtitle.Paragraphs) + { + XmlNode paragraph = xml.CreateElement("par", ns); + XmlNode text = xml.CreateElement("text", ns); + XmlNode audio = xml.CreateElement("audio", ns); + text.InnerText = p.Text; + + XmlAttribute start = xml.CreateAttribute("clipBegin"); + start.InnerText = ToTimeCode(p.StartTime); + audio.Attributes.Append(start); + + XmlAttribute end = xml.CreateAttribute("clipEnd"); + end.InnerText = ToTimeCode(p.EndTime); + audio.Attributes.Append(end); + + XmlAttribute textSource = xml.CreateAttribute("src"); + textSource.InnerText = $"text.xhtml#para{count}"; + text.Attributes.Append(textSource); + + XmlAttribute audioSource = xml.CreateAttribute("src"); + audioSource.InnerText = "audio.mp3"; + audio.Attributes.Append(audioSource); + + bodyNode.AppendChild(paragraph); + paragraph.AppendChild(text); + paragraph.AppendChild(audio); + + count++; + } + + return ToUtf8XmlString(xml); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + var sb = new StringBuilder(); + lines.ForEach(line => sb.AppendLine(line)); + var allText = sb.ToString(); + if (!allText.Contains("")) + { + return; + } + + var xml = new XmlDocument { XmlResolver = null }; + try + { + xml.LoadXml(allText); + } + catch + { + _errorCount = 1; + return; + } + + const string ns = "http://www.w3.org/ns/SMIL"; + var nsmgr = new XmlNamespaceManager(xml.NameTable); + nsmgr.AddNamespace("smil", ns); + nsmgr.AddNamespace("epub", "http://www.idpf.org/2007/ops"); + + foreach (XmlNode node in xml.DocumentElement.SelectNodes("//smil:par", nsmgr)) + { + try + { + var textNode = node.SelectSingleNode("smil:text", nsmgr); + var audioNode = node.SelectSingleNode("smil:audio", nsmgr); + + var text = textNode.InnerText; + var start = audioNode.Attributes["clipBegin"].InnerText; + var end = audioNode.Attributes["clipEnd"].InnerText; + subtitle.Paragraphs.Add(new Paragraph(DecodeTimeCode(start), DecodeTimeCode(end), text)); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine(ex.Message); + _errorCount++; + } + } + + subtitle.Renumber(); + } + } +} diff --git a/src/libse/SubtitleFormats/SubtitleFormat.cs b/src/libse/SubtitleFormats/SubtitleFormat.cs index d10790c90..8ef4bb055 100644 --- a/src/libse/SubtitleFormats/SubtitleFormat.cs +++ b/src/libse/SubtitleFormats/SubtitleFormat.cs @@ -192,6 +192,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats new ScenaristClosedCaptions(), new ScenaristClosedCaptionsDropFrame(), new SmartTitler(), + new Smil30(), new SmilTimesheetData(), new SmpteTt2052(), new SoftNiSub(), diff --git a/src/ui/Forms/Options/Settings.Designer.cs b/src/ui/Forms/Options/Settings.Designer.cs index 770f12171..a07d576af 100644 --- a/src/ui/Forms/Options/Settings.Designer.cs +++ b/src/ui/Forms/Options/Settings.Designer.cs @@ -465,8 +465,8 @@ this.label11 = new System.Windows.Forms.Label(); this.groupBoxAutoTranslateChatGpt = new System.Windows.Forms.GroupBox(); this.nikseTextBoxChatGptUrl = new Nikse.SubtitleEdit.Controls.NikseTextBox(); - this.nikseComboBoxChatGptDelay = new Nikse.SubtitleEdit.Controls.NikseComboBox(); - this.labelChatGptDelay = new System.Windows.Forms.Label(); + this.nikseComboBoxChatGptModel = new Nikse.SubtitleEdit.Controls.NikseComboBox(); + this.labelChatGptModel = new System.Windows.Forms.Label(); this.nikseTextBoxChatGptApiKey = new Nikse.SubtitleEdit.Controls.NikseTextBox(); this.labelApiKeyChatGpt = new System.Windows.Forms.Label(); this.labelUrlChatGpt = new System.Windows.Forms.Label(); @@ -6563,8 +6563,8 @@ | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.groupBoxAutoTranslateChatGpt.Controls.Add(this.nikseTextBoxChatGptUrl); - this.groupBoxAutoTranslateChatGpt.Controls.Add(this.nikseComboBoxChatGptDelay); - this.groupBoxAutoTranslateChatGpt.Controls.Add(this.labelChatGptDelay); + this.groupBoxAutoTranslateChatGpt.Controls.Add(this.nikseComboBoxChatGptModel); + this.groupBoxAutoTranslateChatGpt.Controls.Add(this.labelChatGptModel); this.groupBoxAutoTranslateChatGpt.Controls.Add(this.nikseTextBoxChatGptApiKey); this.groupBoxAutoTranslateChatGpt.Controls.Add(this.labelApiKeyChatGpt); this.groupBoxAutoTranslateChatGpt.Controls.Add(this.labelUrlChatGpt); @@ -6585,40 +6585,40 @@ this.nikseTextBoxChatGptUrl.Size = new System.Drawing.Size(384, 21); this.nikseTextBoxChatGptUrl.TabIndex = 34; // - // nikseComboBoxChatGptDelay + // nikseComboBoxChatGptModel // - this.nikseComboBoxChatGptDelay.BackColor = System.Drawing.SystemColors.Window; - this.nikseComboBoxChatGptDelay.BackColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240))))); - this.nikseComboBoxChatGptDelay.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(171)))), ((int)(((byte)(173)))), ((int)(((byte)(179))))); - this.nikseComboBoxChatGptDelay.BorderColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(120)))), ((int)(((byte)(120)))), ((int)(((byte)(120))))); - this.nikseComboBoxChatGptDelay.ButtonForeColor = System.Drawing.SystemColors.ControlText; - this.nikseComboBoxChatGptDelay.ButtonForeColorDown = System.Drawing.Color.Orange; - this.nikseComboBoxChatGptDelay.ButtonForeColorOver = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215))))); - this.nikseComboBoxChatGptDelay.DropDownHeight = 400; - this.nikseComboBoxChatGptDelay.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.nikseComboBoxChatGptDelay.DropDownWidth = 375; - this.nikseComboBoxChatGptDelay.FormattingEnabled = true; - this.nikseComboBoxChatGptDelay.Items.AddRange(new object[] { - "0", - "20"}); - this.nikseComboBoxChatGptDelay.Location = new System.Drawing.Point(52, 109); - this.nikseComboBoxChatGptDelay.MaxLength = 32767; - this.nikseComboBoxChatGptDelay.Name = "nikseComboBoxChatGptDelay"; - this.nikseComboBoxChatGptDelay.SelectedIndex = -1; - this.nikseComboBoxChatGptDelay.SelectedItem = null; - this.nikseComboBoxChatGptDelay.SelectedText = ""; - this.nikseComboBoxChatGptDelay.Size = new System.Drawing.Size(340, 21); - this.nikseComboBoxChatGptDelay.TabIndex = 38; - this.nikseComboBoxChatGptDelay.UsePopupWindow = false; + this.nikseComboBoxChatGptModel.BackColor = System.Drawing.SystemColors.Window; + this.nikseComboBoxChatGptModel.BackColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240))))); + this.nikseComboBoxChatGptModel.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(171)))), ((int)(((byte)(173)))), ((int)(((byte)(179))))); + this.nikseComboBoxChatGptModel.BorderColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(120)))), ((int)(((byte)(120)))), ((int)(((byte)(120))))); + this.nikseComboBoxChatGptModel.ButtonForeColor = System.Drawing.SystemColors.ControlText; + this.nikseComboBoxChatGptModel.ButtonForeColorDown = System.Drawing.Color.Orange; + this.nikseComboBoxChatGptModel.ButtonForeColorOver = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215))))); + this.nikseComboBoxChatGptModel.DropDownHeight = 400; + this.nikseComboBoxChatGptModel.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.nikseComboBoxChatGptModel.DropDownWidth = 375; + this.nikseComboBoxChatGptModel.FormattingEnabled = true; + this.nikseComboBoxChatGptModel.Items.AddRange(new object[] { + "gpt-3.5-turbo", + "gpt-4"}); + this.nikseComboBoxChatGptModel.Location = new System.Drawing.Point(52, 109); + this.nikseComboBoxChatGptModel.MaxLength = 32767; + this.nikseComboBoxChatGptModel.Name = "nikseComboBoxChatGptModel"; + this.nikseComboBoxChatGptModel.SelectedIndex = -1; + this.nikseComboBoxChatGptModel.SelectedItem = null; + this.nikseComboBoxChatGptModel.SelectedText = ""; + this.nikseComboBoxChatGptModel.Size = new System.Drawing.Size(340, 21); + this.nikseComboBoxChatGptModel.TabIndex = 38; + this.nikseComboBoxChatGptModel.UsePopupWindow = false; // - // labelChatGptDelay + // labelChatGptModel // - this.labelChatGptDelay.AutoSize = true; - this.labelChatGptDelay.Location = new System.Drawing.Point(6, 112); - this.labelChatGptDelay.Name = "labelChatGptDelay"; - this.labelChatGptDelay.Size = new System.Drawing.Size(34, 13); - this.labelChatGptDelay.TabIndex = 37; - this.labelChatGptDelay.Text = "Delay"; + this.labelChatGptModel.AutoSize = true; + this.labelChatGptModel.Location = new System.Drawing.Point(6, 112); + this.labelChatGptModel.Name = "labelChatGptModel"; + this.labelChatGptModel.Size = new System.Drawing.Size(35, 13); + this.labelChatGptModel.TabIndex = 37; + this.labelChatGptModel.Text = "Model"; // // nikseTextBoxChatGptApiKey // @@ -6986,8 +6986,8 @@ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(1092, 574); - this.Controls.Add(this.panelShortcuts); this.Controls.Add(this.panelAutoTranslate); + this.Controls.Add(this.panelShortcuts); this.Controls.Add(this.panelVideoPlayer); this.Controls.Add(this.labelUpdateFileTypeAssociationsStatus); this.Controls.Add(this.panelGeneral); @@ -7607,14 +7607,14 @@ private System.Windows.Forms.LinkLabel linkLabelPapago; private System.Windows.Forms.Label label11; private System.Windows.Forms.GroupBox groupBoxAutoTranslateChatGpt; - private System.Windows.Forms.Label labelChatGptDelay; + private System.Windows.Forms.Label labelChatGptModel; private Controls.NikseTextBox nikseTextBoxChatGptApiKey; private System.Windows.Forms.Label labelApiKeyChatGpt; private Controls.NikseTextBox nikseTextBoxChatGptUrl; private System.Windows.Forms.Label labelUrlChatGpt; private System.Windows.Forms.LinkLabel linkLabelMoreInfoChatGpt; private System.Windows.Forms.Label label10; - private Controls.NikseComboBox nikseComboBoxChatGptDelay; + private Controls.NikseComboBox nikseComboBoxChatGptModel; private System.Windows.Forms.Label labelShortcutsFilter; private Controls.NikseComboBox nikseComboBoxShortcutsFilter; } diff --git a/src/ui/Forms/Options/Settings.cs b/src/ui/Forms/Options/Settings.cs index 7c16c2051..227a27371 100644 --- a/src/ui/Forms/Options/Settings.cs +++ b/src/ui/Forms/Options/Settings.cs @@ -912,11 +912,11 @@ namespace Nikse.SubtitleEdit.Forms.Options nikseTextBoxDeepLApiKey.Width = nikseTextBoxDeepLUrl.Width - labelDeepLApiKey.Width - 3; labelApiKeyChatGpt.Text = language.GoogleTranslateApiKey; - labelChatGptDelay.Text = LanguageSettings.Current.Main.VideoControls.DelayInSeconds; + labelChatGptModel.Text = LanguageSettings.Current.AudioToText.Model; nikseTextBoxChatGptApiKey.Left = labelApiKeyChatGpt.Right + 3; nikseTextBoxChatGptApiKey.Width = nikseTextBoxChatGptUrl.Width - labelApiKeyChatGpt.Width - 3; - nikseComboBoxChatGptDelay.Left = labelChatGptDelay.Right + 3; - nikseComboBoxChatGptDelay.Width = nikseTextBoxChatGptUrl.Width - labelChatGptDelay.Width - 3; + nikseComboBoxChatGptModel.Left = labelChatGptModel.Right + 3; + nikseComboBoxChatGptModel.Width = nikseTextBoxChatGptUrl.Width - labelChatGptModel.Width - 3; nikseTextBoxPapagoClientSecret.Left = labelSecretPapago.Right + 3; nikseTextBoxPapagoClientSecret.Width = nikseTextBoxPapagoClientId.Width - labelSecretPapago.Width - 3; @@ -1150,10 +1150,10 @@ namespace Nikse.SubtitleEdit.Forms.Options nikseTextBoxChatGptUrl.Text = Configuration.Settings.Tools.ChatGptUrl; nikseTextBoxChatGptApiKey.Text = Configuration.Settings.Tools.ChatGptApiKey; - nikseComboBoxChatGptDelay.SelectedIndex = 0; - if (Configuration.Settings.Tools.ChatGptDelaySeconds == 20) + nikseComboBoxChatGptModel.Text = Configuration.Settings.Tools.ChatGptModel; + if (string.IsNullOrEmpty(nikseComboBoxChatGptModel.Text)) { - nikseComboBoxChatGptDelay.SelectedIndex = 1; + nikseComboBoxChatGptModel.Text = "gpt-3.5-turbo"; } nikseTextBoxPapagoClientId.Text = Configuration.Settings.Tools.AutoTranslatePapagoApiKeyId; @@ -2371,7 +2371,7 @@ namespace Nikse.SubtitleEdit.Forms.Options toolsSettings.AutoTranslateDeepLApiKey = nikseTextBoxDeepLApiKey.Text; toolsSettings.ChatGptUrl = nikseTextBoxChatGptUrl.Text; toolsSettings.ChatGptApiKey = nikseTextBoxChatGptApiKey.Text; - toolsSettings.ChatGptDelaySeconds = int.Parse(nikseComboBoxChatGptDelay.Text.Split()[0]); + toolsSettings.ChatGptModel = nikseComboBoxChatGptModel.Text; toolsSettings.AutoTranslatePapagoApiKeyId = nikseTextBoxPapagoClientId.Text.Trim(); toolsSettings.AutoTranslatePapagoApiKey = nikseTextBoxPapagoClientSecret.Text.Trim(); diff --git a/src/ui/Forms/Translate/AutoTranslate.Designer.cs b/src/ui/Forms/Translate/AutoTranslate.Designer.cs index f1c9a0b8f..525b15ec7 100644 --- a/src/ui/Forms/Translate/AutoTranslate.Designer.cs +++ b/src/ui/Forms/Translate/AutoTranslate.Designer.cs @@ -60,6 +60,8 @@ this.subtitleListViewSource = new Nikse.SubtitleEdit.Controls.SubtitleListView(); this.comboBoxFormality = new Nikse.SubtitleEdit.Controls.NikseComboBox(); this.labelFormality = new Nikse.SubtitleEdit.Controls.NikseLabel(); + this.delayToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.delayToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.contextMenuStrip2.SuspendLayout(); this.contextMenuStrip1.SuspendLayout(); this.SuspendLayout(); @@ -159,9 +161,10 @@ this.toolStripMenuItemStartNLLBServe, this.toolStripMenuItemStartNLLBApi, this.toolStripSeparator1, - this.translateSingleLinesToolStripMenuItem}); + this.translateSingleLinesToolStripMenuItem, + this.delayToolStripMenuItem}); this.contextMenuStrip2.Name = "contextMenuStrip1"; - this.contextMenuStrip2.Size = new System.Drawing.Size(197, 98); + this.contextMenuStrip2.Size = new System.Drawing.Size(199, 120); this.contextMenuStrip2.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStrip2_Opening); // // toolStripMenuItemStartLibre @@ -203,9 +206,10 @@ this.startNLLBServeServerToolStripMenuItem, this.startNLLBAPIServerToolStripMenuItem, this.toolStripSeparator2, - this.translateSingleLinesToolStripMenuItem1}); + this.translateSingleLinesToolStripMenuItem1, + this.delayToolStripMenuItem1}); this.contextMenuStrip1.Name = "contextMenuStrip1"; - this.contextMenuStrip1.Size = new System.Drawing.Size(197, 98); + this.contextMenuStrip1.Size = new System.Drawing.Size(199, 142); this.contextMenuStrip1.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStrip1_Opening); // // startLibreTranslateServerToolStripMenuItem @@ -443,6 +447,20 @@ this.labelFormality.TabIndex = 113; this.labelFormality.Text = "Formality:"; // + // delayToolStripMenuItem + // + this.delayToolStripMenuItem.Name = "delayToolStripMenuItem"; + this.delayToolStripMenuItem.Size = new System.Drawing.Size(198, 22); + this.delayToolStripMenuItem.Text = "Delay between API calls"; + this.delayToolStripMenuItem.Click += new System.EventHandler(this.delayToolStripMenuItem_Click); + // + // delayToolStripMenuItem1 + // + this.delayToolStripMenuItem1.Name = "delayToolStripMenuItem1"; + this.delayToolStripMenuItem1.Size = new System.Drawing.Size(198, 22); + this.delayToolStripMenuItem1.Text = "Delay between API calls"; + this.delayToolStripMenuItem1.Click += new System.EventHandler(this.delayToolStripMenuItem1_Click); + // // AutoTranslate // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -519,5 +537,7 @@ private System.Windows.Forms.ToolStripMenuItem translateSingleLinesToolStripMenuItem1; private Nikse.SubtitleEdit.Controls.NikseComboBox comboBoxFormality; private Nikse.SubtitleEdit.Controls.NikseLabel labelFormality; + private System.Windows.Forms.ToolStripMenuItem delayToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem delayToolStripMenuItem1; } } \ No newline at end of file diff --git a/src/ui/Forms/Translate/AutoTranslate.cs b/src/ui/Forms/Translate/AutoTranslate.cs index 5f4b30528..473a8e336 100644 --- a/src/ui/Forms/Translate/AutoTranslate.cs +++ b/src/ui/Forms/Translate/AutoTranslate.cs @@ -109,6 +109,7 @@ namespace Nikse.SubtitleEdit.Forms.Translate AutoTranslate_Resize(null, null); UpdateTranslation(); MergeAndSplitHelper.MergeSplitProblems = false; + ShowDelayLabel(); } private void InitializeAutoTranslatorEngines() @@ -625,11 +626,7 @@ namespace Nikse.SubtitleEdit.Forms.Translate _autoTranslator.Name == NoLanguageLeftBehindApi.StaticName || // NLLB seems to miss some text... _autoTranslator.Name == NoLanguageLeftBehindServe.StaticName; - var delaySeconds = 0; - if (_autoTranslator.Name == ChatGptTranslate.StaticName) - { - delaySeconds = Configuration.Settings.Tools.ChatGptDelaySeconds; - } + var delaySeconds = Configuration.Settings.Tools.AutoTranslateDelaySeconds; if (comboBoxSource.SelectedItem is TranslationPair source && comboBoxTarget.SelectedItem is TranslationPair target) { @@ -1200,5 +1197,29 @@ namespace Nikse.SubtitleEdit.Forms.Translate } } } + + private void delayToolStripMenuItem1_Click(object sender, EventArgs e) + { + delayToolStripMenuItem_Click(null, null); + } + + private void delayToolStripMenuItem_Click(object sender, EventArgs e) + { + if (Configuration.Settings.Tools.AutoTranslateDelaySeconds == 0) + { + Configuration.Settings.Tools.AutoTranslateDelaySeconds = 20; + } + else + { + Configuration.Settings.Tools.AutoTranslateDelaySeconds = 0; + } + + ShowDelayLabel(); + } + + private void ShowDelayLabel() + { + delayToolStripMenuItem1.Text = "Delay between API calls in seconds: " + Configuration.Settings.Tools.AutoTranslateDelaySeconds; + } } }