diff --git a/Changelog.txt b/Changelog.txt index 5ad0797e5..aa5309ef9 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -9,6 +9,7 @@ * Add new subtitle format - thx Christophe * Add new subtitle format - thx Chris * Add ASSA style "Replace" - thxMishasama + * Add "audio to text selected lines" shortcuts * IMPROVED: * Update Chinese translation - thx nkh0472 * Update Korean translation - thx domddol diff --git a/LanguageBaseEnglish.xml b/LanguageBaseEnglish.xml index a2cf72641..dc978efdf 100644 --- a/LanguageBaseEnglish.xml +++ b/LanguageBaseEnglish.xml @@ -2519,7 +2519,8 @@ can edit in same subtitle file (collaboration) Reset play rate (speed) and waveform zoom Toggle video controls Toggle contrast (mpv only) - Audio to text + Audio to text ({0}) + Audio to text selected lines ({0}) Toggle brightness (mpv only) Translate, custom search 1 Translate, custom search 2 diff --git a/src/libse/Common/Settings.cs b/src/libse/Common/Settings.cs index bf618c5fc..2f3fddcf9 100644 --- a/src/libse/Common/Settings.cs +++ b/src/libse/Common/Settings.cs @@ -2362,7 +2362,8 @@ $HorzAlign = Center public string MainVideoReset { get; set; } public string MainVideoToggleBrightness { get; set; } public string MainVideoToggleContrast { get; set; } - public string MainVideoAudioToText { get; set; } + public string MainVideoAudioToTextVosk { get; set; } + public string MainVideoAudioToTextWhisper { get; set; } // spell check public string MainSpellCheck { get; set; } @@ -2538,6 +2539,8 @@ $HorzAlign = Center public string Waveform100MsRight { get; set; } public string Waveform1000MsLeft { get; set; } public string Waveform1000MsRight { get; set; } + public string WaveformAudioToTextVosk { get; set; } + public string WaveformAudioToTextWhisper { get; set; } public string MainCheckFixTimingViaShotChanges { get; set; } public string MainTranslateGoogleIt { get; set; } public string MainTranslateGoogleTranslateIt { get; set; } @@ -8787,10 +8790,16 @@ $HorzAlign = Center shortcuts.MainVideoToggleContrast = subNode.InnerText; } - subNode = node.SelectSingleNode("MainVideoAudioToText"); + subNode = node.SelectSingleNode("MainVideoAudioToTextVosk"); if (subNode != null) { - shortcuts.MainVideoAudioToText = subNode.InnerText; + shortcuts.MainVideoAudioToTextVosk = subNode.InnerText; + } + + subNode = node.SelectSingleNode("MainVideoAudioToTextWhisper"); + if (subNode != null) + { + shortcuts.MainVideoAudioToTextWhisper = subNode.InnerText; } subNode = node.SelectSingleNode("MainSpellCheck"); @@ -9861,6 +9870,18 @@ $HorzAlign = Center shortcuts.Waveform1000MsRight = subNode.InnerText; } + subNode = node.SelectSingleNode("WaveformAudioToTextVosk"); + if (subNode != null) + { + shortcuts.WaveformAudioToTextVosk = subNode.InnerText; + } + + subNode = node.SelectSingleNode("WaveformAudioToTextWhisper"); + if (subNode != null) + { + shortcuts.WaveformAudioToTextWhisper = subNode.InnerText; + } + subNode = node.SelectSingleNode("MainCheckFixTimingViaShotChanges"); if (subNode != null) { @@ -11107,7 +11128,8 @@ $HorzAlign = Center textWriter.WriteElementString("MainVideoReset", shortcuts.MainVideoReset); textWriter.WriteElementString("MainVideoToggleBrightness", shortcuts.MainVideoToggleBrightness); textWriter.WriteElementString("MainVideoToggleContrast", shortcuts.MainVideoToggleContrast); - textWriter.WriteElementString("MainVideoAudioToText", shortcuts.MainVideoAudioToText); + textWriter.WriteElementString("MainVideoAudioToTextVosk", shortcuts.MainVideoAudioToTextVosk); + textWriter.WriteElementString("MainVideoAudioToTextWhisper", shortcuts.MainVideoAudioToTextWhisper); textWriter.WriteElementString("MainSpellCheck", shortcuts.MainSpellCheck); textWriter.WriteElementString("MainSpellCheckFindDoubleWords", shortcuts.MainSpellCheckFindDoubleWords); textWriter.WriteElementString("MainSpellCheckAddWordToNames", shortcuts.MainSpellCheckAddWordToNames); @@ -11285,6 +11307,8 @@ $HorzAlign = Center textWriter.WriteElementString("Waveform100MsRight", shortcuts.Waveform100MsRight); textWriter.WriteElementString("Waveform1000MsLeft", shortcuts.Waveform1000MsLeft); textWriter.WriteElementString("Waveform1000MsRight", shortcuts.Waveform1000MsRight); + textWriter.WriteElementString("WaveformAudioToTextVosk", shortcuts.WaveformAudioToTextVosk); + textWriter.WriteElementString("WaveformAudioToTextWhisper", shortcuts.WaveformAudioToTextWhisper); textWriter.WriteElementString("MainCheckFixTimingViaShotChanges", shortcuts.MainCheckFixTimingViaShotChanges); textWriter.WriteElementString("MainTranslateGoogleIt", shortcuts.MainTranslateGoogleIt); textWriter.WriteElementString("MainTranslateGoogleTranslateIt", shortcuts.MainTranslateGoogleTranslateIt); diff --git a/src/ui/Forms/Main.cs b/src/ui/Forms/Main.cs index 802d383ee..08b6a23f4 100644 --- a/src/ui/Forms/Main.cs +++ b/src/ui/Forms/Main.cs @@ -8883,66 +8883,9 @@ namespace Nikse.SubtitleEdit.Forms UiUtil.OpenFolder(Path.GetDirectoryName(audioClips[0].AudioFileName)); }; - audioToTextWhisper.Click += (senderNew, eNew) => - { - if (!RequireFfmpegOk()) - { - return; - } + audioToTextWhisper.Click += (senderNew, eNew) => { AudioToTextWhisperSelectedLines(); }; - var audioClips = GetAudioClips(); - using (var form = new WhisperAudioToTextSelectedLines(audioClips, this)) - { - CheckWhisperCpp(); - if (form.ShowDialog(this) == DialogResult.OK) - { - MakeHistoryForUndo(string.Format(_language.BeforeX, string.Format(LanguageSettings.Current.Main.Menu.Video.VideoAudioToTextX, "Whisper"))); - SubtitleListview1.BeginUpdate(); - foreach (var ac in audioClips) - { - var p = _subtitle.Paragraphs.FirstOrDefault(pa => pa.Id == ac.Paragraph.Id); - if (p != null) - { - p.Text = ac.Paragraph.Text; - var idx = _subtitle.Paragraphs.IndexOf(p); - SubtitleListview1.SetText(idx, p.Text); - } - } - SubtitleListview1.EndUpdate(); - RefreshSelectedParagraph(); - } - } - }; - - audioToTextVosk.Click += (senderNew, eNew) => - { - if (!RequireFfmpegOk()) - { - return; - } - - var audioClips = GetAudioClips(); - using (var form = new VoskAudioToTextSelectedLines(audioClips, this)) - { - if (form.ShowDialog(this) == DialogResult.OK) - { - MakeHistoryForUndo(string.Format(_language.BeforeX, string.Format(LanguageSettings.Current.Main.Menu.Video.VideoAudioToTextX, "Vosk/Kaldi"))); - SubtitleListview1.BeginUpdate(); - foreach (var ac in audioClips) - { - var p = _subtitle.Paragraphs.FirstOrDefault(pa => pa.Id == ac.Paragraph.Id); - if (p != null) - { - p.Text = ac.Paragraph.Text; - var idx = _subtitle.Paragraphs.IndexOf(p); - SubtitleListview1.SetText(idx, p.Text); - } - } - SubtitleListview1.EndUpdate(); - RefreshSelectedParagraph(); - } - } - }; + audioToTextVosk.Click += (senderNew, eNew) => { AudioToTextVoskSelectedLines(); }; } toolStripMenuItemSetRegion.Visible = false; @@ -9400,6 +9343,69 @@ namespace Nikse.SubtitleEdit.Forms } } + private void AudioToTextVoskSelectedLines() + { + if (!RequireFfmpegOk()) + { + return; + } + + var audioClips = GetAudioClips(); + using (var form = new VoskAudioToTextSelectedLines(audioClips, this)) + { + if (form.ShowDialog(this) == DialogResult.OK) + { + MakeHistoryForUndo(string.Format(_language.BeforeX, string.Format(LanguageSettings.Current.Main.Menu.Video.VideoAudioToTextX, "Vosk/Kaldi"))); + SubtitleListview1.BeginUpdate(); + foreach (var ac in audioClips) + { + var p = _subtitle.Paragraphs.FirstOrDefault(pa => pa.Id == ac.Paragraph.Id); + if (p != null) + { + p.Text = ac.Paragraph.Text; + var idx = _subtitle.Paragraphs.IndexOf(p); + SubtitleListview1.SetText(idx, p.Text); + } + } + + SubtitleListview1.EndUpdate(); + RefreshSelectedParagraph(); + } + } + } + + private void AudioToTextWhisperSelectedLines() + { + if (!RequireFfmpegOk()) + { + return; + } + + var audioClips = GetAudioClips(); + using (var form = new WhisperAudioToTextSelectedLines(audioClips, this)) + { + CheckWhisperCpp(); + if (form.ShowDialog(this) == DialogResult.OK) + { + MakeHistoryForUndo(string.Format(_language.BeforeX, string.Format(LanguageSettings.Current.Main.Menu.Video.VideoAudioToTextX, "Whisper"))); + SubtitleListview1.BeginUpdate(); + foreach (var ac in audioClips) + { + var p = _subtitle.Paragraphs.FirstOrDefault(pa => pa.Id == ac.Paragraph.Id); + if (p != null) + { + p.Text = ac.Paragraph.Text; + var idx = _subtitle.Paragraphs.IndexOf(p); + SubtitleListview1.SetText(idx, p.Text); + } + } + + SubtitleListview1.EndUpdate(); + RefreshSelectedParagraph(); + } + } + } + private List GetAudioClips() { var selectedParagraphs = new List(); @@ -17629,6 +17635,16 @@ namespace Nikse.SubtitleEdit.Forms AutoGuessStartTime(_subtitleListViewIndex); e.SuppressKeyPress = true; } + else if (!string.IsNullOrEmpty(_videoFileName) && mediaPlayer.IsPaused && e.KeyData == _shortcuts.WaveformAudioToTextVosk) + { + e.SuppressKeyPress = true; + AudioToTextVoskSelectedLines(); + } + else if (!string.IsNullOrEmpty(_videoFileName) && mediaPlayer.IsPaused && e.KeyData == _shortcuts.WaveformAudioToTextWhisper) + { + e.SuppressKeyPress = true; + AudioToTextWhisperSelectedLines(); + } else if (audioVisualizer.Focused && e.KeyCode == Keys.Delete) { ToolStripMenuItemDeleteClick(null, null); diff --git a/src/ui/Forms/Options/Settings.cs b/src/ui/Forms/Options/Settings.cs index 976f911ee..b1024599b 100644 --- a/src/ui/Forms/Options/Settings.cs +++ b/src/ui/Forms/Options/Settings.cs @@ -1423,7 +1423,8 @@ namespace Nikse.SubtitleEdit.Forms.Options AddNode(videoNode, language.PlayRateToggle, nameof(Configuration.Settings.Shortcuts.MainVideoSpeedToggle)); AddNode(videoNode, language.VideoResetSpeedAndZoom, nameof(Configuration.Settings.Shortcuts.MainVideoReset)); AddNode(videoNode, language.MainToggleVideoControls, nameof(Configuration.Settings.Shortcuts.MainVideoToggleControls)); - AddNode(videoNode, language.VideoAudioToText, nameof(Configuration.Settings.Shortcuts.MainVideoAudioToText)); + AddNode(videoNode, string.Format(language.AudioToTextX, "Vosk"), nameof(Configuration.Settings.Shortcuts.MainVideoAudioToTextVosk)); + AddNode(videoNode, string.Format(language.AudioToTextX, "Whisper"), nameof(Configuration.Settings.Shortcuts.MainVideoAudioToTextWhisper)); AddNode(videoNode, language.VideoToggleContrast, nameof(Configuration.Settings.Shortcuts.MainVideoToggleContrast)); AddNode(videoNode, language.VideoToggleBrightness, nameof(Configuration.Settings.Shortcuts.MainVideoToggleBrightness)); _shortcuts.Nodes.Add(videoNode); @@ -1627,6 +1628,8 @@ namespace Nikse.SubtitleEdit.Forms.Options AddNode(audioVisualizerNode, language.GoForward100Milliseconds, nameof(Configuration.Settings.Shortcuts.Waveform100MsRight)); AddNode(audioVisualizerNode, language.GoBack1Second, nameof(Configuration.Settings.Shortcuts.Waveform1000MsLeft)); AddNode(audioVisualizerNode, language.GoForward1Second, nameof(Configuration.Settings.Shortcuts.Waveform1000MsRight)); + AddNode(audioVisualizerNode, string.Format(language.AudioToTextSelectedLinesX, "Vosk"), nameof(Configuration.Settings.Shortcuts.WaveformAudioToTextVosk)); + AddNode(audioVisualizerNode, string.Format(language.AudioToTextSelectedLinesX, "Whisper"), nameof(Configuration.Settings.Shortcuts.WaveformAudioToTextWhisper)); _shortcuts.Nodes.Add(audioVisualizerNode); LoadPluginsShortcuts(); diff --git a/src/ui/Logic/Language.cs b/src/ui/Logic/Language.cs index f11586222..841813848 100644 --- a/src/ui/Logic/Language.cs +++ b/src/ui/Logic/Language.cs @@ -2851,7 +2851,8 @@ can edit in same subtitle file (collaboration)", VideoResetSpeedAndZoom = "Reset play rate (speed) and waveform zoom", MainToggleVideoControls = "Toggle video controls", VideoToggleContrast = "Toggle contrast (mpv only)", - VideoAudioToText = "Audio to text", + AudioToTextX = "Audio to text ({0})", + AudioToTextSelectedLinesX = "Audio to text selected lines ({0})", VideoToggleBrightness = "Toggle brightness (mpv only)", CustomSearch1 = "Translate, custom search 1", CustomSearch2 = "Translate, custom search 2", diff --git a/src/ui/Logic/LanguageDeserializer.cs b/src/ui/Logic/LanguageDeserializer.cs index b244c3538..8cf233fec 100644 --- a/src/ui/Logic/LanguageDeserializer.cs +++ b/src/ui/Logic/LanguageDeserializer.cs @@ -6904,8 +6904,11 @@ namespace Nikse.SubtitleEdit.Logic case "Settings/VideoToggleContrast": language.Settings.VideoToggleContrast = reader.Value; break; - case "Settings/VideoAudioToText": - language.Settings.VideoAudioToText = reader.Value; + case "Settings/AudioToTextX": + language.Settings.AudioToTextX = reader.Value; + break; + case "Settings/AudioToTextSelectedLinesX": + language.Settings.AudioToTextSelectedLinesX = reader.Value; break; case "Settings/VideoToggleBrightness": language.Settings.VideoToggleBrightness = reader.Value; diff --git a/src/ui/Logic/LanguageStructure.cs b/src/ui/Logic/LanguageStructure.cs index 16bf42133..291925155 100644 --- a/src/ui/Logic/LanguageStructure.cs +++ b/src/ui/Logic/LanguageStructure.cs @@ -2705,7 +2705,8 @@ namespace Nikse.SubtitleEdit.Logic public string VideoResetSpeedAndZoom { get; set; } public string MainToggleVideoControls { get; set; } public string VideoToggleContrast { get; set; } - public string VideoAudioToText { get; set; } + public string AudioToTextX { get; set; } + public string AudioToTextSelectedLinesX { get; set; } public string VideoToggleBrightness { get; set; } public string CustomSearch1 { get; set; } public string CustomSearch2 { get; set; } diff --git a/src/ui/Logic/MainShortcuts.cs b/src/ui/Logic/MainShortcuts.cs index fb752f9d9..69352e28a 100644 --- a/src/ui/Logic/MainShortcuts.cs +++ b/src/ui/Logic/MainShortcuts.cs @@ -231,6 +231,8 @@ namespace Nikse.SubtitleEdit.Logic public Keys WaveformToggleShotChange { get; set; } public Keys WaveformListShotChanges { get; set; } public Keys WaveformGuessStart { get; set; } + public Keys WaveformAudioToTextVosk { get; set; } + public Keys WaveformAudioToTextWhisper { get; set; } public Keys MainTranslateGoogleIt { get; set; } public Keys MainCheckFixTimingViaShotChanges { get; set; } public Keys MainTranslateGoogleTranslateIt { get; set; } @@ -335,7 +337,7 @@ namespace Nikse.SubtitleEdit.Logic MainVideoFaster = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoFaster); MainVideoSpeedToggle = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoSpeedToggle); MainVideoReset = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoReset); - MainVideoAudioToText = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoAudioToText); + MainVideoAudioToText = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoAudioToTextVosk); MainVideoToggleBrightness = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoToggleBrightness); MainVideoToggleContrast = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoToggleContrast); MainToolsAutoDuration = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainToolsAutoDuration); @@ -467,6 +469,8 @@ namespace Nikse.SubtitleEdit.Logic WaveformToggleShotChange = UiUtil.GetKeys(Configuration.Settings.Shortcuts.WaveformToggleShotChange); WaveformListShotChanges = UiUtil.GetKeys(Configuration.Settings.Shortcuts.WaveformListShotChanges); WaveformGuessStart = UiUtil.GetKeys(Configuration.Settings.Shortcuts.WaveformGuessStart); + WaveformAudioToTextVosk = UiUtil.GetKeys(Configuration.Settings.Shortcuts.WaveformAudioToTextVosk); + WaveformAudioToTextWhisper = UiUtil.GetKeys(Configuration.Settings.Shortcuts.WaveformAudioToTextWhisper); MainTranslateGoogleIt = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainTranslateGoogleIt); MainCheckFixTimingViaShotChanges = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainCheckFixTimingViaShotChanges); MainTranslateGoogleTranslateIt = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainTranslateGoogleTranslateIt);