Work on Whisper and Translator mode problems - thx rRobis :)

Work #8204
This commit is contained in:
Nikolaj Olsson 2024-04-17 19:09:09 +02:00
parent d6f56a0aec
commit c2120b6797

View File

@ -48,7 +48,6 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using Nikse.SubtitleEdit.Forms.Tts; using Nikse.SubtitleEdit.Forms.Tts;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TrackBar;
using CheckForUpdatesHelper = Nikse.SubtitleEdit.Logic.CheckForUpdatesHelper; using CheckForUpdatesHelper = Nikse.SubtitleEdit.Logic.CheckForUpdatesHelper;
using MessageBox = Nikse.SubtitleEdit.Forms.SeMsgBox.MessageBox; using MessageBox = Nikse.SubtitleEdit.Forms.SeMsgBox.MessageBox;
using Timer = System.Windows.Forms.Timer; using Timer = System.Windows.Forms.Timer;
@ -9850,6 +9849,9 @@ namespace Nikse.SubtitleEdit.Forms
return; return;
} }
var useOriginal = Configuration.Settings.General.AllowEditOfOriginalSubtitle &&
_subtitleOriginal != null &&
SubtitleListview1.IsOriginalTextColumnVisible;
var audioClips = GetAudioClips(); var audioClips = GetAudioClips();
if (audioClips.Count == 1 && audioClips[0].Paragraph.DurationTotalMilliseconds > 8_000) if (audioClips.Count == 1 && audioClips[0].Paragraph.DurationTotalMilliseconds > 8_000)
{ {
@ -9875,9 +9877,18 @@ namespace Nikse.SubtitleEdit.Forms
foreach (var p in form.TranscribedSubtitle.Paragraphs) foreach (var p in form.TranscribedSubtitle.Paragraphs)
{ {
p.Adjust(1, audioClips[0].Paragraph.StartTime.TotalSeconds); p.Adjust(1, audioClips[0].Paragraph.StartTime.TotalSeconds);
if (useOriginal)
{
_subtitleOriginal.InsertParagraphInCorrectTimeOrder(p);
}
else
{
_subtitle.InsertParagraphInCorrectTimeOrder(p); _subtitle.InsertParagraphInCorrectTimeOrder(p);
} }
}
_subtitle.Renumber();
_subtitleOriginal.Renumber();
SubtitleListview1.Fill(_subtitle, _subtitleOriginal); SubtitleListview1.Fill(_subtitle, _subtitleOriginal);
RestoreSubtitleListviewIndices(); RestoreSubtitleListviewIndices();
RefreshSelectedParagraph(); RefreshSelectedParagraph();
@ -9897,12 +9908,25 @@ namespace Nikse.SubtitleEdit.Forms
{ {
var p = _subtitle.Paragraphs.FirstOrDefault(pa => pa.Id == ac.Paragraph.Id); var p = _subtitle.Paragraphs.FirstOrDefault(pa => pa.Id == ac.Paragraph.Id);
if (p != null) if (p != null)
{
if (useOriginal)
{
var original = Utilities.GetOriginalParagraph(_subtitle.Paragraphs.IndexOf(p), p, _subtitleOriginal.Paragraphs);
if (original != null)
{
original.Text = ac.Paragraph.Text;
var idx = _subtitleOriginal.Paragraphs.IndexOf(original);
SubtitleListview1.SetOriginalText(idx, original.Text);
}
}
else
{ {
p.Text = ac.Paragraph.Text; p.Text = ac.Paragraph.Text;
var idx = _subtitle.Paragraphs.IndexOf(p); var idx = _subtitle.Paragraphs.IndexOf(p);
SubtitleListview1.SetText(idx, p.Text); SubtitleListview1.SetText(idx, p.Text);
} }
} }
}
SubtitleListview1.EndUpdate(); SubtitleListview1.EndUpdate();
RefreshSelectedParagraph(); RefreshSelectedParagraph();