From 5f8a53b2a7db64c16741bf040fedd6ad8f97d7ed Mon Sep 17 00:00:00 2001 From: Nikolaj Olsson Date: Tue, 22 Oct 2024 21:11:08 +0200 Subject: [PATCH] Add elevenlabs stability/similarity settings - thx aymanmostafa11 :) Related to #8928 --- src/libse/Settings/Settings.cs | 14 + src/libse/Settings/ToolsSettings.cs | 4 + src/ui/Forms/Tts/TextToSpeech.Designer.cs | 376 ++++++++++++++-------- src/ui/Forms/Tts/TextToSpeech.cs | 28 +- 4 files changed, 286 insertions(+), 136 deletions(-) diff --git a/src/libse/Settings/Settings.cs b/src/libse/Settings/Settings.cs index 6a5d8f58d..d43ccf660 100644 --- a/src/libse/Settings/Settings.cs +++ b/src/libse/Settings/Settings.cs @@ -2359,6 +2359,18 @@ namespace Nikse.SubtitleEdit.Core.Settings settings.Tools.TextToSpeechElevenLabsLanguage = subNode.InnerText; } + subNode = node.SelectSingleNode("TextToSpeechElevenLabsStability"); + if (subNode != null) + { + settings.Tools.TextToSpeechElevenLabsStability = Convert.ToDouble(subNode.InnerText, CultureInfo.InvariantCulture); + } + + subNode = node.SelectSingleNode("TextToSpeechElevenLabsSimilarity"); + if (subNode != null) + { + settings.Tools.TextToSpeechElevenLabsSimilarity = Convert.ToDouble(subNode.InnerText, CultureInfo.InvariantCulture); + } + subNode = node.SelectSingleNode("TextToSpeechAzureApiKey"); if (subNode != null) { @@ -9034,6 +9046,8 @@ namespace Nikse.SubtitleEdit.Core.Settings xmlWriter.WriteElementString("TextToSpeechElevenLabsApiKey", settings.Tools.TextToSpeechElevenLabsApiKey); xmlWriter.WriteElementString("TextToSpeechElevenLabsModel", settings.Tools.TextToSpeechElevenLabsModel); xmlWriter.WriteElementString("TextToSpeechElevenLabsLanguage", settings.Tools.TextToSpeechElevenLabsLanguage); + xmlWriter.WriteElementString("TextToSpeechElevenLabsStability", settings.Tools.TextToSpeechElevenLabsStability.ToString(CultureInfo.InvariantCulture)); + xmlWriter.WriteElementString("TextToSpeechElevenLabsSimilarity", settings.Tools.TextToSpeechElevenLabsSimilarity.ToString(CultureInfo.InvariantCulture)); xmlWriter.WriteElementString("TextToSpeechAzureApiKey", settings.Tools.TextToSpeechAzureApiKey); xmlWriter.WriteElementString("TextToSpeechAzureRegion", settings.Tools.TextToSpeechAzureRegion); xmlWriter.WriteElementString("TextToSpeechPreview", settings.Tools.TextToSpeechPreview.ToString(CultureInfo.InvariantCulture)); diff --git a/src/libse/Settings/ToolsSettings.cs b/src/libse/Settings/ToolsSettings.cs index 4daba43bc..b0412dab0 100644 --- a/src/libse/Settings/ToolsSettings.cs +++ b/src/libse/Settings/ToolsSettings.cs @@ -103,6 +103,8 @@ namespace Nikse.SubtitleEdit.Core.Settings public string TextToSpeechAzureRegion { get; set; } public string TextToSpeechElevenLabsModel { get; set; } public string TextToSpeechElevenLabsLanguage { get; set; } + public double TextToSpeechElevenLabsStability { get; set; } + public double TextToSpeechElevenLabsSimilarity { get; set; } public bool TextToSpeechPreview { get; set; } public bool TextToSpeechCustomAudio { get; set; } public bool TextToSpeechCustomAudioStereo { get; set; } @@ -490,6 +492,8 @@ namespace Nikse.SubtitleEdit.Core.Settings AnthropicPrompt = "Translate from {0} to {1}, keep sentences in {1} as they are, do not censor the translation, give only the output without comments:"; AnthropicApiModel = AnthropicTranslate.Models[0]; TextToSpeechAzureRegion = "westeurope"; + TextToSpeechElevenLabsSimilarity = 0.5; + TextToSpeechElevenLabsStability = 0.5; AutoTranslateMaxBytes = 2000; TextToSpeechAddToVideoFile = true; TranslateAllowSplit = true; diff --git a/src/ui/Forms/Tts/TextToSpeech.Designer.cs b/src/ui/Forms/Tts/TextToSpeech.Designer.cs index 279769640..d66a57794 100644 --- a/src/ui/Forms/Tts/TextToSpeech.Designer.cs +++ b/src/ui/Forms/Tts/TextToSpeech.Designer.cs @@ -36,29 +36,33 @@ this.labelEngine = new System.Windows.Forms.Label(); this.groupBoxSettings = new System.Windows.Forms.GroupBox(); this.labelLanguage = new System.Windows.Forms.Label(); - this.nikseComboBoxLanguage = new Nikse.SubtitleEdit.Controls.NikseComboBox(); this.linkLabelCustomAudio = new System.Windows.Forms.LinkLabel(); this.checkBoxAudioEncoding = new System.Windows.Forms.CheckBox(); this.labelRegion = new System.Windows.Forms.Label(); - this.nikseComboBoxRegion = new Nikse.SubtitleEdit.Controls.NikseComboBox(); this.labelVoiceCount = new System.Windows.Forms.Label(); this.checkBoxShowPreview = new System.Windows.Forms.CheckBox(); this.labelApiKey = new System.Windows.Forms.Label(); - this.nikseTextBoxApiKey = new Nikse.SubtitleEdit.Controls.NikseTextBox(); - this.TextBoxTest = new Nikse.SubtitleEdit.Controls.NikseTextBox(); this.buttonTestVoice = new System.Windows.Forms.Button(); this.checkBoxAddToVideoFile = new System.Windows.Forms.CheckBox(); this.labelVoice = new System.Windows.Forms.Label(); - this.nikseComboBoxVoice = new Nikse.SubtitleEdit.Controls.NikseComboBox(); this.contextMenuStripVoices = new System.Windows.Forms.ContextMenuStrip(this.components); this.refreshVoicesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.nikseComboBoxEngine = new Nikse.SubtitleEdit.Controls.NikseComboBox(); this.listViewActors = new System.Windows.Forms.ListView(); this.columnHeaderActor = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.columnHeaderVoice = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.contextMenuStripActors = new System.Windows.Forms.ContextMenuStrip(this.components); this.labelActors = new System.Windows.Forms.Label(); this.buttonCancel = new System.Windows.Forms.Button(); + this.nikseUpDownStability = new Nikse.SubtitleEdit.Controls.NikseUpDown(); + this.nikseUpDownSimilarity = new Nikse.SubtitleEdit.Controls.NikseUpDown(); + this.labelSimilarity = new Nikse.SubtitleEdit.Controls.NikseLabel(); + this.labelStability = new Nikse.SubtitleEdit.Controls.NikseLabel(); + this.nikseComboBoxLanguage = new Nikse.SubtitleEdit.Controls.NikseComboBox(); + this.nikseComboBoxRegion = new Nikse.SubtitleEdit.Controls.NikseComboBox(); + this.nikseTextBoxApiKey = new Nikse.SubtitleEdit.Controls.NikseTextBox(); + this.TextBoxTest = new Nikse.SubtitleEdit.Controls.NikseTextBox(); + this.nikseComboBoxVoice = new Nikse.SubtitleEdit.Controls.NikseComboBox(); + this.nikseComboBoxEngine = new Nikse.SubtitleEdit.Controls.NikseComboBox(); this.groupBoxSettings.SuspendLayout(); this.contextMenuStripVoices.SuspendLayout(); this.SuspendLayout(); @@ -121,6 +125,10 @@ // this.groupBoxSettings.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left))); + this.groupBoxSettings.Controls.Add(this.nikseUpDownStability); + this.groupBoxSettings.Controls.Add(this.nikseUpDownSimilarity); + this.groupBoxSettings.Controls.Add(this.labelSimilarity); + this.groupBoxSettings.Controls.Add(this.labelStability); this.groupBoxSettings.Controls.Add(this.labelLanguage); this.groupBoxSettings.Controls.Add(this.nikseComboBoxLanguage); this.groupBoxSettings.Controls.Add(this.linkLabelCustomAudio); @@ -155,31 +163,6 @@ this.labelLanguage.TabIndex = 36; this.labelLanguage.Text = "Language"; // - // nikseComboBoxLanguage - // - this.nikseComboBoxLanguage.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.nikseComboBoxLanguage.BackColor = System.Drawing.SystemColors.Window; - this.nikseComboBoxLanguage.BackColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240))))); - this.nikseComboBoxLanguage.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(171)))), ((int)(((byte)(173)))), ((int)(((byte)(179))))); - this.nikseComboBoxLanguage.BorderColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(120)))), ((int)(((byte)(120)))), ((int)(((byte)(120))))); - this.nikseComboBoxLanguage.ButtonForeColor = System.Drawing.SystemColors.ControlText; - this.nikseComboBoxLanguage.ButtonForeColorDown = System.Drawing.Color.Orange; - this.nikseComboBoxLanguage.ButtonForeColorOver = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215))))); - this.nikseComboBoxLanguage.DropDownHeight = 400; - this.nikseComboBoxLanguage.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.nikseComboBoxLanguage.DropDownWidth = 0; - this.nikseComboBoxLanguage.FormattingEnabled = false; - this.nikseComboBoxLanguage.Location = new System.Drawing.Point(102, 269); - this.nikseComboBoxLanguage.MaxLength = 32767; - this.nikseComboBoxLanguage.Name = "nikseComboBoxLanguage"; - this.nikseComboBoxLanguage.SelectedIndex = -1; - this.nikseComboBoxLanguage.SelectedItem = null; - this.nikseComboBoxLanguage.SelectedText = ""; - this.nikseComboBoxLanguage.Size = new System.Drawing.Size(266, 23); - this.nikseComboBoxLanguage.TabIndex = 35; - this.nikseComboBoxLanguage.UsePopupWindow = false; - // // linkLabelCustomAudio // this.linkLabelCustomAudio.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); @@ -213,38 +196,12 @@ this.labelRegion.TabIndex = 32; this.labelRegion.Text = "Region"; // - // nikseComboBoxRegion - // - this.nikseComboBoxRegion.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.nikseComboBoxRegion.BackColor = System.Drawing.SystemColors.Window; - this.nikseComboBoxRegion.BackColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240))))); - this.nikseComboBoxRegion.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(171)))), ((int)(((byte)(173)))), ((int)(((byte)(179))))); - this.nikseComboBoxRegion.BorderColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(120)))), ((int)(((byte)(120)))), ((int)(((byte)(120))))); - this.nikseComboBoxRegion.ButtonForeColor = System.Drawing.SystemColors.ControlText; - this.nikseComboBoxRegion.ButtonForeColorDown = System.Drawing.Color.Orange; - this.nikseComboBoxRegion.ButtonForeColorOver = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215))))); - this.nikseComboBoxRegion.DropDownHeight = 400; - this.nikseComboBoxRegion.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.nikseComboBoxRegion.DropDownWidth = 0; - this.nikseComboBoxRegion.FormattingEnabled = false; - this.nikseComboBoxRegion.Location = new System.Drawing.Point(102, 240); - this.nikseComboBoxRegion.MaxLength = 32767; - this.nikseComboBoxRegion.Name = "nikseComboBoxRegion"; - this.nikseComboBoxRegion.SelectedIndex = -1; - this.nikseComboBoxRegion.SelectedItem = null; - this.nikseComboBoxRegion.SelectedText = ""; - this.nikseComboBoxRegion.Size = new System.Drawing.Size(266, 23); - this.nikseComboBoxRegion.TabIndex = 31; - this.nikseComboBoxRegion.UsePopupWindow = false; - this.nikseComboBoxRegion.SelectedIndexChanged += new System.EventHandler(this.nikseComboBoxRegion_SelectedIndexChanged); - // // labelVoiceCount // this.labelVoiceCount.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.labelVoiceCount.Location = new System.Drawing.Point(268, 83); + this.labelVoiceCount.Location = new System.Drawing.Point(172, 83); this.labelVoiceCount.Name = "labelVoiceCount"; - this.labelVoiceCount.Size = new System.Drawing.Size(100, 23); + this.labelVoiceCount.Size = new System.Drawing.Size(196, 23); this.labelVoiceCount.TabIndex = 29; this.labelVoiceCount.Text = "255"; this.labelVoiceCount.TextAlign = System.Drawing.ContentAlignment.BottomRight; @@ -266,34 +223,12 @@ // this.labelApiKey.AutoSize = true; this.labelApiKey.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.labelApiKey.Location = new System.Drawing.Point(14, 217); + this.labelApiKey.Location = new System.Drawing.Point(14, 216); this.labelApiKey.Name = "labelApiKey"; this.labelApiKey.Size = new System.Drawing.Size(44, 13); this.labelApiKey.TabIndex = 28; this.labelApiKey.Text = "API key"; // - // nikseTextBoxApiKey - // - this.nikseTextBoxApiKey.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.nikseTextBoxApiKey.FocusedColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215))))); - this.nikseTextBoxApiKey.Location = new System.Drawing.Point(102, 214); - this.nikseTextBoxApiKey.Name = "nikseTextBoxApiKey"; - this.nikseTextBoxApiKey.Size = new System.Drawing.Size(266, 20); - this.nikseTextBoxApiKey.TabIndex = 27; - // - // TextBoxTest - // - this.TextBoxTest.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.TextBoxTest.FocusedColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215))))); - this.TextBoxTest.Location = new System.Drawing.Point(17, 172); - this.TextBoxTest.Name = "TextBoxTest"; - this.TextBoxTest.Size = new System.Drawing.Size(351, 20); - this.TextBoxTest.TabIndex = 20; - this.TextBoxTest.Text = "Hello, how are you?"; - this.TextBoxTest.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxTest_KeyDown); - // // buttonTestVoice // this.buttonTestVoice.Location = new System.Drawing.Point(17, 141); @@ -327,32 +262,6 @@ this.labelVoice.TabIndex = 16; this.labelVoice.Text = "Voice"; // - // nikseComboBoxVoice - // - this.nikseComboBoxVoice.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.nikseComboBoxVoice.BackColor = System.Drawing.SystemColors.Window; - this.nikseComboBoxVoice.BackColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240))))); - this.nikseComboBoxVoice.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(171)))), ((int)(((byte)(173)))), ((int)(((byte)(179))))); - this.nikseComboBoxVoice.BorderColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(120)))), ((int)(((byte)(120)))), ((int)(((byte)(120))))); - this.nikseComboBoxVoice.ButtonForeColor = System.Drawing.SystemColors.ControlText; - this.nikseComboBoxVoice.ButtonForeColorDown = System.Drawing.Color.Orange; - this.nikseComboBoxVoice.ButtonForeColorOver = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215))))); - this.nikseComboBoxVoice.ContextMenuStrip = this.contextMenuStripVoices; - this.nikseComboBoxVoice.DropDownHeight = 400; - this.nikseComboBoxVoice.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.nikseComboBoxVoice.DropDownWidth = 0; - this.nikseComboBoxVoice.FormattingEnabled = false; - this.nikseComboBoxVoice.Location = new System.Drawing.Point(17, 110); - this.nikseComboBoxVoice.MaxLength = 32767; - this.nikseComboBoxVoice.Name = "nikseComboBoxVoice"; - this.nikseComboBoxVoice.SelectedIndex = -1; - this.nikseComboBoxVoice.SelectedItem = null; - this.nikseComboBoxVoice.SelectedText = ""; - this.nikseComboBoxVoice.Size = new System.Drawing.Size(351, 23); - this.nikseComboBoxVoice.TabIndex = 10; - this.nikseComboBoxVoice.UsePopupWindow = false; - // // contextMenuStripVoices // this.contextMenuStripVoices.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -368,33 +277,6 @@ this.refreshVoicesToolStripMenuItem.Text = "Refresh voices"; this.refreshVoicesToolStripMenuItem.Click += new System.EventHandler(this.refreshVoicesToolStripMenuItem_Click); // - // nikseComboBoxEngine - // - this.nikseComboBoxEngine.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.nikseComboBoxEngine.BackColor = System.Drawing.SystemColors.Window; - this.nikseComboBoxEngine.BackColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240))))); - this.nikseComboBoxEngine.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(171)))), ((int)(((byte)(173)))), ((int)(((byte)(179))))); - this.nikseComboBoxEngine.BorderColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(120)))), ((int)(((byte)(120)))), ((int)(((byte)(120))))); - this.nikseComboBoxEngine.ButtonForeColor = System.Drawing.SystemColors.ControlText; - this.nikseComboBoxEngine.ButtonForeColorDown = System.Drawing.Color.Orange; - this.nikseComboBoxEngine.ButtonForeColorOver = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215))))); - this.nikseComboBoxEngine.DropDownHeight = 400; - this.nikseComboBoxEngine.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDown; - this.nikseComboBoxEngine.DropDownWidth = 391; - this.nikseComboBoxEngine.FormattingEnabled = false; - this.nikseComboBoxEngine.Location = new System.Drawing.Point(17, 40); - this.nikseComboBoxEngine.MaxLength = 32767; - this.nikseComboBoxEngine.Name = "nikseComboBoxEngine"; - this.nikseComboBoxEngine.SelectedIndex = -1; - this.nikseComboBoxEngine.SelectedItem = null; - this.nikseComboBoxEngine.SelectedText = ""; - this.nikseComboBoxEngine.Size = new System.Drawing.Size(351, 23); - this.nikseComboBoxEngine.TabIndex = 5; - this.nikseComboBoxEngine.TabStop = false; - this.nikseComboBoxEngine.Text = "nikseComboBox1"; - this.nikseComboBoxEngine.UsePopupWindow = false; - // // listViewActors // this.listViewActors.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) @@ -452,6 +334,226 @@ this.buttonCancel.UseVisualStyleBackColor = true; this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); // + // nikseUpDownStability + // + this.nikseUpDownStability.BackColor = System.Drawing.SystemColors.Window; + this.nikseUpDownStability.BackColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240))))); + this.nikseUpDownStability.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(171)))), ((int)(((byte)(173)))), ((int)(((byte)(179))))); + this.nikseUpDownStability.BorderColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(120)))), ((int)(((byte)(120)))), ((int)(((byte)(120))))); + this.nikseUpDownStability.ButtonForeColor = System.Drawing.SystemColors.ControlText; + this.nikseUpDownStability.ButtonForeColorDown = System.Drawing.Color.Orange; + this.nikseUpDownStability.ButtonForeColorOver = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215))))); + this.nikseUpDownStability.DecimalPlaces = 0; + this.nikseUpDownStability.Increment = new decimal(new int[] { + 1, + 0, + 0, + 0}); + this.nikseUpDownStability.Location = new System.Drawing.Point(102, 270); + this.nikseUpDownStability.Maximum = new decimal(new int[] { + 100, + 0, + 0, + 0}); + this.nikseUpDownStability.Minimum = new decimal(new int[] { + 0, + 0, + 0, + 0}); + this.nikseUpDownStability.Name = "nikseUpDownStability"; + this.nikseUpDownStability.Size = new System.Drawing.Size(75, 23); + this.nikseUpDownStability.TabIndex = 101; + this.nikseUpDownStability.TabStop = false; + this.nikseUpDownStability.Text = "nikseUpDownStability"; + this.nikseUpDownStability.ThousandsSeparator = false; + this.nikseUpDownStability.Value = new decimal(new int[] { + 0, + 0, + 0, + 0}); + // + // nikseUpDownSimilarity + // + this.nikseUpDownSimilarity.BackColor = System.Drawing.SystemColors.Window; + this.nikseUpDownSimilarity.BackColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240))))); + this.nikseUpDownSimilarity.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(171)))), ((int)(((byte)(173)))), ((int)(((byte)(179))))); + this.nikseUpDownSimilarity.BorderColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(120)))), ((int)(((byte)(120)))), ((int)(((byte)(120))))); + this.nikseUpDownSimilarity.ButtonForeColor = System.Drawing.SystemColors.ControlText; + this.nikseUpDownSimilarity.ButtonForeColorDown = System.Drawing.Color.Orange; + this.nikseUpDownSimilarity.ButtonForeColorOver = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215))))); + this.nikseUpDownSimilarity.DecimalPlaces = 0; + this.nikseUpDownSimilarity.Increment = new decimal(new int[] { + 1, + 0, + 0, + 0}); + this.nikseUpDownSimilarity.Location = new System.Drawing.Point(102, 299); + this.nikseUpDownSimilarity.Maximum = new decimal(new int[] { + 100, + 0, + 0, + 0}); + this.nikseUpDownSimilarity.Minimum = new decimal(new int[] { + 0, + 0, + 0, + 0}); + this.nikseUpDownSimilarity.Name = "nikseUpDownSimilarity"; + this.nikseUpDownSimilarity.Size = new System.Drawing.Size(75, 23); + this.nikseUpDownSimilarity.TabIndex = 100; + this.nikseUpDownSimilarity.TabStop = false; + this.nikseUpDownSimilarity.Text = "nikseUpDownSimilarity"; + this.nikseUpDownSimilarity.ThousandsSeparator = false; + this.nikseUpDownSimilarity.Value = new decimal(new int[] { + 0, + 0, + 0, + 0}); + // + // labelSimilarity + // + this.labelSimilarity.AutoSize = true; + this.labelSimilarity.Location = new System.Drawing.Point(14, 305); + this.labelSimilarity.Name = "labelSimilarity"; + this.labelSimilarity.Size = new System.Drawing.Size(47, 13); + this.labelSimilarity.TabIndex = 99; + this.labelSimilarity.Text = "Similarity"; + // + // labelStability + // + this.labelStability.AutoSize = true; + this.labelStability.Location = new System.Drawing.Point(15, 274); + this.labelStability.Name = "labelStability"; + this.labelStability.Size = new System.Drawing.Size(43, 13); + this.labelStability.TabIndex = 97; + this.labelStability.Text = "Stability"; + // + // nikseComboBoxLanguage + // + this.nikseComboBoxLanguage.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.nikseComboBoxLanguage.BackColor = System.Drawing.SystemColors.Window; + this.nikseComboBoxLanguage.BackColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240))))); + this.nikseComboBoxLanguage.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(171)))), ((int)(((byte)(173)))), ((int)(((byte)(179))))); + this.nikseComboBoxLanguage.BorderColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(120)))), ((int)(((byte)(120)))), ((int)(((byte)(120))))); + this.nikseComboBoxLanguage.ButtonForeColor = System.Drawing.SystemColors.ControlText; + this.nikseComboBoxLanguage.ButtonForeColorDown = System.Drawing.Color.Orange; + this.nikseComboBoxLanguage.ButtonForeColorOver = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215))))); + this.nikseComboBoxLanguage.DropDownHeight = 400; + this.nikseComboBoxLanguage.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.nikseComboBoxLanguage.DropDownWidth = 0; + this.nikseComboBoxLanguage.FormattingEnabled = false; + this.nikseComboBoxLanguage.Location = new System.Drawing.Point(102, 269); + this.nikseComboBoxLanguage.MaxLength = 32767; + this.nikseComboBoxLanguage.Name = "nikseComboBoxLanguage"; + this.nikseComboBoxLanguage.SelectedIndex = -1; + this.nikseComboBoxLanguage.SelectedItem = null; + this.nikseComboBoxLanguage.SelectedText = ""; + this.nikseComboBoxLanguage.Size = new System.Drawing.Size(266, 23); + this.nikseComboBoxLanguage.TabIndex = 35; + this.nikseComboBoxLanguage.UsePopupWindow = false; + // + // nikseComboBoxRegion + // + this.nikseComboBoxRegion.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.nikseComboBoxRegion.BackColor = System.Drawing.SystemColors.Window; + this.nikseComboBoxRegion.BackColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240))))); + this.nikseComboBoxRegion.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(171)))), ((int)(((byte)(173)))), ((int)(((byte)(179))))); + this.nikseComboBoxRegion.BorderColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(120)))), ((int)(((byte)(120)))), ((int)(((byte)(120))))); + this.nikseComboBoxRegion.ButtonForeColor = System.Drawing.SystemColors.ControlText; + this.nikseComboBoxRegion.ButtonForeColorDown = System.Drawing.Color.Orange; + this.nikseComboBoxRegion.ButtonForeColorOver = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215))))); + this.nikseComboBoxRegion.DropDownHeight = 400; + this.nikseComboBoxRegion.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.nikseComboBoxRegion.DropDownWidth = 0; + this.nikseComboBoxRegion.FormattingEnabled = false; + this.nikseComboBoxRegion.Location = new System.Drawing.Point(102, 240); + this.nikseComboBoxRegion.MaxLength = 32767; + this.nikseComboBoxRegion.Name = "nikseComboBoxRegion"; + this.nikseComboBoxRegion.SelectedIndex = -1; + this.nikseComboBoxRegion.SelectedItem = null; + this.nikseComboBoxRegion.SelectedText = ""; + this.nikseComboBoxRegion.Size = new System.Drawing.Size(266, 23); + this.nikseComboBoxRegion.TabIndex = 31; + this.nikseComboBoxRegion.UsePopupWindow = false; + this.nikseComboBoxRegion.SelectedIndexChanged += new System.EventHandler(this.nikseComboBoxRegion_SelectedIndexChanged); + // + // nikseTextBoxApiKey + // + this.nikseTextBoxApiKey.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.nikseTextBoxApiKey.FocusedColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215))))); + this.nikseTextBoxApiKey.Location = new System.Drawing.Point(102, 213); + this.nikseTextBoxApiKey.Name = "nikseTextBoxApiKey"; + this.nikseTextBoxApiKey.Size = new System.Drawing.Size(266, 20); + this.nikseTextBoxApiKey.TabIndex = 27; + // + // TextBoxTest + // + this.TextBoxTest.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.TextBoxTest.FocusedColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215))))); + this.TextBoxTest.Location = new System.Drawing.Point(17, 172); + this.TextBoxTest.Name = "TextBoxTest"; + this.TextBoxTest.Size = new System.Drawing.Size(351, 20); + this.TextBoxTest.TabIndex = 20; + this.TextBoxTest.Text = "Hello, how are you?"; + this.TextBoxTest.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxTest_KeyDown); + // + // nikseComboBoxVoice + // + this.nikseComboBoxVoice.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.nikseComboBoxVoice.BackColor = System.Drawing.SystemColors.Window; + this.nikseComboBoxVoice.BackColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240))))); + this.nikseComboBoxVoice.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(171)))), ((int)(((byte)(173)))), ((int)(((byte)(179))))); + this.nikseComboBoxVoice.BorderColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(120)))), ((int)(((byte)(120)))), ((int)(((byte)(120))))); + this.nikseComboBoxVoice.ButtonForeColor = System.Drawing.SystemColors.ControlText; + this.nikseComboBoxVoice.ButtonForeColorDown = System.Drawing.Color.Orange; + this.nikseComboBoxVoice.ButtonForeColorOver = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215))))); + this.nikseComboBoxVoice.ContextMenuStrip = this.contextMenuStripVoices; + this.nikseComboBoxVoice.DropDownHeight = 400; + this.nikseComboBoxVoice.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.nikseComboBoxVoice.DropDownWidth = 0; + this.nikseComboBoxVoice.FormattingEnabled = false; + this.nikseComboBoxVoice.Location = new System.Drawing.Point(17, 110); + this.nikseComboBoxVoice.MaxLength = 32767; + this.nikseComboBoxVoice.Name = "nikseComboBoxVoice"; + this.nikseComboBoxVoice.SelectedIndex = -1; + this.nikseComboBoxVoice.SelectedItem = null; + this.nikseComboBoxVoice.SelectedText = ""; + this.nikseComboBoxVoice.Size = new System.Drawing.Size(351, 23); + this.nikseComboBoxVoice.TabIndex = 10; + this.nikseComboBoxVoice.UsePopupWindow = false; + // + // nikseComboBoxEngine + // + this.nikseComboBoxEngine.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.nikseComboBoxEngine.BackColor = System.Drawing.SystemColors.Window; + this.nikseComboBoxEngine.BackColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240))))); + this.nikseComboBoxEngine.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(171)))), ((int)(((byte)(173)))), ((int)(((byte)(179))))); + this.nikseComboBoxEngine.BorderColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(120)))), ((int)(((byte)(120)))), ((int)(((byte)(120))))); + this.nikseComboBoxEngine.ButtonForeColor = System.Drawing.SystemColors.ControlText; + this.nikseComboBoxEngine.ButtonForeColorDown = System.Drawing.Color.Orange; + this.nikseComboBoxEngine.ButtonForeColorOver = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215))))); + this.nikseComboBoxEngine.DropDownHeight = 400; + this.nikseComboBoxEngine.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDown; + this.nikseComboBoxEngine.DropDownWidth = 391; + this.nikseComboBoxEngine.FormattingEnabled = false; + this.nikseComboBoxEngine.Location = new System.Drawing.Point(17, 40); + this.nikseComboBoxEngine.MaxLength = 32767; + this.nikseComboBoxEngine.Name = "nikseComboBoxEngine"; + this.nikseComboBoxEngine.SelectedIndex = -1; + this.nikseComboBoxEngine.SelectedItem = null; + this.nikseComboBoxEngine.SelectedText = ""; + this.nikseComboBoxEngine.Size = new System.Drawing.Size(351, 23); + this.nikseComboBoxEngine.TabIndex = 5; + this.nikseComboBoxEngine.TabStop = false; + this.nikseComboBoxEngine.Text = "nikseComboBox1"; + this.nikseComboBoxEngine.UsePopupWindow = false; + // // TextToSpeech // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -517,5 +619,9 @@ private System.Windows.Forms.LinkLabel linkLabelCustomAudio; private System.Windows.Forms.Label labelLanguage; private Controls.NikseComboBox nikseComboBoxLanguage; + private Controls.NikseUpDown nikseUpDownStability; + private Controls.NikseUpDown nikseUpDownSimilarity; + private Controls.NikseLabel labelSimilarity; + private Controls.NikseLabel labelStability; } } \ No newline at end of file diff --git a/src/ui/Forms/Tts/TextToSpeech.cs b/src/ui/Forms/Tts/TextToSpeech.cs index b5d04fb80..f6c282e3a 100644 --- a/src/ui/Forms/Tts/TextToSpeech.cs +++ b/src/ui/Forms/Tts/TextToSpeech.cs @@ -186,6 +186,8 @@ namespace Nikse.SubtitleEdit.Forms.Tts checkBoxShowPreview.Checked = Configuration.Settings.Tools.TextToSpeechPreview; checkBoxAudioEncoding.Checked = Configuration.Settings.Tools.TextToSpeechCustomAudio; checkBoxAddToVideoFile.Enabled = _videoFileName != null; + nikseUpDownStability.Value = (int)Math.Round(Configuration.Settings.Tools.TextToSpeechElevenLabsStability * 100.0); + nikseUpDownSimilarity.Value = (int)Math.Round(Configuration.Settings.Tools.TextToSpeechElevenLabsSimilarity * 100.0); } private void SetActor(ActorAndVoice actor) @@ -220,6 +222,8 @@ namespace Nikse.SubtitleEdit.Forms.Tts private void ButtonGenerateTtsClick(object sender, EventArgs e) { + SaveConfiguration(); + if (buttonGenerateTTS.Text == LanguageSettings.Current.General.Cancel) { buttonGenerateTTS.Enabled = false; @@ -1131,7 +1135,9 @@ namespace Nikse.SubtitleEdit.Forms.Tts } } - var data = "{ \"text\": \"" + Json.EncodeJsonText(text) + $"\", \"model_id\": \"{model}\"{language}, \"voice_settings\": {{ \"stability\": 0.8, \"similarity_boost\": 1.0 }} }}"; + var stability = Math.Round(Configuration.Settings.Tools.TextToSpeechElevenLabsStability, 1).ToString(CultureInfo.InvariantCulture); + var similarity = Math.Round(Configuration.Settings.Tools.TextToSpeechElevenLabsSimilarity, 1).ToString(CultureInfo.InvariantCulture); + var data = "{ \"text\": \"" + Json.EncodeJsonText(text) + $"\", \"model_id\": \"{model}\"{language}, \"voice_settings\": {{ \"stability\": {stability}, \"similarity_boost\": {similarity} }} }}"; var content = new StringContent(data, Encoding.UTF8); content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json"); var result = httpClient.PostAsync(url, content, CancellationToken.None).Result; @@ -1360,6 +1366,11 @@ namespace Nikse.SubtitleEdit.Forms.Tts labelLanguage.Visible = false; nikseComboBoxLanguage.Visible = false; + labelStability.Visible = false; + labelSimilarity.Visible = false; + nikseUpDownStability.Visible = false; + nikseUpDownSimilarity.Visible = false; + labelRegion.Text = LanguageSettings.Current.General.Region; labelVoice.Text = LanguageSettings.Current.TextToSpeech.Voice; if (SubtitleFormatHasActors() && _actors.Any()) @@ -1485,6 +1496,11 @@ namespace Nikse.SubtitleEdit.Forms.Tts } nikseComboBoxRegion.Visible = true; + + labelStability.Visible = true; + labelSimilarity.Visible = true; + nikseUpDownStability.Visible = true; + nikseUpDownSimilarity.Visible = true; } if (engine.Id == TextToSpeechEngineId.AzureTextToSpeech) @@ -2214,6 +2230,8 @@ namespace Nikse.SubtitleEdit.Forms.Tts private void buttonTestVoice_Click(object sender, EventArgs e) { + SaveConfiguration(); + try { if (string.IsNullOrWhiteSpace(TextBoxTest.Text)) @@ -2266,6 +2284,12 @@ namespace Nikse.SubtitleEdit.Forms.Tts } } + private void SaveConfiguration() + { + Configuration.Settings.Tools.TextToSpeechElevenLabsStability = (double)nikseUpDownStability.Value / 100.0; + Configuration.Settings.Tools.TextToSpeechElevenLabsSimilarity = (double)nikseUpDownSimilarity.Value / 100.0; + } + private void HandleError(Exception ex) { var engine = _engines.First(p => p.Index == nikseComboBoxEngine.SelectedIndex); @@ -2282,6 +2306,8 @@ namespace Nikse.SubtitleEdit.Forms.Tts { var engine = _engines.First(p => p.Index == nikseComboBoxEngine.SelectedIndex); + SaveConfiguration(); + if (engine.Id == TextToSpeechEngineId.ElevenLabs) { Configuration.Settings.Tools.TextToSpeechElevenLabsApiKey = nikseTextBoxApiKey.Text;