mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-10-27 22:42:38 +01:00
Audio to text: Select model after download + fix tab stops
This commit is contained in:
parent
ff03ad42e5
commit
00811a6169
12
src/ui/Forms/AudioToText.Designer.cs
generated
12
src/ui/Forms/AudioToText.Designer.cs
generated
@ -63,7 +63,7 @@
|
||||
this.buttonCancel.Location = new System.Drawing.Point(622, 427);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonCancel.TabIndex = 8;
|
||||
this.buttonCancel.TabIndex = 10;
|
||||
this.buttonCancel.Text = "C&ancel";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
|
||||
@ -75,7 +75,7 @@
|
||||
this.buttonGenerate.Location = new System.Drawing.Point(373, 427);
|
||||
this.buttonGenerate.Name = "buttonGenerate";
|
||||
this.buttonGenerate.Size = new System.Drawing.Size(125, 23);
|
||||
this.buttonGenerate.TabIndex = 6;
|
||||
this.buttonGenerate.TabIndex = 8;
|
||||
this.buttonGenerate.Text = "&Generate";
|
||||
this.buttonGenerate.UseVisualStyleBackColor = true;
|
||||
this.buttonGenerate.Click += new System.EventHandler(this.ButtonGenerate_Click);
|
||||
@ -87,7 +87,7 @@
|
||||
this.progressBar1.Location = new System.Drawing.Point(12, 427);
|
||||
this.progressBar1.Name = "progressBar1";
|
||||
this.progressBar1.Size = new System.Drawing.Size(355, 12);
|
||||
this.progressBar1.TabIndex = 5;
|
||||
this.progressBar1.TabIndex = 7;
|
||||
this.progressBar1.Visible = false;
|
||||
//
|
||||
// labelProgress
|
||||
@ -97,7 +97,7 @@
|
||||
this.labelProgress.Location = new System.Drawing.Point(12, 409);
|
||||
this.labelProgress.Name = "labelProgress";
|
||||
this.labelProgress.Size = new System.Drawing.Size(70, 13);
|
||||
this.labelProgress.TabIndex = 4;
|
||||
this.labelProgress.TabIndex = 6;
|
||||
this.labelProgress.Text = "labelProgress";
|
||||
//
|
||||
// textBoxLog
|
||||
@ -153,7 +153,7 @@
|
||||
this.linkLabelOpenModelsFolder.Location = new System.Drawing.Point(301, 51);
|
||||
this.linkLabelOpenModelsFolder.Name = "linkLabelOpenModelsFolder";
|
||||
this.linkLabelOpenModelsFolder.Size = new System.Drawing.Size(98, 13);
|
||||
this.linkLabelOpenModelsFolder.TabIndex = 0;
|
||||
this.linkLabelOpenModelsFolder.TabIndex = 3;
|
||||
this.linkLabelOpenModelsFolder.TabStop = true;
|
||||
this.linkLabelOpenModelsFolder.Text = "Open models folder";
|
||||
this.linkLabelOpenModelsFolder.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabelOpenModelFolder_LinkClicked);
|
||||
@ -220,7 +220,7 @@
|
||||
this.buttonBatchMode.Location = new System.Drawing.Point(504, 427);
|
||||
this.buttonBatchMode.Name = "buttonBatchMode";
|
||||
this.buttonBatchMode.Size = new System.Drawing.Size(112, 23);
|
||||
this.buttonBatchMode.TabIndex = 7;
|
||||
this.buttonBatchMode.TabIndex = 9;
|
||||
this.buttonBatchMode.Text = "Batch mode";
|
||||
this.buttonBatchMode.UseVisualStyleBackColor = true;
|
||||
this.buttonBatchMode.Click += new System.EventHandler(this.buttonBatchMode_Click);
|
||||
|
@ -64,7 +64,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
checkBoxUsePostProcessing.Checked = Configuration.Settings.Tools.VoskPostProcessing;
|
||||
_voskFolder = Path.Combine(Configuration.DataDirectory, "Vosk");
|
||||
FillModels();
|
||||
FillModels(string.Empty);
|
||||
|
||||
textBoxLog.Visible = false;
|
||||
textBoxLog.Dock = DockStyle.Fill;
|
||||
@ -85,8 +85,9 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
listViewInputFiles.Visible = false;
|
||||
}
|
||||
|
||||
private void FillModels()
|
||||
private void FillModels(string lastDownloadedModel)
|
||||
{
|
||||
var selectName = string.IsNullOrEmpty(lastDownloadedModel) ? Configuration.Settings.Tools.VoskModel : lastDownloadedModel;
|
||||
comboBoxModels.Items.Clear();
|
||||
foreach (var directory in Directory.GetDirectories(_voskFolder))
|
||||
{
|
||||
@ -97,7 +98,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
comboBoxModels.Items.Add(name);
|
||||
if (name == Configuration.Settings.Tools.VoskModel)
|
||||
if (name == selectName)
|
||||
{
|
||||
comboBoxModels.SelectedIndex = comboBoxModels.Items.Count - 1;
|
||||
}
|
||||
@ -140,6 +141,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
buttonGenerate.Enabled = false;
|
||||
buttonDownload.Enabled = false;
|
||||
buttonBatchMode.Enabled = false;
|
||||
comboBoxModels.Enabled = false;
|
||||
var waveFileName = GenerateWavFile(_videoFileName, _audioTrackNumber);
|
||||
textBoxLog.AppendText("Wav file name: " + waveFileName);
|
||||
textBoxLog.AppendText(Environment.NewLine);
|
||||
@ -570,10 +572,10 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
private void buttonDownload_Click(object sender, EventArgs e)
|
||||
{
|
||||
using (var form = new AudioToTextModelDownload() { AutoClose = true })
|
||||
using (var form = new AudioToTextModelDownload { AutoClose = true })
|
||||
{
|
||||
form.ShowDialog(this);
|
||||
FillModels();
|
||||
FillModels(form.LastDownloadedModel);
|
||||
}
|
||||
}
|
||||
|
||||
@ -620,12 +622,14 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
if (_batchMode)
|
||||
{
|
||||
groupBoxInputFiles.Enabled = true;
|
||||
Height = checkBoxUsePostProcessing.Bottom + progressBar1.Height + buttonCancel.Height + 450;
|
||||
listViewInputFiles.Visible = true;
|
||||
buttonBatchMode.Text = LanguageSettings.Current.Split.Basic;
|
||||
}
|
||||
else
|
||||
{
|
||||
groupBoxInputFiles.Enabled = false;
|
||||
Height = checkBoxUsePostProcessing.Bottom + progressBar1.Height + buttonCancel.Height + 70;
|
||||
listViewInputFiles.Visible = false;
|
||||
buttonBatchMode.Text = LanguageSettings.Current.AudioToText.BatchMode;
|
||||
|
@ -42,7 +42,7 @@
|
||||
this.labelPleaseWait.Location = new System.Drawing.Point(12, 92);
|
||||
this.labelPleaseWait.Name = "labelPleaseWait";
|
||||
this.labelPleaseWait.Size = new System.Drawing.Size(70, 13);
|
||||
this.labelPleaseWait.TabIndex = 2;
|
||||
this.labelPleaseWait.TabIndex = 3;
|
||||
this.labelPleaseWait.Text = "Please wait...";
|
||||
//
|
||||
// buttonDownload
|
||||
@ -64,7 +64,7 @@
|
||||
this.buttonCancel.Location = new System.Drawing.Point(328, 87);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonCancel.TabIndex = 3;
|
||||
this.buttonCancel.TabIndex = 4;
|
||||
this.buttonCancel.Text = "Cancel";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
|
||||
@ -88,7 +88,7 @@
|
||||
this.textBoxError.Name = "textBoxError";
|
||||
this.textBoxError.ReadOnly = true;
|
||||
this.textBoxError.Size = new System.Drawing.Size(388, 12);
|
||||
this.textBoxError.TabIndex = 19;
|
||||
this.textBoxError.TabIndex = 2;
|
||||
//
|
||||
// AudioToTextModelDownload
|
||||
//
|
||||
|
@ -12,6 +12,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
public sealed partial class AudioToTextModelDownload : Form
|
||||
{
|
||||
public bool AutoClose { get; internal set; }
|
||||
public string LastDownloadedModel { get; internal set; }
|
||||
private readonly CancellationTokenSource _cancellationTokenSource;
|
||||
|
||||
public AudioToTextModelDownload()
|
||||
@ -123,6 +124,11 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
var dir = zip.ReadCentralDir();
|
||||
foreach (var entry in dir)
|
||||
{
|
||||
if (LastDownloadedModel == null)
|
||||
{
|
||||
LastDownloadedModel = Path.GetDirectoryName(entry.FilenameInZip);
|
||||
}
|
||||
|
||||
var path = Path.Combine(folder, entry.FilenameInZip);
|
||||
zip.ExtractFile(entry, path);
|
||||
}
|
||||
@ -131,6 +137,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
Cursor = Cursors.Default;
|
||||
labelPleaseWait.Text = string.Empty;
|
||||
|
||||
|
||||
|
||||
if (AutoClose)
|
||||
{
|
||||
DialogResult = DialogResult.OK;
|
||||
|
24
src/ui/Forms/AudioToTextSelectedLines.Designer.cs
generated
24
src/ui/Forms/AudioToTextSelectedLines.Designer.cs
generated
@ -59,7 +59,7 @@
|
||||
this.buttonCancel.Location = new System.Drawing.Point(622, 427);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonCancel.TabIndex = 8;
|
||||
this.buttonCancel.TabIndex = 6;
|
||||
this.buttonCancel.Text = "C&ancel";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
|
||||
@ -68,10 +68,10 @@
|
||||
//
|
||||
this.buttonGenerate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonGenerate.ImeMode = System.Windows.Forms.ImeMode.NoControl;
|
||||
this.buttonGenerate.Location = new System.Drawing.Point(373, 427);
|
||||
this.buttonGenerate.Location = new System.Drawing.Point(491, 427);
|
||||
this.buttonGenerate.Name = "buttonGenerate";
|
||||
this.buttonGenerate.Size = new System.Drawing.Size(125, 23);
|
||||
this.buttonGenerate.TabIndex = 6;
|
||||
this.buttonGenerate.TabIndex = 5;
|
||||
this.buttonGenerate.Text = "&Generate";
|
||||
this.buttonGenerate.UseVisualStyleBackColor = true;
|
||||
this.buttonGenerate.Click += new System.EventHandler(this.ButtonGenerate_Click);
|
||||
@ -82,8 +82,8 @@
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.progressBar1.Location = new System.Drawing.Point(12, 427);
|
||||
this.progressBar1.Name = "progressBar1";
|
||||
this.progressBar1.Size = new System.Drawing.Size(355, 12);
|
||||
this.progressBar1.TabIndex = 5;
|
||||
this.progressBar1.Size = new System.Drawing.Size(473, 12);
|
||||
this.progressBar1.TabIndex = 4;
|
||||
this.progressBar1.Visible = false;
|
||||
//
|
||||
// labelProgress
|
||||
@ -128,7 +128,7 @@
|
||||
this.groupBoxModels.Location = new System.Drawing.Point(15, 66);
|
||||
this.groupBoxModels.Name = "groupBoxModels";
|
||||
this.groupBoxModels.Size = new System.Drawing.Size(682, 82);
|
||||
this.groupBoxModels.TabIndex = 3;
|
||||
this.groupBoxModels.TabIndex = 1;
|
||||
this.groupBoxModels.TabStop = false;
|
||||
this.groupBoxModels.Text = "Models";
|
||||
//
|
||||
@ -138,7 +138,7 @@
|
||||
this.buttonDownload.Location = new System.Drawing.Point(265, 43);
|
||||
this.buttonDownload.Name = "buttonDownload";
|
||||
this.buttonDownload.Size = new System.Drawing.Size(28, 23);
|
||||
this.buttonDownload.TabIndex = 2;
|
||||
this.buttonDownload.TabIndex = 1;
|
||||
this.buttonDownload.Text = "...";
|
||||
this.buttonDownload.UseVisualStyleBackColor = true;
|
||||
this.buttonDownload.Click += new System.EventHandler(this.buttonDownload_Click);
|
||||
@ -149,7 +149,7 @@
|
||||
this.linkLabelOpenModelsFolder.Location = new System.Drawing.Point(301, 51);
|
||||
this.linkLabelOpenModelsFolder.Name = "linkLabelOpenModelsFolder";
|
||||
this.linkLabelOpenModelsFolder.Size = new System.Drawing.Size(98, 13);
|
||||
this.linkLabelOpenModelsFolder.TabIndex = 0;
|
||||
this.linkLabelOpenModelsFolder.TabIndex = 2;
|
||||
this.linkLabelOpenModelsFolder.TabStop = true;
|
||||
this.linkLabelOpenModelsFolder.Text = "Open models folder";
|
||||
this.linkLabelOpenModelsFolder.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabelOpenModelFolder_LinkClicked);
|
||||
@ -170,7 +170,7 @@
|
||||
this.comboBoxModels.Location = new System.Drawing.Point(19, 45);
|
||||
this.comboBoxModels.Name = "comboBoxModels";
|
||||
this.comboBoxModels.Size = new System.Drawing.Size(240, 21);
|
||||
this.comboBoxModels.TabIndex = 1;
|
||||
this.comboBoxModels.TabIndex = 0;
|
||||
this.comboBoxModels.SelectedIndexChanged += new System.EventHandler(this.comboBoxModels_SelectedIndexChanged);
|
||||
//
|
||||
// linkLabelVoskWebSite
|
||||
@ -179,7 +179,7 @@
|
||||
this.linkLabelVoskWebSite.Location = new System.Drawing.Point(12, 26);
|
||||
this.linkLabelVoskWebSite.Name = "linkLabelVoskWebSite";
|
||||
this.linkLabelVoskWebSite.Size = new System.Drawing.Size(70, 13);
|
||||
this.linkLabelVoskWebSite.TabIndex = 2;
|
||||
this.linkLabelVoskWebSite.TabIndex = 0;
|
||||
this.linkLabelVoskWebSite.TabStop = true;
|
||||
this.linkLabelVoskWebSite.Text = "Vosk website";
|
||||
this.linkLabelVoskWebSite.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabelVoskWebsite_LinkClicked);
|
||||
@ -205,7 +205,7 @@
|
||||
this.checkBoxUsePostProcessing.Location = new System.Drawing.Point(15, 162);
|
||||
this.checkBoxUsePostProcessing.Name = "checkBoxUsePostProcessing";
|
||||
this.checkBoxUsePostProcessing.Size = new System.Drawing.Size(312, 17);
|
||||
this.checkBoxUsePostProcessing.TabIndex = 4;
|
||||
this.checkBoxUsePostProcessing.TabIndex = 2;
|
||||
this.checkBoxUsePostProcessing.Text = "Use post-processing (line merge, fix casing, and punctuation)";
|
||||
this.checkBoxUsePostProcessing.UseVisualStyleBackColor = true;
|
||||
//
|
||||
@ -218,7 +218,7 @@
|
||||
this.groupBoxInputFiles.Location = new System.Drawing.Point(15, 200);
|
||||
this.groupBoxInputFiles.Name = "groupBoxInputFiles";
|
||||
this.groupBoxInputFiles.Size = new System.Drawing.Size(682, 185);
|
||||
this.groupBoxInputFiles.TabIndex = 5;
|
||||
this.groupBoxInputFiles.TabIndex = 3;
|
||||
this.groupBoxInputFiles.TabStop = false;
|
||||
this.groupBoxInputFiles.Text = "Input files";
|
||||
//
|
||||
|
@ -49,7 +49,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
checkBoxUsePostProcessing.Checked = Configuration.Settings.Tools.VoskPostProcessing;
|
||||
_voskFolder = Path.Combine(Configuration.DataDirectory, "Vosk");
|
||||
FillModels();
|
||||
FillModels(string.Empty);
|
||||
|
||||
textBoxLog.Visible = false;
|
||||
textBoxLog.Dock = DockStyle.Fill;
|
||||
@ -64,8 +64,9 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
|
||||
private void FillModels()
|
||||
private void FillModels(string lastDownloadedModel)
|
||||
{
|
||||
var selectName = string.IsNullOrEmpty(lastDownloadedModel) ? Configuration.Settings.Tools.VoskModel : lastDownloadedModel;
|
||||
comboBoxModels.Items.Clear();
|
||||
foreach (var directory in Directory.GetDirectories(_voskFolder))
|
||||
{
|
||||
@ -76,7 +77,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
comboBoxModels.Items.Add(name);
|
||||
if (name == Configuration.Settings.Tools.VoskModel)
|
||||
if (name == selectName)
|
||||
{
|
||||
comboBoxModels.SelectedIndex = comboBoxModels.Items.Count - 1;
|
||||
}
|
||||
@ -125,6 +126,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
var modelFileName = Path.Combine(_voskFolder, comboBoxModels.Text);
|
||||
buttonGenerate.Enabled = false;
|
||||
buttonDownload.Enabled = false;
|
||||
comboBoxModels.Enabled = false;
|
||||
var waveFileName = videoFileName;
|
||||
textBoxLog.AppendText("Wav file name: " + waveFileName + Environment.NewLine);
|
||||
var transcript = TranscribeViaVosk(waveFileName, modelFileName);
|
||||
@ -382,10 +384,10 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
private void buttonDownload_Click(object sender, EventArgs e)
|
||||
{
|
||||
using (var form = new AudioToTextModelDownload() { AutoClose = true })
|
||||
using (var form = new AudioToTextModelDownload { AutoClose = true })
|
||||
{
|
||||
form.ShowDialog(this);
|
||||
FillModels();
|
||||
FillModels(form.LastDownloadedModel);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user