Minor tts ui fix

This commit is contained in:
Nikolaj Olsson 2024-04-22 19:36:47 +02:00
parent 1aa8688c5c
commit 8615c0a126
2 changed files with 110 additions and 89 deletions

View File

@ -37,19 +37,20 @@
this.groupBoxMsSettings = new System.Windows.Forms.GroupBox();
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.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.labelVoiceCount = new System.Windows.Forms.Label();
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.groupBoxMsSettings.SuspendLayout();
this.SuspendLayout();
//
@ -111,6 +112,7 @@
//
this.groupBoxMsSettings.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.groupBoxMsSettings.Controls.Add(this.labelVoiceCount);
this.groupBoxMsSettings.Controls.Add(this.checkBoxShowPreview);
this.groupBoxMsSettings.Controls.Add(this.labelApiKey);
this.groupBoxMsSettings.Controls.Add(this.nikseTextBoxApiKey);
@ -151,28 +153,6 @@
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(17, 258);
this.nikseTextBoxApiKey.Name = "nikseTextBoxApiKey";
this.nikseTextBoxApiKey.Size = new System.Drawing.Size(351, 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, 187);
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, 158);
@ -206,59 +186,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.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, 124);
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;
this.nikseComboBoxEngine.SelectedIndexChanged += new System.EventHandler(this.nikseComboBoxEngine_SelectedIndexChanged);
//
// listViewActors
//
this.listViewActors.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
@ -316,6 +243,91 @@
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// 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, 98);
this.labelVoiceCount.Name = "labelVoiceCount";
this.labelVoiceCount.Size = new System.Drawing.Size(100, 23);
this.labelVoiceCount.TabIndex = 29;
this.labelVoiceCount.Text = "255";
this.labelVoiceCount.TextAlign = System.Drawing.ContentAlignment.BottomRight;
//
// 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(17, 258);
this.nikseTextBoxApiKey.Name = "nikseTextBoxApiKey";
this.nikseTextBoxApiKey.Size = new System.Drawing.Size(351, 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, 187);
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.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, 124);
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;
this.nikseComboBoxEngine.SelectedIndexChanged += new System.EventHandler(this.nikseComboBoxEngine_SelectedIndexChanged);
//
// TextToSpeech
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -371,5 +383,6 @@
private Controls.NikseTextBox nikseTextBoxApiKey;
private System.Windows.Forms.CheckBox checkBoxShowPreview;
private System.Windows.Forms.Button buttonCancel;
private System.Windows.Forms.Label labelVoiceCount;
}
}

View File

@ -1,4 +1,5 @@
using Nikse.SubtitleEdit.Core.Common;
using Nikse.SubtitleEdit.Controls;
using Nikse.SubtitleEdit.Core.Common;
using Nikse.SubtitleEdit.Core.SubtitleFormats;
using Nikse.SubtitleEdit.Core.TextToSpeech;
using Nikse.SubtitleEdit.Logic;
@ -6,6 +7,7 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net.Http;
@ -14,7 +16,6 @@ using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Controls;
using MessageBox = Nikse.SubtitleEdit.Forms.SeMsgBox.MessageBox;
namespace Nikse.SubtitleEdit.Forms.Tts
@ -102,6 +103,7 @@ namespace Nikse.SubtitleEdit.Forms.Tts
progressBar1.Visible = false;
labelProgress.Text = string.Empty;
labelVoiceCount.Text = string.Empty;
_engines = new List<TextToSpeechEngine>();
_engines.Add(new TextToSpeechEngine(TextToSpeechEngineId.Piper, "Piper (fast/good)", _engines.Count));
@ -137,7 +139,7 @@ namespace Nikse.SubtitleEdit.Forms.Tts
if (!SubtitleFormatHasActors() || !_actors.Any())
{
var w = groupBoxMsSettings.Width + 100;
var right = buttonOK.Right;
var right = buttonCancel.Right;
groupBoxMsSettings.Left = progressBar1.Left;
groupBoxMsSettings.Width = right - progressBar1.Left;
groupBoxMsSettings.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom;
@ -894,6 +896,7 @@ namespace Nikse.SubtitleEdit.Forms.Tts
private void nikseComboBoxEngine_SelectedIndexChanged(object sender, EventArgs e)
{
labelVoiceCount.Text = string.Empty;
nikseComboBoxVoice.Items.Clear();
labelApiKey.Visible = false;
@ -968,7 +971,7 @@ namespace Nikse.SubtitleEdit.Forms.Tts
if (_elevenLabVoices.Count == 0)
{
_elevenLabVoices.AddRange(GetElevelLabVoices());
_elevenLabVoices.AddRange(GetElevenLabVoices());
}
foreach (var voice in _elevenLabVoices)
@ -982,6 +985,11 @@ namespace Nikse.SubtitleEdit.Forms.Tts
nikseComboBoxVoice.SelectedIndex = 0;
}
if (nikseComboBoxVoice.Items.Count > 1)
{
labelVoiceCount.Text = nikseComboBoxVoice.Items.Count.ToString(CultureInfo.InvariantCulture);
}
_actorAndVoices.Clear();
if (SubtitleFormatHasActors())
@ -1114,7 +1122,7 @@ namespace Nikse.SubtitleEdit.Forms.Tts
}
}
private List<ElevenLabModel> GetElevelLabVoices()
private List<ElevenLabModel> GetElevenLabVoices()
{
var ttsPath = Path.Combine(Configuration.DataDirectory, "TextToSpeech");
if (!Directory.Exists(ttsPath))
@ -1122,15 +1130,15 @@ namespace Nikse.SubtitleEdit.Forms.Tts
Directory.CreateDirectory(ttsPath);
}
var elevelLabsPath = Path.Combine(ttsPath, "ElevenLabs");
if (!Directory.Exists(elevelLabsPath))
var elevenLabsPath = Path.Combine(ttsPath, "ElevenLabs");
if (!Directory.Exists(elevenLabsPath))
{
Directory.CreateDirectory(elevelLabsPath);
Directory.CreateDirectory(elevenLabsPath);
}
var result = new List<ElevenLabModel>();
var jsonFileName = Path.Combine(elevelLabsPath, "eleven-labs-voices.json");
var jsonFileName = Path.Combine(elevenLabsPath, "eleven-labs-voices.json");
if (!File.Exists(jsonFileName))
{
@ -1147,7 +1155,7 @@ namespace Nikse.SubtitleEdit.Forms.Tts
if (!string.IsNullOrEmpty(fileName))
{
var name = entry.FilenameInZip;
var path = Path.Combine(elevelLabsPath, name.Replace('/', Path.DirectorySeparatorChar));
var path = Path.Combine(elevenLabsPath, name.Replace('/', Path.DirectorySeparatorChar));
zip.ExtractFile(entry, path);
}
}