mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-21 18:52:36 +01:00
Work on tts
This commit is contained in:
parent
1171be7919
commit
c7363b2f24
161
src/ui/Forms/Tts/TextToSpeech.Designer.cs
generated
161
src/ui/Forms/Tts/TextToSpeech.Designer.cs
generated
@ -35,19 +35,19 @@
|
||||
this.progressBar1 = new System.Windows.Forms.ProgressBar();
|
||||
this.labelEngine = new System.Windows.Forms.Label();
|
||||
this.groupBoxMsSettings = new System.Windows.Forms.GroupBox();
|
||||
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.labelApiKey = 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();
|
||||
//
|
||||
@ -125,6 +125,37 @@
|
||||
this.groupBoxMsSettings.TabStop = false;
|
||||
this.groupBoxMsSettings.Text = "Settings";
|
||||
//
|
||||
// labelApiKey
|
||||
//
|
||||
this.labelApiKey.AutoSize = true;
|
||||
this.labelApiKey.ImeMode = System.Windows.Forms.ImeMode.NoControl;
|
||||
this.labelApiKey.Location = new System.Drawing.Point(20, 242);
|
||||
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(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?";
|
||||
//
|
||||
// buttonTestVoice
|
||||
//
|
||||
this.buttonTestVoice.Location = new System.Drawing.Point(17, 158);
|
||||
@ -158,81 +189,6 @@
|
||||
this.labelVoice.TabIndex = 16;
|
||||
this.labelVoice.Text = "Voice";
|
||||
//
|
||||
// listViewActors
|
||||
//
|
||||
this.listViewActors.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.listViewActors.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||
this.columnHeaderActor,
|
||||
this.columnHeaderVoice});
|
||||
this.listViewActors.ContextMenuStrip = this.contextMenuStripActors;
|
||||
this.listViewActors.FullRowSelect = true;
|
||||
this.listViewActors.GridLines = true;
|
||||
this.listViewActors.HideSelection = false;
|
||||
this.listViewActors.Location = new System.Drawing.Point(412, 42);
|
||||
this.listViewActors.Name = "listViewActors";
|
||||
this.listViewActors.Size = new System.Drawing.Size(430, 375);
|
||||
this.listViewActors.TabIndex = 40;
|
||||
this.listViewActors.UseCompatibleStateImageBehavior = false;
|
||||
this.listViewActors.View = System.Windows.Forms.View.Details;
|
||||
//
|
||||
// columnHeaderActor
|
||||
//
|
||||
this.columnHeaderActor.Text = "Actor";
|
||||
this.columnHeaderActor.Width = 200;
|
||||
//
|
||||
// columnHeaderVoice
|
||||
//
|
||||
this.columnHeaderVoice.Text = "Voice";
|
||||
this.columnHeaderVoice.Width = 200;
|
||||
//
|
||||
// contextMenuStripActors
|
||||
//
|
||||
this.contextMenuStripActors.Name = "contextMenuStripActors";
|
||||
this.contextMenuStripActors.Size = new System.Drawing.Size(61, 4);
|
||||
//
|
||||
// labelActors
|
||||
//
|
||||
this.labelActors.AutoSize = true;
|
||||
this.labelActors.ImeMode = System.Windows.Forms.ImeMode.NoControl;
|
||||
this.labelActors.Location = new System.Drawing.Point(412, 20);
|
||||
this.labelActors.Name = "labelActors";
|
||||
this.labelActors.Size = new System.Drawing.Size(170, 13);
|
||||
this.labelActors.TabIndex = 19;
|
||||
this.labelActors.Text = "Right-click to assign actor to voice";
|
||||
//
|
||||
// labelApiKey
|
||||
//
|
||||
this.labelApiKey.AutoSize = true;
|
||||
this.labelApiKey.ImeMode = System.Windows.Forms.ImeMode.NoControl;
|
||||
this.labelApiKey.Location = new System.Drawing.Point(20, 242);
|
||||
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(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?";
|
||||
//
|
||||
// nikseComboBoxVoice
|
||||
//
|
||||
this.nikseComboBoxVoice.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
@ -286,6 +242,50 @@
|
||||
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)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.listViewActors.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||
this.columnHeaderActor,
|
||||
this.columnHeaderVoice});
|
||||
this.listViewActors.ContextMenuStrip = this.contextMenuStripActors;
|
||||
this.listViewActors.FullRowSelect = true;
|
||||
this.listViewActors.GridLines = true;
|
||||
this.listViewActors.HideSelection = false;
|
||||
this.listViewActors.Location = new System.Drawing.Point(412, 42);
|
||||
this.listViewActors.Name = "listViewActors";
|
||||
this.listViewActors.Size = new System.Drawing.Size(430, 375);
|
||||
this.listViewActors.TabIndex = 40;
|
||||
this.listViewActors.UseCompatibleStateImageBehavior = false;
|
||||
this.listViewActors.View = System.Windows.Forms.View.Details;
|
||||
//
|
||||
// columnHeaderActor
|
||||
//
|
||||
this.columnHeaderActor.Text = "Actor";
|
||||
this.columnHeaderActor.Width = 200;
|
||||
//
|
||||
// columnHeaderVoice
|
||||
//
|
||||
this.columnHeaderVoice.Text = "Voice";
|
||||
this.columnHeaderVoice.Width = 200;
|
||||
//
|
||||
// contextMenuStripActors
|
||||
//
|
||||
this.contextMenuStripActors.Name = "contextMenuStripActors";
|
||||
this.contextMenuStripActors.Size = new System.Drawing.Size(61, 4);
|
||||
//
|
||||
// labelActors
|
||||
//
|
||||
this.labelActors.AutoSize = true;
|
||||
this.labelActors.ImeMode = System.Windows.Forms.ImeMode.NoControl;
|
||||
this.labelActors.Location = new System.Drawing.Point(412, 20);
|
||||
this.labelActors.Name = "labelActors";
|
||||
this.labelActors.Size = new System.Drawing.Size(170, 13);
|
||||
this.labelActors.TabIndex = 19;
|
||||
this.labelActors.Text = "Right-click to assign actor to voice";
|
||||
//
|
||||
// TextToSpeech
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
@ -309,6 +309,7 @@
|
||||
this.Load += new System.EventHandler(this.TextToSpeech_Load);
|
||||
this.ResizeEnd += new System.EventHandler(this.TextToSpeech_ResizeEnd);
|
||||
this.SizeChanged += new System.EventHandler(this.TextToSpeech_SizeChanged);
|
||||
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextToSpeech_KeyDown);
|
||||
this.groupBoxMsSettings.ResumeLayout(false);
|
||||
this.groupBoxMsSettings.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
@ -648,7 +648,7 @@ namespace Nikse.SubtitleEdit.Forms.Tts
|
||||
var files = Directory.EnumerateFiles(pythonFolder, pyFileName, SearchOption.AllDirectories).ToList();
|
||||
if (files.Count == 0)
|
||||
{
|
||||
MessageBox.Show($"{pyFileName} not found under {pythonFolder}");
|
||||
MessageBox.Show(this, $"{pyFileName} not found under {pythonFolder}");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -819,7 +819,7 @@ namespace Nikse.SubtitleEdit.Forms.Tts
|
||||
{
|
||||
var error = Encoding.UTF8.GetString(bytes).Trim();
|
||||
SeLogger.Error($"ElevenLabs TTS failed calling API as base address {httpClient.BaseAddress} : Status code={result.StatusCode} {error}" + Environment.NewLine + "Data=" + data);
|
||||
MessageBox.Show("Calling url: " + url + Environment.NewLine + "With: " + data + Environment.NewLine + Environment.NewLine + "Error: " + error);
|
||||
MessageBox.Show(this, "Calling url: " + url + Environment.NewLine + "With: " + data + Environment.NewLine + Environment.NewLine + "Error: " + error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1165,7 +1165,7 @@ namespace Nikse.SubtitleEdit.Forms.Tts
|
||||
var ok = await GenerateParagraphAudio(sub, false, waveFileNameOnly);
|
||||
if (!ok)
|
||||
{
|
||||
MessageBox.Show("Ups, voice generation failed!");
|
||||
MessageBox.Show(this, "Ups, voice generation failed!");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1200,7 +1200,7 @@ namespace Nikse.SubtitleEdit.Forms.Tts
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message + Environment.NewLine + ex.StackTrace);
|
||||
HandleError(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -1208,6 +1208,18 @@ namespace Nikse.SubtitleEdit.Forms.Tts
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleError(Exception ex)
|
||||
{
|
||||
var engine = _engines.First(p => p.Index == nikseComboBoxEngine.SelectedIndex);
|
||||
var msg = "An error occurred while trying to generate speech.";
|
||||
if (engine.Id == TextToSpeechEngineId.Coqui)
|
||||
{
|
||||
msg += Environment.NewLine + "Make sure you have started the Coqui-ai TTS web server locally";
|
||||
}
|
||||
|
||||
MessageBox.Show(this, msg + Environment.NewLine + Environment.NewLine + ex.Message + Environment.NewLine + ex.StackTrace);
|
||||
}
|
||||
|
||||
private void TextToSpeech_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
var engine = _engines.First(p => p.Index == nikseComboBoxEngine.SelectedIndex);
|
||||
@ -1219,5 +1231,14 @@ namespace Nikse.SubtitleEdit.Forms.Tts
|
||||
|
||||
Configuration.Settings.Tools.TextToSpeechEngine = engine.Id.ToString();
|
||||
}
|
||||
|
||||
private void TextToSpeech_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyData == UiUtil.HelpKeys)
|
||||
{
|
||||
UiUtil.ShowHelp("#text_to_speech");
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user