mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 03:02:35 +01:00
Allow only whisper-post-processing via context menu - thx Udoachim :)
Somewhat fix #6870
This commit is contained in:
parent
f6a239df5c
commit
a3155236e5
@ -64,6 +64,8 @@
|
||||
this.comboBoxCharsPerSub = new System.Windows.Forms.ComboBox();
|
||||
this.comboBoxWhisperEngine = new System.Windows.Forms.ComboBox();
|
||||
this.labelEngine = new System.Windows.Forms.Label();
|
||||
this.runOnlyPostProcessingToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparatorRunOnlyPostprocessing = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.groupBoxModels.SuspendLayout();
|
||||
this.groupBoxInputFiles.SuspendLayout();
|
||||
this.contextMenuStripWhisperAdvanced.SuspendLayout();
|
||||
@ -367,10 +369,12 @@
|
||||
// contextMenuStripWhisperAdvanced
|
||||
//
|
||||
this.contextMenuStripWhisperAdvanced.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.runOnlyPostProcessingToolStripMenuItem,
|
||||
this.toolStripSeparatorRunOnlyPostprocessing,
|
||||
this.setCPPConstmeModelsFolderToolStripMenuItem,
|
||||
this.removeTemporaryFilesToolStripMenuItem});
|
||||
this.contextMenuStripWhisperAdvanced.Name = "contextMenuStripWhisperAdvanced";
|
||||
this.contextMenuStripWhisperAdvanced.Size = new System.Drawing.Size(259, 48);
|
||||
this.contextMenuStripWhisperAdvanced.Size = new System.Drawing.Size(259, 98);
|
||||
this.contextMenuStripWhisperAdvanced.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStripWhisperAdvanced_Opening);
|
||||
//
|
||||
// setCPPConstmeModelsFolderToolStripMenuItem
|
||||
@ -436,6 +440,18 @@
|
||||
this.labelEngine.TabIndex = 27;
|
||||
this.labelEngine.Text = "Engine";
|
||||
//
|
||||
// runOnlyPostProcessingToolStripMenuItem
|
||||
//
|
||||
this.runOnlyPostProcessingToolStripMenuItem.Name = "runOnlyPostProcessingToolStripMenuItem";
|
||||
this.runOnlyPostProcessingToolStripMenuItem.Size = new System.Drawing.Size(258, 22);
|
||||
this.runOnlyPostProcessingToolStripMenuItem.Text = "Run only post processing";
|
||||
this.runOnlyPostProcessingToolStripMenuItem.Click += new System.EventHandler(this.runOnlyPostProcessingToolStripMenuItem_Click);
|
||||
//
|
||||
// toolStripSeparatorRunOnlyPostprocessing
|
||||
//
|
||||
this.toolStripSeparatorRunOnlyPostprocessing.Name = "toolStripSeparatorRunOnlyPostprocessing";
|
||||
this.toolStripSeparatorRunOnlyPostprocessing.Size = new System.Drawing.Size(255, 6);
|
||||
//
|
||||
// WhisperAudioToText
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
@ -519,5 +535,7 @@
|
||||
private System.Windows.Forms.ComboBox comboBoxWhisperEngine;
|
||||
private System.Windows.Forms.Label labelEngine;
|
||||
private System.Windows.Forms.ToolStripMenuItem setCPPConstmeModelsFolderToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem runOnlyPostProcessingToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparatorRunOnlyPostprocessing;
|
||||
}
|
||||
}
|
@ -20,6 +20,7 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
public sealed partial class WhisperAudioToText : Form
|
||||
{
|
||||
private readonly string _videoFileName;
|
||||
private Subtitle _subtitle;
|
||||
private readonly int _audioTrackNumber;
|
||||
private bool _cancel;
|
||||
private bool _batchMode;
|
||||
@ -46,13 +47,14 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
|
||||
public Subtitle TranscribedSubtitle { get; private set; }
|
||||
|
||||
public WhisperAudioToText(string videoFileName, int audioTrackNumber, Form parentForm, WavePeakData wavePeaks)
|
||||
public WhisperAudioToText(string videoFileName, Subtitle subtitle, int audioTrackNumber, Form parentForm, WavePeakData wavePeaks)
|
||||
{
|
||||
UiUtil.PreInitialize(this);
|
||||
InitializeComponent();
|
||||
UiUtil.FixFonts(this);
|
||||
UiUtil.FixLargeFonts(this, buttonGenerate);
|
||||
_videoFileName = videoFileName;
|
||||
_subtitle = subtitle;
|
||||
_audioTrackNumber = audioTrackNumber;
|
||||
_parentForm = parentForm;
|
||||
_wavePeaks = wavePeaks;
|
||||
@ -75,7 +77,8 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
buttonAddFile.Text = LanguageSettings.Current.DvdSubRip.Add;
|
||||
buttonRemoveFile.Text = LanguageSettings.Current.DvdSubRip.Remove;
|
||||
buttonClear.Text = LanguageSettings.Current.DvdSubRip.Clear;
|
||||
setCPPConstmeModelsFolderToolStripMenuItem.Text = LanguageSettings.Current.AudioToText.ChooseLanguage;
|
||||
runOnlyPostProcessingToolStripMenuItem.Text = LanguageSettings.Current.AudioToText.OnlyRunPostProcessing;
|
||||
setCPPConstmeModelsFolderToolStripMenuItem.Text = LanguageSettings.Current.AudioToText.SetCppConstMeFolder;
|
||||
removeTemporaryFilesToolStripMenuItem.Text = LanguageSettings.Current.AudioToText.RemoveTemporaryFiles;
|
||||
|
||||
columnHeaderFileName.Text = LanguageSettings.Current.JoinSubtitles.FileName;
|
||||
@ -95,6 +98,17 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
listViewInputFiles.Items.Add(videoFileName);
|
||||
}
|
||||
|
||||
if (_subtitle == null || _subtitle.Paragraphs.Count == 0)
|
||||
{
|
||||
runOnlyPostProcessingToolStripMenuItem.Visible = false;
|
||||
toolStripSeparatorRunOnlyPostprocessing.Visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
runOnlyPostProcessingToolStripMenuItem.Visible = true;
|
||||
toolStripSeparatorRunOnlyPostprocessing.Visible = true;
|
||||
}
|
||||
|
||||
textBoxLog.Visible = false;
|
||||
textBoxLog.Dock = DockStyle.Fill;
|
||||
labelProgress.Text = string.Empty;
|
||||
@ -1491,11 +1505,46 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
if (!string.IsNullOrEmpty(Configuration.Settings.Tools.WhisperCppModelLocation) &&
|
||||
Directory.Exists(Configuration.Settings.Tools.WhisperCppModelLocation))
|
||||
{
|
||||
setCPPConstmeModelsFolderToolStripMenuItem.Text = $"Set CPP/Const-me models folder... [{Configuration.Settings.Tools.WhisperCppModelLocation}]";
|
||||
setCPPConstmeModelsFolderToolStripMenuItem.Text = $"{LanguageSettings.Current.AudioToText.SetCppConstMeFolder} [{Configuration.Settings.Tools.WhisperCppModelLocation}]";
|
||||
}
|
||||
else
|
||||
{
|
||||
setCPPConstmeModelsFolderToolStripMenuItem.Text = "Set CPP/Const-me models folder...";
|
||||
setCPPConstmeModelsFolderToolStripMenuItem.Text = LanguageSettings.Current.AudioToText.SetCppConstMeFolder;
|
||||
}
|
||||
}
|
||||
|
||||
private void runOnlyPostProcessingToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_languageCode = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle);
|
||||
var postProcessor = new AudioToTextPostProcessor(_languageCode)
|
||||
{
|
||||
ParagraphMaxChars = Configuration.Settings.General.SubtitleLineMaximumLength * 2,
|
||||
};
|
||||
|
||||
WavePeakData wavePeaks = null;
|
||||
if (checkBoxAutoAdjustTimings.Checked)
|
||||
{
|
||||
wavePeaks = _wavePeaks ?? MakeWavePeaks();
|
||||
}
|
||||
|
||||
if (checkBoxAutoAdjustTimings.Checked && wavePeaks != null)
|
||||
{
|
||||
_subtitle = WhisperTimingFixer.ShortenLongTexts(_subtitle);
|
||||
_subtitle = WhisperTimingFixer.ShortenViaWavePeaks(_subtitle, wavePeaks);
|
||||
}
|
||||
|
||||
TranscribedSubtitle = postProcessor.Fix(AudioToTextPostProcessor.Engine.Whisper, _subtitle, true, true, true, true, true, true);
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
finally
|
||||
{
|
||||
buttonGenerate.Enabled = true;
|
||||
buttonDownload.Enabled = true;
|
||||
buttonBatchMode.Enabled = true;
|
||||
comboBoxLanguages.Enabled = true;
|
||||
comboBoxModels.Enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34813,7 +34813,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
CloseVideoToolStripMenuItemClick(sender, e);
|
||||
}
|
||||
|
||||
using (var form = new WhisperAudioToText(oldVideoFileName, _videoAudioTrackNumber, this, audioVisualizer?.WavePeaks))
|
||||
using (var form = new WhisperAudioToText(oldVideoFileName, _subtitle, _videoAudioTrackNumber, this, audioVisualizer?.WavePeaks))
|
||||
{
|
||||
var result = form.ShowDialog(this);
|
||||
|
||||
|
@ -350,6 +350,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
MaxCharsPerSubtitle = "Max. chars per subtitle line",
|
||||
RemoveTemporaryFiles = "Remove temporary files",
|
||||
SetCppConstMeFolder = "Set CPP/Const-me models folder...",
|
||||
OnlyRunPostProcessing = "",
|
||||
};
|
||||
|
||||
AssaAttachments = new LanguageStructure.AssaAttachments
|
||||
|
@ -207,6 +207,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
public string MaxCharsPerSubtitle { get; set; }
|
||||
public string RemoveTemporaryFiles { get; set; }
|
||||
public string SetCppConstMeFolder { get; set; }
|
||||
public string OnlyRunPostProcessing { get; set; }
|
||||
}
|
||||
|
||||
public class AssaAttachments
|
||||
|
Loading…
Reference in New Issue
Block a user