Allow configure of Whisper post-processing

This commit is contained in:
Nikolaj Olsson 2023-12-08 17:26:55 +01:00
parent 33cf42647f
commit 23364040cd
11 changed files with 3397 additions and 2890 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -479,6 +479,11 @@ namespace Nikse.SubtitleEdit.Core.Common
public string WhisperExtraSettingsHistory { get; set; }
public bool WhisperAutoAdjustTimings { get; set; }
public bool WhisperUseLineMaxChars { get; set; }
public bool WhisperPostProcessingAddPeriods { get; set; }
public bool WhisperPostProcessingMergeLines { get; set; }
public bool WhisperPostProcessingSplitLines { get; set; }
public bool WhisperPostProcessingFixCasing { get; set; }
public bool WhisperPostProcessingFixShortDuration { get; set; }
public int AudioToTextLineMaxChars { get; set; }
public int AudioToTextLineMaxCharsJp { get; set; }
public int AudioToTextLineMaxCharsCn { get; set; }
@ -704,6 +709,11 @@ namespace Nikse.SubtitleEdit.Core.Common
WhisperExtraSettings = "";
WhisperLanguageCode = "en";
WhisperAutoAdjustTimings = true;
WhisperPostProcessingAddPeriods = false;
WhisperPostProcessingMergeLines = true;
WhisperPostProcessingSplitLines = true;
WhisperPostProcessingFixCasing = false;
WhisperPostProcessingFixShortDuration = true;
AudioToTextLineMaxChars = 86;
AudioToTextLineMaxCharsJp = 32;
AudioToTextLineMaxCharsCn = 36;
@ -6965,6 +6975,36 @@ $HorzAlign = Center
settings.Tools.WhisperDeleteTempFiles = Convert.ToBoolean(subNode.InnerText, CultureInfo.InvariantCulture);
}
subNode = node.SelectSingleNode("WhisperPostProcessingAddPeriods");
if (subNode != null)
{
settings.Tools.WhisperPostProcessingAddPeriods = Convert.ToBoolean(subNode.InnerText, CultureInfo.InvariantCulture);
}
subNode = node.SelectSingleNode("WhisperPostProcessingMergeLines");
if (subNode != null)
{
settings.Tools.WhisperPostProcessingMergeLines = Convert.ToBoolean(subNode.InnerText, CultureInfo.InvariantCulture);
}
subNode = node.SelectSingleNode("WhisperPostProcessingSplitLines");
if (subNode != null)
{
settings.Tools.WhisperPostProcessingSplitLines = Convert.ToBoolean(subNode.InnerText, CultureInfo.InvariantCulture);
}
subNode = node.SelectSingleNode("WhisperPostProcessingFixCasing");
if (subNode != null)
{
settings.Tools.WhisperPostProcessingFixCasing = Convert.ToBoolean(subNode.InnerText, CultureInfo.InvariantCulture);
}
subNode = node.SelectSingleNode("WhisperPostProcessingFixShortDuration");
if (subNode != null)
{
settings.Tools.WhisperPostProcessingFixShortDuration = Convert.ToBoolean(subNode.InnerText, CultureInfo.InvariantCulture);
}
subNode = node.SelectSingleNode("WhisperModel");
if (subNode != null)
{
@ -11903,6 +11943,11 @@ $HorzAlign = Center
textWriter.WriteElementString("WhisperLanguageCode", settings.Tools.WhisperLanguageCode);
textWriter.WriteElementString("WhisperAutoAdjustTimings", settings.Tools.WhisperAutoAdjustTimings.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("WhisperUseLineMaxChars", settings.Tools.WhisperUseLineMaxChars.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("WhisperPostProcessingAddPeriods", settings.Tools.WhisperPostProcessingAddPeriods.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("WhisperPostProcessingSplitLines", settings.Tools.WhisperPostProcessingSplitLines.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("WhisperPostProcessingMergeLines", settings.Tools.WhisperPostProcessingMergeLines.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("WhisperPostProcessingFixCasing", settings.Tools.WhisperPostProcessingFixCasing.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("WhisperPostProcessingFixShortDuration", settings.Tools.WhisperPostProcessingFixShortDuration.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("AudioToTextLineMaxChars", settings.Tools.AudioToTextLineMaxChars.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("AudioToTextLineMaxCharsJp", settings.Tools.AudioToTextLineMaxCharsJp.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("AudioToTextLineMaxCharsCn", settings.Tools.AudioToTextLineMaxCharsCn.ToString(CultureInfo.InvariantCulture));

View File

@ -0,0 +1,152 @@
namespace Nikse.SubtitleEdit.Forms.AudioToText
{
partial class PostProcessingSettings
{
/// <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.checkBoxFixCasing = new System.Windows.Forms.CheckBox();
this.checkBoxAddPeriods = new System.Windows.Forms.CheckBox();
this.checkBoxMergeShortLines = new System.Windows.Forms.CheckBox();
this.checkBoxSplitLongLines = new System.Windows.Forms.CheckBox();
this.checkBoxFixShortDuration = new System.Windows.Forms.CheckBox();
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonOK = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// checkBoxFixCasing
//
this.checkBoxFixCasing.AutoSize = true;
this.checkBoxFixCasing.Location = new System.Drawing.Point(24, 98);
this.checkBoxFixCasing.Name = "checkBoxFixCasing";
this.checkBoxFixCasing.Size = new System.Drawing.Size(73, 17);
this.checkBoxFixCasing.TabIndex = 3;
this.checkBoxFixCasing.Text = "Fix casing";
this.checkBoxFixCasing.UseVisualStyleBackColor = true;
//
// checkBoxAddPeriods
//
this.checkBoxAddPeriods.AutoSize = true;
this.checkBoxAddPeriods.Location = new System.Drawing.Point(24, 121);
this.checkBoxAddPeriods.Name = "checkBoxAddPeriods";
this.checkBoxAddPeriods.Size = new System.Drawing.Size(82, 17);
this.checkBoxAddPeriods.TabIndex = 4;
this.checkBoxAddPeriods.Text = "Add periods";
this.checkBoxAddPeriods.UseVisualStyleBackColor = true;
//
// checkBoxMergeShortLines
//
this.checkBoxMergeShortLines.AutoSize = true;
this.checkBoxMergeShortLines.Location = new System.Drawing.Point(24, 29);
this.checkBoxMergeShortLines.Name = "checkBoxMergeShortLines";
this.checkBoxMergeShortLines.Size = new System.Drawing.Size(106, 17);
this.checkBoxMergeShortLines.TabIndex = 0;
this.checkBoxMergeShortLines.Text = "Merge short lines";
this.checkBoxMergeShortLines.UseVisualStyleBackColor = true;
//
// checkBoxSplitLongLines
//
this.checkBoxSplitLongLines.AutoSize = true;
this.checkBoxSplitLongLines.Location = new System.Drawing.Point(24, 52);
this.checkBoxSplitLongLines.Name = "checkBoxSplitLongLines";
this.checkBoxSplitLongLines.Size = new System.Drawing.Size(93, 17);
this.checkBoxSplitLongLines.TabIndex = 1;
this.checkBoxSplitLongLines.Text = "Split long lines";
this.checkBoxSplitLongLines.UseVisualStyleBackColor = true;
//
// checkBoxFixShortDuration
//
this.checkBoxFixShortDuration.AutoSize = true;
this.checkBoxFixShortDuration.Location = new System.Drawing.Point(24, 75);
this.checkBoxFixShortDuration.Name = "checkBoxFixShortDuration";
this.checkBoxFixShortDuration.Size = new System.Drawing.Size(106, 17);
this.checkBoxFixShortDuration.TabIndex = 2;
this.checkBoxFixShortDuration.Text = "Fix short duration";
this.checkBoxFixShortDuration.UseVisualStyleBackColor = true;
//
// 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(259, 151);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.buttonCancel.TabIndex = 6;
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.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonOK.Location = new System.Drawing.Point(178, 151);
this.buttonOK.Name = "buttonOK";
this.buttonOK.Size = new System.Drawing.Size(75, 23);
this.buttonOK.TabIndex = 5;
this.buttonOK.Text = "&OK";
this.buttonOK.UseVisualStyleBackColor = true;
this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click);
//
// PostProcessingSettings
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(346, 186);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonOK);
this.Controls.Add(this.checkBoxFixShortDuration);
this.Controls.Add(this.checkBoxSplitLongLines);
this.Controls.Add(this.checkBoxMergeShortLines);
this.Controls.Add(this.checkBoxAddPeriods);
this.Controls.Add(this.checkBoxFixCasing);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.KeyPreview = true;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "PostProcessingSettings";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Settings";
this.Shown += new System.EventHandler(this.PostProcessingSettings_Shown);
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.PostProcessingSettings_KeyDown);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.CheckBox checkBoxFixCasing;
private System.Windows.Forms.CheckBox checkBoxAddPeriods;
private System.Windows.Forms.CheckBox checkBoxMergeShortLines;
private System.Windows.Forms.CheckBox checkBoxSplitLongLines;
private System.Windows.Forms.CheckBox checkBoxFixShortDuration;
private System.Windows.Forms.Button buttonCancel;
private System.Windows.Forms.Button buttonOK;
}
}

View File

@ -0,0 +1,59 @@
using Nikse.SubtitleEdit.Logic;
using System.Windows.Forms;
namespace Nikse.SubtitleEdit.Forms.AudioToText
{
public partial class PostProcessingSettings : Form
{
public bool AddPeriods { get; set; }
public bool MergeLines { get; set; }
public bool SplitLines { get; set; }
public bool FixCasing { get; set; }
public bool FixShortDuration { get; set; }
public PostProcessingSettings()
{
UiUtil.PreInitialize(this);
InitializeComponent();
UiUtil.FixFonts(this);
Text = LanguageSettings.Current.Settings.Title;
buttonOK.Text = LanguageSettings.Current.General.Ok;
buttonCancel.Text = LanguageSettings.Current.General.Cancel;
}
private void PostProcessingSettings_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Escape)
{
DialogResult = DialogResult.Cancel;
}
}
private void buttonOK_Click(object sender, System.EventArgs e)
{
AddPeriods = checkBoxAddPeriods.Checked;
MergeLines = checkBoxMergeShortLines.Checked;
SplitLines = checkBoxSplitLongLines.Checked;
FixCasing = checkBoxFixCasing.Checked;
FixShortDuration = checkBoxFixShortDuration.Checked;
DialogResult = DialogResult.OK;
}
private void buttonCancel_Click(object sender, System.EventArgs e)
{
DialogResult = DialogResult.Cancel;
}
private void PostProcessingSettings_Shown(object sender, System.EventArgs e)
{
checkBoxAddPeriods.Checked = AddPeriods;
checkBoxMergeShortLines.Checked = MergeLines;
checkBoxSplitLongLines.Checked = SplitLines;
checkBoxFixCasing.Checked = FixCasing;
checkBoxFixShortDuration.Checked = FixShortDuration;
}
}
}

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

@ -36,11 +36,9 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
this.labelInfo = new System.Windows.Forms.Label();
this.groupBoxModels = new System.Windows.Forms.GroupBox();
this.labelChooseLanguage = new System.Windows.Forms.Label();
this.comboBoxLanguages = new Nikse.SubtitleEdit.Controls.NikseComboBox();
this.buttonDownload = new System.Windows.Forms.Button();
this.linkLabelOpenModelsFolder = new System.Windows.Forms.LinkLabel();
this.labelModel = new System.Windows.Forms.Label();
this.comboBoxModels = new Nikse.SubtitleEdit.Controls.NikseComboBox();
this.linkLabeWhisperWebSite = new System.Windows.Forms.LinkLabel();
this.labelTime = new System.Windows.Forms.Label();
this.timer1 = new System.Windows.Forms.Timer(this.components);
@ -67,7 +65,10 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
this.labelEngine = new System.Windows.Forms.Label();
this.buttonAdvanced = new System.Windows.Forms.Button();
this.labelAdvanced = new System.Windows.Forms.Label();
this.linkLabelPostProcessingConfigure = new System.Windows.Forms.LinkLabel();
this.comboBoxWhisperEngine = new Nikse.SubtitleEdit.Controls.NikseComboBox();
this.comboBoxLanguages = new Nikse.SubtitleEdit.Controls.NikseComboBox();
this.comboBoxModels = new Nikse.SubtitleEdit.Controls.NikseComboBox();
this.textBoxLog = new Nikse.SubtitleEdit.Controls.NikseTextBox();
this.groupBoxModels.SuspendLayout();
this.groupBoxInputFiles.SuspendLayout();
@ -154,30 +155,6 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
this.labelChooseLanguage.TabIndex = 4;
this.labelChooseLanguage.Text = "Choose language";
//
// comboBoxLanguages
//
this.comboBoxLanguages.BackColor = System.Drawing.SystemColors.Window;
this.comboBoxLanguages.BackColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
this.comboBoxLanguages.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(171)))), ((int)(((byte)(173)))), ((int)(((byte)(179)))));
this.comboBoxLanguages.BorderColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(120)))), ((int)(((byte)(120)))), ((int)(((byte)(120)))));
this.comboBoxLanguages.ButtonForeColor = System.Drawing.SystemColors.ControlText;
this.comboBoxLanguages.ButtonForeColorDown = System.Drawing.Color.Orange;
this.comboBoxLanguages.ButtonForeColorOver = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215)))));
this.comboBoxLanguages.DropDownHeight = 400;
this.comboBoxLanguages.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxLanguages.DropDownWidth = 240;
this.comboBoxLanguages.FormattingEnabled = true;
this.comboBoxLanguages.Location = new System.Drawing.Point(6, 44);
this.comboBoxLanguages.MaxLength = 32767;
this.comboBoxLanguages.Name = "comboBoxLanguages";
this.comboBoxLanguages.SelectedIndex = -1;
this.comboBoxLanguages.SelectedItem = null;
this.comboBoxLanguages.SelectedText = "";
this.comboBoxLanguages.Size = new System.Drawing.Size(240, 21);
this.comboBoxLanguages.TabIndex = 0;
this.comboBoxLanguages.UsePopupWindow = false;
this.comboBoxLanguages.SelectedIndexChanged += new System.EventHandler(this.comboBoxLanguages_SelectedIndexChanged);
//
// buttonDownload
//
this.buttonDownload.ImeMode = System.Windows.Forms.ImeMode.NoControl;
@ -209,29 +186,6 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
this.labelModel.TabIndex = 0;
this.labelModel.Text = "Choose speech recognition model";
//
// comboBoxModels
//
this.comboBoxModels.BackColor = System.Drawing.SystemColors.Window;
this.comboBoxModels.BackColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
this.comboBoxModels.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(171)))), ((int)(((byte)(173)))), ((int)(((byte)(179)))));
this.comboBoxModels.BorderColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(120)))), ((int)(((byte)(120)))), ((int)(((byte)(120)))));
this.comboBoxModels.ButtonForeColor = System.Drawing.SystemColors.ControlText;
this.comboBoxModels.ButtonForeColorDown = System.Drawing.Color.Orange;
this.comboBoxModels.ButtonForeColorOver = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215)))));
this.comboBoxModels.DropDownHeight = 400;
this.comboBoxModels.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxModels.DropDownWidth = 240;
this.comboBoxModels.FormattingEnabled = true;
this.comboBoxModels.Location = new System.Drawing.Point(280, 44);
this.comboBoxModels.MaxLength = 32767;
this.comboBoxModels.Name = "comboBoxModels";
this.comboBoxModels.SelectedIndex = -1;
this.comboBoxModels.SelectedItem = null;
this.comboBoxModels.SelectedText = "";
this.comboBoxModels.Size = new System.Drawing.Size(240, 21);
this.comboBoxModels.TabIndex = 1;
this.comboBoxModels.UsePopupWindow = false;
//
// linkLabeWhisperWebSite
//
this.linkLabeWhisperWebSite.AutoSize = true;
@ -395,7 +349,7 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
this.downloadNvidiaCudaForCPPCuBLASToolStripMenuItem,
this.showWhisperlogtxtToolStripMenuItem});
this.contextMenuStripWhisperAdvanced.Name = "contextMenuStripWhisperAdvanced";
this.contextMenuStripWhisperAdvanced.Size = new System.Drawing.Size(284, 164);
this.contextMenuStripWhisperAdvanced.Size = new System.Drawing.Size(284, 142);
this.contextMenuStripWhisperAdvanced.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStripWhisperAdvanced_Opening);
//
// runOnlyPostProcessingToolStripMenuItem
@ -486,6 +440,17 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
this.labelAdvanced.TabIndex = 29;
this.labelAdvanced.Text = "Advanced...";
//
// linkLabelPostProcessingConfigure
//
this.linkLabelPostProcessingConfigure.AutoSize = true;
this.linkLabelPostProcessingConfigure.Location = new System.Drawing.Point(328, 199);
this.linkLabelPostProcessingConfigure.Name = "linkLabelPostProcessingConfigure";
this.linkLabelPostProcessingConfigure.Size = new System.Drawing.Size(45, 13);
this.linkLabelPostProcessingConfigure.TabIndex = 5;
this.linkLabelPostProcessingConfigure.TabStop = true;
this.linkLabelPostProcessingConfigure.Text = "Settings";
this.linkLabelPostProcessingConfigure.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabelPostProcessingConfigure_LinkClicked);
//
// comboBoxWhisperEngine
//
this.comboBoxWhisperEngine.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
@ -511,6 +476,53 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
this.comboBoxWhisperEngine.UsePopupWindow = false;
this.comboBoxWhisperEngine.SelectedIndexChanged += new System.EventHandler(this.comboBoxWhisperEngine_SelectedIndexChanged);
//
// comboBoxLanguages
//
this.comboBoxLanguages.BackColor = System.Drawing.SystemColors.Window;
this.comboBoxLanguages.BackColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
this.comboBoxLanguages.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(171)))), ((int)(((byte)(173)))), ((int)(((byte)(179)))));
this.comboBoxLanguages.BorderColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(120)))), ((int)(((byte)(120)))), ((int)(((byte)(120)))));
this.comboBoxLanguages.ButtonForeColor = System.Drawing.SystemColors.ControlText;
this.comboBoxLanguages.ButtonForeColorDown = System.Drawing.Color.Orange;
this.comboBoxLanguages.ButtonForeColorOver = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215)))));
this.comboBoxLanguages.DropDownHeight = 400;
this.comboBoxLanguages.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxLanguages.DropDownWidth = 240;
this.comboBoxLanguages.FormattingEnabled = true;
this.comboBoxLanguages.Location = new System.Drawing.Point(6, 44);
this.comboBoxLanguages.MaxLength = 32767;
this.comboBoxLanguages.Name = "comboBoxLanguages";
this.comboBoxLanguages.SelectedIndex = -1;
this.comboBoxLanguages.SelectedItem = null;
this.comboBoxLanguages.SelectedText = "";
this.comboBoxLanguages.Size = new System.Drawing.Size(240, 21);
this.comboBoxLanguages.TabIndex = 0;
this.comboBoxLanguages.UsePopupWindow = false;
this.comboBoxLanguages.SelectedIndexChanged += new System.EventHandler(this.comboBoxLanguages_SelectedIndexChanged);
//
// comboBoxModels
//
this.comboBoxModels.BackColor = System.Drawing.SystemColors.Window;
this.comboBoxModels.BackColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
this.comboBoxModels.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(171)))), ((int)(((byte)(173)))), ((int)(((byte)(179)))));
this.comboBoxModels.BorderColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(120)))), ((int)(((byte)(120)))), ((int)(((byte)(120)))));
this.comboBoxModels.ButtonForeColor = System.Drawing.SystemColors.ControlText;
this.comboBoxModels.ButtonForeColorDown = System.Drawing.Color.Orange;
this.comboBoxModels.ButtonForeColorOver = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215)))));
this.comboBoxModels.DropDownHeight = 400;
this.comboBoxModels.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxModels.DropDownWidth = 240;
this.comboBoxModels.FormattingEnabled = true;
this.comboBoxModels.Location = new System.Drawing.Point(280, 44);
this.comboBoxModels.MaxLength = 32767;
this.comboBoxModels.Name = "comboBoxModels";
this.comboBoxModels.SelectedIndex = -1;
this.comboBoxModels.SelectedItem = null;
this.comboBoxModels.SelectedText = "";
this.comboBoxModels.Size = new System.Drawing.Size(240, 21);
this.comboBoxModels.TabIndex = 1;
this.comboBoxModels.UsePopupWindow = false;
//
// textBoxLog
//
this.textBoxLog.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
@ -530,6 +542,7 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(709, 494);
this.Controls.Add(this.linkLabelPostProcessingConfigure);
this.Controls.Add(this.labelTime);
this.Controls.Add(this.labelAdvanced);
this.Controls.Add(this.buttonAdvanced);
@ -613,5 +626,6 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
private System.Windows.Forms.ToolStripMenuItem downloadCUDAForPurfviewsWhisperFasterToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem showWhisperlogtxtToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem downloadNvidiaCudaForCPPCuBLASToolStripMenuItem;
private System.Windows.Forms.LinkLabel linkLabelPostProcessingConfigure;
}
}

