mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-10-27 06:22:38 +01:00
Purfview Faster Whiaper:: Remove preprocessor_config.json
file if empty - thx Purfview :)
Fix #7813
This commit is contained in:
parent
abd36e5f9a
commit
087060d4d2
@ -8,22 +8,27 @@ namespace Nikse.SubtitleEdit.Core.AudioToText
|
||||
{
|
||||
public static IWhisperModel GetWhisperModel()
|
||||
{
|
||||
if (Configuration.Settings.Tools.WhisperChoice == WhisperChoice.Cpp || Configuration.Settings.Tools.WhisperChoice == WhisperChoice.CppCuBlas)
|
||||
return GetWhisperModel(Configuration.Settings.Tools.WhisperChoice);
|
||||
}
|
||||
|
||||
public static IWhisperModel GetWhisperModel(string whisperChoice)
|
||||
{
|
||||
if (whisperChoice == WhisperChoice.Cpp || whisperChoice == WhisperChoice.CppCuBlas)
|
||||
{
|
||||
return new WhisperCppModel();
|
||||
}
|
||||
|
||||
if (Configuration.Settings.Tools.WhisperChoice == WhisperChoice.ConstMe)
|
||||
if (whisperChoice == WhisperChoice.ConstMe)
|
||||
{
|
||||
return new WhisperConstMeModel();
|
||||
}
|
||||
|
||||
if (Configuration.Settings.Tools.WhisperChoice == WhisperChoice.CTranslate2)
|
||||
if (whisperChoice == WhisperChoice.CTranslate2)
|
||||
{
|
||||
return new WhisperCTranslate2Model();
|
||||
}
|
||||
|
||||
if (Configuration.Settings.Tools.WhisperChoice == WhisperChoice.PurfviewFasterWhisper)
|
||||
if (whisperChoice == WhisperChoice.PurfviewFasterWhisper)
|
||||
{
|
||||
return new WhisperPurfviewFasterWhisperModel();
|
||||
}
|
||||
|
@ -470,8 +470,8 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
}
|
||||
|
||||
TranscribedSubtitle = postProcessor.Fix(
|
||||
AudioToTextPostProcessor.Engine.Whisper,
|
||||
transcript,
|
||||
AudioToTextPostProcessor.Engine.Whisper,
|
||||
transcript,
|
||||
checkBoxUsePostProcessing.Checked,
|
||||
Configuration.Settings.Tools.WhisperPostProcessingAddPeriods,
|
||||
Configuration.Settings.Tools.WhisperPostProcessingMergeLines,
|
||||
@ -569,8 +569,8 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
ParagraphMaxChars = Configuration.Settings.General.SubtitleLineMaximumLength * 2,
|
||||
};
|
||||
TranscribedSubtitle = postProcessor.Fix(
|
||||
AudioToTextPostProcessor.Engine.Whisper,
|
||||
transcript,
|
||||
AudioToTextPostProcessor.Engine.Whisper,
|
||||
transcript,
|
||||
checkBoxUsePostProcessing.Checked,
|
||||
Configuration.Settings.Tools.WhisperPostProcessingAddPeriods,
|
||||
Configuration.Settings.Tools.WhisperPostProcessingMergeLines,
|
||||
@ -755,6 +755,32 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
TaskbarList.SetProgressValue(_parentForm.Handle, 1, 100);
|
||||
}
|
||||
|
||||
//Delete invalid preprocessor_config.json file
|
||||
if (Configuration.Settings.Tools.WhisperChoice == WhisperChoice.PurfviewFasterWhisper ||
|
||||
Configuration.Settings.Tools.WhisperChoice == WhisperChoice.PurfviewFasterWhisperCuda)
|
||||
{
|
||||
var dir = Path.Combine(WhisperHelper.GetWhisperFolder(), "_models", model.Folder);
|
||||
if (Directory.Exists(dir))
|
||||
{
|
||||
try
|
||||
{
|
||||
var preprocessorFileName = Path.Combine(dir, "preprocessor_config.json");
|
||||
if (File.Exists(preprocessorFileName))
|
||||
{
|
||||
var text = FileUtil.ReadAllTextShared(preprocessorFileName, Encoding.UTF8);
|
||||
if (text.StartsWith("Entry not found", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
File.Delete(preprocessorFileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
labelProgress.Refresh();
|
||||
Application.DoEvents();
|
||||
_resultList = new List<ResultText>();
|
||||
@ -2104,8 +2130,8 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
return;
|
||||
}
|
||||
|
||||
TranscribedSubtitle = postProcessor.Fix(AudioToTextPostProcessor.Engine.Whisper,
|
||||
_subtitle,
|
||||
TranscribedSubtitle = postProcessor.Fix(AudioToTextPostProcessor.Engine.Whisper,
|
||||
_subtitle,
|
||||
checkBoxUsePostProcessing.Checked,
|
||||
Configuration.Settings.Tools.WhisperPostProcessingAddPeriods,
|
||||
Configuration.Settings.Tools.WhisperPostProcessingMergeLines,
|
||||
|
@ -204,7 +204,7 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
if (streamLength < 50)
|
||||
{
|
||||
var text = FileUtil.ReadAllTextShared(_downloadFileName, Encoding.UTF8);
|
||||
if (text == "Entry not found" && _downloadFileName.Contains("vocabulary."))
|
||||
if (text.StartsWith("Entry not found", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -214,6 +214,7 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user