Restructuring Whisper folders

This commit is contained in:
niksedk 2023-08-03 20:14:17 +02:00
parent 59300d7b92
commit 2187aed40c
15 changed files with 263 additions and 168 deletions

View File

@ -2,12 +2,12 @@
{ {
public class WhisperChoice public class WhisperChoice
{ {
public const string OpenAI = "OpenAI"; public const string OpenAi = "OpenAI";
public const string Cpp = "CPP"; public const string Cpp = "CPP";
public const string WhisperX = "WhisperX"; public const string WhisperX = "WhisperX";
public const string ConstMe = "Const-me"; public const string ConstMe = "Const-me";
public const string CTranslate2 = "CTranslate2"; public const string CTranslate2 = "CTranslate2";
public const string StableTs = "stable-ts"; public const string StableTs = "stable-ts";
public const string PurfviewFasterWhisper = "PurfviewFasterWhisper"; public const string PurfviewFasterWhisper = "Purfview's Faster-Whisper";
} }
} }

View File

@ -15,7 +15,7 @@ namespace Nikse.SubtitleEdit.Core.AudioToText
return Configuration.Settings.Tools.WhisperCppModelLocation; return Configuration.Settings.Tools.WhisperCppModelLocation;
} }
return Path.Combine(Configuration.DataDirectory, "Whisper", "Models"); return Path.Combine(Configuration.DataDirectory, "Whisper", "Cpp", "Models");
} }
} }
@ -27,13 +27,19 @@ namespace Nikse.SubtitleEdit.Core.AudioToText
Directory.CreateDirectory(whisperFolder); Directory.CreateDirectory(whisperFolder);
} }
whisperFolder = Path.Combine(whisperFolder, "Cpp");
if (!Directory.Exists(whisperFolder))
{
Directory.CreateDirectory(whisperFolder);
}
if (!Directory.Exists(ModelFolder)) if (!Directory.Exists(ModelFolder))
{ {
Directory.CreateDirectory(ModelFolder); Directory.CreateDirectory(ModelFolder);
} }
} }
public WhisperModel[] Models => new[] public WhisperModel[] Models => new[]
{ {
new WhisperModel new WhisperModel
{ {

View File

@ -91,9 +91,14 @@ namespace Nikse.SubtitleEdit.Core.AudioToText
public static string GetWhisperFolder() public static string GetWhisperFolder()
{ {
if (Configuration.IsRunningOnLinux && Configuration.Settings.Tools.WhisperChoice == WhisperChoice.Cpp) return GetWhisperFolder(Configuration.Settings.Tools.WhisperChoice);
}
public static string GetWhisperFolder(string whisperChoice)
{
if (Configuration.IsRunningOnLinux && whisperChoice == WhisperChoice.Cpp)
{ {
var path = Path.Combine(Configuration.DataDirectory, "Whisper"); var path = Path.Combine(Configuration.DataDirectory, "Whisper", "Cpp");
return Directory.Exists(path) ? path : null; return Directory.Exists(path) ? path : null;
} }
@ -104,7 +109,7 @@ namespace Nikse.SubtitleEdit.Core.AudioToText
try try
{ {
if (Configuration.Settings.Tools.WhisperChoice == WhisperChoice.OpenAI) if (whisperChoice == WhisperChoice.OpenAi)
{ {
var location = Configuration.Settings.Tools.WhisperLocation; var location = Configuration.Settings.Tools.WhisperLocation;
if (!string.IsNullOrEmpty(location)) if (!string.IsNullOrEmpty(location))
@ -121,7 +126,7 @@ namespace Nikse.SubtitleEdit.Core.AudioToText
} }
} }
if (Configuration.Settings.Tools.WhisperChoice == WhisperChoice.CTranslate2) if (whisperChoice == WhisperChoice.CTranslate2)
{ {
var location = Configuration.Settings.Tools.WhisperCtranslate2Location; var location = Configuration.Settings.Tools.WhisperCtranslate2Location;
if (!string.IsNullOrEmpty(location)) if (!string.IsNullOrEmpty(location))
@ -138,7 +143,7 @@ namespace Nikse.SubtitleEdit.Core.AudioToText
} }
} }
if (Configuration.Settings.Tools.WhisperChoice == WhisperChoice.PurfviewFasterWhisper) if (whisperChoice == WhisperChoice.PurfviewFasterWhisper)
{ {
var location = Configuration.Settings.Tools.WhisperCtranslate2Location; var location = Configuration.Settings.Tools.WhisperCtranslate2Location;
if (!string.IsNullOrEmpty(location)) if (!string.IsNullOrEmpty(location))
@ -154,17 +159,17 @@ namespace Nikse.SubtitleEdit.Core.AudioToText
} }
} }
location = Path.Combine(Configuration.DataDirectory, "Whisper", "Purfview", "Whisper-Faster"); location = Path.Combine(Configuration.DataDirectory, "Whisper", "Purfview-Whisper-Faster");
return Directory.Exists(location) ? location : null; return Directory.Exists(location) ? location : null;
} }
if (Configuration.Settings.Tools.WhisperChoice == WhisperChoice.Cpp) if (whisperChoice == WhisperChoice.Cpp)
{ {
var path = Path.Combine(Configuration.DataDirectory, "Whisper"); var path = Path.Combine(Configuration.DataDirectory, "Whisper", "Cpp");
return Directory.Exists(path) ? path : null; return Directory.Exists(path) ? path : null;
} }
if (Configuration.Settings.Tools.WhisperChoice == WhisperChoice.WhisperX && !string.IsNullOrEmpty(Configuration.Settings.Tools.WhisperXLocation)) if (whisperChoice == WhisperChoice.WhisperX && !string.IsNullOrEmpty(Configuration.Settings.Tools.WhisperXLocation))
{ {
if (Configuration.Settings.Tools.WhisperXLocation.EndsWith("whisperx.exe", StringComparison.InvariantCultureIgnoreCase) && File.Exists(Configuration.Settings.Tools.WhisperXLocation)) if (Configuration.Settings.Tools.WhisperXLocation.EndsWith("whisperx.exe", StringComparison.InvariantCultureIgnoreCase) && File.Exists(Configuration.Settings.Tools.WhisperXLocation))
{ {
@ -177,7 +182,7 @@ namespace Nikse.SubtitleEdit.Core.AudioToText
} }
} }
if (Configuration.Settings.Tools.WhisperChoice == WhisperChoice.WhisperX) if (whisperChoice == WhisperChoice.WhisperX)
{ {
var path = Path.Combine( var path = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
@ -188,7 +193,7 @@ namespace Nikse.SubtitleEdit.Core.AudioToText
} }
} }
if (Configuration.Settings.Tools.WhisperChoice == WhisperChoice.StableTs && !string.IsNullOrEmpty(Configuration.Settings.Tools.WhisperStableTsLocation)) if (whisperChoice == WhisperChoice.StableTs && !string.IsNullOrEmpty(Configuration.Settings.Tools.WhisperStableTsLocation))
{ {
if (Configuration.Settings.Tools.WhisperStableTsLocation.EndsWith("stable-ts.exe", StringComparison.InvariantCultureIgnoreCase) && File.Exists(Configuration.Settings.Tools.WhisperStableTsLocation)) if (Configuration.Settings.Tools.WhisperStableTsLocation.EndsWith("stable-ts.exe", StringComparison.InvariantCultureIgnoreCase) && File.Exists(Configuration.Settings.Tools.WhisperStableTsLocation))
{ {
@ -201,7 +206,7 @@ namespace Nikse.SubtitleEdit.Core.AudioToText
} }
} }
if (Configuration.Settings.Tools.WhisperChoice == WhisperChoice.ConstMe) if (whisperChoice == WhisperChoice.ConstMe)
{ {
var path = Path.Combine(Configuration.DataDirectory, "Whisper", "Const-me"); var path = Path.Combine(Configuration.DataDirectory, "Whisper", "Const-me");
return Directory.Exists(path) ? path : null; return Directory.Exists(path) ? path : null;
@ -219,7 +224,7 @@ namespace Nikse.SubtitleEdit.Core.AudioToText
var dirName = Path.GetFileName(dir); var dirName = Path.GetFileName(dir);
if (dirName != null && dirName.StartsWith("Python3")) if (dirName != null && dirName.StartsWith("Python3"))
{ {
if (Configuration.Settings.Tools.WhisperChoice == WhisperChoice.WhisperX) if (whisperChoice == WhisperChoice.WhisperX)
{ {
var whisperXFullPath = Path.Combine(dir, "Scripts", "whisperx.exe"); var whisperXFullPath = Path.Combine(dir, "Scripts", "whisperx.exe");
if (File.Exists(whisperXFullPath)) if (File.Exists(whisperXFullPath))
@ -230,7 +235,7 @@ namespace Nikse.SubtitleEdit.Core.AudioToText
return null; return null;
} }
if (Configuration.Settings.Tools.WhisperChoice == WhisperChoice.CTranslate2) if (whisperChoice == WhisperChoice.CTranslate2)
{ {
var whisperCTranslate2FullPath = Path.Combine(dir, "Scripts", "whisper-ctranslate2.exe"); var whisperCTranslate2FullPath = Path.Combine(dir, "Scripts", "whisper-ctranslate2.exe");
if (File.Exists(whisperCTranslate2FullPath)) if (File.Exists(whisperCTranslate2FullPath))
@ -241,7 +246,7 @@ namespace Nikse.SubtitleEdit.Core.AudioToText
return null; return null;
} }
if (Configuration.Settings.Tools.WhisperChoice == WhisperChoice.StableTs) if (whisperChoice == WhisperChoice.StableTs)
{ {
var whisperCTranslate2FullPath = Path.Combine(dir, "Scripts", "stable-ts.exe"); var whisperCTranslate2FullPath = Path.Combine(dir, "Scripts", "stable-ts.exe");
if (File.Exists(whisperCTranslate2FullPath)) if (File.Exists(whisperCTranslate2FullPath))
@ -269,37 +274,42 @@ namespace Nikse.SubtitleEdit.Core.AudioToText
return null; return null;
} }
public static string GetWhisperPathAndFileName() public static string GetExecutableFileName()
{ {
var whisperFolder = GetWhisperFolder(); return GetExecutableFileName(Configuration.Settings.Tools.WhisperChoice);
}
public static string GetExecutableFileName(string whisperChoice)
{
var whisperFolder = GetWhisperFolder(whisperChoice);
if (string.IsNullOrEmpty(whisperFolder)) if (string.IsNullOrEmpty(whisperFolder))
{ {
if (Configuration.Settings.Tools.WhisperChoice == WhisperChoice.Cpp) if (whisperChoice == WhisperChoice.Cpp)
{ {
return "main"; return "main";
} }
if (Configuration.Settings.Tools.WhisperChoice == WhisperChoice.CTranslate2) if (whisperChoice == WhisperChoice.CTranslate2)
{ {
return "whisper-ctranslate2"; return "whisper-ctranslate2";
} }
if (Configuration.Settings.Tools.WhisperChoice == WhisperChoice.PurfviewFasterWhisper) if (whisperChoice == WhisperChoice.PurfviewFasterWhisper)
{ {
return "whisper-faster.exe"; return "whisper-faster.exe";
} }
if (Configuration.Settings.Tools.WhisperChoice == WhisperChoice.WhisperX) if (whisperChoice == WhisperChoice.WhisperX)
{ {
return "whisperx"; return "whisperx";
} }
if (Configuration.Settings.Tools.WhisperChoice == WhisperChoice.ConstMe) if (whisperChoice == WhisperChoice.ConstMe)
{ {
return "main"; return "main";
} }
if (Configuration.Settings.Tools.WhisperChoice == WhisperChoice.StableTs) if (whisperChoice == WhisperChoice.StableTs)
{ {
return "stable-ts"; return "stable-ts";
} }
@ -309,49 +319,124 @@ namespace Nikse.SubtitleEdit.Core.AudioToText
if (Configuration.IsRunningOnWindows) if (Configuration.IsRunningOnWindows)
{ {
if (Configuration.Settings.Tools.WhisperChoice == WhisperChoice.Cpp) if (whisperChoice == WhisperChoice.Cpp)
{ {
var f = Path.Combine(whisperFolder, "main.exe"); return "main.exe";
}
if (whisperChoice == WhisperChoice.WhisperX)
{
return "whisperx.exe";
}
if (whisperChoice == WhisperChoice.CTranslate2)
{
return "whisper-ctranslate2.exe";
}
if (whisperChoice == WhisperChoice.PurfviewFasterWhisper)
{
return "whisper-faster.exe";
}
if (whisperChoice == WhisperChoice.StableTs)
{
return "stable-ts.exe";
}
if (whisperChoice == WhisperChoice.ConstMe)
{
return "main.exe";
}
return "whisper.exe";
}
if (Configuration.IsRunningOnLinux && whisperChoice == WhisperChoice.Cpp)
{
return "main";
}
if (Configuration.IsRunningOnLinux && whisperChoice == WhisperChoice.WhisperX)
{
return "whisperx";
}
if (whisperChoice == WhisperChoice.CTranslate2)
{
return "whisper-ctranslate2";
}
if (whisperChoice == WhisperChoice.StableTs)
{
return "stable-ts";
}
return "whisper";
}
public static string GetWhisperPathAndFileName()
{
return GetWhisperPathAndFileName(Configuration.Settings.Tools.WhisperChoice);
}
/// <summary>
/// Get installed path
/// </summary>
public static string GetWhisperPathAndFileName(string whisperChoice)
{
var fileNameOnly = GetExecutableFileName(whisperChoice);
var whisperFolder = GetWhisperFolder(whisperChoice);
if (string.IsNullOrEmpty(whisperFolder))
{
return fileNameOnly;
}
if (Configuration.IsRunningOnWindows)
{
if (whisperChoice == WhisperChoice.Cpp)
{
var f = Path.Combine(whisperFolder, fileNameOnly);
if (File.Exists(f)) if (File.Exists(f))
{ {
return f; return f;
} }
} }
else if (Configuration.Settings.Tools.WhisperChoice == WhisperChoice.WhisperX) else if (whisperChoice == WhisperChoice.WhisperX)
{ {
var f = Path.Combine(whisperFolder, "whisperx.exe"); var f = Path.Combine(whisperFolder, fileNameOnly);
if (File.Exists(f)) if (File.Exists(f))
{ {
return f; return f;
} }
} }
else if (Configuration.Settings.Tools.WhisperChoice == WhisperChoice.CTranslate2) else if (whisperChoice == WhisperChoice.CTranslate2)
{ {
var f = Path.Combine(whisperFolder, "whisper-ctranslate2.exe"); var f = Path.Combine(whisperFolder, fileNameOnly);
if (File.Exists(f)) if (File.Exists(f))
{ {
return f; return f;
} }
} }
else if (Configuration.Settings.Tools.WhisperChoice == WhisperChoice.PurfviewFasterWhisper) else if (whisperChoice == WhisperChoice.PurfviewFasterWhisper)
{ {
var f = Path.Combine(whisperFolder, "whisper-faster.exe"); var f = Path.Combine(whisperFolder, fileNameOnly);
if (File.Exists(f)) if (File.Exists(f))
{ {
return f; return f;
} }
} }
else if (Configuration.Settings.Tools.WhisperChoice == WhisperChoice.StableTs) else if (whisperChoice == WhisperChoice.StableTs)
{ {
var f = Path.Combine(whisperFolder, "stable-ts.exe"); var f = Path.Combine(whisperFolder, fileNameOnly);
if (File.Exists(f)) if (File.Exists(f))
{ {
return f; return f;
} }
} }
else if (Configuration.Settings.Tools.WhisperChoice == WhisperChoice.ConstMe) else if (whisperChoice == WhisperChoice.ConstMe)
{ {
var f = Path.Combine(whisperFolder, "main.exe"); var f = Path.Combine(whisperFolder, fileNameOnly);
if (File.Exists(f)) if (File.Exists(f))
{ {
return f; return f;
@ -361,7 +446,7 @@ namespace Nikse.SubtitleEdit.Core.AudioToText
} }
else else
{ {
var f = Path.Combine(whisperFolder, "whisper.exe"); var f = Path.Combine(whisperFolder, fileNameOnly);
if (File.Exists(f)) if (File.Exists(f))
{ {
return f; return f;
@ -369,40 +454,7 @@ namespace Nikse.SubtitleEdit.Core.AudioToText
} }
} }
if (Configuration.IsRunningOnLinux && Configuration.Settings.Tools.WhisperChoice == WhisperChoice.Cpp) return fileNameOnly;
{
var f = Path.Combine(whisperFolder, "main");
if (File.Exists(f))
{
return f;
}
}
else if (Configuration.IsRunningOnLinux && Configuration.Settings.Tools.WhisperChoice == WhisperChoice.WhisperX)
{
var f = Path.Combine(whisperFolder, "whisperx");
if (File.Exists(f))
{
return f;
}
}
else if (Configuration.Settings.Tools.WhisperChoice == WhisperChoice.CTranslate2)
{
var f = Path.Combine(whisperFolder, "whisper-ctranslate2");
if (File.Exists(f))
{
return f;
}
}
else if (Configuration.Settings.Tools.WhisperChoice == WhisperChoice.StableTs)
{
var f = Path.Combine(whisperFolder, "stable-ts");
if (File.Exists(f))
{
return f;
}
}
return "whisper";
} }
public static string GetWhisperModelForCmdLine(string model) public static string GetWhisperModelForCmdLine(string model)
@ -424,7 +476,7 @@ namespace Nikse.SubtitleEdit.Core.AudioToText
{ {
return Configuration.Settings.Tools.WhisperChoice == WhisperChoice.Cpp || return Configuration.Settings.Tools.WhisperChoice == WhisperChoice.Cpp ||
Configuration.Settings.Tools.WhisperChoice == WhisperChoice.ConstMe Configuration.Settings.Tools.WhisperChoice == WhisperChoice.ConstMe
? "--translate " ? "--translate "
: "--task translate "; : "--task translate ";
} }
} }

View File

@ -20,17 +20,11 @@ namespace Nikse.SubtitleEdit.Core.AudioToText
private readonly string[] _fileNames = { "model.bin", "config.json", "vocabulary.txt", "tokenizer.json" }; private readonly string[] _fileNames = { "model.bin", "config.json", "vocabulary.txt", "tokenizer.json" };
public string ModelFolder => Path.Combine(Configuration.DataDirectory, "Whisper", "Purfview", "Whisper-Faster", "_models"); public string ModelFolder => Path.Combine(Configuration.DataDirectory, "Whisper", "Purfview-Whisper-Faster", "_models");
public void CreateModelFolder() public void CreateModelFolder()
{ {
var dir = Path.Combine(Configuration.DataDirectory, "Whisper", "Purfview"); var dir = Path.Combine(Configuration.DataDirectory, "Whisper", "Purfview-Whisper-Faster");
if (!Directory.Exists(dir))
{
Directory.CreateDirectory(dir);
}
dir = Path.Combine(Configuration.DataDirectory, "Whisper-Faster");
if (!Directory.Exists(dir)) if (!Directory.Exists(dir))
{ {
Directory.CreateDirectory(dir); Directory.CreateDirectory(dir);

View File

@ -666,7 +666,7 @@ namespace Nikse.SubtitleEdit.Core.Common
GenVideoNonAssaBoxColor = Color.FromArgb(150, 0, 0, 0); GenVideoNonAssaBoxColor = Color.FromArgb(150, 0, 0, 0);
GenVideoNonAssaTextColor = Color.White; GenVideoNonAssaTextColor = Color.White;
VoskPostProcessing = true; VoskPostProcessing = true;
WhisperChoice = Configuration.IsRunningOnWindows ? AudioToText.WhisperChoice.Cpp : AudioToText.WhisperChoice.OpenAI; WhisperChoice = Configuration.IsRunningOnWindows ? AudioToText.WhisperChoice.Cpp : AudioToText.WhisperChoice.OpenAi;
WhisperDeleteTempFiles = true; WhisperDeleteTempFiles = true;
WhisperExtraSettings = ""; WhisperExtraSettings = "";
WhisperLanguageCode = "en"; WhisperLanguageCode = "en";

View File

@ -837,6 +837,8 @@ namespace Nikse.SubtitleEdit.Controls
public bool DroppedDown => _listViewShown; public bool DroppedDown => _listViewShown;
public bool FormattingEnabled { get; set; }
private static void DrawArrowDown(PaintEventArgs e, Brush brush, int left, int top, int height) private static void DrawArrowDown(PaintEventArgs e, Brush brush, int left, int top, int height)
{ {
e.Graphics.FillPolygon(brush, e.Graphics.FillPolygon(brush,

View File

@ -37,11 +37,11 @@
this.labelInfo = new System.Windows.Forms.Label(); this.labelInfo = new System.Windows.Forms.Label();
this.groupBoxModels = new System.Windows.Forms.GroupBox(); this.groupBoxModels = new System.Windows.Forms.GroupBox();
this.labelChooseLanguage = new System.Windows.Forms.Label(); this.labelChooseLanguage = new System.Windows.Forms.Label();
this.comboBoxLanguages = new System.Windows.Forms.ComboBox(); this.comboBoxLanguages = new Nikse.SubtitleEdit.Controls.NikseComboBox();
this.buttonDownload = new System.Windows.Forms.Button(); this.buttonDownload = new System.Windows.Forms.Button();
this.linkLabelOpenModelsFolder = new System.Windows.Forms.LinkLabel(); this.linkLabelOpenModelsFolder = new System.Windows.Forms.LinkLabel();
this.labelModel = new System.Windows.Forms.Label(); this.labelModel = new System.Windows.Forms.Label();
this.comboBoxModels = new System.Windows.Forms.ComboBox(); this.comboBoxModels = new Nikse.SubtitleEdit.Controls.NikseComboBox();
this.linkLabeWhisperWebSite = new System.Windows.Forms.LinkLabel(); this.linkLabeWhisperWebSite = new System.Windows.Forms.LinkLabel();
this.labelTime = new System.Windows.Forms.Label(); this.labelTime = new System.Windows.Forms.Label();
this.timer1 = new System.Windows.Forms.Timer(this.components); this.timer1 = new System.Windows.Forms.Timer(this.components);
@ -62,7 +62,7 @@
this.setCPPConstmeModelsFolderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.setCPPConstmeModelsFolderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.removeTemporaryFilesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.removeTemporaryFilesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.checkBoxAutoAdjustTimings = new System.Windows.Forms.CheckBox(); this.checkBoxAutoAdjustTimings = new System.Windows.Forms.CheckBox();
this.comboBoxWhisperEngine = new System.Windows.Forms.ComboBox(); this.comboBoxWhisperEngine = new Nikse.SubtitleEdit.Controls.NikseComboBox();
this.labelEngine = new System.Windows.Forms.Label(); this.labelEngine = new System.Windows.Forms.Label();
this.buttonAdvanced = new System.Windows.Forms.Button(); this.buttonAdvanced = new System.Windows.Forms.Button();
this.labelAdvanced = new System.Windows.Forms.Label(); this.labelAdvanced = new System.Windows.Forms.Label();
@ -417,10 +417,9 @@
// //
this.comboBoxWhisperEngine.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 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.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxWhisperEngine.FormattingEnabled = true; this.comboBoxWhisperEngine.Location = new System.Drawing.Point(521, 9);
this.comboBoxWhisperEngine.Location = new System.Drawing.Point(547, 9);
this.comboBoxWhisperEngine.Name = "comboBoxWhisperEngine"; this.comboBoxWhisperEngine.Name = "comboBoxWhisperEngine";
this.comboBoxWhisperEngine.Size = new System.Drawing.Size(154, 21); this.comboBoxWhisperEngine.Size = new System.Drawing.Size(180, 21);
this.comboBoxWhisperEngine.TabIndex = 26; this.comboBoxWhisperEngine.TabIndex = 26;
this.comboBoxWhisperEngine.SelectedIndexChanged += new System.EventHandler(this.comboBoxWhisperEngine_SelectedIndexChanged); this.comboBoxWhisperEngine.SelectedIndexChanged += new System.EventHandler(this.comboBoxWhisperEngine_SelectedIndexChanged);
// //
@ -428,7 +427,7 @@
// //
this.labelEngine.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.labelEngine.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.labelEngine.AutoSize = true; this.labelEngine.AutoSize = true;
this.labelEngine.Location = new System.Drawing.Point(501, 12); this.labelEngine.Location = new System.Drawing.Point(475, 12);
this.labelEngine.Name = "labelEngine"; this.labelEngine.Name = "labelEngine";
this.labelEngine.Size = new System.Drawing.Size(40, 13); this.labelEngine.Size = new System.Drawing.Size(40, 13);
this.labelEngine.TabIndex = 27; this.labelEngine.TabIndex = 27;
@ -512,7 +511,7 @@
private System.Windows.Forms.GroupBox groupBoxModels; private System.Windows.Forms.GroupBox groupBoxModels;
private System.Windows.Forms.LinkLabel linkLabeWhisperWebSite; private System.Windows.Forms.LinkLabel linkLabeWhisperWebSite;
private System.Windows.Forms.Label labelModel; private System.Windows.Forms.Label labelModel;
private System.Windows.Forms.ComboBox comboBoxModels; private Nikse.SubtitleEdit.Controls.NikseComboBox comboBoxModels;
private System.Windows.Forms.LinkLabel linkLabelOpenModelsFolder; private System.Windows.Forms.LinkLabel linkLabelOpenModelsFolder;
private System.Windows.Forms.Label labelTime; private System.Windows.Forms.Label labelTime;
private System.Windows.Forms.Timer timer1; private System.Windows.Forms.Timer timer1;
@ -527,13 +526,13 @@
private System.Windows.Forms.Button buttonAddFile; private System.Windows.Forms.Button buttonAddFile;
private System.Windows.Forms.Label labelFC; private System.Windows.Forms.Label labelFC;
private System.Windows.Forms.Label labelChooseLanguage; private System.Windows.Forms.Label labelChooseLanguage;
private System.Windows.Forms.ComboBox comboBoxLanguages; private Nikse.SubtitleEdit.Controls.NikseComboBox comboBoxLanguages;
private System.Windows.Forms.CheckBox checkBoxTranslateToEnglish; private System.Windows.Forms.CheckBox checkBoxTranslateToEnglish;
private System.Windows.Forms.Label labelElapsed; private System.Windows.Forms.Label labelElapsed;
private System.Windows.Forms.ContextMenuStrip contextMenuStripWhisperAdvanced; private System.Windows.Forms.ContextMenuStrip contextMenuStripWhisperAdvanced;
private System.Windows.Forms.ToolStripMenuItem removeTemporaryFilesToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem removeTemporaryFilesToolStripMenuItem;
private System.Windows.Forms.CheckBox checkBoxAutoAdjustTimings; private System.Windows.Forms.CheckBox checkBoxAutoAdjustTimings;
private System.Windows.Forms.ComboBox comboBoxWhisperEngine; private Nikse.SubtitleEdit.Controls.NikseComboBox comboBoxWhisperEngine;
private System.Windows.Forms.Label labelEngine; private System.Windows.Forms.Label labelEngine;
private System.Windows.Forms.ToolStripMenuItem setCPPConstmeModelsFolderToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem setCPPConstmeModelsFolderToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem runOnlyPostProcessingToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem runOnlyPostProcessingToolStripMenuItem;

View File

@ -14,6 +14,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Windows.Forms; using System.Windows.Forms;
using Nikse.SubtitleEdit.Controls;
namespace Nikse.SubtitleEdit.Forms.AudioToText namespace Nikse.SubtitleEdit.Forms.AudioToText
{ {
@ -123,11 +124,11 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
InitializeWhisperEngines(comboBoxWhisperEngine); InitializeWhisperEngines(comboBoxWhisperEngine);
} }
public static void InitializeWhisperEngines(ComboBox cb) public static void InitializeWhisperEngines(NikseComboBox cb)
{ {
cb.Items.Clear(); cb.Items.Clear();
var engines = new List<string>(); var engines = new List<string>();
engines.Add(WhisperChoice.OpenAI); engines.Add(WhisperChoice.OpenAi);
engines.Add(WhisperChoice.Cpp); engines.Add(WhisperChoice.Cpp);
if (Configuration.IsRunningOnWindows) if (Configuration.IsRunningOnWindows)
{ {
@ -135,7 +136,7 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
engines.Add(WhisperChoice.PurfviewFasterWhisper); engines.Add(WhisperChoice.PurfviewFasterWhisper);
} }
engines.Add(WhisperChoice.CTranslate2); engines.Add(WhisperChoice.CTranslate2);
// engines.Add(WhisperChoice.StableTs); // engines.Add(WhisperChoice.StableTs);
engines.Add(WhisperChoice.WhisperX); engines.Add(WhisperChoice.WhisperX);
foreach (var engine in engines) foreach (var engine in engines)
@ -168,7 +169,7 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
ContextMenuStrip = contextMenuStripWhisperAdvanced; ContextMenuStrip = contextMenuStripWhisperAdvanced;
} }
public static void FillModels(ComboBox comboBoxModels, string lastDownloadedModel) public static void FillModels(NikseComboBox comboBoxModels, string lastDownloadedModel)
{ {
var whisperModel = WhisperHelper.GetWhisperModel(); var whisperModel = WhisperHelper.GetWhisperModel();
var modelsFolder = whisperModel.ModelFolder; var modelsFolder = whisperModel.ModelFolder;
@ -1331,7 +1332,7 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
private void WhisperPhpOriginalChoose() private void WhisperPhpOriginalChoose()
{ {
Configuration.Settings.Tools.WhisperChoice = WhisperChoice.OpenAI; Configuration.Settings.Tools.WhisperChoice = WhisperChoice.OpenAi;
if (Configuration.IsRunningOnWindows) if (Configuration.IsRunningOnWindows)
{ {
@ -1531,13 +1532,28 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
return; return;
} }
if (comboBoxWhisperEngine.Text == WhisperChoice.OpenAI) if (comboBoxWhisperEngine.Text == WhisperChoice.OpenAi)
{ {
WhisperPhpOriginalChoose(); WhisperPhpOriginalChoose();
} }
else if (comboBoxWhisperEngine.Text == WhisperChoice.Cpp) else if (comboBoxWhisperEngine.Text == WhisperChoice.Cpp)
{ {
Configuration.Settings.Tools.WhisperChoice = WhisperChoice.Cpp; Configuration.Settings.Tools.WhisperChoice = WhisperChoice.Cpp;
var fileName = WhisperHelper.GetWhisperPathAndFileName();
if (!File.Exists(fileName) || WhisperDownload.IsOld(fileName, WhisperChoice.Cpp))
{
if (MessageBox.Show(string.Format(LanguageSettings.Current.Settings.DownloadX, "Whisper CPP"), "Subtitle Edit", MessageBoxButtons.YesNoCancel) == DialogResult.Yes)
{
using (var downloadForm = new WhisperDownload(WhisperChoice.Cpp))
{
if (downloadForm.ShowDialog(this) != DialogResult.OK)
{
return;
}
}
}
}
Init(); Init();
} }
else if (comboBoxWhisperEngine.Text == WhisperChoice.ConstMe) else if (comboBoxWhisperEngine.Text == WhisperChoice.ConstMe)

View File

@ -37,11 +37,11 @@
this.labelInfo = new System.Windows.Forms.Label(); this.labelInfo = new System.Windows.Forms.Label();
this.groupBoxModels = new System.Windows.Forms.GroupBox(); this.groupBoxModels = new System.Windows.Forms.GroupBox();
this.labelChooseLanguage = new System.Windows.Forms.Label(); this.labelChooseLanguage = new System.Windows.Forms.Label();
this.comboBoxLanguages = new System.Windows.Forms.ComboBox(); this.comboBoxLanguages = new Nikse.SubtitleEdit.Controls.NikseComboBox();
this.buttonDownload = new System.Windows.Forms.Button(); this.buttonDownload = new System.Windows.Forms.Button();
this.linkLabelOpenModelsFolder = new System.Windows.Forms.LinkLabel(); this.linkLabelOpenModelsFolder = new System.Windows.Forms.LinkLabel();
this.labelModel = new System.Windows.Forms.Label(); this.labelModel = new System.Windows.Forms.Label();
this.comboBoxModels = new System.Windows.Forms.ComboBox(); this.comboBoxModels = new Nikse.SubtitleEdit.Controls.NikseComboBox();
this.linkLabeWhisperWebSite = new System.Windows.Forms.LinkLabel(); this.linkLabeWhisperWebSite = new System.Windows.Forms.LinkLabel();
this.labelTime = new System.Windows.Forms.Label(); this.labelTime = new System.Windows.Forms.Label();
this.timer1 = new System.Windows.Forms.Timer(this.components); this.timer1 = new System.Windows.Forms.Timer(this.components);
@ -54,7 +54,7 @@
this.setCPPConstmeModelsFolderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.setCPPConstmeModelsFolderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.removeTemporaryFilesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.removeTemporaryFilesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.labelEngine = new System.Windows.Forms.Label(); this.labelEngine = new System.Windows.Forms.Label();
this.comboBoxWhisperEngine = new System.Windows.Forms.ComboBox(); this.comboBoxWhisperEngine = new Nikse.SubtitleEdit.Controls.NikseComboBox();
this.labelAdvanced = new System.Windows.Forms.Label(); this.labelAdvanced = new System.Windows.Forms.Label();
this.buttonAdvanced = new System.Windows.Forms.Button(); this.buttonAdvanced = new System.Windows.Forms.Button();
this.groupBoxModels.SuspendLayout(); this.groupBoxModels.SuspendLayout();
@ -323,7 +323,6 @@
// //
this.comboBoxWhisperEngine.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 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.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxWhisperEngine.FormattingEnabled = true;
this.comboBoxWhisperEngine.Location = new System.Drawing.Point(543, 6); this.comboBoxWhisperEngine.Location = new System.Drawing.Point(543, 6);
this.comboBoxWhisperEngine.Name = "comboBoxWhisperEngine"; this.comboBoxWhisperEngine.Name = "comboBoxWhisperEngine";
this.comboBoxWhisperEngine.Size = new System.Drawing.Size(154, 21); this.comboBoxWhisperEngine.Size = new System.Drawing.Size(154, 21);
@ -404,7 +403,7 @@
private System.Windows.Forms.GroupBox groupBoxModels; private System.Windows.Forms.GroupBox groupBoxModels;
private System.Windows.Forms.LinkLabel linkLabeWhisperWebSite; private System.Windows.Forms.LinkLabel linkLabeWhisperWebSite;
private System.Windows.Forms.Label labelModel; private System.Windows.Forms.Label labelModel;
private System.Windows.Forms.ComboBox comboBoxModels; private Nikse.SubtitleEdit.Controls.NikseComboBox comboBoxModels;
private System.Windows.Forms.LinkLabel linkLabelOpenModelsFolder; private System.Windows.Forms.LinkLabel linkLabelOpenModelsFolder;
private System.Windows.Forms.Label labelTime; private System.Windows.Forms.Label labelTime;
private System.Windows.Forms.Timer timer1; private System.Windows.Forms.Timer timer1;
@ -414,12 +413,12 @@
private System.Windows.Forms.ListView listViewInputFiles; private System.Windows.Forms.ListView listViewInputFiles;
private System.Windows.Forms.ColumnHeader columnHeaderFileName; private System.Windows.Forms.ColumnHeader columnHeaderFileName;
private System.Windows.Forms.Label labelChooseLanguage; private System.Windows.Forms.Label labelChooseLanguage;
private System.Windows.Forms.ComboBox comboBoxLanguages; private Nikse.SubtitleEdit.Controls.NikseComboBox comboBoxLanguages;
private System.Windows.Forms.CheckBox checkBoxTranslateToEnglish; private System.Windows.Forms.CheckBox checkBoxTranslateToEnglish;
private System.Windows.Forms.ContextMenuStrip contextMenuStripWhisperAdvanced; private System.Windows.Forms.ContextMenuStrip contextMenuStripWhisperAdvanced;
private System.Windows.Forms.ToolStripMenuItem removeTemporaryFilesToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem removeTemporaryFilesToolStripMenuItem;
private System.Windows.Forms.Label labelEngine; private System.Windows.Forms.Label labelEngine;
private System.Windows.Forms.ComboBox comboBoxWhisperEngine; private Nikse.SubtitleEdit.Controls.NikseComboBox comboBoxWhisperEngine;
private System.Windows.Forms.ToolStripMenuItem setCPPConstmeModelsFolderToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem setCPPConstmeModelsFolderToolStripMenuItem;
private System.Windows.Forms.Label labelAdvanced; private System.Windows.Forms.Label labelAdvanced;
private System.Windows.Forms.Button buttonAdvanced; private System.Windows.Forms.Button buttonAdvanced;

View File

@ -424,7 +424,7 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
private void whisperPhpOriginalToolStripMenuItem_Click(object sender, EventArgs e) private void whisperPhpOriginalToolStripMenuItem_Click(object sender, EventArgs e)
{ {
Configuration.Settings.Tools.WhisperChoice = WhisperChoice.OpenAI; Configuration.Settings.Tools.WhisperChoice = WhisperChoice.OpenAi;
if (Configuration.IsRunningOnWindows) if (Configuration.IsRunningOnWindows)
{ {
@ -624,7 +624,7 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
return; return;
} }
if (comboBoxWhisperEngine.Text == WhisperChoice.OpenAI) if (comboBoxWhisperEngine.Text == WhisperChoice.OpenAi)
{ {
whisperPhpOriginalToolStripMenuItem_Click(null, null); whisperPhpOriginalToolStripMenuItem_Click(null, null);
} }

View File

@ -30,7 +30,6 @@
{ {
this.labelDescription1 = new System.Windows.Forms.Label(); this.labelDescription1 = new System.Windows.Forms.Label();
this.labelPleaseWait = new System.Windows.Forms.Label(); this.labelPleaseWait = new System.Windows.Forms.Label();
this.labelWhisperChoice = new System.Windows.Forms.Label();
this.SuspendLayout(); this.SuspendLayout();
// //
// labelDescription1 // labelDescription1
@ -51,23 +50,11 @@
this.labelPleaseWait.TabIndex = 28; this.labelPleaseWait.TabIndex = 28;
this.labelPleaseWait.Text = "Please wait..."; this.labelPleaseWait.Text = "Please wait...";
// //
// labelWhisperChoice
//
this.labelWhisperChoice.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.labelWhisperChoice.AutoSize = true;
this.labelWhisperChoice.ForeColor = System.Drawing.SystemColors.ControlDarkDark;
this.labelWhisperChoice.Location = new System.Drawing.Point(274, 9);
this.labelWhisperChoice.Name = "labelWhisperChoice";
this.labelWhisperChoice.Size = new System.Drawing.Size(28, 13);
this.labelWhisperChoice.TabIndex = 30;
this.labelWhisperChoice.Text = "CPP";
//
// WhisperDownload // WhisperDownload
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(320, 93); this.ClientSize = new System.Drawing.Size(320, 93);
this.Controls.Add(this.labelWhisperChoice);
this.Controls.Add(this.labelDescription1); this.Controls.Add(this.labelDescription1);
this.Controls.Add(this.labelPleaseWait); this.Controls.Add(this.labelPleaseWait);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
@ -87,6 +74,5 @@
private System.Windows.Forms.Label labelDescription1; private System.Windows.Forms.Label labelDescription1;
private System.Windows.Forms.Label labelPleaseWait; private System.Windows.Forms.Label labelPleaseWait;
private System.Windows.Forms.Label labelWhisperChoice;
} }
} }

View File

@ -81,8 +81,6 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
labelDescription1.Text = LanguageSettings.Current.GetTesseractDictionaries.Download + " " + whisperChoice; labelDescription1.Text = LanguageSettings.Current.GetTesseractDictionaries.Download + " " + whisperChoice;
_cancellationTokenSource = new CancellationTokenSource(); _cancellationTokenSource = new CancellationTokenSource();
_whisperChoice = whisperChoice; _whisperChoice = whisperChoice;
labelWhisperChoice.Text = _whisperChoice;
labelWhisperChoice.Left = Width - labelWhisperChoice.Width - 20;
} }
private void WhisperDownload_Shown(object sender, EventArgs e) private void WhisperDownload_Shown(object sender, EventArgs e)
@ -170,6 +168,16 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
Directory.CreateDirectory(folder); Directory.CreateDirectory(folder);
} }
if (_whisperChoice == WhisperChoice.Cpp)
{
folder = Path.Combine(folder, "Cpp");
if (!Directory.Exists(folder))
{
Directory.CreateDirectory(folder);
}
}
if (_whisperChoice == WhisperChoice.ConstMe) if (_whisperChoice == WhisperChoice.ConstMe)
{ {
folder = Path.Combine(folder, "Const-me"); folder = Path.Combine(folder, "Const-me");
@ -178,30 +186,58 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
{ {
Directory.CreateDirectory(folder); Directory.CreateDirectory(folder);
} }
try
{
File.WriteAllText(Path.Combine(folder, "models.txt"), "Whisper Const-me uses models from Whisper.cpp");
}
catch
{
// ignore
}
} }
if (_whisperChoice == WhisperChoice.PurfviewFasterWhisper) if (_whisperChoice == WhisperChoice.PurfviewFasterWhisper)
{ {
folder = Path.Combine(folder, "Purfview"); folder = Path.Combine(folder, "Purfview-Whisper-Faster");
if (!Directory.Exists(folder)) if (!Directory.Exists(folder))
{ {
Directory.CreateDirectory(folder); Directory.CreateDirectory(folder);
} }
}
var skipFileNames = new[] { "command.exe", "stream.exe", "talk.exe", "bench.exe" }; using (var zip = ZipExtractor.Open(downloadStream))
using (var zip = ZipExtractor.Open(downloadStream))
{
var dir = zip.ReadCentralDir();
foreach (var entry in dir)
{ {
var path = Path.Combine(folder, entry.FilenameInZip); var dir = zip.ReadCentralDir();
if (!skipFileNames.Contains(entry.FilenameInZip)) foreach (var entry in dir)
{ {
zip.ExtractFile(entry, path); if (entry.FilenameInZip.EndsWith(WhisperHelper.GetExecutableFileName(WhisperChoice.PurfviewFasterWhisper)))
{
var path = Path.Combine(folder, Path.GetFileName(entry.FilenameInZip));
zip.ExtractFile(entry, path);
}
} }
} }
} }
else
{
var skipFileNames = new[] { "command.exe", "stream.exe", "talk.exe", "bench.exe" };
using (var zip = ZipExtractor.Open(downloadStream))
{
var dir = zip.ReadCentralDir();
foreach (var entry in dir)
{
var path = Path.Combine(folder, entry.FilenameInZip);
if (!skipFileNames.Contains(entry.FilenameInZip))
{
zip.ExtractFile(entry, path);
}
}
}
}
Cursor = Cursors.Default; Cursor = Cursors.Default;
labelPleaseWait.Text = string.Empty; labelPleaseWait.Text = string.Empty;

View File

@ -31,7 +31,7 @@
this.labelPleaseWait = new System.Windows.Forms.Label(); this.labelPleaseWait = new System.Windows.Forms.Label();
this.buttonDownload = new System.Windows.Forms.Button(); this.buttonDownload = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button(); this.buttonCancel = new System.Windows.Forms.Button();
this.comboBoxModels = new System.Windows.Forms.ComboBox(); this.comboBoxModels = new Nikse.SubtitleEdit.Controls.NikseComboBox();
this.textBoxError = new System.Windows.Forms.TextBox(); this.textBoxError = new System.Windows.Forms.TextBox();
this.labelFileName = new System.Windows.Forms.Label(); this.labelFileName = new System.Windows.Forms.Label();
this.SuspendLayout(); this.SuspendLayout();
@ -132,7 +132,7 @@
private System.Windows.Forms.Label labelPleaseWait; private System.Windows.Forms.Label labelPleaseWait;
private System.Windows.Forms.Button buttonDownload; private System.Windows.Forms.Button buttonDownload;
private System.Windows.Forms.Button buttonCancel; private System.Windows.Forms.Button buttonCancel;
private System.Windows.Forms.ComboBox comboBoxModels; private Nikse.SubtitleEdit.Controls.NikseComboBox comboBoxModels;
private System.Windows.Forms.TextBox textBoxError; private System.Windows.Forms.TextBox textBoxError;
private System.Windows.Forms.Label labelFileName; private System.Windows.Forms.Label labelFileName;
} }

View File

@ -1046,6 +1046,7 @@
this.comboBoxSubtitleFormats.SelectedItem = null; this.comboBoxSubtitleFormats.SelectedItem = null;
this.comboBoxSubtitleFormats.SelectedText = null; this.comboBoxSubtitleFormats.SelectedText = null;
this.comboBoxSubtitleFormats.Size = new System.Drawing.Size(150, 23); this.comboBoxSubtitleFormats.Size = new System.Drawing.Size(150, 23);
this.comboBoxSubtitleFormats.Text = null;
this.comboBoxSubtitleFormats.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSubtitleFormatsSelectedIndexChanged); this.comboBoxSubtitleFormats.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSubtitleFormatsSelectedIndexChanged);
this.comboBoxSubtitleFormats.DropDown += new System.EventHandler(this.comboBoxSubtitleFormats_DropDown); this.comboBoxSubtitleFormats.DropDown += new System.EventHandler(this.comboBoxSubtitleFormats_DropDown);
this.comboBoxSubtitleFormats.DropDownClosed += new System.EventHandler(this.comboBoxSubtitleFormats_DropDownClosed); this.comboBoxSubtitleFormats.DropDownClosed += new System.EventHandler(this.comboBoxSubtitleFormats_DropDownClosed);
@ -1083,6 +1084,7 @@
this.comboBoxEncoding.SelectedItem = null; this.comboBoxEncoding.SelectedItem = null;
this.comboBoxEncoding.SelectedText = null; this.comboBoxEncoding.SelectedText = null;
this.comboBoxEncoding.Size = new System.Drawing.Size(129, 23); this.comboBoxEncoding.Size = new System.Drawing.Size(129, 23);
this.comboBoxEncoding.Text = null;
this.comboBoxEncoding.DropDown += new System.EventHandler(this.MenuOpened); this.comboBoxEncoding.DropDown += new System.EventHandler(this.MenuOpened);
this.comboBoxEncoding.DropDownClosed += new System.EventHandler(this.MenuClosed); this.comboBoxEncoding.DropDownClosed += new System.EventHandler(this.MenuClosed);
// //
@ -3418,9 +3420,9 @@
this.toolStripButtonWaveformPlay, this.toolStripButtonWaveformPlay,
this.toolStripButtonLockCenter, this.toolStripButtonLockCenter,
this.toolStripSplitButtonPlayRate}); this.toolStripSplitButtonPlayRate});
this.toolStripWaveControls.Location = new System.Drawing.Point(0, 3); this.toolStripWaveControls.Location = new System.Drawing.Point(0, 2);
this.toolStripWaveControls.Name = "toolStripWaveControls"; this.toolStripWaveControls.Name = "toolStripWaveControls";
this.toolStripWaveControls.Size = new System.Drawing.Size(251, 25); this.toolStripWaveControls.Size = new System.Drawing.Size(195, 26);
this.toolStripWaveControls.TabIndex = 0; this.toolStripWaveControls.TabIndex = 0;
this.toolStripWaveControls.Text = "toolStrip2"; this.toolStripWaveControls.Text = "toolStrip2";
// //
@ -3431,16 +3433,28 @@
this.toolStripButtonWaveformZoomOut.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; this.toolStripButtonWaveformZoomOut.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
this.toolStripButtonWaveformZoomOut.ImageTransparentColor = System.Drawing.Color.Magenta; this.toolStripButtonWaveformZoomOut.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripButtonWaveformZoomOut.Name = "toolStripButtonWaveformZoomOut"; this.toolStripButtonWaveformZoomOut.Name = "toolStripButtonWaveformZoomOut";
this.toolStripButtonWaveformZoomOut.Size = new System.Drawing.Size(23, 22); this.toolStripButtonWaveformZoomOut.Size = new System.Drawing.Size(23, 23);
this.toolStripButtonWaveformZoomOut.Text = "toolStripButton3"; this.toolStripButtonWaveformZoomOut.Text = "toolStripButton3";
this.toolStripButtonWaveformZoomOut.Click += new System.EventHandler(this.toolStripButtonWaveformZoomOut_Click); this.toolStripButtonWaveformZoomOut.Click += new System.EventHandler(this.toolStripButtonWaveformZoomOut_Click);
// //
// toolStripComboBoxWaveform // toolStripComboBoxWaveform
// //
this.toolStripComboBoxWaveform.AutoSize = false; this.toolStripComboBoxWaveform.AutoSize = false;
this.toolStripComboBoxWaveform.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(171)))), ((int)(((byte)(173)))), ((int)(((byte)(179)))));
this.toolStripComboBoxWaveform.BackColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
this.toolStripComboBoxWaveform.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(171)))), ((int)(((byte)(173)))), ((int)(((byte)(179)))));
this.toolStripComboBoxWaveform.ButtonForeColor = System.Drawing.SystemColors.ControlText;
this.toolStripComboBoxWaveform.ButtonForeColorDown = System.Drawing.Color.Orange;
this.toolStripComboBoxWaveform.ButtonForeColorOver = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215)))));
this.toolStripComboBoxWaveform.DropDownHeight = 400;
this.toolStripComboBoxWaveform.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.toolStripComboBoxWaveform.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.toolStripComboBoxWaveform.Name = "toolStripComboBoxWaveform"; this.toolStripComboBoxWaveform.Name = "toolStripComboBoxWaveform";
this.toolStripComboBoxWaveform.Padding = new System.Windows.Forms.Padding(2);
this.toolStripComboBoxWaveform.SelectedIndex = -1;
this.toolStripComboBoxWaveform.SelectedItem = null;
this.toolStripComboBoxWaveform.SelectedText = null;
this.toolStripComboBoxWaveform.Size = new System.Drawing.Size(62, 23); this.toolStripComboBoxWaveform.Size = new System.Drawing.Size(62, 23);
this.toolStripComboBoxWaveform.Text = null;
// //
// toolStripButtonWaveformZoomIn // toolStripButtonWaveformZoomIn
// //
@ -3449,14 +3463,14 @@
this.toolStripButtonWaveformZoomIn.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; this.toolStripButtonWaveformZoomIn.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
this.toolStripButtonWaveformZoomIn.ImageTransparentColor = System.Drawing.Color.Magenta; this.toolStripButtonWaveformZoomIn.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripButtonWaveformZoomIn.Name = "toolStripButtonWaveformZoomIn"; this.toolStripButtonWaveformZoomIn.Name = "toolStripButtonWaveformZoomIn";
this.toolStripButtonWaveformZoomIn.Size = new System.Drawing.Size(23, 22); this.toolStripButtonWaveformZoomIn.Size = new System.Drawing.Size(23, 23);
this.toolStripButtonWaveformZoomIn.Text = "toolStripButton1"; this.toolStripButtonWaveformZoomIn.Text = "toolStripButton1";
this.toolStripButtonWaveformZoomIn.Click += new System.EventHandler(this.toolStripButtonWaveformZoomIn_Click); this.toolStripButtonWaveformZoomIn.Click += new System.EventHandler(this.toolStripButtonWaveformZoomIn_Click);
// //
// toolStripSeparator16 // toolStripSeparator16
// //
this.toolStripSeparator16.Name = "toolStripSeparator16"; this.toolStripSeparator16.Name = "toolStripSeparator16";
this.toolStripSeparator16.Size = new System.Drawing.Size(6, 25); this.toolStripSeparator16.Size = new System.Drawing.Size(6, 26);
// //
// toolStripButtonWaveformPause // toolStripButtonWaveformPause
// //
@ -3466,7 +3480,7 @@
this.toolStripButtonWaveformPause.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; this.toolStripButtonWaveformPause.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
this.toolStripButtonWaveformPause.ImageTransparentColor = System.Drawing.Color.Magenta; this.toolStripButtonWaveformPause.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripButtonWaveformPause.Name = "toolStripButtonWaveformPause"; this.toolStripButtonWaveformPause.Name = "toolStripButtonWaveformPause";
this.toolStripButtonWaveformPause.Size = new System.Drawing.Size(23, 22); this.toolStripButtonWaveformPause.Size = new System.Drawing.Size(23, 23);
this.toolStripButtonWaveformPause.Text = "toolStripButton1"; this.toolStripButtonWaveformPause.Text = "toolStripButton1";
this.toolStripButtonWaveformPause.Visible = false; this.toolStripButtonWaveformPause.Visible = false;
this.toolStripButtonWaveformPause.Click += new System.EventHandler(this.toolStripButtonWaveformPause_Click); this.toolStripButtonWaveformPause.Click += new System.EventHandler(this.toolStripButtonWaveformPause_Click);
@ -3479,7 +3493,7 @@
this.toolStripButtonWaveformPlay.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; this.toolStripButtonWaveformPlay.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
this.toolStripButtonWaveformPlay.ImageTransparentColor = System.Drawing.Color.Magenta; this.toolStripButtonWaveformPlay.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripButtonWaveformPlay.Name = "toolStripButtonWaveformPlay"; this.toolStripButtonWaveformPlay.Name = "toolStripButtonWaveformPlay";
this.toolStripButtonWaveformPlay.Size = new System.Drawing.Size(23, 22); this.toolStripButtonWaveformPlay.Size = new System.Drawing.Size(23, 23);
this.toolStripButtonWaveformPlay.Text = "toolStripButton1"; this.toolStripButtonWaveformPlay.Text = "toolStripButton1";
this.toolStripButtonWaveformPlay.Click += new System.EventHandler(this.toolStripButtonWaveformPlay_Click); this.toolStripButtonWaveformPlay.Click += new System.EventHandler(this.toolStripButtonWaveformPlay_Click);
// //
@ -3490,7 +3504,7 @@
this.toolStripButtonLockCenter.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; this.toolStripButtonLockCenter.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
this.toolStripButtonLockCenter.ImageTransparentColor = System.Drawing.Color.Magenta; this.toolStripButtonLockCenter.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripButtonLockCenter.Name = "toolStripButtonLockCenter"; this.toolStripButtonLockCenter.Name = "toolStripButtonLockCenter";
this.toolStripButtonLockCenter.Size = new System.Drawing.Size(23, 22); this.toolStripButtonLockCenter.Size = new System.Drawing.Size(23, 23);
this.toolStripButtonLockCenter.Text = "Center"; this.toolStripButtonLockCenter.Text = "Center";
this.toolStripButtonLockCenter.Click += new System.EventHandler(this.toolStripButtonLockCenter_Click); this.toolStripButtonLockCenter.Click += new System.EventHandler(this.toolStripButtonLockCenter_Click);
// //
@ -3501,7 +3515,7 @@
this.toolStripSplitButtonPlayRate.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; this.toolStripSplitButtonPlayRate.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
this.toolStripSplitButtonPlayRate.ImageTransparentColor = System.Drawing.Color.Magenta; this.toolStripSplitButtonPlayRate.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripSplitButtonPlayRate.Name = "toolStripSplitButtonPlayRate"; this.toolStripSplitButtonPlayRate.Name = "toolStripSplitButtonPlayRate";
this.toolStripSplitButtonPlayRate.Size = new System.Drawing.Size(32, 22); this.toolStripSplitButtonPlayRate.Size = new System.Drawing.Size(32, 23);
this.toolStripSplitButtonPlayRate.Text = "Play rate (speed)"; this.toolStripSplitButtonPlayRate.Text = "Play rate (speed)";
this.toolStripSplitButtonPlayRate.ButtonClick += new System.EventHandler(this.toolStripSplitButtonPlayRate_ButtonClick); this.toolStripSplitButtonPlayRate.ButtonClick += new System.EventHandler(this.toolStripSplitButtonPlayRate_ButtonClick);
// //
@ -3634,6 +3648,7 @@
this.comboBoxAutoContinue.DropDownHeight = 400; this.comboBoxAutoContinue.DropDownHeight = 400;
this.comboBoxAutoContinue.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboBoxAutoContinue.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxAutoContinue.DropDownWidth = 96; this.comboBoxAutoContinue.DropDownWidth = 96;
this.comboBoxAutoContinue.FormattingEnabled = false;
this.comboBoxAutoContinue.Items.AddRange(new object[] { this.comboBoxAutoContinue.Items.AddRange(new object[] {
"0", "0",
"1", "1",
@ -3658,6 +3673,7 @@
this.comboBoxAutoContinue.SelectedText = null; this.comboBoxAutoContinue.SelectedText = null;
this.comboBoxAutoContinue.Size = new System.Drawing.Size(96, 21); this.comboBoxAutoContinue.Size = new System.Drawing.Size(96, 21);
this.comboBoxAutoContinue.TabIndex = 2; this.comboBoxAutoContinue.TabIndex = 2;
this.comboBoxAutoContinue.Text = null;
// //
// labelAutoContinueDelay // labelAutoContinueDelay
// //
@ -3713,6 +3729,7 @@
this.comboBoxAutoRepeat.DropDownHeight = 400; this.comboBoxAutoRepeat.DropDownHeight = 400;
this.comboBoxAutoRepeat.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboBoxAutoRepeat.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxAutoRepeat.DropDownWidth = 96; this.comboBoxAutoRepeat.DropDownWidth = 96;
this.comboBoxAutoRepeat.FormattingEnabled = false;
this.comboBoxAutoRepeat.Items.AddRange(new object[] { this.comboBoxAutoRepeat.Items.AddRange(new object[] {
"0", "0",
"1", "1",
@ -3731,6 +3748,7 @@
this.comboBoxAutoRepeat.SelectedText = null; this.comboBoxAutoRepeat.SelectedText = null;
this.comboBoxAutoRepeat.Size = new System.Drawing.Size(96, 21); this.comboBoxAutoRepeat.Size = new System.Drawing.Size(96, 21);
this.comboBoxAutoRepeat.TabIndex = 2; this.comboBoxAutoRepeat.TabIndex = 2;
this.comboBoxAutoRepeat.Text = null;
// //
// labelAutoRepeatCount // labelAutoRepeatCount
// //

View File

@ -34957,10 +34957,10 @@ namespace Nikse.SubtitleEdit.Forms
return true; return true;
} }
var fullPath = Path.Combine(Configuration.DataDirectory, "Whisper", "main.exe"); var fullPath = Path.Combine(Configuration.DataDirectory, "Whisper", "Cpp", "main.exe");
if (!File.Exists(fullPath) || WhisperDownload.IsOld(fullPath, WhisperChoice.Cpp)) if (!File.Exists(fullPath) || WhisperDownload.IsOld(fullPath, WhisperChoice.Cpp))
{ {
if (MessageBox.Show(string.Format(LanguageSettings.Current.Settings.DownloadX, "whisper.cpp"), "Subtitle Edit", MessageBoxButtons.YesNoCancel) != DialogResult.Yes) if (MessageBox.Show(string.Format(LanguageSettings.Current.Settings.DownloadX, "Whisper.cpp"), "Subtitle Edit", MessageBoxButtons.YesNoCancel) != DialogResult.Yes)
{ {
return false; return false;
} }
@ -35196,16 +35196,6 @@ namespace Nikse.SubtitleEdit.Forms
} }
} }
if (!WhisperHelper.IsWhisperInstalled())
{
if (MessageBox.Show(LanguageSettings.Current.AudioToText.WhisperNotFound,
"Subtitle Edit",
MessageBoxButtons.YesNoCancel) == DialogResult.Yes)
{
UiUtil.ShowHelp("#audio_to_text_whisper");
}
}
CheckWhisperCpp(); CheckWhisperCpp();
var oldVideoFileName = _videoFileName; var oldVideoFileName = _videoFileName;
@ -35237,16 +35227,13 @@ namespace Nikse.SubtitleEdit.Forms
} }
else if (form.UnknownArgument) else if (form.UnknownArgument)
{ {
if (MessageBox.Show(string.Format(LanguageSettings.Current.Settings.DownloadX, "whisper.cpp"), "Subtitle Edit", MessageBoxButtons.YesNoCancel) == DialogResult.Yes) var customArgument = Configuration.Settings.Tools.WhisperExtraSettings;
var extraMessage = string.Empty;
if (!string.IsNullOrEmpty(customArgument))
{ {
using (var downloadForm = new WhisperDownload(WhisperChoice.Cpp)) extraMessage = Environment.NewLine + "Note you have a custom argument: " + customArgument;
{
if (form.ShowDialog(this) == DialogResult.OK)
{
audioToTextWhisperTolStripMenuItem_Click(null, null);
}
}
} }
MessageBox.Show($"Whisper reported unknown argument - check 'error_log.txt'" + extraMessage);
} }
else else
{ {
@ -35276,13 +35263,13 @@ namespace Nikse.SubtitleEdit.Forms
if (Configuration.IsRunningOnLinux && WhisperHelper.GetWhisperPathAndFileName() == "whisper") if (Configuration.IsRunningOnLinux && WhisperHelper.GetWhisperPathAndFileName() == "whisper")
{ {
SeLogger.Error("UseWhisperChoice changed to 'OpenAI' as 'Whisper/whisper' or '/Whisper/main' was not found!"); SeLogger.Error("UseWhisperChoice changed to 'OpenAI' as 'Whisper/whisper' or '/Whisper/main' was not found!");
Configuration.Settings.Tools.WhisperChoice = WhisperChoice.OpenAI; Configuration.Settings.Tools.WhisperChoice = WhisperChoice.OpenAi;
} }
if (Configuration.IsRunningOnWindows && WhisperHelper.GetWhisperPathAndFileName() == "whisper") if (Configuration.IsRunningOnWindows && WhisperHelper.GetWhisperPathAndFileName() == "whisper")
{ {
SeLogger.Error("UseWhisperChoice changed to 'OpenAI' as 'Whisper/whisper.exe' or '/Whisper/main.exe' was not found!"); SeLogger.Error("UseWhisperChoice changed to 'OpenAI' as 'Whisper/whisper.exe' or '/Whisper/main.exe' was not found!");
Configuration.Settings.Tools.WhisperChoice = WhisperChoice.OpenAI; Configuration.Settings.Tools.WhisperChoice = WhisperChoice.OpenAi;
} }
} }