mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 03:02:35 +01:00
parent
9a8ec59a55
commit
24ae7397bf
@ -194,6 +194,7 @@ Read more info (web)?</WhisperNotFound>
|
||||
<UsePostProcessing>Use post-processing (line merge, fix casing, punctuation, and more)</UsePostProcessing>
|
||||
<BatchMode>Batch mode</BatchMode>
|
||||
<KeepPartialTranscription>Keep partial transcription</KeepPartialTranscription>
|
||||
<TranslateToEnglish>Translate to English</TranslateToEnglish>
|
||||
</AudioToText>
|
||||
<AssaAttachments>
|
||||
<Title>Advanced Sub Station Alpha attachments</Title>
|
||||
|
@ -54,6 +54,7 @@
|
||||
this.listViewInputFiles = new System.Windows.Forms.ListView();
|
||||
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.groupBoxModels.SuspendLayout();
|
||||
this.groupBoxInputFiles.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
@ -134,9 +135,9 @@
|
||||
this.groupBoxModels.Controls.Add(this.linkLabelOpenModelsFolder);
|
||||
this.groupBoxModels.Controls.Add(this.labelModel);
|
||||
this.groupBoxModels.Controls.Add(this.comboBoxModels);
|
||||
this.groupBoxModels.Location = new System.Drawing.Point(15, 66);
|
||||
this.groupBoxModels.Location = new System.Drawing.Point(15, 59);
|
||||
this.groupBoxModels.Name = "groupBoxModels";
|
||||
this.groupBoxModels.Size = new System.Drawing.Size(682, 82);
|
||||
this.groupBoxModels.Size = new System.Drawing.Size(682, 83);
|
||||
this.groupBoxModels.TabIndex = 3;
|
||||
this.groupBoxModels.TabStop = false;
|
||||
this.groupBoxModels.Text = "Language and models";
|
||||
@ -158,6 +159,7 @@
|
||||
this.comboBoxLanguages.Name = "comboBoxLanguages";
|
||||
this.comboBoxLanguages.Size = new System.Drawing.Size(240, 21);
|
||||
this.comboBoxLanguages.TabIndex = 5;
|
||||
this.comboBoxLanguages.SelectedIndexChanged += new System.EventHandler(this.comboBoxLanguages_SelectedIndexChanged);
|
||||
//
|
||||
// buttonDownload
|
||||
//
|
||||
@ -228,7 +230,7 @@
|
||||
// checkBoxUsePostProcessing
|
||||
//
|
||||
this.checkBoxUsePostProcessing.AutoSize = true;
|
||||
this.checkBoxUsePostProcessing.Location = new System.Drawing.Point(15, 162);
|
||||
this.checkBoxUsePostProcessing.Location = new System.Drawing.Point(15, 177);
|
||||
this.checkBoxUsePostProcessing.Name = "checkBoxUsePostProcessing";
|
||||
this.checkBoxUsePostProcessing.Size = new System.Drawing.Size(312, 17);
|
||||
this.checkBoxUsePostProcessing.TabIndex = 4;
|
||||
@ -332,11 +334,22 @@
|
||||
this.labelFC.Text = "labelFC";
|
||||
this.labelFC.TextAlign = System.Drawing.ContentAlignment.TopRight;
|
||||
//
|
||||
// checkBoxTranslateToEnglish
|
||||
//
|
||||
this.checkBoxTranslateToEnglish.AutoSize = true;
|
||||
this.checkBoxTranslateToEnglish.Location = new System.Drawing.Point(15, 153);
|
||||
this.checkBoxTranslateToEnglish.Name = "checkBoxTranslateToEnglish";
|
||||
this.checkBoxTranslateToEnglish.Size = new System.Drawing.Size(119, 17);
|
||||
this.checkBoxTranslateToEnglish.TabIndex = 20;
|
||||
this.checkBoxTranslateToEnglish.Text = "Translate to English";
|
||||
this.checkBoxTranslateToEnglish.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// WhisperAudioToText
|
||||
//
|
||||
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.checkBoxTranslateToEnglish);
|
||||
this.Controls.Add(this.labelFC);
|
||||
this.Controls.Add(this.groupBoxInputFiles);
|
||||
this.Controls.Add(this.buttonBatchMode);
|
||||
@ -397,5 +410,6 @@
|
||||
private System.Windows.Forms.Label labelFC;
|
||||
private System.Windows.Forms.Label labelChooseLanguage;
|
||||
private System.Windows.Forms.ComboBox comboBoxLanguages;
|
||||
private System.Windows.Forms.CheckBox checkBoxTranslateToEnglish;
|
||||
}
|
||||
}
|
@ -49,6 +49,7 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
labelModel.Text = LanguageSettings.Current.AudioToText.ChooseModel;
|
||||
labelChooseLanguage.Text = LanguageSettings.Current.AudioToText.ChooseLanguage;
|
||||
linkLabelOpenModelsFolder.Text = LanguageSettings.Current.AudioToText.OpenModelsFolder;
|
||||
checkBoxTranslateToEnglish.Text = LanguageSettings.Current.AudioToText.TranslateToEnglish;
|
||||
checkBoxUsePostProcessing.Text = LanguageSettings.Current.AudioToText.UsePostProcessing;
|
||||
buttonGenerate.Text = LanguageSettings.Current.Watermark.Generate;
|
||||
buttonCancel.Text = LanguageSettings.Current.General.Cancel;
|
||||
@ -305,7 +306,7 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
labelProgress.Refresh();
|
||||
Application.DoEvents();
|
||||
_resultList = new List<ResultText>();
|
||||
var process = GetWhisperProcess(waveFileName, model.Name, comboBoxLanguages.Text, OutputHandler);
|
||||
var process = GetWhisperProcess(waveFileName, model.Name, comboBoxLanguages.Text, checkBoxTranslateToEnglish.Checked, OutputHandler);
|
||||
_outputText.Add("Calling whisper with : whisper " + process.StartInfo.Arguments);
|
||||
ShowProgressBar();
|
||||
progressBar1.Style = ProgressBarStyle.Marquee;
|
||||
@ -518,10 +519,17 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
}
|
||||
}
|
||||
|
||||
public static Process GetWhisperProcess(string waveFileName, string model, string language, DataReceivedEventHandler dataReceivedHandler = null)
|
||||
public static Process GetWhisperProcess(string waveFileName, string model, string language, bool translate, DataReceivedEventHandler dataReceivedHandler = null)
|
||||
{
|
||||
// whisper --model tiny.en --language English --fp16 False a.wav
|
||||
var parameters = $"--model {model} --language \"{language}\" {Configuration.Settings.Tools.WhisperExtraSettings} \"{waveFileName}\"";
|
||||
|
||||
var translateToEnglish = translate ? "--task translate " : string.Empty;
|
||||
if (language.ToLowerInvariant() == "english" || language.ToLowerInvariant() == "en")
|
||||
{
|
||||
translateToEnglish = string.Empty;
|
||||
}
|
||||
|
||||
var parameters = $"--model {model} --language \"{language}\" {translateToEnglish}{Configuration.Settings.Tools.WhisperExtraSettings} \"{waveFileName}\"";
|
||||
var process = new Process { StartInfo = new ProcessStartInfo("whisper", parameters) { WindowStyle = ProcessWindowStyle.Hidden, CreateNoWindow = true } };
|
||||
|
||||
if (!string.IsNullOrEmpty(Configuration.Settings.General.FFmpegLocation) && process.StartInfo.EnvironmentVariables["Path"] != null)
|
||||
@ -801,5 +809,10 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBoxLanguages_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
checkBoxTranslateToEnglish.Enabled = comboBoxLanguages.Text.ToLowerInvariant() != "english";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -49,6 +49,7 @@
|
||||
this.groupBoxInputFiles = new System.Windows.Forms.GroupBox();
|
||||
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.groupBoxModels.SuspendLayout();
|
||||
this.groupBoxInputFiles.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
@ -129,7 +130,7 @@
|
||||
this.groupBoxModels.Controls.Add(this.linkLabelOpenModelsFolder);
|
||||
this.groupBoxModels.Controls.Add(this.labelModel);
|
||||
this.groupBoxModels.Controls.Add(this.comboBoxModels);
|
||||
this.groupBoxModels.Location = new System.Drawing.Point(15, 66);
|
||||
this.groupBoxModels.Location = new System.Drawing.Point(15, 60);
|
||||
this.groupBoxModels.Name = "groupBoxModels";
|
||||
this.groupBoxModels.Size = new System.Drawing.Size(682, 82);
|
||||
this.groupBoxModels.TabIndex = 1;
|
||||
@ -153,6 +154,7 @@
|
||||
this.comboBoxLanguages.Name = "comboBoxLanguages";
|
||||
this.comboBoxLanguages.Size = new System.Drawing.Size(194, 21);
|
||||
this.comboBoxLanguages.TabIndex = 7;
|
||||
this.comboBoxLanguages.SelectedIndexChanged += new System.EventHandler(this.comboBoxLanguages_SelectedIndexChanged);
|
||||
//
|
||||
// buttonDownload
|
||||
//
|
||||
@ -223,7 +225,7 @@
|
||||
// checkBoxUsePostProcessing
|
||||
//
|
||||
this.checkBoxUsePostProcessing.AutoSize = true;
|
||||
this.checkBoxUsePostProcessing.Location = new System.Drawing.Point(15, 162);
|
||||
this.checkBoxUsePostProcessing.Location = new System.Drawing.Point(15, 172);
|
||||
this.checkBoxUsePostProcessing.Name = "checkBoxUsePostProcessing";
|
||||
this.checkBoxUsePostProcessing.Size = new System.Drawing.Size(312, 17);
|
||||
this.checkBoxUsePostProcessing.TabIndex = 2;
|
||||
@ -265,11 +267,22 @@
|
||||
this.columnHeaderFileName.Text = "File name";
|
||||
this.columnHeaderFileName.Width = 455;
|
||||
//
|
||||
// checkBoxTranslateToEnglish
|
||||
//
|
||||
this.checkBoxTranslateToEnglish.AutoSize = true;
|
||||
this.checkBoxTranslateToEnglish.Location = new System.Drawing.Point(15, 148);
|
||||
this.checkBoxTranslateToEnglish.Name = "checkBoxTranslateToEnglish";
|
||||
this.checkBoxTranslateToEnglish.Size = new System.Drawing.Size(119, 17);
|
||||
this.checkBoxTranslateToEnglish.TabIndex = 21;
|
||||
this.checkBoxTranslateToEnglish.Text = "Translate to English";
|
||||
this.checkBoxTranslateToEnglish.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// 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.checkBoxTranslateToEnglish);
|
||||
this.Controls.Add(this.groupBoxInputFiles);
|
||||
this.Controls.Add(this.checkBoxUsePostProcessing);
|
||||
this.Controls.Add(this.labelTime);
|
||||
@ -323,5 +336,6 @@
|
||||
private System.Windows.Forms.ColumnHeader columnHeaderFileName;
|
||||
private System.Windows.Forms.Label labelChooseLanguage;
|
||||
private System.Windows.Forms.ComboBox comboBoxLanguages;
|
||||
private System.Windows.Forms.CheckBox checkBoxTranslateToEnglish;
|
||||
}
|
||||
}
|
@ -40,6 +40,7 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
labelModel.Text = LanguageSettings.Current.AudioToText.ChooseModel;
|
||||
labelChooseLanguage.Text = LanguageSettings.Current.AudioToText.ChooseLanguage;
|
||||
linkLabelOpenModelsFolder.Text = LanguageSettings.Current.AudioToText.OpenModelsFolder;
|
||||
checkBoxTranslateToEnglish.Text = LanguageSettings.Current.AudioToText.TranslateToEnglish;
|
||||
checkBoxUsePostProcessing.Text = LanguageSettings.Current.AudioToText.UsePostProcessing;
|
||||
buttonGenerate.Text = LanguageSettings.Current.Watermark.Generate;
|
||||
buttonCancel.Text = LanguageSettings.Current.General.Cancel;
|
||||
@ -172,7 +173,7 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
labelProgress.Refresh();
|
||||
Application.DoEvents();
|
||||
_resultList = new List<ResultText>();
|
||||
var process = WhisperAudioToText.GetWhisperProcess(waveFileName, model.Name, comboBoxLanguages.Text, OutputHandler);
|
||||
var process = WhisperAudioToText.GetWhisperProcess(waveFileName, model.Name, comboBoxLanguages.Text, checkBoxTranslateToEnglish.Checked, OutputHandler);
|
||||
_outputText.Add("Calling whisper with : whisper " + process.StartInfo.Arguments);
|
||||
ShowProgressBar();
|
||||
progressBar1.Style = ProgressBarStyle.Marquee;
|
||||
@ -438,5 +439,10 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
{
|
||||
listViewInputFiles.AutoSizeLastColumn();
|
||||
}
|
||||
|
||||
private void comboBoxLanguages_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
checkBoxTranslateToEnglish.Enabled = comboBoxLanguages.Text.ToLowerInvariant() != "english";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -340,6 +340,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
BatchMode = "Batch mode",
|
||||
XFilesSavedToVideoSourceFolder = "{0} files saved to video source folder",
|
||||
KeepPartialTranscription = "Keep partial transcription",
|
||||
TranslateToEnglish = "Translate to English",
|
||||
};
|
||||
|
||||
AssaAttachments = new LanguageStructure.AssaAttachments
|
||||
|
@ -523,6 +523,9 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
case "AudioToText/KeepPartialTranscription":
|
||||
language.AudioToText.KeepPartialTranscription = reader.Value;
|
||||
break;
|
||||
case "AudioToText/TranslateToEnglish":
|
||||
language.AudioToText.TranslateToEnglish = reader.Value;
|
||||
break;
|
||||
case "AssaAttachments/Title":
|
||||
language.AssaAttachments.Title = reader.Value;
|
||||
break;
|
||||
|
@ -1,4 +1,6 @@
|
||||
namespace Nikse.SubtitleEdit.Logic
|
||||
using System.Drawing;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Logic
|
||||
{
|
||||
// The language classes are built for easy xml-serialization (makes save/load code simple)
|
||||
public static class LanguageStructure
|
||||
@ -196,6 +198,7 @@
|
||||
public string UsePostProcessing { get; set; }
|
||||
public string BatchMode { get; set; }
|
||||
public string KeepPartialTranscription { get; set; }
|
||||
public string TranslateToEnglish { get; set; }
|
||||
}
|
||||
|
||||
public class AssaAttachments
|
||||
|
Loading…
Reference in New Issue
Block a user