Merge branch 'SubtitleEdit:main' into main

This commit is contained in:
May Kittens Devour Your Soul 2024-04-21 19:40:06 +02:00 committed by GitHub
commit cbd0ce0b16
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with 1865 additions and 254 deletions

View File

@ -2,8 +2,8 @@
4.0.6 (xth May 2024) BETA
* NEW:
* Add "Text To Speech" - thx darnn
* Add burn-in batch mode - thx Leon
* Add "Text To Speech" - thx darnn/cvrle77/msjsc001
* Add burn-in batch mode - thx Leon/David
* IMPROVED:
* Update Portuguese translation - thx hugok79
* Update Bulgarian translation - thx Калин

View File

@ -191,6 +191,7 @@ namespace Nikse.SubtitleEdit.Core.Common
public int AutoTranslateDelaySeconds { get; set; }
public string GeminiProApiKey { get; set; }
public string TextToSpeechEngine { get; set; }
public string TextToSpeechLastVoice { get; set; }
public string TextToSpeechElevenLabsApiKey { get; set; }
public bool DisableVidoInfoViaLabel { get; set; }
public bool ListViewSyntaxColorDurationSmall { get; set; }
@ -480,6 +481,9 @@ namespace Nikse.SubtitleEdit.Core.Common
public string GenVideoEmbedOutputSuffix { get; set; }
public string GenVideoEmbedOutputReplace { get; set; }
public bool GenVideoDeleteInputVideoFile { get; set; }
public bool GenVideoUseOutputFolder { get; set; }
public string GenVideoOutputFolder { get; set; }
public string GenVideoOutputFileSuffix { get; set; }
public bool VoskPostProcessing { get; set; }
public string VoskModel { get; set; }
@ -733,6 +737,7 @@ namespace Nikse.SubtitleEdit.Core.Common
GenVideoNonAssaTextColor = Color.White;
GenVideoEmbedOutputSuffix = "embed";
GenVideoEmbedOutputReplace = "embed" + Environment.NewLine + "SoftSub" + Environment.NewLine + "SoftSubbed";
GenVideoOutputFileSuffix = "_new";
VoskPostProcessing = true;
WhisperChoice = Configuration.IsRunningOnWindows ? AudioToText.WhisperChoice.PurfviewFasterWhisper : AudioToText.WhisperChoice.OpenAi;
WhisperDeleteTempFiles = true;
@ -5464,6 +5469,12 @@ $HorzAlign = Center
settings.Tools.TextToSpeechEngine = subNode.InnerText;
}
subNode = node.SelectSingleNode("TextToSpeechLastVoice");
if (subNode != null)
{
settings.Tools.TextToSpeechLastVoice = subNode.InnerText;
}
subNode = node.SelectSingleNode("TextToSpeechElevenLabsApiKey");
if (subNode != null)
{
@ -7176,6 +7187,24 @@ $HorzAlign = Center
settings.Tools.GenVideoDeleteInputVideoFile = Convert.ToBoolean(subNode.InnerText, CultureInfo.InvariantCulture);
}
subNode = node.SelectSingleNode("GenVideoUseOutputFolder");
if (subNode != null)
{
settings.Tools.GenVideoUseOutputFolder = Convert.ToBoolean(subNode.InnerText, CultureInfo.InvariantCulture);
}
subNode = node.SelectSingleNode("GenVideoOutputFolder");
if (subNode != null)
{
settings.Tools.GenVideoOutputFolder = subNode.InnerText;
}
subNode = node.SelectSingleNode("GenVideoOutputFileSuffix");
if (subNode != null)
{
settings.Tools.GenVideoOutputFileSuffix = subNode.InnerText;
}
subNode = node.SelectSingleNode("VoskPostProcessing");
if (subNode != null)
@ -11992,6 +12021,7 @@ $HorzAlign = Center
textWriter.WriteElementString("AutoTranslateDelaySeconds", settings.Tools.AutoTranslateDelaySeconds.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("GeminiProApiKey", settings.Tools.GeminiProApiKey);
textWriter.WriteElementString("TextToSpeechEngine", settings.Tools.TextToSpeechEngine);
textWriter.WriteElementString("TextToSpeechLastVoice", settings.Tools.TextToSpeechLastVoice);
textWriter.WriteElementString("TextToSpeechElevenLabsApiKey", settings.Tools.TextToSpeechElevenLabsApiKey);
textWriter.WriteElementString("DisableVidoInfoViaLabel", settings.Tools.DisableVidoInfoViaLabel.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("ListViewSyntaxColorDurationSmall", settings.Tools.ListViewSyntaxColorDurationSmall.ToString(CultureInfo.InvariantCulture));
@ -12275,6 +12305,9 @@ $HorzAlign = Center
textWriter.WriteElementString("GenVideoEmbedOutputSuffix", settings.Tools.GenVideoEmbedOutputSuffix);
textWriter.WriteElementString("GenVideoEmbedOutputReplace", settings.Tools.GenVideoEmbedOutputReplace);
textWriter.WriteElementString("GenVideoDeleteInputVideoFile", settings.Tools.GenVideoDeleteInputVideoFile.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("GenVideoUseOutputFolder", settings.Tools.GenVideoUseOutputFolder.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("GenVideoOutputFileSuffix", settings.Tools.GenVideoOutputFolder);
textWriter.WriteElementString("GenVideoOutputFileSuffix", settings.Tools.GenVideoOutputFileSuffix);
textWriter.WriteElementString("VoskPostProcessing", settings.Tools.VoskPostProcessing.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("VoskModel", settings.Tools.VoskModel);
textWriter.WriteElementString("WhisperChoice", settings.Tools.WhisperChoice);

View File

@ -37,20 +37,7 @@ namespace Nikse.SubtitleEdit.Forms
this.buttonCancel = new System.Windows.Forms.Button();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.groupBoxSettings = new System.Windows.Forms.GroupBox();
this.listViewBatch = new System.Windows.Forms.ListView();
this.columnHeaderVideoFile = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeaderResolution = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeaderSize = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeaderSubtitleFile = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeaderStatus = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.contextMenuStripBatch = new System.Windows.Forms.ContextMenuStrip(this.components);
this.addFilesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.pickSubtitleFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.removeSubtitleFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.clearToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.buttonOutputFileSettings = new System.Windows.Forms.Button();
this.buttonClear = new System.Windows.Forms.Button();
this.panelForeColor = new System.Windows.Forms.Panel();
this.buttonRemoveFile = new System.Windows.Forms.Button();
@ -109,9 +96,24 @@ namespace Nikse.SubtitleEdit.Forms
this.labelFileName = new Nikse.SubtitleEdit.Controls.NikseLabel();
this.numericUpDownFontSize = new Nikse.SubtitleEdit.Controls.NikseUpDown();
this.labelFontSize = new Nikse.SubtitleEdit.Controls.NikseLabel();
this.listViewBatch = new System.Windows.Forms.ListView();
this.columnHeaderVideoFile = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeaderResolution = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeaderSize = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeaderSubtitleFile = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeaderStatus = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.contextMenuStripBatch = new System.Windows.Forms.ContextMenuStrip(this.components);
this.addFilesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.pickSubtitleFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.removeSubtitleFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.clearToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.buttonPreview = new System.Windows.Forms.Button();
this.linkLabelHelp = new System.Windows.Forms.LinkLabel();
this.contextMenuStripRes = new System.Windows.Forms.ContextMenuStrip(this.components);
this.useSourceResolutionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.x2160ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.uHD3840x2160ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.k2048x1080ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@ -134,10 +136,10 @@ namespace Nikse.SubtitleEdit.Forms
this.textBoxLog = new Nikse.SubtitleEdit.Controls.NikseTextBox();
this.contextMenuStripGenerate.SuspendLayout();
this.groupBoxSettings.SuspendLayout();
this.contextMenuStripBatch.SuspendLayout();
this.groupBoxCut.SuspendLayout();
this.groupBoxVideo.SuspendLayout();
this.groupBoxAudio.SuspendLayout();
this.contextMenuStripBatch.SuspendLayout();
this.contextMenuStripRes.SuspendLayout();
this.SuspendLayout();
//
@ -201,6 +203,7 @@ namespace Nikse.SubtitleEdit.Forms
this.groupBoxSettings.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.groupBoxSettings.Controls.Add(this.buttonOutputFileSettings);
this.groupBoxSettings.Controls.Add(this.buttonClear);
this.groupBoxSettings.Controls.Add(this.panelForeColor);
this.groupBoxSettings.Controls.Add(this.buttonRemoveFile);
@ -233,114 +236,16 @@ namespace Nikse.SubtitleEdit.Forms
this.groupBoxSettings.TabStop = false;
this.groupBoxSettings.Text = "Settings";
//
// listViewBatch
// buttonOutputFileSettings
//
this.listViewBatch.AllowDrop = true;
this.listViewBatch.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.listViewBatch.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeaderVideoFile,
this.columnHeaderResolution,
this.columnHeaderSize,
this.columnHeaderSubtitleFile,
this.columnHeaderStatus});
this.listViewBatch.ContextMenuStrip = this.contextMenuStripBatch;
this.listViewBatch.FullRowSelect = true;
this.listViewBatch.HideSelection = false;
this.listViewBatch.Location = new System.Drawing.Point(6, 316);
this.listViewBatch.Name = "listViewBatch";
this.listViewBatch.Size = new System.Drawing.Size(852, 191);
this.listViewBatch.TabIndex = 3;
this.listViewBatch.UseCompatibleStateImageBehavior = false;
this.listViewBatch.View = System.Windows.Forms.View.Details;
this.listViewBatch.DragDrop += new System.Windows.Forms.DragEventHandler(this.listViewBatch_DragDrop);
this.listViewBatch.DragEnter += new System.Windows.Forms.DragEventHandler(this.listViewBatch_DragEnter);
this.listViewBatch.KeyDown += new System.Windows.Forms.KeyEventHandler(this.listViewBatch_KeyDown);
//
// columnHeaderVideoFile
//
this.columnHeaderVideoFile.Text = "Video file";
this.columnHeaderVideoFile.Width = 420;
//
// columnHeaderResolution
//
this.columnHeaderResolution.Text = "Resolution";
this.columnHeaderResolution.Width = 80;
//
// columnHeaderSize
//
this.columnHeaderSize.Text = "Size";
this.columnHeaderSize.Width = 80;
//
// columnHeaderSubtitleFile
//
this.columnHeaderSubtitleFile.Text = "Subtitle file";
this.columnHeaderSubtitleFile.Width = 180;
//
// columnHeaderStatus
//
this.columnHeaderStatus.Text = "Status";
this.columnHeaderStatus.Width = 80;
//
// contextMenuStripBatch
//
this.contextMenuStripBatch.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.addFilesToolStripMenuItem,
this.toolStripSeparator2,
this.pickSubtitleFileToolStripMenuItem,
this.removeSubtitleFileToolStripMenuItem,
this.toolStripSeparator1,
this.deleteToolStripMenuItem,
this.clearToolStripMenuItem});
this.contextMenuStripBatch.Name = "contextMenuStripBatch";
this.contextMenuStripBatch.Size = new System.Drawing.Size(179, 126);
this.contextMenuStripBatch.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStripBatch_Opening);
//
// addFilesToolStripMenuItem
//
this.addFilesToolStripMenuItem.Name = "addFilesToolStripMenuItem";
this.addFilesToolStripMenuItem.Size = new System.Drawing.Size(178, 22);
this.addFilesToolStripMenuItem.Text = "Add video files...";
this.addFilesToolStripMenuItem.Click += new System.EventHandler(this.addFilesToolStripMenuItem_Click);
//
// toolStripSeparator2
//
this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(175, 6);
//
// pickSubtitleFileToolStripMenuItem
//
this.pickSubtitleFileToolStripMenuItem.Name = "pickSubtitleFileToolStripMenuItem";
this.pickSubtitleFileToolStripMenuItem.Size = new System.Drawing.Size(178, 22);
this.pickSubtitleFileToolStripMenuItem.Text = "Pick subtitle file...";
this.pickSubtitleFileToolStripMenuItem.Click += new System.EventHandler(this.pickSubtitleFileToolStripMenuItem_Click);
//
// removeSubtitleFileToolStripMenuItem
//
this.removeSubtitleFileToolStripMenuItem.Name = "removeSubtitleFileToolStripMenuItem";
this.removeSubtitleFileToolStripMenuItem.Size = new System.Drawing.Size(178, 22);
this.removeSubtitleFileToolStripMenuItem.Text = "Remove subtitle file";
this.removeSubtitleFileToolStripMenuItem.Click += new System.EventHandler(this.removeSubtitleFileToolStripMenuItem_Click);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(175, 6);
//
// deleteToolStripMenuItem
//
this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem";
this.deleteToolStripMenuItem.Size = new System.Drawing.Size(178, 22);
this.deleteToolStripMenuItem.Text = "Delete";
this.deleteToolStripMenuItem.Click += new System.EventHandler(this.deleteToolStripMenuItem_Click);
//
// clearToolStripMenuItem
//
this.clearToolStripMenuItem.Name = "clearToolStripMenuItem";
this.clearToolStripMenuItem.Size = new System.Drawing.Size(178, 22);
this.clearToolStripMenuItem.Text = "Clear";
this.clearToolStripMenuItem.Click += new System.EventHandler(this.clearToolStripMenuItem_Click);
this.buttonOutputFileSettings.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.buttonOutputFileSettings.Location = new System.Drawing.Point(245, 513);
this.buttonOutputFileSettings.Name = "buttonOutputFileSettings";
this.buttonOutputFileSettings.Size = new System.Drawing.Size(167, 23);
this.buttonOutputFileSettings.TabIndex = 148;
this.buttonOutputFileSettings.Text = "Output file/folder...";
this.buttonOutputFileSettings.UseVisualStyleBackColor = true;
this.buttonOutputFileSettings.Click += new System.EventHandler(this.buttonOutputFileSettings_Click);
//
// buttonClear
//
@ -1397,6 +1302,115 @@ namespace Nikse.SubtitleEdit.Forms
this.labelFontSize.TabIndex = 0;
this.labelFontSize.Text = "Font size";
//
// listViewBatch
//
this.listViewBatch.AllowDrop = true;
this.listViewBatch.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.listViewBatch.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeaderVideoFile,
this.columnHeaderResolution,
this.columnHeaderSize,
this.columnHeaderSubtitleFile,
this.columnHeaderStatus});
this.listViewBatch.ContextMenuStrip = this.contextMenuStripBatch;
this.listViewBatch.FullRowSelect = true;
this.listViewBatch.HideSelection = false;
this.listViewBatch.Location = new System.Drawing.Point(6, 316);
this.listViewBatch.Name = "listViewBatch";
this.listViewBatch.Size = new System.Drawing.Size(852, 191);
this.listViewBatch.TabIndex = 3;
this.listViewBatch.UseCompatibleStateImageBehavior = false;
this.listViewBatch.View = System.Windows.Forms.View.Details;
this.listViewBatch.DragDrop += new System.Windows.Forms.DragEventHandler(this.listViewBatch_DragDrop);
this.listViewBatch.DragEnter += new System.Windows.Forms.DragEventHandler(this.listViewBatch_DragEnter);
this.listViewBatch.KeyDown += new System.Windows.Forms.KeyEventHandler(this.listViewBatch_KeyDown);
//
// columnHeaderVideoFile
//
this.columnHeaderVideoFile.Text = "Video file";
this.columnHeaderVideoFile.Width = 420;
//
// columnHeaderResolution
//
this.columnHeaderResolution.Text = "Resolution";
this.columnHeaderResolution.Width = 80;
//
// columnHeaderSize
//
this.columnHeaderSize.Text = "Size";
this.columnHeaderSize.Width = 80;
//
// columnHeaderSubtitleFile
//
this.columnHeaderSubtitleFile.Text = "Subtitle file";
this.columnHeaderSubtitleFile.Width = 180;
//
// columnHeaderStatus
//
this.columnHeaderStatus.Text = "Status";
this.columnHeaderStatus.Width = 80;
//
// contextMenuStripBatch
//
this.contextMenuStripBatch.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.addFilesToolStripMenuItem,
this.toolStripSeparator2,
this.pickSubtitleFileToolStripMenuItem,
this.removeSubtitleFileToolStripMenuItem,
this.toolStripSeparator1,
this.deleteToolStripMenuItem,
this.clearToolStripMenuItem});
this.contextMenuStripBatch.Name = "contextMenuStripBatch";
this.contextMenuStripBatch.Size = new System.Drawing.Size(179, 126);
this.contextMenuStripBatch.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStripBatch_Opening);
//
// addFilesToolStripMenuItem
//
this.addFilesToolStripMenuItem.Name = "addFilesToolStripMenuItem";
this.addFilesToolStripMenuItem.Size = new System.Drawing.Size(178, 22);
this.addFilesToolStripMenuItem.Text = "Add video files...";
this.addFilesToolStripMenuItem.Click += new System.EventHandler(this.addFilesToolStripMenuItem_Click);
//
// toolStripSeparator2
//
this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(175, 6);
//
// pickSubtitleFileToolStripMenuItem
//
this.pickSubtitleFileToolStripMenuItem.Name = "pickSubtitleFileToolStripMenuItem";
this.pickSubtitleFileToolStripMenuItem.Size = new System.Drawing.Size(178, 22);
this.pickSubtitleFileToolStripMenuItem.Text = "Pick subtitle file...";
this.pickSubtitleFileToolStripMenuItem.Click += new System.EventHandler(this.pickSubtitleFileToolStripMenuItem_Click);
//
// removeSubtitleFileToolStripMenuItem
//
this.removeSubtitleFileToolStripMenuItem.Name = "removeSubtitleFileToolStripMenuItem";
this.removeSubtitleFileToolStripMenuItem.Size = new System.Drawing.Size(178, 22);
this.removeSubtitleFileToolStripMenuItem.Text = "Remove subtitle file";
this.removeSubtitleFileToolStripMenuItem.Click += new System.EventHandler(this.removeSubtitleFileToolStripMenuItem_Click);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(175, 6);
//
// deleteToolStripMenuItem
//
this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem";
this.deleteToolStripMenuItem.Size = new System.Drawing.Size(178, 22);
this.deleteToolStripMenuItem.Text = "Delete";
this.deleteToolStripMenuItem.Click += new System.EventHandler(this.deleteToolStripMenuItem_Click);
//
// clearToolStripMenuItem
//
this.clearToolStripMenuItem.Name = "clearToolStripMenuItem";
this.clearToolStripMenuItem.Size = new System.Drawing.Size(178, 22);
this.clearToolStripMenuItem.Text = "Clear";
this.clearToolStripMenuItem.Click += new System.EventHandler(this.clearToolStripMenuItem_Click);
//
// buttonPreview
//
this.buttonPreview.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
@ -1423,6 +1437,7 @@ namespace Nikse.SubtitleEdit.Forms
// contextMenuStripRes
//
this.contextMenuStripRes.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.useSourceResolutionToolStripMenuItem,
this.x2160ToolStripMenuItem,
this.uHD3840x2160ToolStripMenuItem,
this.k2048x1080ToolStripMenuItem,
@ -1438,7 +1453,15 @@ namespace Nikse.SubtitleEdit.Forms
this.x352ToolStripMenuItem,
this.x272ToolStripMenuItem});
this.contextMenuStripRes.Name = "contextMenuStripRes";
this.contextMenuStripRes.Size = new System.Drawing.Size(204, 312);
this.contextMenuStripRes.Size = new System.Drawing.Size(204, 334);
this.contextMenuStripRes.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStripRes_Opening);
//
// useSourceResolutionToolStripMenuItem
//
this.useSourceResolutionToolStripMenuItem.Name = "useSourceResolutionToolStripMenuItem";
this.useSourceResolutionToolStripMenuItem.Size = new System.Drawing.Size(203, 22);
this.useSourceResolutionToolStripMenuItem.Text = "Use source resoluton";
this.useSourceResolutionToolStripMenuItem.Click += new System.EventHandler(this.useSourceResolutionToolStripMenuItem_Click);
//
// x2160ToolStripMenuItem
//
@ -1631,13 +1654,13 @@ namespace Nikse.SubtitleEdit.Forms
this.contextMenuStripGenerate.ResumeLayout(false);
this.groupBoxSettings.ResumeLayout(false);
this.groupBoxSettings.PerformLayout();
this.contextMenuStripBatch.ResumeLayout(false);
this.groupBoxCut.ResumeLayout(false);
this.groupBoxCut.PerformLayout();
this.groupBoxVideo.ResumeLayout(false);
this.groupBoxVideo.PerformLayout();
this.groupBoxAudio.ResumeLayout(false);
this.groupBoxAudio.PerformLayout();
this.contextMenuStripBatch.ResumeLayout(false);
this.contextMenuStripRes.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
@ -1748,5 +1771,7 @@ namespace Nikse.SubtitleEdit.Forms
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
private System.Windows.Forms.ToolStripMenuItem removeSubtitleFileToolStripMenuItem;
private System.Windows.Forms.ColumnHeader columnHeaderResolution;
private System.Windows.Forms.ToolStripMenuItem useSourceResolutionToolStripMenuItem;
private System.Windows.Forms.Button buttonOutputFileSettings;
}
}

