From 2fd8ee30410bdb04829cafe9baac353fb4742f95 Mon Sep 17 00:00:00 2001 From: Nikolaj Olsson Date: Thu, 28 Mar 2024 09:04:00 +0100 Subject: [PATCH] Fix ChatGTP translate - thx longhoang1993 :) Related to #7850 --- Changelog.txt | 5 +++-- src/libse/AudioToText/WhisperHelper.cs | 5 +++++ src/libse/AutoTranslate/ChatGptTranslate.cs | 4 ++-- src/ui/Forms/AudioToText/WhisperAudioToText.cs | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index a3000ad85..232970433 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,6 +1,6 @@ Subtitle Edit Changelog -4.0.5 (xth May 2024) BETA +4.0.5 (xth April 2024) BETA * NEW: * Add "Open video" toolbar button/image - thx jmaraujouy/Cyberyoda1411 * Add support for S_HDMV/TEXTST in MKV in batch/cmd-line - thx ipsi @@ -17,7 +17,8 @@ * FIXED: * Fix for Whisper post-processing - thx Purfview/cvrle77 * Fix crash in "Fix common errors" - thx Joe - * Fix issue with NikseCombobox and ContextMenuStrip - thx ivandrofly + * Fix issue with Combobox and ContextMenuStrip - thx ivandrofly + * Fix ChatGTP translate - thx longhoang1993 4.0.4 (17th March 2024) diff --git a/src/libse/AudioToText/WhisperHelper.cs b/src/libse/AudioToText/WhisperHelper.cs index 3a0caecd9..f433eee4a 100644 --- a/src/libse/AudioToText/WhisperHelper.cs +++ b/src/libse/AudioToText/WhisperHelper.cs @@ -502,6 +502,11 @@ namespace Nikse.SubtitleEdit.Core.AudioToText return Path.Combine(GetWhisperModel().ModelFolder, model + ModelExtension()); } + if (Configuration.Settings.Tools.WhisperChoice == WhisperChoice.WhisperX && model == "large-v3") + { + return "large"; + } + return model; } diff --git a/src/libse/AutoTranslate/ChatGptTranslate.cs b/src/libse/AutoTranslate/ChatGptTranslate.cs index 513eb854a..5230456f9 100644 --- a/src/libse/AutoTranslate/ChatGptTranslate.cs +++ b/src/libse/AutoTranslate/ChatGptTranslate.cs @@ -47,11 +47,11 @@ namespace Nikse.SubtitleEdit.Core.AutoTranslate public async Task Translate(string text, string sourceLanguageCode, string targetLanguageCode, CancellationToken cancellationToken) { - var model = Configuration.Settings.Tools.ChatGptApiKey; + var model = Configuration.Settings.Tools.ChatGptModel; if (string.IsNullOrEmpty(model)) { model = "gpt-3.5-turbo"; - Configuration.Settings.Tools.ChatGptApiKey = model; + Configuration.Settings.Tools.ChatGptModel = model; } var input = "{\"model\": \"" + model + "\",\"messages\": [{ \"role\": \"user\", \"content\": \"Please translate the following text from " + sourceLanguageCode + " to " + targetLanguageCode + ", only write the result: \\n\\n" + Json.EncodeJsonText(text.Trim()) + "\" }]}"; diff --git a/src/ui/Forms/AudioToText/WhisperAudioToText.cs b/src/ui/Forms/AudioToText/WhisperAudioToText.cs index 6ee8f38a3..ae717b79e 100644 --- a/src/ui/Forms/AudioToText/WhisperAudioToText.cs +++ b/src/ui/Forms/AudioToText/WhisperAudioToText.cs @@ -166,7 +166,7 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText } engines.Add(WhisperChoice.CTranslate2); engines.Add(WhisperChoice.StableTs); - //engines.Add(WhisperChoice.WhisperX); -- impossible to install... + engines.Add(WhisperChoice.WhisperX); foreach (var engine in engines) {