View File

@ -1,3 +1,4 @@
using Nikse.SubtitleEdit.Controls;
using Nikse.SubtitleEdit.Core.AudioToText;
using Nikse.SubtitleEdit.Core.Common;
using Nikse.SubtitleEdit.Core.ContainerFormats.Matroska;
@ -14,7 +15,6 @@ using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Controls;
using MessageBox = Nikse.SubtitleEdit.Forms.SeMsgBox.MessageBox;
namespace Nikse.SubtitleEdit.Forms.AudioToText
@ -75,6 +75,8 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
linkLabelOpenModelsFolder.Text = LanguageSettings.Current.AudioToText.OpenModelsFolder;
checkBoxTranslateToEnglish.Text = LanguageSettings.Current.AudioToText.TranslateToEnglish;
checkBoxUsePostProcessing.Text = LanguageSettings.Current.AudioToText.UsePostProcessing;
linkLabelPostProcessingConfigure.Left = checkBoxUsePostProcessing.Right + 1;
linkLabelPostProcessingConfigure.Text = LanguageSettings.Current.Settings.Title;
checkBoxAutoAdjustTimings.Text = LanguageSettings.Current.AudioToText.AutoAdjustTimings;
buttonGenerate.Text = LanguageSettings.Current.Watermark.Generate;
buttonCancel.Text = LanguageSettings.Current.General.Cancel;
@ -466,7 +468,15 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
transcript = WhisperTimingFixer.ShortenViaWavePeaks(transcript, wavePeaks);
}
TranscribedSubtitle = postProcessor.Fix(AudioToTextPostProcessor.Engine.Whisper, transcript, checkBoxUsePostProcessing.Checked, true, true, true, true, true);
TranscribedSubtitle = postProcessor.Fix(
AudioToTextPostProcessor.Engine.Whisper,
transcript,
checkBoxUsePostProcessing.Checked,
Configuration.Settings.Tools.WhisperPostProcessingAddPeriods,
Configuration.Settings.Tools.WhisperPostProcessingMergeLines,
Configuration.Settings.Tools.WhisperPostProcessingFixCasing,
Configuration.Settings.Tools.WhisperPostProcessingFixShortDuration,
Configuration.Settings.Tools.WhisperPostProcessingSplitLines);
if (transcript == null || transcript.Paragraphs.Count == 0)
{
@ -557,7 +567,16 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
{
ParagraphMaxChars = Configuration.Settings.General.SubtitleLineMaximumLength * 2,
};
TranscribedSubtitle = postProcessor.Fix(AudioToTextPostProcessor.Engine.Whisper, transcript, checkBoxUsePostProcessing.Checked, true, true, true, true, true);
TranscribedSubtitle = postProcessor.Fix(
AudioToTextPostProcessor.Engine.Whisper,
transcript,
checkBoxUsePostProcessing.Checked,
Configuration.Settings.Tools.WhisperPostProcessingAddPeriods,
Configuration.Settings.Tools.WhisperPostProcessingMergeLines,
Configuration.Settings.Tools.WhisperPostProcessingFixCasing,
Configuration.Settings.Tools.WhisperPostProcessingFixShortDuration,
Configuration.Settings.Tools.WhisperPostProcessingSplitLines);
SaveToSourceFolder(videoFileName);
TaskbarList.SetProgressValue(_parentForm.Handle, _batchFileNumber, listViewInputFiles.Items.Count);
@ -2084,7 +2103,14 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
return;
}
TranscribedSubtitle = postProcessor.Fix(AudioToTextPostProcessor.Engine.Whisper, _subtitle, checkBoxUsePostProcessing.Checked, true, true, true, true, true);
TranscribedSubtitle = postProcessor.Fix(AudioToTextPostProcessor.Engine.Whisper,
_subtitle,
checkBoxUsePostProcessing.Checked,
Configuration.Settings.Tools.WhisperPostProcessingAddPeriods,
Configuration.Settings.Tools.WhisperPostProcessingMergeLines,
Configuration.Settings.Tools.WhisperPostProcessingFixCasing,
Configuration.Settings.Tools.WhisperPostProcessingFixShortDuration,
Configuration.Settings.Tools.WhisperPostProcessingSplitLines);
DialogResult = DialogResult.OK;
}
finally
@ -2222,5 +2248,31 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
{
UiUtil.OpenUrl("https://developer.nvidia.com/cuda-downloads");
}
private void linkLabelPostProcessingConfigure_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
ShowPostProcessingSettings(this);
}
public static void ShowPostProcessingSettings(Form owner)
{
using (var form = new PostProcessingSettings()
{
AddPeriods = Configuration.Settings.Tools.WhisperPostProcessingAddPeriods,
MergeLines = Configuration.Settings.Tools.WhisperPostProcessingMergeLines,
SplitLines = Configuration.Settings.Tools.WhisperPostProcessingSplitLines,
FixCasing = Configuration.Settings.Tools.WhisperPostProcessingFixCasing,
FixShortDuration = Configuration.Settings.Tools.WhisperPostProcessingFixShortDuration,
})
{
if (form.ShowDialog(owner) == DialogResult.OK)
{
Configuration.Settings.Tools.WhisperPostProcessingAddPeriods = form.AddPeriods;
Configuration.Settings.Tools.WhisperPostProcessingMergeLines = form.MergeLines;
Configuration.Settings.Tools.WhisperPostProcessingSplitLines = form.SplitLines;
Configuration.Settings.Tools.WhisperPostProcessingFixCasing = form.FixCasing;
}
}
}
}
}

View File

@ -58,6 +58,7 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
this.comboBoxWhisperEngine = new Nikse.SubtitleEdit.Controls.NikseComboBox();
this.labelAdvanced = new System.Windows.Forms.Label();
this.buttonAdvanced = new System.Windows.Forms.Button();
this.linkLabelPostProcessingConfigure = new System.Windows.Forms.LinkLabel();
this.groupBoxModels.SuspendLayout();
this.groupBoxInputFiles.SuspendLayout();
this.contextMenuStripWhisperAdvanced.SuspendLayout();
@ -403,11 +404,23 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
this.buttonAdvanced.UseVisualStyleBackColor = true;
this.buttonAdvanced.Click += new System.EventHandler(this.buttonAdvanced_Click);
//
// linkLabelPostProcessingConfigure
//
this.linkLabelPostProcessingConfigure.AutoSize = true;
this.linkLabelPostProcessingConfigure.Location = new System.Drawing.Point(333, 173);
this.linkLabelPostProcessingConfigure.Name = "linkLabelPostProcessingConfigure";
this.linkLabelPostProcessingConfigure.Size = new System.Drawing.Size(45, 13);
this.linkLabelPostProcessingConfigure.TabIndex = 32;
this.linkLabelPostProcessingConfigure.TabStop = true;
this.linkLabelPostProcessingConfigure.Text = "Settings";
this.linkLabelPostProcessingConfigure.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabelPostProcessingConfigure_LinkClicked);
//
// WhisperAudioToTextSelectedLines
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(709, 464);
this.Controls.Add(this.linkLabelPostProcessingConfigure);
this.Controls.Add(this.labelAdvanced);
this.Controls.Add(this.buttonAdvanced);
this.Controls.Add(this.labelEngine);
@ -476,5 +489,6 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
private System.Windows.Forms.Label labelAdvanced;
private System.Windows.Forms.Button buttonAdvanced;
private System.Windows.Forms.ToolStripMenuItem downloadCUDAForPurfviewsWhisperFasterToolStripMenuItem;
private System.Windows.Forms.LinkLabel linkLabelPostProcessingConfigure;
}
}