View File

@ -42,8 +42,8 @@ namespace Nikse.SubtitleEdit.Forms
public bool BatchMode { get; set; }
public string BatchInfo { get; set; }
private readonly List<BatchVideoAndSub> _batchVideoAndSubList;
private const int ListViewBatchSubItemIndexColumnSubtitleFile = 2;
private const int ListViewBatchSubItemIndexColumnStatus = 3;
private const int ListViewBatchSubItemIndexColumnSubtitleFile = 3;
private const int ListViewBatchSubItemIndexColumnStatus = 4;
public class BatchVideoAndSub
{
@ -314,11 +314,13 @@ namespace Nikse.SubtitleEdit.Forms
buttonRemoveFile.Visible = BatchMode;
buttonClear.Visible = BatchMode;
buttonAddFile.Visible = BatchMode;
buttonOutputFileSettings.Visible = BatchMode;
var audioTracks = _mediaInfo.Tracks.Where(p => p.TrackType == FfmpegTrackType.Audio).ToList();
if (BatchMode)
{
listViewAudioTracks.Visible = false;
useSourceResolutionToolStripMenuItem_Click(null, null);
}
else if (audioTracks.Count > 1)
{
@ -437,9 +439,13 @@ namespace Nikse.SubtitleEdit.Forms
Stopwatch stopWatch;
if (BatchMode)
{
checkBoxTargetFileSize.Checked = false;
var useSourceResolution = numericUpDownWidth.Value == 0 && numericUpDownHeight.Value == 0;
listViewBatch.SelectedIndices.Clear();
stopWatch = Stopwatch.StartNew();
var sbInfo = new StringBuilder();
sbInfo.AppendLine($"Input for convert: {_batchVideoAndSubList.Count} video files:");
sbInfo.AppendLine("Conversion report:");
sbInfo.AppendLine();
var okCount = 0;
var failCount = 0;
@ -447,6 +453,12 @@ namespace Nikse.SubtitleEdit.Forms
{
var videoAndSub = _batchVideoAndSubList[index];
_videoInfo = UiUtil.GetVideoInfo(videoAndSub.VideoFileName);
if (useSourceResolution)
{
numericUpDownWidth.Value = _videoInfo.Width;
numericUpDownHeight.Value = _videoInfo.Height;
}
var subtitle = new Subtitle();
if (!string.IsNullOrEmpty(videoAndSub.SubtitleFileName) & File.Exists(videoAndSub.SubtitleFileName))
{
@ -454,14 +466,21 @@ namespace Nikse.SubtitleEdit.Forms
}
var path = Path.GetDirectoryName(videoAndSub.VideoFileName);
if (Configuration.Settings.Tools.GenVideoUseOutputFolder &&
!string.IsNullOrEmpty(Configuration.Settings.Tools.GenVideoOutputFolder) &&
Directory.Exists(Configuration.Settings.Tools.GenVideoOutputFolder))
{
path = Configuration.Settings.Tools.GenVideoOutputFolder;
}
var nameNoExt = Path.GetFileNameWithoutExtension(videoAndSub.VideoFileName);
var ext = Path.GetExtension(videoAndSub.VideoFileName);
VideoFileName = Path.Combine(path, $"{nameNoExt.TrimEnd('.', '.')}_new{ext}");
VideoFileName = Path.Combine(path, $"{nameNoExt.TrimEnd('.', '.')}{Configuration.Settings.Tools.GenVideoOutputFileSuffix}{ext}");
if (File.Exists(VideoFileName))
{
for (var i = 2; i < int.MaxValue; i++)
{
VideoFileName = Path.Combine(path, $"{nameNoExt.TrimEnd('.', '.')}_new_{i}{ext}");
VideoFileName = Path.Combine(path, $"{nameNoExt.TrimEnd('.', '.')}{Configuration.Settings.Tools.GenVideoOutputFileSuffix}_{i}{ext}");
if (!File.Exists(VideoFileName))
{
break;
@ -469,9 +488,9 @@ namespace Nikse.SubtitleEdit.Forms
}
}
if (File.Exists(VideoFileName))
{
}
listViewBatch.Items[index].Selected = true;
listViewBatch.Items[index].Focused = true;
listViewBatch.Items[index].EnsureVisible();
if (ConvertVideo(oldFontSizeEnabled, videoAndSub.VideoFileName, subtitle))
{
@ -488,10 +507,20 @@ namespace Nikse.SubtitleEdit.Forms
}
sbInfo.AppendLine();
sbInfo.AppendLine($"Video files converted in {stopWatch.Elapsed}: {okCount}");
var timeString = $"{stopWatch.Elapsed.Hours + stopWatch.Elapsed.Days * 24:00}:{stopWatch.Elapsed.Minutes:00}:{stopWatch.Elapsed.Seconds:00}";
if (okCount == 1)
{
sbInfo.AppendLine($"One video file converted in {timeString}");
}
else
{
sbInfo.AppendLine($"{okCount} video files converted in {timeString}");
}
if (failCount > 0)
{
sbInfo.AppendLine($"Video files failed: {failCount}");
sbInfo.AppendLine($"{failCount} video file(s) failed!");
}
BatchInfo = sbInfo.ToString();
@ -703,7 +732,10 @@ namespace Nikse.SubtitleEdit.Forms
fileName += ".burn-in";
fileName += $".{numericUpDownWidth.Value}x{numericUpDownHeight.Value}";
if (numericUpDownWidth.Value > 0 && numericUpDownHeight.Value > 0)
{
fileName += $".{numericUpDownWidth.Value}x{numericUpDownHeight.Value}";
}
if (comboBoxVideoEncoding.Text == "libx265" || comboBoxVideoEncoding.Text == "hevc_nvenc" || comboBoxVideoEncoding.Text == "hevc_amf")
{
@ -1503,20 +1535,7 @@ namespace Nikse.SubtitleEdit.Forms
private void MediaPlayer_OnButtonClicked(object sender, EventArgs e)
{
if (sender is PictureBox pb && pb.Name == "_pictureBoxFullscreenOver")
{
if (_previewVideo != null && !_previewVideo.IsDisposed)
{
_previewVideo.Close();
_previewVideo.Dispose();
_previewVideo = null;
}
else
{
_previewVideo = new PreviewVideo(_inputVideoFileName, _mpvSubtitleFileName, _assaSubtitle, true);
_previewVideo.Show(this);
}
}
}
private void checkBoxTargetFileSize_CheckedChanged(object sender, EventArgs e)
@ -1715,6 +1734,11 @@ namespace Nikse.SubtitleEdit.Forms
private void ResolutionPickClick(object sender, EventArgs e)
{
labelX.Left = numericUpDownWidth.Left + numericUpDownWidth.Width + 3;
numericUpDownWidth.Visible = true;
labelX.Text = "x";
numericUpDownHeight.Visible = true;
var text = (sender as ToolStripMenuItem).Text;
var match = new Regex("\\d+x\\d+").Match(text);
var parts = match.Value.Split('x');
@ -1974,11 +1998,27 @@ namespace Nikse.SubtitleEdit.Forms
buttonAddFile.Visible = BatchMode;
buttonRemoveFile.Visible = BatchMode;
buttonClear.Visible = BatchMode;
buttonOutputFileSettings.Visible = BatchMode;
buttonMode.Text = BatchMode
? LanguageSettings.Current.Split.Basic
: LanguageSettings.Current.AudioToText.BatchMode;
FontEnableOrDisable(BatchMode || _initialFontOn);
if (!numericUpDownWidth.Visible)
{
var item = new ToolStripMenuItem();
if (_videoInfo == null)
{
item.Text = "(1920x1080)";
}
else
{
item.Text = $"({_videoInfo.Width}x{_videoInfo.Height})";
}
ResolutionPickClick(item, null);
}
}
private void addFilesToolStripMenuItem_Click(object sender, EventArgs e)
@ -2220,5 +2260,30 @@ namespace Nikse.SubtitleEdit.Forms
_batchVideoAndSubList[i].SubtitleFileName = null;
}
}
private void buttonOutputFileSettings_Click(object sender, EventArgs e)
{
using (var form = new GenerateVideoWithHardSubsOutFile())
{
form.ShowDialog(this);
}
}
private void useSourceResolutionToolStripMenuItem_Click(object sender, EventArgs e)
{
numericUpDownWidth.Visible = false;
numericUpDownHeight.Visible = false;
labelX.Left = numericUpDownWidth.Left;
labelX.Text = "Use source";
numericUpDownWidth.Value = 0;
numericUpDownHeight.Value = 0;
}
private void contextMenuStripRes_Opening(object sender, System.ComponentModel.CancelEventArgs e)
{
useSourceResolutionToolStripMenuItem.Visible = BatchMode;
}
}
}

View File

@ -0,0 +1,183 @@
namespace Nikse.SubtitleEdit.Forms
{
partial class GenerateVideoWithHardSubsOutFile
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.radioButtonSaveInOutputFolder = new System.Windows.Forms.RadioButton();
this.linkLabelOpenOutputFolder = new System.Windows.Forms.LinkLabel();
this.buttonChooseFolder = new System.Windows.Forms.Button();
this.textBoxOutputFolder = new Nikse.SubtitleEdit.Controls.NikseTextBox();
this.radioButtonSaveInSourceFolder = new System.Windows.Forms.RadioButton();
this.labelSuffix = new System.Windows.Forms.Label();
this.textBoxSuffix = new Nikse.SubtitleEdit.Controls.NikseTextBox();
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonOK = new System.Windows.Forms.Button();
this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
this.SuspendLayout();
//
// radioButtonSaveInOutputFolder
//
this.radioButtonSaveInOutputFolder.AutoSize = true;
this.radioButtonSaveInOutputFolder.Location = new System.Drawing.Point(21, 54);
this.radioButtonSaveInOutputFolder.Name = "radioButtonSaveInOutputFolder";
this.radioButtonSaveInOutputFolder.Size = new System.Drawing.Size(154, 17);
this.radioButtonSaveInOutputFolder.TabIndex = 6;
this.radioButtonSaveInOutputFolder.Text = "Save in output folder below";
this.radioButtonSaveInOutputFolder.UseVisualStyleBackColor = true;
this.radioButtonSaveInOutputFolder.CheckedChanged += new System.EventHandler(this.radioButtonSaveInOutputFolder_CheckedChanged);
//
// linkLabelOpenOutputFolder
//
this.linkLabelOpenOutputFolder.AutoSize = true;
this.linkLabelOpenOutputFolder.Location = new System.Drawing.Point(368, 83);
this.linkLabelOpenOutputFolder.Name = "linkLabelOpenOutputFolder";
this.linkLabelOpenOutputFolder.Size = new System.Drawing.Size(42, 13);
this.linkLabelOpenOutputFolder.TabIndex = 9;
this.linkLabelOpenOutputFolder.TabStop = true;
this.linkLabelOpenOutputFolder.Text = "Open...";
this.linkLabelOpenOutputFolder.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabelOpenOutputFolder_LinkClicked);
//
// buttonChooseFolder
//
this.buttonChooseFolder.Enabled = false;
this.buttonChooseFolder.Location = new System.Drawing.Point(336, 78);
this.buttonChooseFolder.Name = "buttonChooseFolder";
this.buttonChooseFolder.Size = new System.Drawing.Size(26, 23);
this.buttonChooseFolder.TabIndex = 8;
this.buttonChooseFolder.Text = "...";
this.buttonChooseFolder.UseVisualStyleBackColor = true;
this.buttonChooseFolder.Click += new System.EventHandler(this.buttonChooseFolder_Click);
//
// textBoxOutputFolder
//
this.textBoxOutputFolder.Enabled = false;
this.textBoxOutputFolder.FocusedColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215)))));
this.textBoxOutputFolder.Location = new System.Drawing.Point(28, 81);
this.textBoxOutputFolder.Name = "textBoxOutputFolder";
this.textBoxOutputFolder.Size = new System.Drawing.Size(302, 20);
this.textBoxOutputFolder.TabIndex = 7;
//
// radioButtonSaveInSourceFolder
//
this.radioButtonSaveInSourceFolder.AutoSize = true;
this.radioButtonSaveInSourceFolder.Checked = true;
this.radioButtonSaveInSourceFolder.Location = new System.Drawing.Point(21, 23);
this.radioButtonSaveInSourceFolder.Name = "radioButtonSaveInSourceFolder";
this.radioButtonSaveInSourceFolder.Size = new System.Drawing.Size(141, 17);
this.radioButtonSaveInSourceFolder.TabIndex = 5;
this.radioButtonSaveInSourceFolder.TabStop = true;
this.radioButtonSaveInSourceFolder.Text = "Save in source file folder";
this.radioButtonSaveInSourceFolder.UseVisualStyleBackColor = true;
this.radioButtonSaveInSourceFolder.CheckedChanged += new System.EventHandler(this.radioButtonSaveInSourceFolder_CheckedChanged);
//
// labelSuffix
//
this.labelSuffix.AutoSize = true;
this.labelSuffix.Location = new System.Drawing.Point(21, 135);
this.labelSuffix.Name = "labelSuffix";
this.labelSuffix.Size = new System.Drawing.Size(79, 13);
this.labelSuffix.TabIndex = 11;
this.labelSuffix.Text = "File name suffix";
//
// textBoxSuffix
//
this.textBoxSuffix.FocusedColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215)))));
this.textBoxSuffix.Location = new System.Drawing.Point(21, 151);
this.textBoxSuffix.Name = "textBoxSuffix";
this.textBoxSuffix.Size = new System.Drawing.Size(309, 20);
this.textBoxSuffix.TabIndex = 12;
//
// buttonCancel
//
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonCancel.Location = new System.Drawing.Point(349, 214);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.buttonCancel.TabIndex = 105;
this.buttonCancel.Text = "C&ancel";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// buttonOK
//
this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK;
this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonOK.Location = new System.Drawing.Point(268, 214);
this.buttonOK.Name = "buttonOK";
this.buttonOK.Size = new System.Drawing.Size(75, 23);
this.buttonOK.TabIndex = 104;
this.buttonOK.Text = "&OK";
this.buttonOK.UseVisualStyleBackColor = true;
this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click);
//
// GenerateVideoWithHardSubsOutFile
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(436, 249);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonOK);
this.Controls.Add(this.labelSuffix);
this.Controls.Add(this.textBoxSuffix);
this.Controls.Add(this.radioButtonSaveInOutputFolder);
this.Controls.Add(this.linkLabelOpenOutputFolder);
this.Controls.Add(this.buttonChooseFolder);
this.Controls.Add(this.textBoxOutputFolder);
this.Controls.Add(this.radioButtonSaveInSourceFolder);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.KeyPreview = true;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "GenerateVideoWithHardSubsOutFile";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "GenerateVideoWithHardSubsOutFile";
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.GenerateVideoWithHardSubsOutFile_KeyDown);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.RadioButton radioButtonSaveInOutputFolder;
private System.Windows.Forms.LinkLabel linkLabelOpenOutputFolder;
private System.Windows.Forms.Button buttonChooseFolder;
private Controls.NikseTextBox textBoxOutputFolder;
private System.Windows.Forms.RadioButton radioButtonSaveInSourceFolder;
private System.Windows.Forms.Label labelSuffix;
private Controls.NikseTextBox textBoxSuffix;
private System.Windows.Forms.Button buttonCancel;
private System.Windows.Forms.Button buttonOK;
private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1;
}
}

