mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 11:12:36 +01:00
use whisper_log.tdt
This commit is contained in:
parent
8b84d6248b
commit
d257776412
@ -67,12 +67,41 @@ namespace Nikse.SubtitleEdit.Core.Common
|
||||
writer.WriteLine();
|
||||
}
|
||||
}
|
||||
catch
|
||||
catch
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
public static void WhisperInfo(string message)
|
||||
{
|
||||
try
|
||||
{
|
||||
var filePath = GetWhisperLogFilePath();
|
||||
using (var writer = new StreamWriter(filePath, true, Encoding.UTF8))
|
||||
{
|
||||
writer.WriteLine("-----------------------------------------------------------------------------");
|
||||
writer.WriteLine($"Date: {DateTime.Now.ToString(CultureInfo.InvariantCulture)}");
|
||||
writer.WriteLine($"SE: {GetSeInfo()}");
|
||||
if (!string.IsNullOrWhiteSpace(message))
|
||||
{
|
||||
writer.WriteLine("Message: " + message);
|
||||
}
|
||||
|
||||
writer.WriteLine();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetWhisperLogFilePath()
|
||||
{
|
||||
return Path.Combine(Configuration.DataDirectory, "whisper_log.txt");
|
||||
}
|
||||
|
||||
private static string GetSeInfo()
|
||||
{
|
||||
try
|
||||
|
@ -5,6 +5,7 @@ using System.Drawing;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Nikse.SubtitleEdit.Logic;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Controls
|
||||
{
|
||||
@ -744,6 +745,36 @@ namespace Nikse.SubtitleEdit.Controls
|
||||
}
|
||||
}
|
||||
|
||||
public bool ReadOnly
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_simpleTextBox != null)
|
||||
{
|
||||
return _simpleTextBox.ReadOnly;
|
||||
}
|
||||
|
||||
if (_uiTextBox != null)
|
||||
{
|
||||
return _uiTextBox.ReadOnly;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_simpleTextBox != null)
|
||||
{
|
||||
_simpleTextBox.ReadOnly = value;
|
||||
}
|
||||
|
||||
if (_uiTextBox != null)
|
||||
{
|
||||
_uiTextBox.ReadOnly = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async Task CheckForLanguageChange(Subtitle subtitle)
|
||||
{
|
||||
|
@ -10,6 +10,7 @@ using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.IO.Ports;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
@ -313,14 +314,13 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
if (transcript == null || transcript.Paragraphs.Count == 0)
|
||||
{
|
||||
UpdateLog();
|
||||
SeLogger.Error(textBoxLog.Text);
|
||||
SeLogger.WhisperInfo(textBoxLog.Text);
|
||||
IncompleteModelName = comboBoxModels.Text;
|
||||
}
|
||||
else
|
||||
{
|
||||
//TODO: remove at some point
|
||||
UpdateLog();
|
||||
SeLogger.Error(textBoxLog.Text);
|
||||
SeLogger.WhisperInfo(textBoxLog.Text);
|
||||
}
|
||||
|
||||
DialogResult = DialogResult.OK;
|
||||
@ -847,7 +847,7 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
|
||||
if (!File.Exists(outWaveFile))
|
||||
{
|
||||
SeLogger.Error("Generated wave file not found: " + outWaveFile + Environment.NewLine +
|
||||
SeLogger.WhisperInfo("Generated wave file not found: " + outWaveFile + Environment.NewLine +
|
||||
"ffmpeg: " + process.StartInfo.FileName + Environment.NewLine +
|
||||
"Parameters: " + process.StartInfo.Arguments + Environment.NewLine +
|
||||
"OS: " + Environment.OSVersion + Environment.NewLine +
|
||||
@ -944,7 +944,7 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
var m = WhisperHelper.GetWhisperModelForCmdLine(model);
|
||||
var parameters = $"--language {language} --model \"{m}\" {outputSrt}{translateToEnglish}{Configuration.Settings.Tools.WhisperExtraSettings} \"{waveFileName}\"{postParams}";
|
||||
|
||||
SeLogger.Error($"{w} {parameters}");
|
||||
SeLogger.WhisperInfo($"{w} {parameters}");
|
||||
|
||||
var process = new Process { StartInfo = new ProcessStartInfo(w, parameters) { WindowStyle = ProcessWindowStyle.Hidden, CreateNoWindow = true } };
|
||||
|
||||
@ -1250,6 +1250,19 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
Init();
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var f = SeLogger.GetWhisperLogFilePath();
|
||||
if (File.Exists(f) && new FileInfo(f).Length > 50_000)
|
||||
{
|
||||
File.Delete(f);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
private void listViewInputFiles_DragEnter(object sender, DragEventArgs e)
|
||||
|
10
src/ui/Forms/CheckForUpdates.Designer.cs
generated
10
src/ui/Forms/CheckForUpdates.Designer.cs
generated
@ -1,4 +1,6 @@
|
||||
namespace Nikse.SubtitleEdit.Forms
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
partial class CheckForUpdates
|
||||
{
|
||||
@ -30,7 +32,7 @@
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.labelStatus = new System.Windows.Forms.Label();
|
||||
this.textBoxChangeLog = new System.Windows.Forms.TextBox();
|
||||
this.textBoxChangeLog = new Nikse.SubtitleEdit.Controls.SETextBox(true);
|
||||
this.buttonOK = new System.Windows.Forms.Button();
|
||||
this.buttonDownloadAndInstall = new System.Windows.Forms.Button();
|
||||
this.timerCheckForUpdates = new System.Windows.Forms.Timer(this.components);
|
||||
@ -56,7 +58,7 @@
|
||||
this.textBoxChangeLog.Multiline = true;
|
||||
this.textBoxChangeLog.Name = "textBoxChangeLog";
|
||||
this.textBoxChangeLog.ReadOnly = true;
|
||||
this.textBoxChangeLog.ScrollBars = System.Windows.Forms.ScrollBars.Both;
|
||||
this.textBoxChangeLog.ScrollBars = RichTextBoxScrollBars.Both;
|
||||
this.textBoxChangeLog.Size = new System.Drawing.Size(618, 53);
|
||||
this.textBoxChangeLog.TabIndex = 4;
|
||||
//
|
||||
@ -126,7 +128,7 @@
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Label labelStatus;
|
||||
private System.Windows.Forms.TextBox textBoxChangeLog;
|
||||
private Nikse.SubtitleEdit.Controls.SETextBox textBoxChangeLog;
|
||||
private System.Windows.Forms.Button buttonOK;
|
||||
private System.Windows.Forms.Button buttonDownloadAndInstall;
|
||||
private System.Windows.Forms.Timer timerCheckForUpdates;
|
||||
|
@ -35252,7 +35252,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
if (form.IncompleteModel)
|
||||
{
|
||||
MessageBox.Show($"No text found - model incomplete.{Environment.NewLine}Please re-download model: {form.IncompleteModelName}");
|
||||
MessageBox.Show($"No text found - model incomplete.{Environment.NewLine}" +
|
||||
$"Please re-download model: {form.IncompleteModelName}", MessageBoxIcon.Error);
|
||||
}
|
||||
else if (form.UnknownArgument)
|
||||
{
|
||||
@ -35262,11 +35263,22 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
extraMessage = Environment.NewLine + "Note you have a custom argument: " + customArgument;
|
||||
}
|
||||
MessageBox.Show($"Whisper reported unknown argument - check 'error_log.txt'" + extraMessage);
|
||||
extraMessage = extraMessage + Environment.NewLine + Environment.NewLine + "View the log file `whisper_log.txt`?";
|
||||
var r = MessageBox.Show($"Whisper reported unknown argument'" + extraMessage, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Error);
|
||||
if (r == DialogResult.Yes)
|
||||
{
|
||||
UiUtil.OpenFile(SeLogger.GetWhisperLogFilePath());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("No text found!");
|
||||
var r = MessageBox.Show("No text found!" + Environment.NewLine +
|
||||
Environment.NewLine +
|
||||
"View the log file `whisper_log.txt`?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Error);
|
||||
if (r == DialogResult.Yes)
|
||||
{
|
||||
UiUtil.OpenFile(SeLogger.GetWhisperLogFilePath());
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -4,6 +4,22 @@ namespace Nikse.SubtitleEdit.Forms.SeMsgBox
|
||||
{
|
||||
public static class MessageBox
|
||||
{
|
||||
public static DialogResult Show(string text, MessageBoxIcon icon)
|
||||
{
|
||||
using (var msgBox = new MessageBoxForm(text, string.Empty, MessageBoxButtons.OK, icon))
|
||||
{
|
||||
return msgBox.ShowDialog(Form.ActiveForm);
|
||||
}
|
||||
}
|
||||
|
||||
public static DialogResult Show(string text, MessageBoxButtons buttons, MessageBoxIcon icon)
|
||||
{
|
||||
using (var msgBox = new MessageBoxForm(text, string.Empty, buttons, icon))
|
||||
{
|
||||
return msgBox.ShowDialog(Form.ActiveForm);
|
||||
}
|
||||
}
|
||||
|
||||
public static DialogResult Show(string text)
|
||||
{
|
||||
using (var msgBox = new MessageBoxForm(text, string.Empty, MessageBoxButtons.OK))
|
||||
|
Loading…
Reference in New Issue
Block a user