From e4574183f76c73d487d368676f3e408b7157598a Mon Sep 17 00:00:00 2001 From: Nikolaj Olsson Date: Thu, 17 Oct 2024 08:03:45 +0200 Subject: [PATCH] Minor fixes --- .../WhisperPurfviewFasterWhisperModel.cs | 1 - src/libse/AutoTranslate/DeepLXTranslate.cs | 7 ++++++- src/ui/Forms/Main.cs | 2 +- src/ui/Forms/Translate/AutoTranslate.cs | 20 ++++++++++++++++++- src/ui/Forms/Tts/TextToSpeech.cs | 4 ++-- src/ui/Logic/Ocr/Binary/BinaryOcrDb.cs | 4 ++-- 6 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/libse/AudioToText/WhisperPurfviewFasterWhisperModel.cs b/src/libse/AudioToText/WhisperPurfviewFasterWhisperModel.cs index 684e6f12c..fc25160e6 100644 --- a/src/libse/AudioToText/WhisperPurfviewFasterWhisperModel.cs +++ b/src/libse/AudioToText/WhisperPurfviewFasterWhisperModel.cs @@ -1,7 +1,6 @@ using Nikse.SubtitleEdit.Core.Common; using System.Collections.Generic; using System.IO; -using static System.Net.WebRequestMethods; namespace Nikse.SubtitleEdit.Core.AudioToText { diff --git a/src/libse/AutoTranslate/DeepLXTranslate.cs b/src/libse/AutoTranslate/DeepLXTranslate.cs index 5bf498566..5daba0ecb 100644 --- a/src/libse/AutoTranslate/DeepLXTranslate.cs +++ b/src/libse/AutoTranslate/DeepLXTranslate.cs @@ -26,7 +26,12 @@ namespace Nikse.SubtitleEdit.Core.AutoTranslate public void Initialize() { - _apiUrl = Configuration.Settings.Tools.AutoTranslateDeepLUrl; + if (string.IsNullOrEmpty(Configuration.Settings.Tools.AutoTranslateDeepLXUrl)) + { + Configuration.Settings.Tools.AutoTranslateDeepLXUrl = "http://localhost:1188"; + } + _apiUrl = Configuration.Settings.Tools.AutoTranslateDeepLXUrl; + _client = new HttpClient(); _client.BaseAddress = new Uri(_apiUrl.Trim().TrimEnd('/')); } diff --git a/src/ui/Forms/Main.cs b/src/ui/Forms/Main.cs index 778d34b27..049954f76 100644 --- a/src/ui/Forms/Main.cs +++ b/src/ui/Forms/Main.cs @@ -5394,7 +5394,7 @@ namespace Nikse.SubtitleEdit.Forms return DialogResult.No; } - MessageBox.Show("Ups - save original does not support this format - please go to Github and create an issue!"); + MessageBox.Show("Oops - save original does not support this format - please go to Github and create an issue!"); } string allText = subAlt.ToText(format); diff --git a/src/ui/Forms/Translate/AutoTranslate.cs b/src/ui/Forms/Translate/AutoTranslate.cs index 20987ddcc..b94435fc7 100644 --- a/src/ui/Forms/Translate/AutoTranslate.cs +++ b/src/ui/Forms/Translate/AutoTranslate.cs @@ -123,7 +123,6 @@ namespace Nikse.SubtitleEdit.Forms.Translate new GoogleTranslateV2(), new MicrosoftTranslator(), new DeepLTranslate(), - new DeepLXTranslate(), new LibreTranslate(), new MyMemoryApi(), new ChatGptTranslate(), @@ -134,6 +133,7 @@ namespace Nikse.SubtitleEdit.Forms.Translate new OpenRouterTranslate(), new GeminiTranslate(), new PapagoTranslate(), + new DeepLXTranslate(), new NoLanguageLeftBehindServe(), new NoLanguageLeftBehindApi(), }; @@ -230,6 +230,11 @@ namespace Nikse.SubtitleEdit.Forms.Translate if (engineType == typeof(DeepLXTranslate)) { + if (string.IsNullOrEmpty(Configuration.Settings.Tools.AutoTranslateDeepLXUrl)) + { + Configuration.Settings.Tools.AutoTranslateDeepLXUrl = "http://localhost:1188"; + } + FillUrls(new List { Configuration.Settings.Tools.AutoTranslateDeepLXUrl, @@ -1065,6 +1070,19 @@ namespace Nikse.SubtitleEdit.Forms.Translate UiUtil.ShowHelp("#translation"); } } + else if (linesTranslate == 0 && engineType == typeof(DeepLXTranslate) && exception.Message.Contains("No connection could be made because the target machine actively refused it")) + { + MessageBox.Show( + this, "You need a local API to use DeepLX. Run ths docker command: "+ Environment.NewLine + + "docker run -itd -p 1188:1188 ghcr.io/owo-network/deeplx:latest" + Environment.NewLine + + Environment.NewLine + + exception.Message + Environment.NewLine + + Environment.NewLine + + "For more information visit: " + new DeepLXTranslate().Url, + Text, + MessageBoxButtons.OKCancel, + MessageBoxIcon.Error); + } else if (linesTranslate == 0 && (nikseComboBoxUrl.Text.Contains("//192.", StringComparison.OrdinalIgnoreCase) || nikseComboBoxUrl.Text.Contains("//127.", StringComparison.OrdinalIgnoreCase) || diff --git a/src/ui/Forms/Tts/TextToSpeech.cs b/src/ui/Forms/Tts/TextToSpeech.cs index e107a14ec..437057930 100644 --- a/src/ui/Forms/Tts/TextToSpeech.cs +++ b/src/ui/Forms/Tts/TextToSpeech.cs @@ -319,7 +319,7 @@ namespace Nikse.SubtitleEdit.Forms.Tts } catch (Exception exception) { - MessageBox.Show("Ups: " + exception.Message + Environment.NewLine + exception.Message); + MessageBox.Show("Oops: " + exception.Message + Environment.NewLine + exception.Message); SeLogger.Error(exception, $"{Text}: Error running engine {nikseComboBoxEngine.Text} with video {_videoFileName}"); } } @@ -2230,7 +2230,7 @@ namespace Nikse.SubtitleEdit.Forms.Tts var ok = GenerateParagraphAudio(sub, false, waveFileNameOnly); if (!ok) { - MessageBox.Show(this, "Ups, voice generation failed!"); + MessageBox.Show(this, "Oops, voice generation failed!"); return; } diff --git a/src/ui/Logic/Ocr/Binary/BinaryOcrDb.cs b/src/ui/Logic/Ocr/Binary/BinaryOcrDb.cs index b3925b861..b55877487 100644 --- a/src/ui/Logic/Ocr/Binary/BinaryOcrDb.cs +++ b/src/ui/Logic/Ocr/Binary/BinaryOcrDb.cs @@ -41,7 +41,7 @@ namespace Nikse.SubtitleEdit.Logic.Ocr.Binary { if (bob.ExpandCount > 0) { - System.Windows.Forms.MessageBox.Show("Ups, expand image in CompareImages!"); + System.Windows.Forms.MessageBox.Show("Oops, expand image in CompareImages!"); } bob.Save(gz); @@ -50,7 +50,7 @@ namespace Nikse.SubtitleEdit.Logic.Ocr.Binary { if (bob.ExpandCount == 0) { - System.Windows.Forms.MessageBox.Show("Ups, not expanded image in CompareImagesExpanded!"); + System.Windows.Forms.MessageBox.Show("Oops, not expanded image in CompareImagesExpanded!"); } bob.Save(gz);