View File

@ -0,0 +1,130 @@
using Nikse.SubtitleEdit.Logic;
using System;
using System.IO;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Core.Common;
namespace Nikse.SubtitleEdit.Forms
{
public partial class GenerateVideoWithHardSubsOutFile : Form
{
public GenerateVideoWithHardSubsOutFile()
{
UiUtil.PreInitialize(this);
InitializeComponent();
UiUtil.FixFonts(this);
labelSuffix.Text = LanguageSettings.Current.Settings.Suffix;
buttonOK.Text = LanguageSettings.Current.General.Ok;
buttonCancel.Text = LanguageSettings.Current.General.Cancel;
if (string.IsNullOrEmpty(Configuration.Settings.Tools.GenVideoOutputFolder) || !Directory.Exists(Configuration.Settings.Tools.GenVideoOutputFolder))
{
textBoxOutputFolder.Text = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Output");
}
else
{
textBoxOutputFolder.Text = Configuration.Settings.Tools.GenVideoOutputFolder;
}
textBoxSuffix.Text = Configuration.Settings.Tools.GenVideoOutputFileSuffix;
if (Configuration.Settings.Tools.GenVideoUseOutputFolder)
{
radioButtonSaveInOutputFolder.Checked = true;
}
else
{
radioButtonSaveInSourceFolder.Checked = true;
}
radioButtonSaveInSourceFolder_CheckedChanged(null, null);
}
private void GenerateVideoWithHardSubsOutFile_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Escape)
{
DialogResult = DialogResult.Cancel;
}
}
private void buttonOK_Click(object sender, EventArgs e)
{
if (radioButtonSaveInOutputFolder.Checked && string.IsNullOrWhiteSpace(textBoxOutputFolder.Text))
{
MessageBox.Show("Please choose output folder");
return;
}
try
{
if (!Directory.Exists(textBoxOutputFolder.Text))
{
Directory.CreateDirectory(textBoxOutputFolder.Text);
}
}
catch (Exception exception)
{
MessageBox.Show("Please choose output folder" + Environment.NewLine + exception.Message);
return;
}
Configuration.Settings.Tools.GenVideoOutputFolder = textBoxOutputFolder.Text;
Configuration.Settings.Tools.GenVideoOutputFileSuffix = textBoxSuffix.Text;
Configuration.Settings.Tools.GenVideoUseOutputFolder = radioButtonSaveInOutputFolder.Checked;
DialogResult = DialogResult.OK;
}
private void buttonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
}
private void buttonChooseFolder_Click(object sender, EventArgs e)
{
folderBrowserDialog1.ShowNewFolderButton = true;
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
{
textBoxOutputFolder.Text = folderBrowserDialog1.SelectedPath;
}
}
private void linkLabelOpenOutputFolder_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
if (!Directory.Exists(textBoxOutputFolder.Text))
{
try
{
Directory.CreateDirectory(textBoxOutputFolder.Text);
}
catch
{
// ignore
}
}
if (Directory.Exists(textBoxOutputFolder.Text))
{
UiUtil.OpenFolder(textBoxOutputFolder.Text);
}
else
{
MessageBox.Show(string.Format(LanguageSettings.Current.SplitSubtitle.FolderNotFoundX, textBoxOutputFolder.Text));
}
}
private void radioButtonSaveInSourceFolder_CheckedChanged(object sender, EventArgs e)
{
textBoxOutputFolder.Enabled = !radioButtonSaveInSourceFolder.Checked;
buttonChooseFolder.Enabled = !radioButtonSaveInSourceFolder.Checked;
}
private void radioButtonSaveInOutputFolder_CheckedChanged(object sender, EventArgs e)
{
textBoxOutputFolder.Enabled = !radioButtonSaveInSourceFolder.Checked;
buttonChooseFolder.Enabled = !radioButtonSaveInSourceFolder.Checked;
}
}
}

View File

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="folderBrowserDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -36804,9 +36804,13 @@ namespace Nikse.SubtitleEdit.Forms
{
using (var form = new TextToSpeech(_subtitle, GetCurrentSubtitleFormat(), _videoFileName, _videoInfo))
{
if (form.ShowDialog(this) != DialogResult.OK)
if (form.ShowDialog(this) == DialogResult.OK)
{
return;
var idx = FirstSelectedIndex;
_subtitle = form.EditedSubtitle;
SubtitleListview1.Fill(_subtitle, _subtitleOriginal);
_subtitleListViewIndex = -1;
SubtitleListview1.SelectIndexAndEnsureVisibleFaster(idx);
}
}
}

View File

@ -0,0 +1,150 @@
namespace Nikse.SubtitleEdit.Forms.Tts
{
partial class RegenerateAudioClip
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.buttonCancel = new System.Windows.Forms.Button();
this.TextBoxReGenerate = new Nikse.SubtitleEdit.Controls.NikseTextBox();
this.buttonReGenerate = new System.Windows.Forms.Button();
this.labelVoice = new System.Windows.Forms.Label();
this.nikseComboBoxVoice = new Nikse.SubtitleEdit.Controls.NikseComboBox();
this.labelText = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// buttonCancel
//
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonCancel.Location = new System.Drawing.Point(730, 208);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(84, 23);
this.buttonCancel.TabIndex = 7;
this.buttonCancel.Text = "C&ancel";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// TextBoxReGenerate
//
this.TextBoxReGenerate.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.TextBoxReGenerate.FocusedColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215)))));
this.TextBoxReGenerate.Location = new System.Drawing.Point(12, 40);
this.TextBoxReGenerate.Multiline = true;
this.TextBoxReGenerate.Name = "TextBoxReGenerate";
this.TextBoxReGenerate.Size = new System.Drawing.Size(802, 162);
this.TextBoxReGenerate.TabIndex = 22;
//
// buttonReGenerate
//
this.buttonReGenerate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonReGenerate.Location = new System.Drawing.Point(550, 208);
this.buttonReGenerate.Name = "buttonReGenerate";
this.buttonReGenerate.Size = new System.Drawing.Size(174, 23);
this.buttonReGenerate.TabIndex = 21;
this.buttonReGenerate.Text = "Regenerate ";
this.buttonReGenerate.UseVisualStyleBackColor = true;
this.buttonReGenerate.Click += new System.EventHandler(this.buttonReGenerate_Click);
//
// labelVoice
//
this.labelVoice.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.labelVoice.AutoSize = true;
this.labelVoice.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.labelVoice.Location = new System.Drawing.Point(153, 213);
this.labelVoice.Name = "labelVoice";
this.labelVoice.Size = new System.Drawing.Size(34, 13);
this.labelVoice.TabIndex = 24;
this.labelVoice.Text = "Voice";
//
// nikseComboBoxVoice
//
this.nikseComboBoxVoice.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | 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(193, 208);
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 = 23;
this.nikseComboBoxVoice.UsePopupWindow = false;
//
// labelText
//
this.labelText.AutoSize = true;
this.labelText.Location = new System.Drawing.Point(13, 21);
this.labelText.Name = "labelText";
this.labelText.Size = new System.Drawing.Size(28, 13);
this.labelText.TabIndex = 25;
this.labelText.Text = "Text";
//
// RegenerateAudioClip
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(826, 243);
this.Controls.Add(this.labelText);
this.Controls.Add(this.labelVoice);
this.Controls.Add(this.nikseComboBoxVoice);
this.Controls.Add(this.TextBoxReGenerate);
this.Controls.Add(this.buttonReGenerate);
this.Controls.Add(this.buttonCancel);
this.KeyPreview = true;
this.MinimumSize = new System.Drawing.Size(600, 250);
this.Name = "RegenerateAudioClip";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Regenerate audio clip";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button buttonCancel;
private Controls.NikseTextBox TextBoxReGenerate;
private System.Windows.Forms.Button buttonReGenerate;
private System.Windows.Forms.Label labelVoice;
private Controls.NikseComboBox nikseComboBoxVoice;
private System.Windows.Forms.Label labelText;
}
}

