mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-25 12:44:46 +01:00
Testing #6816 a little
This commit is contained in:
parent
bf7f80a462
commit
415d714a43
@ -1,6 +1,5 @@
|
||||
using System.IO;
|
||||
using System;
|
||||
using Nikse.SubtitleEdit.Core.Common;
|
||||
using Nikse.SubtitleEdit.Core.Common;
|
||||
using System.IO;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.AudioToText
|
||||
{
|
||||
|
@ -6,5 +6,6 @@
|
||||
public const string Cpp = "CPP";
|
||||
public const string WhisperX = "WhisperX";
|
||||
public const string ConstMe = "ConstMe";
|
||||
public const string CTranslate2 = "CTranslate2";
|
||||
}
|
||||
}
|
||||
|
@ -45,6 +45,11 @@ namespace Nikse.SubtitleEdit.Core.AudioToText
|
||||
return "https://github.com/Const-me/Whisper";
|
||||
}
|
||||
|
||||
if (Configuration.Settings.Tools.WhisperChoice == WhisperChoice.CTranslate2)
|
||||
{
|
||||
return "https://github.com/jordimas/whisper-ctranslate2";
|
||||
}
|
||||
|
||||
return "https://github.com/openai/whisper";
|
||||
}
|
||||
|
||||
@ -90,6 +95,23 @@ namespace Nikse.SubtitleEdit.Core.AudioToText
|
||||
}
|
||||
}
|
||||
|
||||
if (Configuration.Settings.Tools.WhisperChoice == WhisperChoice.CTranslate2)
|
||||
{
|
||||
var location = Configuration.Settings.Tools.WhisperCtranslate2Location;
|
||||
if (!string.IsNullOrEmpty(location))
|
||||
{
|
||||
if (location.EndsWith("whisper-ctranslate2.exe", StringComparison.InvariantCultureIgnoreCase) && File.Exists(location))
|
||||
{
|
||||
return Path.GetDirectoryName(location);
|
||||
}
|
||||
|
||||
if (Directory.Exists(location) && File.Exists(Path.Combine(location, "whisper-ctranslate2.exe")))
|
||||
{
|
||||
return location;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Configuration.Settings.Tools.WhisperChoice == WhisperChoice.Cpp)
|
||||
{
|
||||
var path = Path.Combine(Configuration.DataDirectory, "Whisper");
|
||||
@ -134,6 +156,19 @@ namespace Nikse.SubtitleEdit.Core.AudioToText
|
||||
{
|
||||
return Path.Combine(dir, "Scripts");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if (Configuration.Settings.Tools.WhisperChoice == WhisperChoice.CTranslate2)
|
||||
{
|
||||
var whisperCTranslate2FullPath = Path.Combine(dir, "Scripts", "whisper-ctranslate2.exe");
|
||||
if (File.Exists(whisperCTranslate2FullPath))
|
||||
{
|
||||
return Path.Combine(dir, "Scripts");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
var whisperFullPath = Path.Combine(dir, "Scripts", "whisper.exe");
|
||||
@ -163,6 +198,11 @@ namespace Nikse.SubtitleEdit.Core.AudioToText
|
||||
return "main";
|
||||
}
|
||||
|
||||
if (Configuration.Settings.Tools.WhisperChoice == WhisperChoice.CTranslate2)
|
||||
{
|
||||
return "whisper-ctranslate2";
|
||||
}
|
||||
|
||||
if (Configuration.Settings.Tools.WhisperChoice == WhisperChoice.WhisperX)
|
||||
{
|
||||
return "whisperx";
|
||||
@ -194,6 +234,14 @@ namespace Nikse.SubtitleEdit.Core.AudioToText
|
||||
return f;
|
||||
}
|
||||
}
|
||||
else if (Configuration.Settings.Tools.WhisperChoice == WhisperChoice.CTranslate2)
|
||||
{
|
||||
var f = Path.Combine(whisperFolder, "whisper-ctranslate2.exe");
|
||||
if (File.Exists(f))
|
||||
{
|
||||
return f;
|
||||
}
|
||||
}
|
||||
else if (Configuration.Settings.Tools.WhisperChoice == WhisperChoice.ConstMe)
|
||||
{
|
||||
var f = Path.Combine(whisperFolder, "main.exe");
|
||||
@ -230,6 +278,16 @@ namespace Nikse.SubtitleEdit.Core.AudioToText
|
||||
return f;
|
||||
}
|
||||
}
|
||||
else if (Configuration.Settings.Tools.WhisperChoice == WhisperChoice.CTranslate2)
|
||||
{
|
||||
var f = Path.Combine(whisperFolder, "whisper-ctranslate2");
|
||||
if (File.Exists(f))
|
||||
{
|
||||
return f;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return "whisper";
|
||||
}
|
||||
|
@ -430,7 +430,9 @@ namespace Nikse.SubtitleEdit.Core.Common
|
||||
public string WhisperModel { get; set; }
|
||||
public string WhisperLanguageCode { get; set; }
|
||||
public string WhisperLocation { get; set; }
|
||||
public string WhisperCtranslate2Location { get; set; }
|
||||
public string WhisperXLocation { get; set; }
|
||||
public string WhisperCppModelLocation { get; set; }
|
||||
public string WhisperExtraSettings { get; set; }
|
||||
public bool WhisperAutoAdjustTimings { get; set; }
|
||||
public int AudioToTextLineMaxChars { get; set; }
|
||||
@ -6348,6 +6350,18 @@ $HorzAlign = Center
|
||||
settings.Tools.WhisperXLocation = subNode.InnerText;
|
||||
}
|
||||
|
||||
subNode = node.SelectSingleNode("WhisperCppModelLocation");
|
||||
if (subNode != null)
|
||||
{
|
||||
settings.Tools.WhisperCppModelLocation = subNode.InnerText;
|
||||
}
|
||||
|
||||
subNode = node.SelectSingleNode("WhisperCtranslate2Location");
|
||||
if (subNode != null)
|
||||
{
|
||||
settings.Tools.WhisperCtranslate2Location = subNode.InnerText;
|
||||
}
|
||||
|
||||
subNode = node.SelectSingleNode("WhisperExtraSettings");
|
||||
if (subNode != null)
|
||||
{
|
||||
@ -10714,7 +10728,9 @@ $HorzAlign = Center
|
||||
textWriter.WriteElementString("WhisperDeleteTempFiles", settings.Tools.WhisperDeleteTempFiles.ToString(CultureInfo.InvariantCulture));
|
||||
textWriter.WriteElementString("WhisperModel", settings.Tools.WhisperModel);
|
||||
textWriter.WriteElementString("WhisperLocation", settings.Tools.WhisperLocation);
|
||||
textWriter.WriteElementString("WhisperCtranslate2Location", settings.Tools.WhisperCtranslate2Location);
|
||||
textWriter.WriteElementString("WhisperXLocation", settings.Tools.WhisperXLocation);
|
||||
textWriter.WriteElementString("WhisperCppModelLocation", settings.Tools.WhisperCppModelLocation);
|
||||
textWriter.WriteElementString("WhisperExtraSettings", settings.Tools.WhisperExtraSettings);
|
||||
textWriter.WriteElementString("WhisperLanguageCode", settings.Tools.WhisperLanguageCode);
|
||||
textWriter.WriteElementString("WhisperAutoAdjustTimings", settings.Tools.WhisperAutoAdjustTimings.ToString(CultureInfo.InvariantCulture));
|
||||
|
@ -55,17 +55,15 @@
|
||||
this.columnHeaderFileName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.labelFC = new System.Windows.Forms.Label();
|
||||
this.checkBoxTranslateToEnglish = new System.Windows.Forms.CheckBox();
|
||||
this.labelCpp = new System.Windows.Forms.Label();
|
||||
this.labelElapsed = new System.Windows.Forms.Label();
|
||||
this.contextMenuStripWhisperAdvanced = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.whisperPhpOriginalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.whisperCppCToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.whisperConstMeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.removeTemporaryFilesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.checkBoxAutoAdjustTimings = new System.Windows.Forms.CheckBox();
|
||||
this.labelCharsPerSub = new System.Windows.Forms.Label();
|
||||
this.comboBoxCharsPerSub = new System.Windows.Forms.ComboBox();
|
||||
this.comboBoxWhisperEngine = new System.Windows.Forms.ComboBox();
|
||||
this.labelEngine = new System.Windows.Forms.Label();
|
||||
this.setCPPConstmeModelsFolderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.groupBoxModels.SuspendLayout();
|
||||
this.groupBoxInputFiles.SuspendLayout();
|
||||
this.contextMenuStripWhisperAdvanced.SuspendLayout();
|
||||
@ -356,18 +354,6 @@
|
||||
this.checkBoxTranslateToEnglish.Text = "Translate to English";
|
||||
this.checkBoxTranslateToEnglish.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// labelCpp
|
||||
//
|
||||
this.labelCpp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.labelCpp.ForeColor = System.Drawing.SystemColors.ControlDark;
|
||||
this.labelCpp.Location = new System.Drawing.Point(580, 9);
|
||||
this.labelCpp.Name = "labelCpp";
|
||||
this.labelCpp.Size = new System.Drawing.Size(117, 30);
|
||||
this.labelCpp.TabIndex = 21;
|
||||
this.labelCpp.Text = "CPP";
|
||||
this.labelCpp.TextAlign = System.Drawing.ContentAlignment.TopRight;
|
||||
this.labelCpp.Click += new System.EventHandler(this.labelCpp_Click);
|
||||
//
|
||||
// labelElapsed
|
||||
//
|
||||
this.labelElapsed.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
@ -381,39 +367,10 @@
|
||||
// contextMenuStripWhisperAdvanced
|
||||
//
|
||||
this.contextMenuStripWhisperAdvanced.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.whisperPhpOriginalToolStripMenuItem,
|
||||
this.whisperCppCToolStripMenuItem,
|
||||
this.whisperConstMeToolStripMenuItem,
|
||||
this.toolStripSeparator1,
|
||||
this.setCPPConstmeModelsFolderToolStripMenuItem,
|
||||
this.removeTemporaryFilesToolStripMenuItem});
|
||||
this.contextMenuStripWhisperAdvanced.Name = "contextMenuStripWhisperAdvanced";
|
||||
this.contextMenuStripWhisperAdvanced.Size = new System.Drawing.Size(210, 98);
|
||||
//
|
||||
// whisperPhpOriginalToolStripMenuItem
|
||||
//
|
||||
this.whisperPhpOriginalToolStripMenuItem.Name = "whisperPhpOriginalToolStripMenuItem";
|
||||
this.whisperPhpOriginalToolStripMenuItem.Size = new System.Drawing.Size(209, 22);
|
||||
this.whisperPhpOriginalToolStripMenuItem.Text = "Whisper OpenAI (Python)";
|
||||
this.whisperPhpOriginalToolStripMenuItem.Click += new System.EventHandler(this.whisperPhpOriginalToolStripMenuItem_Click);
|
||||
//
|
||||
// whisperCppCToolStripMenuItem
|
||||
//
|
||||
this.whisperCppCToolStripMenuItem.Name = "whisperCppCToolStripMenuItem";
|
||||
this.whisperCppCToolStripMenuItem.Size = new System.Drawing.Size(209, 22);
|
||||
this.whisperCppCToolStripMenuItem.Text = "Whisper cpp (C++)";
|
||||
this.whisperCppCToolStripMenuItem.Click += new System.EventHandler(this.whisperCppCToolStripMenuItem_Click);
|
||||
//
|
||||
// whisperConstMeToolStripMenuItem
|
||||
//
|
||||
this.whisperConstMeToolStripMenuItem.Name = "whisperConstMeToolStripMenuItem";
|
||||
this.whisperConstMeToolStripMenuItem.Size = new System.Drawing.Size(209, 22);
|
||||
this.whisperConstMeToolStripMenuItem.Text = "Whisper Const-me (GPU)";
|
||||
this.whisperConstMeToolStripMenuItem.Click += new System.EventHandler(this.whisperConstMeToolStripMenuItem_Click);
|
||||
//
|
||||
// toolStripSeparator1
|
||||
//
|
||||
this.toolStripSeparator1.Name = "toolStripSeparator1";
|
||||
this.toolStripSeparator1.Size = new System.Drawing.Size(206, 6);
|
||||
this.contextMenuStripWhisperAdvanced.Size = new System.Drawing.Size(259, 70);
|
||||
//
|
||||
// removeTemporaryFilesToolStripMenuItem
|
||||
//
|
||||
@ -450,16 +407,44 @@
|
||||
this.comboBoxCharsPerSub.Size = new System.Drawing.Size(79, 21);
|
||||
this.comboBoxCharsPerSub.TabIndex = 25;
|
||||
//
|
||||
// comboBoxWhisperEngine
|
||||
//
|
||||
this.comboBoxWhisperEngine.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.comboBoxWhisperEngine.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxWhisperEngine.FormattingEnabled = true;
|
||||
this.comboBoxWhisperEngine.Location = new System.Drawing.Point(547, 9);
|
||||
this.comboBoxWhisperEngine.Name = "comboBoxWhisperEngine";
|
||||
this.comboBoxWhisperEngine.Size = new System.Drawing.Size(154, 21);
|
||||
this.comboBoxWhisperEngine.TabIndex = 26;
|
||||
this.comboBoxWhisperEngine.SelectedIndexChanged += new System.EventHandler(this.comboBoxWhisperEngine_SelectedIndexChanged);
|
||||
//
|
||||
// labelEngine
|
||||
//
|
||||
this.labelEngine.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.labelEngine.AutoSize = true;
|
||||
this.labelEngine.Location = new System.Drawing.Point(501, 12);
|
||||
this.labelEngine.Name = "labelEngine";
|
||||
this.labelEngine.Size = new System.Drawing.Size(40, 13);
|
||||
this.labelEngine.TabIndex = 27;
|
||||
this.labelEngine.Text = "Engine";
|
||||
//
|
||||
// setCPPConstmeModelsFolderToolStripMenuItem
|
||||
//
|
||||
this.setCPPConstmeModelsFolderToolStripMenuItem.Name = "setCPPConstmeModelsFolderToolStripMenuItem";
|
||||
this.setCPPConstmeModelsFolderToolStripMenuItem.Size = new System.Drawing.Size(258, 22);
|
||||
this.setCPPConstmeModelsFolderToolStripMenuItem.Text = "Set CPP/Const-me models folder...";
|
||||
//
|
||||
// WhisperAudioToText
|
||||
//
|
||||
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.labelEngine);
|
||||
this.Controls.Add(this.comboBoxWhisperEngine);
|
||||
this.Controls.Add(this.comboBoxCharsPerSub);
|
||||
this.Controls.Add(this.labelCharsPerSub);
|
||||
this.Controls.Add(this.labelElapsed);
|
||||
this.Controls.Add(this.checkBoxAutoAdjustTimings);
|
||||
this.Controls.Add(this.labelCpp);
|
||||
this.Controls.Add(this.checkBoxTranslateToEnglish);
|
||||
this.Controls.Add(this.labelFC);
|
||||
this.Controls.Add(this.groupBoxInputFiles);
|
||||
@ -523,16 +508,14 @@
|
||||
private System.Windows.Forms.Label labelChooseLanguage;
|
||||
private System.Windows.Forms.ComboBox comboBoxLanguages;
|
||||
private System.Windows.Forms.CheckBox checkBoxTranslateToEnglish;
|
||||
private System.Windows.Forms.Label labelCpp;
|
||||
private System.Windows.Forms.Label labelElapsed;
|
||||
private System.Windows.Forms.ContextMenuStrip contextMenuStripWhisperAdvanced;
|
||||
private System.Windows.Forms.ToolStripMenuItem whisperPhpOriginalToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem whisperCppCToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
|
||||
private System.Windows.Forms.ToolStripMenuItem removeTemporaryFilesToolStripMenuItem;
|
||||
private System.Windows.Forms.CheckBox checkBoxAutoAdjustTimings;
|
||||
private System.Windows.Forms.ToolStripMenuItem whisperConstMeToolStripMenuItem;
|
||||
private System.Windows.Forms.Label labelCharsPerSub;
|
||||
private System.Windows.Forms.ComboBox comboBoxCharsPerSub;
|
||||
private System.Windows.Forms.ComboBox comboBoxWhisperEngine;
|
||||
private System.Windows.Forms.Label labelEngine;
|
||||
private System.Windows.Forms.ToolStripMenuItem setCPPConstmeModelsFolderToolStripMenuItem;
|
||||
}
|
||||
}
|
@ -14,6 +14,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
using Vosk;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
{
|
||||
@ -100,9 +101,11 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
listViewInputFiles.Visible = false;
|
||||
labelElapsed.Text = string.Empty;
|
||||
|
||||
labelEngine.Left = comboBoxWhisperEngine.Left - labelEngine.Width - 5;
|
||||
|
||||
comboBoxCharsPerSub.BeginUpdate();
|
||||
comboBoxCharsPerSub.Items.Add(LanguageSettings.Current.General.None);
|
||||
for (var i= 1; i<99; i++)
|
||||
for (var i = 1; i < 99; i++)
|
||||
{
|
||||
comboBoxCharsPerSub.Items.Add(i.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
@ -122,6 +125,28 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
}
|
||||
|
||||
comboBoxCharsPerSub.Text = maxChars.ToString(CultureInfo.InvariantCulture);
|
||||
|
||||
comboBoxWhisperEngine.Items.Clear();
|
||||
var engines = new List<string>()
|
||||
{
|
||||
WhisperChoice.OpenAI,
|
||||
WhisperChoice.Cpp,
|
||||
WhisperChoice.ConstMe,
|
||||
WhisperChoice.CTranslate2,
|
||||
};
|
||||
foreach (var engine in engines)
|
||||
{
|
||||
comboBoxWhisperEngine.Items.Add(engine);
|
||||
if (engine == Configuration.Settings.Tools.WhisperChoice)
|
||||
{
|
||||
comboBoxWhisperEngine.SelectedIndex = comboBoxWhisperEngine.Items.Count - 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (comboBoxWhisperEngine.SelectedIndex < 0)
|
||||
{
|
||||
comboBoxWhisperEngine.SelectedIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void Init()
|
||||
@ -134,19 +159,15 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
FillModels(comboBoxModels, string.Empty);
|
||||
|
||||
labelFC.Text = string.Empty;
|
||||
labelCpp.Text = Configuration.Settings.Tools.WhisperChoice;
|
||||
labelCpp.Visible = true;
|
||||
|
||||
whisperCppCToolStripMenuItem.Checked = Configuration.Settings.Tools.WhisperChoice == WhisperChoice.Cpp;
|
||||
whisperPhpOriginalToolStripMenuItem.Checked = Configuration.Settings.Tools.WhisperChoice == WhisperChoice.OpenAI;
|
||||
whisperConstMeToolStripMenuItem.Checked = Configuration.Settings.Tools.WhisperChoice == WhisperChoice.ConstMe;
|
||||
whisperConstMeToolStripMenuItem.Visible = Configuration.IsRunningOnWindows;
|
||||
removeTemporaryFilesToolStripMenuItem.Checked = Configuration.Settings.Tools.WhisperDeleteTempFiles;
|
||||
ContextMenuStrip = contextMenuStripWhisperAdvanced;
|
||||
|
||||
comboBoxCharsPerSub.Visible = Configuration.Settings.Tools.WhisperChoice == WhisperChoice.Cpp;
|
||||
labelCharsPerSub.Left = comboBoxCharsPerSub.Left - labelCharsPerSub.Width - 9;
|
||||
labelCharsPerSub.Visible = Configuration.Settings.Tools.WhisperChoice == WhisperChoice.Cpp;
|
||||
|
||||
buttonDownload.Enabled = Configuration.Settings.Tools.WhisperChoice != WhisperChoice.CTranslate2;
|
||||
}
|
||||
|
||||
public static void FillModels(ComboBox comboBoxModels, string lastDownloadedModel)
|
||||
@ -156,6 +177,25 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
var selectName = string.IsNullOrEmpty(lastDownloadedModel) ? Configuration.Settings.Tools.WhisperModel : lastDownloadedModel;
|
||||
comboBoxModels.Items.Clear();
|
||||
|
||||
if (Configuration.Settings.Tools.WhisperChoice == WhisperChoice.CTranslate2)
|
||||
{
|
||||
foreach (var model in whisperModel.Models)
|
||||
{
|
||||
comboBoxModels.Items.Add(model);
|
||||
if (model.Name == selectName)
|
||||
{
|
||||
comboBoxModels.SelectedIndex = comboBoxModels.Items.Count - 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (comboBoxModels.SelectedIndex < 0 && comboBoxModels.Items.Count > 0)
|
||||
{
|
||||
comboBoxModels.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Directory.Exists(modelsFolder))
|
||||
{
|
||||
whisperModel.CreateModelFolder();
|
||||
@ -1295,6 +1335,7 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
if (openFileDialog1.ShowDialog() != DialogResult.OK || !openFileDialog1.FileName.EndsWith("whisper.exe", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
Configuration.Settings.Tools.WhisperChoice = WhisperChoice.Cpp;
|
||||
comboBoxWhisperEngine.Text = WhisperChoice.Cpp;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1351,9 +1392,62 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
Init();
|
||||
}
|
||||
|
||||
private void labelCpp_Click(object sender, EventArgs e)
|
||||
private void WhisperEngineCTranslate2()
|
||||
{
|
||||
contextMenuStripWhisperAdvanced.Show(MousePosition);
|
||||
Configuration.Settings.Tools.WhisperChoice = WhisperChoice.CTranslate2;
|
||||
|
||||
if (Configuration.IsRunningOnWindows)
|
||||
{
|
||||
var path = WhisperHelper.GetWhisperFolder();
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
using (var openFileDialog1 = new OpenFileDialog())
|
||||
{
|
||||
openFileDialog1.Title = "Locate whisper-ctranslate2.exe (Python version)";
|
||||
openFileDialog1.FileName = string.Empty;
|
||||
openFileDialog1.Filter = "whisper-ctranslate2.exe|whisper-ctranslate2.exe";
|
||||
|
||||
if (openFileDialog1.ShowDialog() != DialogResult.OK || !openFileDialog1.FileName.EndsWith("whisper-ctranslate2.exe", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
Configuration.Settings.Tools.WhisperChoice = WhisperChoice.Cpp;
|
||||
comboBoxWhisperEngine.Text = WhisperChoice.Cpp;
|
||||
}
|
||||
else
|
||||
{
|
||||
Configuration.Settings.Tools.WhisperCtranslate2Location = openFileDialog1.FileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Init();
|
||||
}
|
||||
|
||||
|
||||
private void comboBoxWhisperEngine_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (comboBoxWhisperEngine.Text == Configuration.Settings.Tools.WhisperChoice)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (comboBoxWhisperEngine.Text == WhisperChoice.OpenAI)
|
||||
{
|
||||
whisperPhpOriginalToolStripMenuItem_Click(null, null);
|
||||
}
|
||||
else if (comboBoxWhisperEngine.Text == WhisperChoice.Cpp)
|
||||
{
|
||||
Configuration.Settings.Tools.WhisperChoice = WhisperChoice.Cpp;
|
||||
Init();
|
||||
}
|
||||
else if (comboBoxWhisperEngine.Text == WhisperChoice.ConstMe)
|
||||
{
|
||||
whisperConstMeToolStripMenuItem_Click(null, null);
|
||||
}
|
||||
else if (comboBoxWhisperEngine.Text == WhisperChoice.CTranslate2)
|
||||
{
|
||||
WhisperEngineCTranslate2();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -50,13 +50,11 @@
|
||||
this.listViewInputFiles = new System.Windows.Forms.ListView();
|
||||
this.columnHeaderFileName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.checkBoxTranslateToEnglish = new System.Windows.Forms.CheckBox();
|
||||
this.labelCpp = new System.Windows.Forms.Label();
|
||||
this.contextMenuStripWhisperAdvanced = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.whisperPhpOriginalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.whisperCppCToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.whisperConstMeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.removeTemporaryFilesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.labelEngine = new System.Windows.Forms.Label();
|
||||
this.comboBoxWhisperEngine = new System.Windows.Forms.ComboBox();
|
||||
this.setCPPConstmeModelsFolderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.groupBoxModels.SuspendLayout();
|
||||
this.groupBoxInputFiles.SuspendLayout();
|
||||
this.contextMenuStripWhisperAdvanced.SuspendLayout();
|
||||
@ -286,54 +284,13 @@
|
||||
this.checkBoxTranslateToEnglish.Text = "Translate to English";
|
||||
this.checkBoxTranslateToEnglish.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// labelCpp
|
||||
//
|
||||
this.labelCpp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.labelCpp.ForeColor = System.Drawing.SystemColors.ControlDark;
|
||||
this.labelCpp.Location = new System.Drawing.Point(589, 9);
|
||||
this.labelCpp.Name = "labelCpp";
|
||||
this.labelCpp.Size = new System.Drawing.Size(108, 30);
|
||||
this.labelCpp.TabIndex = 22;
|
||||
this.labelCpp.Text = "CPP";
|
||||
this.labelCpp.TextAlign = System.Drawing.ContentAlignment.TopRight;
|
||||
this.labelCpp.Click += new System.EventHandler(this.labelCpp_Click);
|
||||
//
|
||||
// contextMenuStripWhisperAdvanced
|
||||
//
|
||||
this.contextMenuStripWhisperAdvanced.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.whisperPhpOriginalToolStripMenuItem,
|
||||
this.whisperCppCToolStripMenuItem,
|
||||
this.whisperConstMeToolStripMenuItem,
|
||||
this.toolStripSeparator1,
|
||||
this.setCPPConstmeModelsFolderToolStripMenuItem,
|
||||
this.removeTemporaryFilesToolStripMenuItem});
|
||||
this.contextMenuStripWhisperAdvanced.Name = "contextMenuStripWhisperAdvanced";
|
||||
this.contextMenuStripWhisperAdvanced.Size = new System.Drawing.Size(210, 98);
|
||||
//
|
||||
// whisperPhpOriginalToolStripMenuItem
|
||||
//
|
||||
this.whisperPhpOriginalToolStripMenuItem.Name = "whisperPhpOriginalToolStripMenuItem";
|
||||
this.whisperPhpOriginalToolStripMenuItem.Size = new System.Drawing.Size(209, 22);
|
||||
this.whisperPhpOriginalToolStripMenuItem.Text = "Whisper OpenAI (Python)";
|
||||
this.whisperPhpOriginalToolStripMenuItem.Click += new System.EventHandler(this.whisperPhpOriginalToolStripMenuItem_Click);
|
||||
//
|
||||
// whisperCppCToolStripMenuItem
|
||||
//
|
||||
this.whisperCppCToolStripMenuItem.Name = "whisperCppCToolStripMenuItem";
|
||||
this.whisperCppCToolStripMenuItem.Size = new System.Drawing.Size(209, 22);
|
||||
this.whisperCppCToolStripMenuItem.Text = "Whisper cpp (C++)";
|
||||
this.whisperCppCToolStripMenuItem.Click += new System.EventHandler(this.whisperCppCToolStripMenuItem_Click);
|
||||
//
|
||||
// whisperConstMeToolStripMenuItem
|
||||
//
|
||||
this.whisperConstMeToolStripMenuItem.Name = "whisperConstMeToolStripMenuItem";
|
||||
this.whisperConstMeToolStripMenuItem.Size = new System.Drawing.Size(209, 22);
|
||||
this.whisperConstMeToolStripMenuItem.Text = "Whisper Const-me (GPU)";
|
||||
this.whisperConstMeToolStripMenuItem.Click += new System.EventHandler(this.whisperConstMeGPUToolStripMenuItem_Click);
|
||||
//
|
||||
// toolStripSeparator1
|
||||
//
|
||||
this.toolStripSeparator1.Name = "toolStripSeparator1";
|
||||
this.toolStripSeparator1.Size = new System.Drawing.Size(206, 6);
|
||||
this.contextMenuStripWhisperAdvanced.Size = new System.Drawing.Size(259, 70);
|
||||
//
|
||||
// removeTemporaryFilesToolStripMenuItem
|
||||
//
|
||||
@ -342,12 +299,40 @@
|
||||
this.removeTemporaryFilesToolStripMenuItem.Text = "Remove temporary files";
|
||||
this.removeTemporaryFilesToolStripMenuItem.Click += new System.EventHandler(this.removeTemporaryFilesToolStripMenuItem_Click);
|
||||
//
|
||||
// labelEngine
|
||||
//
|
||||
this.labelEngine.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.labelEngine.AutoSize = true;
|
||||
this.labelEngine.Location = new System.Drawing.Point(497, 9);
|
||||
this.labelEngine.Name = "labelEngine";
|
||||
this.labelEngine.Size = new System.Drawing.Size(40, 13);
|
||||
this.labelEngine.TabIndex = 29;
|
||||
this.labelEngine.Text = "Engine";
|
||||
//
|
||||
// comboBoxWhisperEngine
|
||||
//
|
||||
this.comboBoxWhisperEngine.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.comboBoxWhisperEngine.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxWhisperEngine.FormattingEnabled = true;
|
||||
this.comboBoxWhisperEngine.Location = new System.Drawing.Point(543, 6);
|
||||
this.comboBoxWhisperEngine.Name = "comboBoxWhisperEngine";
|
||||
this.comboBoxWhisperEngine.Size = new System.Drawing.Size(154, 21);
|
||||
this.comboBoxWhisperEngine.TabIndex = 28;
|
||||
this.comboBoxWhisperEngine.SelectedIndexChanged += new System.EventHandler(this.comboBoxWhisperEngine_SelectedIndexChanged);
|
||||
//
|
||||
// setCPPConstmeModelsFolderToolStripMenuItem
|
||||
//
|
||||
this.setCPPConstmeModelsFolderToolStripMenuItem.Name = "setCPPConstmeModelsFolderToolStripMenuItem";
|
||||
this.setCPPConstmeModelsFolderToolStripMenuItem.Size = new System.Drawing.Size(258, 22);
|
||||
this.setCPPConstmeModelsFolderToolStripMenuItem.Text = "Set CPP/Const-me models folder...";
|
||||
//
|
||||
// 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.labelCpp);
|
||||
this.Controls.Add(this.labelEngine);
|
||||
this.Controls.Add(this.comboBoxWhisperEngine);
|
||||
this.Controls.Add(this.checkBoxTranslateToEnglish);
|
||||
this.Controls.Add(this.groupBoxInputFiles);
|
||||
this.Controls.Add(this.checkBoxUsePostProcessing);
|
||||
@ -404,12 +389,10 @@
|
||||
private System.Windows.Forms.Label labelChooseLanguage;
|
||||
private System.Windows.Forms.ComboBox comboBoxLanguages;
|
||||
private System.Windows.Forms.CheckBox checkBoxTranslateToEnglish;
|
||||
private System.Windows.Forms.Label labelCpp;
|
||||
private System.Windows.Forms.ContextMenuStrip contextMenuStripWhisperAdvanced;
|
||||
private System.Windows.Forms.ToolStripMenuItem whisperPhpOriginalToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem whisperCppCToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
|
||||
private System.Windows.Forms.ToolStripMenuItem removeTemporaryFilesToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem whisperConstMeToolStripMenuItem;
|
||||
private System.Windows.Forms.Label labelEngine;
|
||||
private System.Windows.Forms.ComboBox comboBoxWhisperEngine;
|
||||
private System.Windows.Forms.ToolStripMenuItem setCPPConstmeModelsFolderToolStripMenuItem;
|
||||
}
|
||||
}
|
@ -62,8 +62,6 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
listViewInputFiles.Visible = true;
|
||||
_audioClips = audioClips;
|
||||
progressBar1.Maximum = 100;
|
||||
labelCpp.Visible = true;
|
||||
labelCpp.Text = Configuration.Settings.Tools.WhisperChoice;
|
||||
foreach (var audioClip in audioClips)
|
||||
{
|
||||
listViewInputFiles.Items.Add(audioClip.AudioFileName);
|
||||
@ -78,13 +76,11 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
comboBoxLanguages.Text = lang != null ? lang.ToString() : "English";
|
||||
WhisperAudioToText.FillModels(comboBoxModels, string.Empty);
|
||||
|
||||
whisperCppCToolStripMenuItem.Checked = Configuration.Settings.Tools.WhisperChoice == WhisperChoice.Cpp;
|
||||
whisperPhpOriginalToolStripMenuItem.Checked = Configuration.Settings.Tools.WhisperChoice == WhisperChoice.OpenAI;
|
||||
removeTemporaryFilesToolStripMenuItem.Checked = Configuration.Settings.Tools.WhisperDeleteTempFiles;
|
||||
whisperConstMeToolStripMenuItem.Checked = Configuration.Settings.Tools.WhisperChoice == WhisperChoice.ConstMe;
|
||||
whisperConstMeToolStripMenuItem.Visible = Configuration.IsRunningOnWindows;
|
||||
|
||||
ContextMenuStrip = contextMenuStripWhisperAdvanced;
|
||||
|
||||
buttonDownload.Enabled = Configuration.Settings.Tools.WhisperChoice != WhisperChoice.CTranslate2;
|
||||
}
|
||||
|
||||
private void ButtonGenerate_Click(object sender, EventArgs e)
|
||||
@ -509,5 +505,63 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
|
||||
Init();
|
||||
}
|
||||
|
||||
private void WhisperEngineCTranslate2()
|
||||
{
|
||||
Configuration.Settings.Tools.WhisperChoice = WhisperChoice.CTranslate2;
|
||||
|
||||
if (Configuration.IsRunningOnWindows)
|
||||
{
|
||||
var path = WhisperHelper.GetWhisperFolder();
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
using (var openFileDialog1 = new OpenFileDialog())
|
||||
{
|
||||
openFileDialog1.Title = "Locate whisper-ctranslate2.exe (Python version)";
|
||||
openFileDialog1.FileName = string.Empty;
|
||||
openFileDialog1.Filter = "whisper-ctranslate2.exe|whisper-ctranslate2.exe";
|
||||
|
||||
if (openFileDialog1.ShowDialog() != DialogResult.OK || !openFileDialog1.FileName.EndsWith("whisper-ctranslate2.exe", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
Configuration.Settings.Tools.WhisperChoice = WhisperChoice.Cpp;
|
||||
comboBoxWhisperEngine.Text = WhisperChoice.Cpp;
|
||||
}
|
||||
else
|
||||
{
|
||||
Configuration.Settings.Tools.WhisperCtranslate2Location = openFileDialog1.FileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Init();
|
||||
}
|
||||
|
||||
|
||||
private void comboBoxWhisperEngine_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (comboBoxWhisperEngine.Text == Configuration.Settings.Tools.WhisperChoice)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (comboBoxWhisperEngine.Text == WhisperChoice.OpenAI)
|
||||
{
|
||||
whisperPhpOriginalToolStripMenuItem_Click(null, null);
|
||||
}
|
||||
else if (comboBoxWhisperEngine.Text == WhisperChoice.Cpp)
|
||||
{
|
||||
Configuration.Settings.Tools.WhisperChoice = WhisperChoice.Cpp;
|
||||
Init();
|
||||
}
|
||||
else if (comboBoxWhisperEngine.Text == WhisperChoice.ConstMe)
|
||||
{
|
||||
whisperConstMeGPUToolStripMenuItem_Click(null, null);
|
||||
}
|
||||
else if (comboBoxWhisperEngine.Text == WhisperChoice.CTranslate2)
|
||||
{
|
||||
WhisperEngineCTranslate2();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user