Work on tts

This commit is contained in:
Nikolaj Olsson 2024-04-14 17:25:41 +02:00
parent 1ed5217fda
commit 68b7d3fd14
2 changed files with 61 additions and 14 deletions

View File

@ -99,7 +99,7 @@ namespace Nikse.SubtitleEdit.Core.TextToSpeech
new PiperModels("huayan", "Chinese", "medium", "https://huggingface.co/rhasspy/piper-voices/resolve/v1.0.0/zh/zh_CN/huayan/medium/zh_CN-huayan-medium.onnx", "https://huggingface.co/rhasspy/piper-voices/resolve/v1.0.0/zh/zh_CN/huayan/medium/zh_CN-huayan-medium.onnx.json"),
};
return models;
return models.OrderBy(p=>p.ToString()).ToList();
}
}
}

View File

@ -773,6 +773,52 @@ namespace Nikse.SubtitleEdit.Forms.Tts
FillActorListView();
contextMenuStripActors.Items.Clear();
if (engine.Id == TextToSpeechEngine.IdPiper)
{
var voices = PiperModels.GetVoices();
foreach (var voiceLanguage in voices
.GroupBy(p => p.Language)
.OrderBy(p => p.Key))
{
if (voiceLanguage.Count() == 1)
{
var voice = voiceLanguage.First();
var tsi = new ToolStripMenuItem();
tsi.Tag = new ActorAndVoice { Voice = voice.Voice, VoiceIndex = voices.IndexOf(voice) };
tsi.Text = voice.ToString();
tsi.Click += (x, args) =>
{
var a = (ActorAndVoice)(x as ToolStripItem).Tag;
SetActor(a);
};
contextMenuStripActors.Items.Add(tsi);
}
else
{
var parent = new ToolStripMenuItem();
parent.Text = voiceLanguage.Key;
contextMenuStripActors.Items.Add(parent);
foreach (var voice in voiceLanguage.OrderBy(p => p.Voice).ToList())
{
var tsi = new ToolStripMenuItem();
tsi.Tag = new ActorAndVoice { Voice = voice.Voice, VoiceIndex = voices.IndexOf(voice) };
tsi.Text = voice.Voice + " (" + voice.Quality + ")";
tsi.Click += (x, args) =>
{
var a = (ActorAndVoice)(x as ToolStripItem).Tag;
SetActor(a);
};
parent.DropDownItems.Add(tsi);
}
DarkTheme.SetDarkTheme(parent);
}
}
}
else
{
for (var index = 0; index < nikseComboBoxVoice.Items.Count; index++)
{
var item = nikseComboBoxVoice.Items[index];
@ -786,13 +832,14 @@ namespace Nikse.SubtitleEdit.Forms.Tts
SetActor(a);
};
contextMenuStripActors.Items.Add(tsi);
}
}
labelActors.Visible = true;
listViewActors.Visible = true;
}
}
}
}
private bool SubtitleFormatHasActors()
{