View File

@ -0,0 +1,62 @@
using Nikse.SubtitleEdit.Core.Common;
using Nikse.SubtitleEdit.Logic;
using System;
using System.Windows.Forms;
namespace Nikse.SubtitleEdit.Forms.Tts
{
public partial class RegenerateAudioClip : Form
{
public TextToSpeech.FileNameAndSpeedFactor FileNameAndSpeedFactor { get; set; }
private readonly TextToSpeech _textToSpeech;
private readonly Subtitle _subtitle;
private readonly int _index;
public RegenerateAudioClip(TextToSpeech textToSpeech, Subtitle subtitle, int idx)
{
UiUtil.PreInitialize(this);
InitializeComponent();
UiUtil.FixFonts(this);
_subtitle = subtitle;
_textToSpeech = textToSpeech;
_index = idx;
buttonCancel.Text = LanguageSettings.Current.General.Cancel;
UiUtil.FixLargeFonts(this, buttonCancel);
TextBoxReGenerate.Text = subtitle.Paragraphs[idx].Text;
textToSpeech.SetCurrentVoices(nikseComboBoxVoice);
}
private async void buttonReGenerate_Click(object sender, EventArgs e)
{
var paragraph = _subtitle.Paragraphs[_index];
paragraph.Text = TextBoxReGenerate.Text.Trim();
try
{
Cursor = Cursors.WaitCursor;
buttonReGenerate.Enabled = false;
var fileNameAndSpeedFactor = await _textToSpeech.ReGenerateAudio(paragraph, nikseComboBoxVoice.Text);
if (fileNameAndSpeedFactor != null)
{
FileNameAndSpeedFactor = fileNameAndSpeedFactor;
Cursor = Cursors.Default;
DialogResult = DialogResult.OK;
}
}
finally
{
Cursor = Cursors.Default;
buttonReGenerate.Enabled = true;
}
}
private void buttonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,216 @@
namespace Nikse.SubtitleEdit.Forms.Tts
{
sealed partial class ReviewAudioClips
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.listView1 = new System.Windows.Forms.ListView();
this.columnHeaderInclude = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeaderNo = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeaderVoice = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeaderCps = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeaderText = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.buttonOK = new System.Windows.Forms.Button();
this.labelInfo = new System.Windows.Forms.Label();
this.buttonPlay = new System.Windows.Forms.Button();
this.labelParagraphInfo = new System.Windows.Forms.Label();
this.checkBoxContinuePlay = new System.Windows.Forms.CheckBox();
this.buttonStop = new System.Windows.Forms.Button();
this.buttonEdit = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// listView1
//
this.listView1.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.listView1.CheckBoxes = true;
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeaderInclude,
this.columnHeaderNo,
this.columnHeaderVoice,
this.columnHeaderCps,
this.columnHeaderText});
this.listView1.FullRowSelect = true;
this.listView1.HideSelection = false;
this.listView1.Location = new System.Drawing.Point(12, 52);
this.listView1.MultiSelect = false;
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(684, 319);
this.listView1.TabIndex = 0;
this.listView1.UseCompatibleStateImageBehavior = false;
this.listView1.View = System.Windows.Forms.View.Details;
this.listView1.SelectedIndexChanged += new System.EventHandler(this.listView1_SelectedIndexChanged);
this.listView1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.listView1_KeyDown);
//
// columnHeaderInclude
//
this.columnHeaderInclude.Text = "Include";
//
// columnHeaderNo
//
this.columnHeaderNo.Text = "#";
this.columnHeaderNo.Width = 50;
//
// columnHeaderVoice
//
this.columnHeaderVoice.Text = "Voice";
this.columnHeaderVoice.Width = 120;
//
// columnHeaderCps
//
this.columnHeaderCps.Text = "CPS";
//
// columnHeaderText
//
this.columnHeaderText.Text = "Text";
this.columnHeaderText.Width = 460;
//
// buttonOK
//
this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonOK.Location = new System.Drawing.Point(795, 413);
this.buttonOK.Name = "buttonOK";
this.buttonOK.Size = new System.Drawing.Size(87, 23);
this.buttonOK.TabIndex = 5;
this.buttonOK.Text = "&OK";
this.buttonOK.UseVisualStyleBackColor = true;
this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click);
//
// labelInfo
//
this.labelInfo.AutoSize = true;
this.labelInfo.Location = new System.Drawing.Point(12, 33);
this.labelInfo.Name = "labelInfo";
this.labelInfo.Size = new System.Drawing.Size(219, 13);
this.labelInfo.TabIndex = 8;
this.labelInfo.Text = "Review and un-include unwanted audio clips";
//
// buttonPlay
//
this.buttonPlay.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonPlay.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonPlay.Location = new System.Drawing.Point(702, 295);
this.buttonPlay.Name = "buttonPlay";
this.buttonPlay.Size = new System.Drawing.Size(180, 23);
this.buttonPlay.TabIndex = 9;
this.buttonPlay.Text = "Play";
this.buttonPlay.UseVisualStyleBackColor = true;
this.buttonPlay.Click += new System.EventHandler(this.buttonPlay_Click);
//
// labelParagraphInfo
//
this.labelParagraphInfo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.labelParagraphInfo.AutoSize = true;
this.labelParagraphInfo.Location = new System.Drawing.Point(12, 383);
this.labelParagraphInfo.Name = "labelParagraphInfo";
this.labelParagraphInfo.Size = new System.Drawing.Size(76, 13);
this.labelParagraphInfo.TabIndex = 10;
this.labelParagraphInfo.Text = "Paragraph info";
//
// checkBoxContinuePlay
//
this.checkBoxContinuePlay.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.checkBoxContinuePlay.AutoSize = true;
this.checkBoxContinuePlay.Location = new System.Drawing.Point(717, 354);
this.checkBoxContinuePlay.Name = "checkBoxContinuePlay";
this.checkBoxContinuePlay.Size = new System.Drawing.Size(92, 17);
this.checkBoxContinuePlay.TabIndex = 11;
this.checkBoxContinuePlay.Text = "Auto continue";
this.checkBoxContinuePlay.UseVisualStyleBackColor = true;
//
// buttonStop
//
this.buttonStop.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonStop.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonStop.Location = new System.Drawing.Point(703, 324);
this.buttonStop.Name = "buttonStop";
this.buttonStop.Size = new System.Drawing.Size(179, 23);
this.buttonStop.TabIndex = 12;
this.buttonStop.Text = "Stop ";
this.buttonStop.UseVisualStyleBackColor = true;
this.buttonStop.Click += new System.EventHandler(this.buttonStop_Click);
//
// buttonEdit
//
this.buttonEdit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonEdit.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonEdit.Location = new System.Drawing.Point(703, 249);
this.buttonEdit.Name = "buttonEdit";
this.buttonEdit.Size = new System.Drawing.Size(180, 23);
this.buttonEdit.TabIndex = 13;
this.buttonEdit.Text = "Edit";
this.buttonEdit.UseVisualStyleBackColor = true;
this.buttonEdit.Click += new System.EventHandler(this.buttonEdit_Click);
//
// ReviewAudioClips
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(894, 448);
this.Controls.Add(this.buttonEdit);
this.Controls.Add(this.buttonStop);
this.Controls.Add(this.checkBoxContinuePlay);
this.Controls.Add(this.labelParagraphInfo);
this.Controls.Add(this.buttonPlay);
this.Controls.Add(this.labelInfo);
this.Controls.Add(this.buttonOK);
this.Controls.Add(this.listView1);
this.KeyPreview = true;
this.MinimumSize = new System.Drawing.Size(800, 450);
this.Name = "ReviewAudioClips";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Review audio clips";
this.Load += new System.EventHandler(this.VoicePreviewList_Load);
this.Shown += new System.EventHandler(this.VoicePreviewList_Shown);
this.ResizeEnd += new System.EventHandler(this.VoicePreviewList_ResizeEnd);
this.Resize += new System.EventHandler(this.VoicePreviewList_Resize);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.ListView listView1;
private System.Windows.Forms.Button buttonOK;
private System.Windows.Forms.Label labelInfo;
private System.Windows.Forms.ColumnHeader columnHeaderInclude;
private System.Windows.Forms.ColumnHeader columnHeaderNo;
private System.Windows.Forms.ColumnHeader columnHeaderVoice;
private System.Windows.Forms.ColumnHeader columnHeaderCps;
private System.Windows.Forms.ColumnHeader columnHeaderText;
private System.Windows.Forms.Button buttonPlay;
private System.Windows.Forms.Label labelParagraphInfo;
private System.Windows.Forms.CheckBox checkBoxContinuePlay;
private System.Windows.Forms.Button buttonStop;
private System.Windows.Forms.Button buttonEdit;
}
}

