diff --git a/src/libse/Settings/Settings.cs b/src/libse/Settings/Settings.cs index 0f58ac60e..ff69b1e0e 100644 --- a/src/libse/Settings/Settings.cs +++ b/src/libse/Settings/Settings.cs @@ -2377,6 +2377,24 @@ namespace Nikse.SubtitleEdit.Core.Settings settings.Tools.TextToSpeechMurfApiKey = subNode.InnerText; } + subNode = node.SelectSingleNode("TextToSpeechMurfVoice"); + if (subNode != null) + { + settings.Tools.TextToSpeechMurfVoice = subNode.InnerText; + } + + subNode = node.SelectSingleNode("TextToSpeechMurfRate"); + if (subNode != null) + { + settings.Tools.TextToSpeechMurfRate = Convert.ToInt32(subNode.InnerText, CultureInfo.InvariantCulture); + } + + subNode = node.SelectSingleNode("TextToSpeechMurfPitch"); + if (subNode != null) + { + settings.Tools.TextToSpeechMurfPitch = Convert.ToInt32(subNode.InnerText, CultureInfo.InvariantCulture); + } + subNode = node.SelectSingleNode("TextToSpeechAzureApiKey"); if (subNode != null) { @@ -9061,6 +9079,9 @@ namespace Nikse.SubtitleEdit.Core.Settings xmlWriter.WriteElementString("TextToSpeechElevenLabsStability", settings.Tools.TextToSpeechElevenLabsStability.ToString(CultureInfo.InvariantCulture)); xmlWriter.WriteElementString("TextToSpeechElevenLabsSimilarity", settings.Tools.TextToSpeechElevenLabsSimilarity.ToString(CultureInfo.InvariantCulture)); xmlWriter.WriteElementString("TextToSpeechMurfApiKey", settings.Tools.TextToSpeechMurfApiKey); + xmlWriter.WriteElementString("TextToSpeechMurfVoice", settings.Tools.TextToSpeechMurfVoice); + xmlWriter.WriteElementString("TextToSpeechMurfRate", settings.Tools.TextToSpeechMurfRate.ToString(CultureInfo.InvariantCulture)); + xmlWriter.WriteElementString("TextToSpeechMurfPitch", settings.Tools.TextToSpeechMurfPitch.ToString(CultureInfo.InvariantCulture)); xmlWriter.WriteElementString("TextToSpeechAzureApiKey", settings.Tools.TextToSpeechAzureApiKey); xmlWriter.WriteElementString("TextToSpeechAzureRegion", settings.Tools.TextToSpeechAzureRegion); xmlWriter.WriteElementString("TextToSpeechPreview", settings.Tools.TextToSpeechPreview.ToString(CultureInfo.InvariantCulture)); diff --git a/src/libse/Settings/ToolsSettings.cs b/src/libse/Settings/ToolsSettings.cs index 7557774ef..c0e87a178 100644 --- a/src/libse/Settings/ToolsSettings.cs +++ b/src/libse/Settings/ToolsSettings.cs @@ -100,6 +100,9 @@ namespace Nikse.SubtitleEdit.Core.Settings public string TextToSpeechLastVoice { get; set; } public string TextToSpeechElevenLabsApiKey { get; set; } public string TextToSpeechMurfApiKey { get; set; } + public int TextToSpeechMurfRate { get; set; } + public int TextToSpeechMurfPitch { get; set; } + public string TextToSpeechMurfVoice { get; set; } public string TextToSpeechAzureApiKey { get; set; } public string TextToSpeechAzureRegion { get; set; } public string TextToSpeechElevenLabsModel { get; set; } diff --git a/src/ui/Forms/AudioToText/WhisperDownload.cs b/src/ui/Forms/AudioToText/WhisperDownload.cs index e19ede470..ee73794da 100644 --- a/src/ui/Forms/AudioToText/WhisperDownload.cs +++ b/src/ui/Forms/AudioToText/WhisperDownload.cs @@ -142,7 +142,7 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText { if (_whisperChoice == WhisperChoice.PurfviewFasterWhisperXXL) { - UiUtil.OpenUrl("https://github.com/Purfview/whisper-standalone-win/releases/download/Faster-Whisper-XXL/Faster-Whisper-XXL_r192.3.4_windows.7z"); + UiUtil.OpenUrl("https://github.com/Purfview/whisper-standalone-win/releases/download/Faster-Whisper-XXL/Faster-Whisper-XXL_r193.1_windows.7z"); var folder = Path.Combine(Configuration.DataDirectory, "Whisper"); if (!Directory.Exists(folder)) diff --git a/src/ui/Forms/Tts/RegenerateAudioClip.cs b/src/ui/Forms/Tts/RegenerateAudioClip.cs index df4ce9f87..4013166b0 100644 --- a/src/ui/Forms/Tts/RegenerateAudioClip.cs +++ b/src/ui/Forms/Tts/RegenerateAudioClip.cs @@ -15,6 +15,7 @@ namespace Nikse.SubtitleEdit.Forms.Tts private readonly Subtitle _subtitle; private readonly int _index; private LibMpvDynamic _libMpv; + private TextToSpeech.TextToSpeechEngine _engine; public RegenerateAudioClip(TextToSpeech textToSpeech, Subtitle subtitle, int idx, TextToSpeech.TextToSpeechEngine engine) { @@ -25,6 +26,7 @@ namespace Nikse.SubtitleEdit.Forms.Tts _subtitle = subtitle; _textToSpeech = textToSpeech; _index = idx; + _engine = engine; Text = LanguageSettings.Current.ExportCustomText.Edit; labelText.Text = LanguageSettings.Current.General.Text; @@ -43,23 +45,47 @@ namespace Nikse.SubtitleEdit.Forms.Tts nikseUpDownStability.Value = (int)Math.Round(Configuration.Settings.Tools.TextToSpeechElevenLabsStability * 100.0); nikseUpDownSimilarity.Value = (int)Math.Round(Configuration.Settings.Tools.TextToSpeechElevenLabsSimilarity * 100.0); - if (engine.Id != TextToSpeech.TextToSpeechEngineId.ElevenLabs) + if (engine.Id == TextToSpeech.TextToSpeechEngineId.ElevenLabs) { - labelStability.Visible = false; - labelSimilarity.Visible = false; - nikseUpDownStability.Visible = false; - nikseUpDownSimilarity.Visible = false; - TextBoxReGenerate.Height = buttonOK.Top - TextBoxReGenerate.Top - 10; - nikseUpDownSimilarity.Left = labelSimilarity.Right + 3; + return; } + + if (engine.Id == TextToSpeech.TextToSpeechEngineId.Murf) + { + labelStability.Text = "Pitch"; + nikseUpDownStability.Minimum = -49; + nikseUpDownStability.Maximum = 50; + nikseUpDownStability.Value = Configuration.Settings.Tools.TextToSpeechMurfPitch; + + labelSimilarity.Text = "Speed"; + nikseUpDownSimilarity.Minimum = -49; + nikseUpDownSimilarity.Maximum = 50; + nikseUpDownSimilarity.Value = Configuration.Settings.Tools.TextToSpeechMurfRate; + return; + } + + labelStability.Visible = false; + labelSimilarity.Visible = false; + nikseUpDownStability.Visible = false; + nikseUpDownSimilarity.Visible = false; + TextBoxReGenerate.Height = buttonOK.Top - TextBoxReGenerate.Top - 10; + nikseUpDownSimilarity.Left = labelSimilarity.Right + 3; } private void buttonReGenerate_Click(object sender, EventArgs e) { _libMpv?.Stop(); - Configuration.Settings.Tools.TextToSpeechElevenLabsStability = (double)nikseUpDownStability.Value / 100.0; - Configuration.Settings.Tools.TextToSpeechElevenLabsSimilarity = (double)nikseUpDownSimilarity.Value / 100.0; + if (_engine.Id == TextToSpeech.TextToSpeechEngineId.ElevenLabs) + { + Configuration.Settings.Tools.TextToSpeechElevenLabsStability = (double)nikseUpDownStability.Value / 100.0; + Configuration.Settings.Tools.TextToSpeechElevenLabsSimilarity = (double)nikseUpDownSimilarity.Value / 100.0; + } + else if (_engine.Id == TextToSpeech.TextToSpeechEngineId.Murf) + { + Configuration.Settings.Tools.TextToSpeechMurfPitch = (int)nikseUpDownStability.Value; + Configuration.Settings.Tools.TextToSpeechMurfRate = (int)nikseUpDownSimilarity.Value; + } var paragraph = _subtitle.Paragraphs[_index]; paragraph.Text = TextBoxReGenerate.Text.Trim(); diff --git a/src/ui/Forms/Tts/TextToSpeech.cs b/src/ui/Forms/Tts/TextToSpeech.cs index c52cc4f37..e7b758ca0 100644 --- a/src/ui/Forms/Tts/TextToSpeech.cs +++ b/src/ui/Forms/Tts/TextToSpeech.cs @@ -211,8 +211,6 @@ namespace Nikse.SubtitleEdit.Forms.Tts checkBoxShowPreview.Checked = Configuration.Settings.Tools.TextToSpeechPreview; checkBoxAudioEncoding.Checked = Configuration.Settings.Tools.TextToSpeechCustomAudio; checkBoxAddToVideoFile.Enabled = _videoFileName != null; - nikseUpDownStability.Value = (int)Math.Round(Configuration.Settings.Tools.TextToSpeechElevenLabsStability * 100.0); - nikseUpDownSimilarity.Value = (int)Math.Round(Configuration.Settings.Tools.TextToSpeechElevenLabsSimilarity * 100.0); } private void SetActor(ActorAndVoice actor) @@ -1434,10 +1432,12 @@ namespace Nikse.SubtitleEdit.Forms.Tts overrideStyle = "Conversational"; } + var rate = Configuration.Settings.Tools.TextToSpeechMurfRate.ToString(CultureInfo.InvariantCulture); + var pitch = Configuration.Settings.Tools.TextToSpeechMurfPitch.ToString(CultureInfo.InvariantCulture); var body = "{ \"voiceId\": \"" + voice.VoiceId + "\", \"style\": \"" + (voice.AvailableStyles.Contains(overrideStyle) - ? overrideStyle - : voice.AvailableStyles.FirstOrDefault()) + - "\", \"text\": \"" + Json.EncodeJsonText(text) + "\", \"rate\": 0, \"pitch\": 0, \"sampleRate\": 48000, \"format\": \"MP3\", \"channelType\": \"MONO\", \"pronunciationDictionary\": { }, \"encodeAsBase64\": false, \"modelVersion\": \"GEN2\" }"; + ? overrideStyle + : voice.AvailableStyles.FirstOrDefault()) + + "\", \"text\": \"" + Json.EncodeJsonText(text) + "\", \"rate\": " + rate + ", \"pitch\": " + pitch + ", \"sampleRate\": 48000, \"format\": \"MP3\", \"channelType\": \"MONO\", \"pronunciationDictionary\": { }, \"encodeAsBase64\": false, \"modelVersion\": \"GEN2\" }"; var requestMessage = new HttpRequestMessage(HttpMethod.Post, url); requestMessage.Content = new StringContent(body, Encoding.UTF8, "application/json"); @@ -1635,8 +1635,19 @@ namespace Nikse.SubtitleEdit.Forms.Tts nikseComboBoxRegion.Visible = true; + labelStability.Text = LanguageSettings.Current.TextToSpeech.Stability; + labelSimilarity.Text = LanguageSettings.Current.TextToSpeech.Similarity; labelStability.Visible = true; labelSimilarity.Visible = true; + + nikseUpDownStability.Minimum = 0; + nikseUpDownStability.Maximum = 100; + nikseUpDownStability.Value = (decimal)Configuration.Settings.Tools.TextToSpeechElevenLabsStability; + + nikseUpDownSimilarity.Minimum = 0; + nikseUpDownSimilarity.Maximum = 100; + nikseUpDownSimilarity.Value = (decimal)Configuration.Settings.Tools.TextToSpeechElevenLabsSimilarity; + nikseUpDownStability.Visible = true; nikseUpDownSimilarity.Visible = true; } @@ -1712,6 +1723,34 @@ namespace Nikse.SubtitleEdit.Forms.Tts labelRegion.Visible = true; nikseComboBoxRegion.Visible = true; nikseComboBoxRegion.Text = "English (US and Canada)"; + + if (!string.IsNullOrEmpty(Configuration.Settings.Tools.TextToSpeechMurfVoice)) + { + var voice = _murfVoices.FirstOrDefault(p => p.ToString() == Configuration.Settings.Tools.TextToSpeechMurfVoice); + if (voice != null) + { + var murfLanguage = _murfLanguages.FirstOrDefault(p => p.Code == voice.Locale); + if (murfLanguage != null) + { + nikseComboBoxRegion.Text = murfLanguage.Name; + } + nikseComboBoxVoice.Text = Configuration.Settings.Tools.TextToSpeechMurfVoice; + } + } + + labelStability.Text = "Pitch"; + nikseUpDownStability.Minimum = -49; + nikseUpDownStability.Maximum = 50; + nikseUpDownStability.Value = Configuration.Settings.Tools.TextToSpeechMurfPitch; + labelStability.Visible = true; + nikseUpDownStability.Visible = true; + + labelSimilarity.Text = "Speed"; + nikseUpDownSimilarity.Minimum = -49; + nikseUpDownSimilarity.Maximum = 50; + nikseUpDownSimilarity.Value = Configuration.Settings.Tools.TextToSpeechMurfRate; + labelSimilarity.Visible = true; + nikseUpDownSimilarity.Visible = true; } if (nikseComboBoxVoice.Items.Count > 0 && nikseComboBoxVoice.SelectedIndex < 0) @@ -2581,8 +2620,17 @@ namespace Nikse.SubtitleEdit.Forms.Tts private void SaveConfiguration() { - Configuration.Settings.Tools.TextToSpeechElevenLabsStability = (double)nikseUpDownStability.Value / 100.0; - Configuration.Settings.Tools.TextToSpeechElevenLabsSimilarity = (double)nikseUpDownSimilarity.Value / 100.0; + var engine = _engines.First(p => p.Index == nikseComboBoxEngine.SelectedIndex); + if (engine.Id == TextToSpeechEngineId.ElevenLabs) + { + Configuration.Settings.Tools.TextToSpeechElevenLabsStability = (double)nikseUpDownStability.Value / 100.0; + Configuration.Settings.Tools.TextToSpeechElevenLabsSimilarity = (double)nikseUpDownSimilarity.Value / 100.0; + } + else if (engine.Id == TextToSpeechEngineId.Murf) + { + Configuration.Settings.Tools.TextToSpeechMurfPitch = (int)nikseUpDownStability.Value; + Configuration.Settings.Tools.TextToSpeechMurfRate = (int)nikseUpDownSimilarity.Value; + } } private void HandleError(Exception ex) @@ -2620,6 +2668,7 @@ namespace Nikse.SubtitleEdit.Forms.Tts else if (engine.Id == TextToSpeechEngineId.Murf) { Configuration.Settings.Tools.TextToSpeechMurfApiKey = nikseTextBoxApiKey.Text; + Configuration.Settings.Tools.TextToSpeechMurfVoice = nikseComboBoxVoice.Text; } Configuration.Settings.Tools.TextToSpeechEngine = engine.Id.ToString();