View File

@ -51,6 +51,8 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
linkLabelOpenModelsFolder.Text = LanguageSettings.Current.AudioToText.OpenModelsFolder;
checkBoxTranslateToEnglish.Text = LanguageSettings.Current.AudioToText.TranslateToEnglish;
checkBoxUsePostProcessing.Text = LanguageSettings.Current.AudioToText.UsePostProcessing;
linkLabelPostProcessingConfigure.Left = checkBoxUsePostProcessing.Right + 1;
linkLabelPostProcessingConfigure.Text = LanguageSettings.Current.Settings.Title;
buttonGenerate.Text = LanguageSettings.Current.Watermark.Generate;
buttonCancel.Text = LanguageSettings.Current.General.Cancel;
groupBoxInputFiles.Text = LanguageSettings.Current.BatchConvert.Input;
@ -158,7 +160,15 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
return;
}
TranscribedSubtitle = postProcessor.Fix(AudioToTextPostProcessor.Engine.Whisper, transcript, checkBoxUsePostProcessing.Checked, true, true, true, true, false);
TranscribedSubtitle = postProcessor.Fix(
AudioToTextPostProcessor.Engine.Whisper,
transcript,
checkBoxUsePostProcessing.Checked,
Configuration.Settings.Tools.WhisperPostProcessingAddPeriods,
Configuration.Settings.Tools.WhisperPostProcessingMergeLines,
Configuration.Settings.Tools.WhisperPostProcessingFixCasing,
Configuration.Settings.Tools.WhisperPostProcessingFixShortDuration,
Configuration.Settings.Tools.WhisperPostProcessingSplitLines);
SaveToAudioClip(_batchFileNumber - 1);
TaskbarList.SetProgressValue(_parentForm.Handle, _batchFileNumber, listViewInputFiles.Items.Count);
@ -297,7 +307,16 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
postSub.Paragraphs.Add(audioClip.Paragraph);
}
var postSubFixed = postProcessor.Fix(postSub, checkBoxUsePostProcessing.Checked, true, false, true, false, false, AudioToTextPostProcessor.Engine.Whisper);
var postSubFixed = postProcessor.Fix(
postSub,
checkBoxUsePostProcessing.Checked,
Configuration.Settings.Tools.WhisperPostProcessingAddPeriods,
Configuration.Settings.Tools.WhisperPostProcessingMergeLines,
Configuration.Settings.Tools.WhisperPostProcessingFixCasing,
Configuration.Settings.Tools.WhisperPostProcessingFixShortDuration,
Configuration.Settings.Tools.WhisperPostProcessingSplitLines,
AudioToTextPostProcessor.Engine.Whisper);
for (var index = 0; index < _audioClips.Count; index++)
{
var audioClip = _audioClips[index];
@ -754,5 +773,10 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
{
WhisperAudioToText.DownloadCudaForWhisperFaster(this);
}
private void linkLabelPostProcessingConfigure_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
WhisperAudioToText.ShowPostProcessingSettings(this);
}
}
}

View File

@ -244,6 +244,12 @@
<DependentUpon>AudioClipsGet.cs</DependentUpon>
</Compile>
<Compile Include="Forms\AudioToText\KillProcessHelper.cs" />
<Compile Include="Forms\AudioToText\PostProcessingSettings.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\AudioToText\PostProcessingSettings.Designer.cs">
<DependentUpon>PostProcessingSettings.cs</DependentUpon>
</Compile>
<Compile Include="Forms\AudioToText\WhisperAdvanced.cs">
<SubType>Form</SubType>
</Compile>
@ -1680,6 +1686,9 @@
<EmbeddedResource Include="Forms\AudioClipsGet.resx">
<DependentUpon>AudioClipsGet.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\AudioToText\PostProcessingSettings.resx">
<DependentUpon>PostProcessingSettings.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\AudioToText\WhisperAdvanced.resx">
<DependentUpon>WhisperAdvanced.cs</DependentUpon>
<SubType>Designer</SubType>