View File

@ -0,0 +1,216 @@
using Nikse.SubtitleEdit.Core.Common;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.VideoPlayers;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Windows.Forms;
namespace Nikse.SubtitleEdit.Forms.Tts
{
public sealed partial class ReviewAudioClips : Form
{
public List<int> SkipIndices { get; set; }
private readonly Subtitle _subtitle;
private readonly TextToSpeech _textToSpeech;
private readonly List<TextToSpeech.FileNameAndSpeedFactor> _fileNames;
private bool _abortPlay;
private LibMpvDynamic _libMpv;
private Timer _mpvDoneTimer;
public ReviewAudioClips(TextToSpeech textToSpeech, Subtitle subtitle, List<TextToSpeech.FileNameAndSpeedFactor> fileNames)
{
UiUtil.PreInitialize(this);
InitializeComponent();
UiUtil.FixFonts(this);
buttonOK.Text = LanguageSettings.Current.General.Ok;
UiUtil.FixLargeFonts(this, buttonOK);
_textToSpeech = textToSpeech;
_subtitle = subtitle;
_fileNames = fileNames;
SkipIndices = new List<int>();
listView1.BeginUpdate();
foreach (var p in subtitle.Paragraphs)
{
var item = new ListViewItem { Tag = p, Checked = true };
item.SubItems.Add(p.Number.ToString(CultureInfo.InvariantCulture));
item.SubItems.Add(_textToSpeech.GetParagraphAudio(p));
item.SubItems.Add(Utilities.GetCharactersPerSecond(p).ToString("0.#", CultureInfo.InvariantCulture));
item.SubItems.Add(p.Text);
listView1.Items.Add(item);
}
listView1.EndUpdate();
if (listView1.Items.Count > 0)
{
listView1.Items[0].Selected = true;
}
labelParagraphInfo.Text = string.Empty;
}
private void buttonOK_Click(object sender, EventArgs e)
{
_libMpv?.Stop();
for (var index = 0; index < listView1.Items.Count; index++)
{
if (!listView1.Items[index].Checked)
{
SkipIndices.Add(index);
}
}
DialogResult = DialogResult.OK;
}
private void VoicePreviewList_Load(object sender, EventArgs e)
{
listView1.AutoSizeLastColumn();
}
private void VoicePreviewList_ResizeEnd(object sender, EventArgs e)
{
listView1.AutoSizeLastColumn();
}
private void VoicePreviewList_Resize(object sender, EventArgs e)
{
listView1.AutoSizeLastColumn();
}
private void Play(bool noAutoContinue = false)
{
if (listView1.SelectedItems.Count == 0)
{
return;
}
var idx = listView1.SelectedItems[0].Index;
var waveFileName = _fileNames[idx].Filename;
if (_libMpv != null)
{
_libMpv.Initialize(
null,
waveFileName,
(sender, args) =>
{
_libMpv.Play();
},
null);
if (checkBoxContinuePlay.Checked && !noAutoContinue)
{
_mpvDoneTimer.Start();
}
}
else
{
using (var soundPlayer = new System.Media.SoundPlayer(waveFileName))
{
soundPlayer.PlaySync();
}
if (!noAutoContinue)
{
PlayNext(idx);
}
}
}
private void PlayNext(int idx)
{
if (checkBoxContinuePlay.Checked && !_abortPlay && idx < listView1.Items.Count - 1)
{
listView1.Items[idx].Selected = false;
listView1.Items[idx + 1].Selected = true;
listView1.Items[idx + 1].Focused = true;
listView1.Items[idx + 1].EnsureVisible();
TaskDelayHelper.RunDelayed(TimeSpan.FromMilliseconds(10), () => Play());
Application.DoEvents();
}
}
private void listView1_SelectedIndexChanged(object sender, EventArgs e)
{
if (listView1.SelectedItems.Count == 0)
{
labelParagraphInfo.Text = string.Empty;
return;
}
var idx = listView1.SelectedItems[0].Index;
var p = _subtitle.Paragraphs[idx];
labelParagraphInfo.Text = p.StartTime.ToDisplayString() + " --> " + p.EndTime.ToDisplayString() + " : " + p.Duration.ToShortDisplayString();
}
private void buttonPlay_Click(object sender, EventArgs e)
{
_abortPlay = false;
Play();
}
private void buttonStop_Click(object sender, EventArgs e)
{
_libMpv?.Stop();
_abortPlay = true;
}
private void VoicePreviewList_Shown(object sender, EventArgs e)
{
if (LibMpvDynamic.IsInstalled)
{
_libMpv = new LibMpvDynamic();
_mpvDoneTimer = new Timer();
_mpvDoneTimer.Interval = 100;
_mpvDoneTimer.Tick += (o, args) =>
{
if (listView1.SelectedItems.Count == 0)
{
return;
}
var idx = listView1.SelectedItems[0].Index;
if (_libMpv.IsPaused && _libMpv.CurrentPosition > _libMpv.Duration - 1)
{
_mpvDoneTimer.Stop();
PlayNext(idx);
}
};
}
}
private void listView1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Space || e.KeyCode == Keys.P || e.KeyCode == Keys.Play)
{
e.SuppressKeyPress = true;
TaskDelayHelper.RunDelayed(TimeSpan.FromMilliseconds(1), () => Play());
}
}
private void buttonEdit_Click(object sender, EventArgs e)
{
if (listView1.SelectedItems.Count == 0)
{
return;
}
var idx = listView1.SelectedItems[0].Index;
using (var form = new RegenerateAudioClip(_textToSpeech, _subtitle, idx))
{
var dr = form.ShowDialog(this);
if (dr == DialogResult.OK)
{
_fileNames[idx].Filename = form.FileNameAndSpeedFactor.Filename;
_fileNames[idx].Factor = form.FileNameAndSpeedFactor.Factor;
listView1.Items[idx].SubItems[4].Text = _subtitle.Paragraphs[idx].Text;
Play(true);
}
}
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -35,19 +35,21 @@
this.progressBar1 = new System.Windows.Forms.ProgressBar();
this.labelEngine = new System.Windows.Forms.Label();
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.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.buttonCancel = new System.Windows.Forms.Button();
this.groupBoxMsSettings.SuspendLayout();
this.SuspendLayout();
//
@ -55,7 +57,7 @@
//
this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonOK.Location = new System.Drawing.Point(767, 456);
this.buttonOK.Location = new System.Drawing.Point(686, 456);
this.buttonOK.Name = "buttonOK";
this.buttonOK.Size = new System.Drawing.Size(75, 23);
this.buttonOK.TabIndex = 100;
@ -92,7 +94,7 @@
| System.Windows.Forms.AnchorStyles.Right)));
this.progressBar1.Location = new System.Drawing.Point(12, 456);
this.progressBar1.Name = "progressBar1";
this.progressBar1.Size = new System.Drawing.Size(749, 10);
this.progressBar1.Size = new System.Drawing.Size(665, 10);
this.progressBar1.TabIndex = 12;
//
// labelEngine
@ -109,6 +111,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.checkBoxShowPreview);
this.groupBoxMsSettings.Controls.Add(this.labelApiKey);
this.groupBoxMsSettings.Controls.Add(this.nikseTextBoxApiKey);
this.groupBoxMsSettings.Controls.Add(this.TextBoxTest);
@ -125,6 +128,19 @@
this.groupBoxMsSettings.TabStop = false;
this.groupBoxMsSettings.Text = "Settings";
//
// checkBoxShowPreview
//
this.checkBoxShowPreview.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.checkBoxShowPreview.AutoSize = true;
this.checkBoxShowPreview.Checked = true;
this.checkBoxShowPreview.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBoxShowPreview.Location = new System.Drawing.Point(17, 350);
this.checkBoxShowPreview.Name = "checkBoxShowPreview";
this.checkBoxShowPreview.Size = new System.Drawing.Size(115, 17);
this.checkBoxShowPreview.TabIndex = 25;
this.checkBoxShowPreview.Text = "Review audio clips";
this.checkBoxShowPreview.UseVisualStyleBackColor = true;
//
// labelApiKey
//
this.labelApiKey.AutoSize = true;
@ -135,28 +151,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);
@ -190,6 +184,72 @@
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";
//
// 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)
@ -243,55 +303,25 @@
this.nikseComboBoxEngine.UsePopupWindow = false;
this.nikseComboBoxEngine.SelectedIndexChanged += new System.EventHandler(this.nikseComboBoxEngine_SelectedIndexChanged);
//
// listViewActors
// buttonCancel
//
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";
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonCancel.Location = new System.Drawing.Point(767, 456);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.buttonCancel.TabIndex = 101;
this.buttonCancel.Text = "C&ancel";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// TextToSpeech
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(854, 491);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.labelActors);
this.Controls.Add(this.listViewActors);
this.Controls.Add(this.groupBoxMsSettings);
@ -338,5 +368,7 @@
private System.Windows.Forms.Label labelActors;
private System.Windows.Forms.Label labelApiKey;
private Controls.NikseTextBox nikseTextBoxApiKey;
private System.Windows.Forms.CheckBox checkBoxShowPreview;
private System.Windows.Forms.Button buttonCancel;
}
}

