Minor UI fix

This commit is contained in:
Nikolaj Olsson 2024-05-09 09:01:23 +02:00
parent 5eacb31f0b
commit 6e8944742a

View File

@ -1439,9 +1439,9 @@ namespace Nikse.SubtitleEdit.Forms.Tts
nikseComboBoxRegion.Text = Configuration.Settings.Tools.TextToSpeechAzureRegion;
}
if (nikseComboBoxVoice.Items.Count > 0)
if (nikseComboBoxVoice.Items.Count > 0 && nikseComboBoxVoice.SelectedIndex < 0)
{
nikseComboBoxVoice.SelectedIndex = 0;
SetFirstLanguageHitAsVoice();
}
if (nikseComboBoxVoice.Items.Count > 1)
@ -1698,6 +1698,28 @@ namespace Nikse.SubtitleEdit.Forms.Tts
}
}
private void SetFirstLanguageHitAsVoice()
{
nikseComboBoxVoice.Text = Configuration.Settings.Tools.TextToSpeechLastVoice;
if (nikseComboBoxVoice.Text == Configuration.Settings.Tools.TextToSpeechLastVoice)
{
return;
}
var language = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle);
for (var index = 0; index < nikseComboBoxVoice.Items.Count; index++)
{
var item = (string)nikseComboBoxVoice.Items[index];
if (item.StartsWith(language, StringComparison.OrdinalIgnoreCase))
{
nikseComboBoxVoice.SelectedIndex = index;
return;
}
}
nikseComboBoxVoice.SelectedIndex = 0;
}
private List<PiperModel> GetPiperVoices(bool useCache)
{
var ttsPath = Path.Combine(Configuration.DataDirectory, "TextToSpeech");