View File

@ -14,12 +14,15 @@ 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
{
public sealed partial class TextToSpeech : Form
{
public Subtitle EditedSubtitle { get; set; }
private readonly Subtitle _subtitle;
private readonly string _videoFileName;
private readonly VideoInfo _videoInfo;
@ -29,7 +32,8 @@ namespace Nikse.SubtitleEdit.Forms.Tts
private bool _abort;
private readonly List<string> _actors;
private readonly List<TextToSpeechEngine> _engines;
private readonly List<ElevenLabModel> _elevelLabVoices;
private readonly List<ElevenLabModel> _elevenLabVoices;
private bool _actorsOn;
public class ActorAndVoice
{
@ -39,6 +43,12 @@ namespace Nikse.SubtitleEdit.Forms.Tts
public int VoiceIndex { get; set; }
}
public class FileNameAndSpeedFactor
{
public string Filename { get; set; }
public decimal Factor { get; set; }
}
public class TextToSpeechEngine
{
public TextToSpeechEngineId Id { get; set; }
@ -68,11 +78,11 @@ namespace Nikse.SubtitleEdit.Forms.Tts
InitializeComponent();
UiUtil.FixFonts(this);
_subtitle = subtitle;
_subtitle = new Subtitle(subtitle, false);
_subtitleFormat = subtitleFormat;
_videoFileName = videoFileName;
_videoInfo = videoInfo;
_elevelLabVoices = new List<ElevenLabModel>();
_elevenLabVoices = new List<ElevenLabModel>();
_actors = _subtitle.Paragraphs
.Where(p => !string.IsNullOrEmpty(p.Actor))
.Select(p => p.Actor)
@ -87,6 +97,7 @@ namespace Nikse.SubtitleEdit.Forms.Tts
checkBoxAddToVideoFile.Text = LanguageSettings.Current.TextToSpeech.AddAudioToVideo;
buttonGenerateTTS.Text = LanguageSettings.Current.TextToSpeech.GenerateSpeech;
buttonOK.Text = LanguageSettings.Current.General.Ok;
buttonCancel.Text = LanguageSettings.Current.General.Cancel;
UiUtil.FixLargeFonts(this, buttonOK);
progressBar1.Visible = false;
@ -135,6 +146,8 @@ namespace Nikse.SubtitleEdit.Forms.Tts
MinimumSize = new Size(w, MinimumSize.Height);
Width = w;
}
nikseComboBoxVoice.Text = Configuration.Settings.Tools.TextToSpeechLastVoice;
}
private void SetActor(ActorAndVoice actor)
@ -189,14 +202,33 @@ namespace Nikse.SubtitleEdit.Forms.Tts
return;
}
var fileNames = FixParagraphAudioSpeed();
var fileNameAndSpeedFactors = FixParagraphAudioSpeed(_subtitle, null);
if (_abort)
{
HandleAbort();
return;
}
var tempAudioFile = MergeAudioParagraphs(fileNames);
if (checkBoxShowPreview.Checked)
{
using (var form = new ReviewAudioClips(this, _subtitle, fileNameAndSpeedFactors))
{
var dr = form.ShowDialog(this);
if (dr != DialogResult.OK)
{
_abort = true;
HandleAbort();
return;
}
foreach (var idx in form.SkipIndices)
{
fileNameAndSpeedFactors[idx] = null; // skip these files
}
}
}
var tempAudioFile = MergeAudioParagraphs(fileNameAndSpeedFactors);
if (_abort)
{
HandleAbort();
@ -307,37 +339,47 @@ namespace Nikse.SubtitleEdit.Forms.Tts
}
}
private List<string> FixParagraphAudioSpeed()
private List<FileNameAndSpeedFactor> FixParagraphAudioSpeed(Subtitle subtitle, string overrideFileName)
{
var fileNames = new List<string>(_subtitle.Paragraphs.Count);
var fileNames = new List<FileNameAndSpeedFactor>(subtitle.Paragraphs.Count);
labelProgress.Text = string.Empty;
labelProgress.Refresh();
Application.DoEvents();
progressBar1.Value = 0;
progressBar1.Maximum = _subtitle.Paragraphs.Count;
progressBar1.Maximum = subtitle.Paragraphs.Count;
progressBar1.Visible = true;
for (var index = 0; index < _subtitle.Paragraphs.Count; index++)
for (var index = 0; index < subtitle.Paragraphs.Count; index++)
{
progressBar1.Value = index + 1;
labelProgress.Text = string.Format(LanguageSettings.Current.TextToSpeech.AdjustingSpeedXOfY, index + 1, _subtitle.Paragraphs.Count);
var p = _subtitle.Paragraphs[index];
var next = _subtitle.GetParagraphOrDefault(index + 1);
labelProgress.Text = string.Format(LanguageSettings.Current.TextToSpeech.AdjustingSpeedXOfY, index + 1, subtitle.Paragraphs.Count);
var p = subtitle.Paragraphs[index];
var next = subtitle.GetParagraphOrDefault(index + 1);
var pFileName = Path.Combine(_waveFolder, index + ".wav");
if (!string.IsNullOrEmpty(overrideFileName) && File.Exists(Path.Combine(_waveFolder, overrideFileName)))
{
pFileName = Path.Combine(_waveFolder, overrideFileName);
}
if (!File.Exists(pFileName))
{
pFileName = Path.Combine(_waveFolder, index + ".mp3");
}
var outputFileName1 = Path.Combine(_waveFolder, index + "_u.wav");
if (!string.IsNullOrEmpty(overrideFileName) && File.Exists(Path.Combine(_waveFolder, overrideFileName)))
{
outputFileName1 = Path.Combine(_waveFolder, Path.GetFileNameWithoutExtension(overrideFileName) + "_u.wav");
}
var trimProcess = VideoPreviewGenerator.TrimSilenceStartAndEnd(pFileName, outputFileName1);
trimProcess.Start();
while (!trimProcess.HasExited)
{
if (_abort)
{
return new List<string>();
return new List<FileNameAndSpeedFactor>();
}
}
@ -354,19 +396,24 @@ namespace Nikse.SubtitleEdit.Forms.Tts
if (_abort)
{
return new List<string>();
return new List<FileNameAndSpeedFactor>();
}
var waveInfo = UiUtil.GetVideoInfo(outputFileName1);
if (waveInfo.TotalMilliseconds <= p.DurationTotalMilliseconds + addDuration)
{
fileNames.Add(outputFileName1);
fileNames.Add(new FileNameAndSpeedFactor { Filename = outputFileName1, Factor = 1 });
continue;
}
var factor = waveInfo.TotalMilliseconds / (p.DurationTotalMilliseconds + addDuration);
var factor = (decimal)waveInfo.TotalMilliseconds / (decimal)(p.DurationTotalMilliseconds + addDuration);
var outputFileName2 = Path.Combine(_waveFolder, index + "_t.wav");
fileNames.Add(outputFileName2);
if (!string.IsNullOrEmpty(overrideFileName) && File.Exists(Path.Combine(_waveFolder, overrideFileName)))
{
outputFileName2 = Path.Combine(_waveFolder, Path.GetFileNameWithoutExtension(overrideFileName) + "_t.wav");
}
fileNames.Add(new FileNameAndSpeedFactor { Filename = outputFileName2, Factor = factor });
var mergeProcess = VideoPreviewGenerator.ChangeSpeed(outputFileName1, outputFileName2, (float)factor);
mergeProcess.Start();
@ -375,7 +422,7 @@ namespace Nikse.SubtitleEdit.Forms.Tts
Application.DoEvents();
if (_abort)
{
return new List<string>();
return new List<FileNameAndSpeedFactor>();
}
}
}
@ -383,7 +430,7 @@ namespace Nikse.SubtitleEdit.Forms.Tts
return fileNames;
}
private string MergeAudioParagraphs(List<string> fileNames)
private string MergeAudioParagraphs(List<FileNameAndSpeedFactor> fileNames)
{
labelProgress.Text = string.Empty;
labelProgress.Refresh();
@ -404,14 +451,14 @@ namespace Nikse.SubtitleEdit.Forms.Tts
labelProgress.Text = string.Format(LanguageSettings.Current.TextToSpeech.MergingAudioTrackXOfY, index + 1, _subtitle.Paragraphs.Count);
var p = _subtitle.Paragraphs[index];
var pFileName = fileNames[index];
if (!File.Exists(pFileName))
if (!File.Exists(pFileName.Filename))
{
SeLogger.Error($"TextToSpeech: File not found (skipping): {pFileName}");
SeLogger.Error($"TextToSpeech: File not found (skipping): {pFileName.Filename}");
continue;
}
outputFileName = Path.Combine(_waveFolder, $"silence{index}.wav");
var mergeProcess = VideoPreviewGenerator.MergeAudioTracks(inputFileName, pFileName, outputFileName, (float)p.StartTime.TotalSeconds);
var mergeProcess = VideoPreviewGenerator.MergeAudioTracks(inputFileName, pFileName.Filename, outputFileName, (float)p.StartTime.TotalSeconds);
inputFileName = outputFileName;
mergeProcess.Start();
@ -778,8 +825,6 @@ namespace Nikse.SubtitleEdit.Forms.Tts
}
var httpClient = new HttpClient();
//httpClient.BaseAddress = new Uri("https://api.elevenlabs.io/v1/text-to-speech/");
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json");
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("accept", "audio/mpeg");
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("xi-api-key", nikseTextBoxApiKey.Text.Trim());
@ -788,7 +833,7 @@ namespace Nikse.SubtitleEdit.Forms.Tts
progressBar1.Maximum = subtitle.Paragraphs.Count;
progressBar1.Visible = showProgressBar;
var voices = _elevelLabVoices;
var voices = _elevenLabVoices;
var v = nikseComboBoxVoice.Text;
for (var index = 0; index < subtitle.Paragraphs.Count; index++)
@ -843,6 +888,7 @@ namespace Nikse.SubtitleEdit.Forms.Tts
private void buttonOK_Click(object sender, EventArgs e)
{
EditedSubtitle = _subtitle;
DialogResult = DialogResult.OK;
}
@ -920,12 +966,12 @@ namespace Nikse.SubtitleEdit.Forms.Tts
labelApiKey.Visible = true;
nikseTextBoxApiKey.Visible = true;
if (_elevelLabVoices.Count == 0)
if (_elevenLabVoices.Count == 0)
{
_elevelLabVoices.AddRange(GetElevelLabVoices());
_elevenLabVoices.AddRange(GetElevelLabVoices());
}
foreach (var voice in _elevelLabVoices)
foreach (var voice in _elevenLabVoices)
{
nikseComboBoxVoice.Items.Add(voice.ToString());
}
@ -1002,7 +1048,7 @@ namespace Nikse.SubtitleEdit.Forms.Tts
}
else if (engine.Id == TextToSpeechEngineId.ElevenLabs)
{
var voices = _elevelLabVoices;
var voices = _elevenLabVoices;
foreach (var voiceLanguage in voices
.GroupBy(p => p.Language)
.OrderBy(p => p.Key))
@ -1063,6 +1109,7 @@ namespace Nikse.SubtitleEdit.Forms.Tts
labelActors.Visible = true;
listViewActors.Visible = true;
_actorsOn = true;
}
}
}
@ -1152,6 +1199,23 @@ namespace Nikse.SubtitleEdit.Forms.Tts
listViewActors.AutoSizeLastColumn();
}
public async Task<FileNameAndSpeedFactor> ReGenerateAudio(Paragraph p, string voice)
{
nikseComboBoxVoice.Text = voice;
var sub = new Subtitle();
sub.Paragraphs.Add(p);
var waveFileNameOnly = Guid.NewGuid() + ".wav";
var ok = await GenerateParagraphAudio(sub, false, waveFileNameOnly);
if (!ok)
{
return null;
}
var fileNameAndSpeedFactors = FixParagraphAudioSpeed(sub, waveFileNameOnly);
return fileNameAndSpeedFactors.First();
}
private async void buttonTestVoice_Click(object sender, EventArgs e)
{
try
@ -1235,6 +1299,7 @@ namespace Nikse.SubtitleEdit.Forms.Tts
}
Configuration.Settings.Tools.TextToSpeechEngine = engine.Id.ToString();
Configuration.Settings.Tools.TextToSpeechLastVoice = nikseComboBoxVoice.Text;
}
private void TextToSpeech_KeyDown(object sender, KeyEventArgs e)
@ -1253,5 +1318,45 @@ namespace Nikse.SubtitleEdit.Forms.Tts
buttonTestVoice_Click(null, null);
}
}
public string GetParagraphAudio(Paragraph paragraph)
{
if (_actorsOn)
{
var engine = _engines.First(p => p.Index == nikseComboBoxEngine.SelectedIndex);
if (engine.Id == TextToSpeechEngineId.Piper)
{
var voices = PiperModels.GetVoices();
var voice = voices.First(x => x.ToString() == nikseComboBoxVoice.Text);
if (_actorAndVoices.Count > 0 && !string.IsNullOrEmpty(paragraph.Actor))
{
var f = _actorAndVoices.FirstOrDefault(x => x.Actor == paragraph.Actor);
if (f != null && !string.IsNullOrEmpty(f.Voice))
{
return voices[f.VoiceIndex].Voice;
}
}
}
}
return nikseComboBoxVoice.Text;
}
public void SetCurrentVoices(NikseComboBox nikseComboBox)
{
nikseComboBox.Items.Clear();
foreach (var voice in nikseComboBoxVoice.Items)
{
nikseComboBox.Items.Add(voice.ToString());
}
nikseComboBox.SelectedIndex = nikseComboBoxVoice.SelectedIndex;
}
private void buttonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
}
}
}

View File

@ -851,9 +851,9 @@ namespace Nikse.SubtitleEdit.Logic.VideoPlayers
}
}
Application.DoEvents();
OnVideoLoaded?.Invoke(this, null);
Application.DoEvents();
Pause();
Application.DoEvents();
OnVideoLoaded?.Invoke(this, null);
}
public override void DisposeVideoPlayer()

View File

@ -385,6 +385,12 @@
<Compile Include="Forms\AudioToText\VoskModelDownload.Designer.cs">
<DependentUpon>VoskModelDownload.cs</DependentUpon>
</Compile>
<Compile Include="Forms\GenerateVideoWithHardSubsOutFile.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\GenerateVideoWithHardSubsOutFile.Designer.cs">
<DependentUpon>GenerateVideoWithHardSubsOutFile.cs</DependentUpon>
</Compile>
<Compile Include="Forms\GenerateVideoWithSoftSubsLanguage.cs">
<SubType>Form</SubType>
</Compile>
@ -686,6 +692,12 @@
<Compile Include="Forms\Tts\PiperDownload.Designer.cs">
<DependentUpon>PiperDownload.cs</DependentUpon>
</Compile>
<Compile Include="Forms\Tts\RegenerateAudioClip.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\Tts\RegenerateAudioClip.Designer.cs">
<DependentUpon>RegenerateAudioClip.cs</DependentUpon>
</Compile>
<Compile Include="Forms\Tts\TextToSpeech.cs">
<SubType>Form</SubType>
</Compile>
@ -1416,6 +1428,12 @@
<Compile Include="Forms\TransportStreamSubtitleChooser.Designer.cs">
<DependentUpon>TransportStreamSubtitleChooser.cs</DependentUpon>
</Compile>
<Compile Include="Forms\Tts\ReviewAudioClips.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\Tts\ReviewAudioClips.Designer.cs">
<DependentUpon>ReviewAudioClips.cs</DependentUpon>
</Compile>
<Compile Include="Forms\UnknownSubtitle.cs">
<SubType>Form</SubType>
</Compile>
@ -1822,6 +1840,9 @@
<EmbeddedResource Include="Forms\GenerateVideoFFmpegPrompt.resx">
<DependentUpon>GenerateVideoFFmpegPrompt.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\GenerateVideoWithHardSubsOutFile.resx">
<DependentUpon>GenerateVideoWithHardSubsOutFile.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\GenerateVideoWithSoftSubs.resx">
<DependentUpon>GenerateVideoWithSoftSubs.cs</DependentUpon>
</EmbeddedResource>
@ -1960,6 +1981,9 @@
<EmbeddedResource Include="Forms\Tts\PiperDownload.resx">
<DependentUpon>PiperDownload.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\Tts\RegenerateAudioClip.resx">
<DependentUpon>RegenerateAudioClip.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\Tts\TextToSpeech.resx">
<DependentUpon>TextToSpeech.cs</DependentUpon>
</EmbeddedResource>
@ -2312,6 +2336,9 @@
<EmbeddedResource Include="Forms\TransportStreamSubtitleChooser.resx">
<DependentUpon>TransportStreamSubtitleChooser.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\Tts\ReviewAudioClips.resx">
<DependentUpon>ReviewAudioClips.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\UnknownSubtitle.resx">
<DependentUpon>UnknownSubtitle.cs</DependentUpon>
<SubType>Designer</SubType>