feat: Add support for saved speaker references in voice selection and enhance related tests

This commit is contained in:
JB
2025-12-20 09:11:35 -08:00
parent e47536e2ab
commit de8debb6b1
2 changed files with 37 additions and 0 deletions
@@ -228,6 +228,17 @@
<option value="__custom_mix" data-role="custom-mix-option" {% if speaker.voice_formula %}selected{% else %}hidden disabled{% endif %}> <option value="__custom_mix" data-role="custom-mix-option" {% if speaker.voice_formula %}selected{% else %}hidden disabled{% endif %}>
Custom mix Custom mix
</option> </option>
{% if options.voice_profile_options %}
<optgroup label="Saved speakers">
{% for profile in options.voice_profile_options %}
{% set profile_value = 'speaker:' ~ profile.name %}
{% set provider_label = 'Supertonic' if profile.provider == 'supertonic' else 'Kokoro' %}
<option value="{{ profile_value }}" {% if selected_voice == profile_value %}selected{% endif %}>
{{ profile.name }} · {{ provider_label }}{% if profile.language %} · {{ profile.language|upper }}{% endif %}
</option>
{% endfor %}
</optgroup>
{% endif %}
{% if speaker.recommended_voices %} {% if speaker.recommended_voices %}
<optgroup label="Recommended"> <optgroup label="Recommended">
{% for voice_id in speaker.recommended_voices[:6] %} {% for voice_id in speaker.recommended_voices[:6] %}
+26
View File
@@ -65,6 +65,32 @@ def test_apply_prepare_form_handles_custom_mix_for_speakers():
assert "voice" not in hero or hero["voice"] != "__custom_mix" assert "voice" not in hero or hero["voice"] != "__custom_mix"
def test_apply_prepare_form_accepts_saved_speaker_reference_for_voice():
pending = _make_pending_job()
pending.speakers = {
"hero": {
"id": "hero",
"label": "Hero",
}
}
form = MultiDict(
{
"chapter_intro_delay": "0.5",
"speaker-hero-voice": "speaker:Female HQ",
"speaker-hero-formula": "",
}
)
_, _, _, errors, *_ = apply_prepare_form(pending, form)
assert not errors
hero = pending.speakers["hero"]
assert hero["voice"] == "speaker:Female HQ"
assert hero["resolved_voice"] == "speaker:Female HQ"
assert "voice_formula" not in hero
def test_resolve_voice_setting_handles_profile_reference(): def test_resolve_voice_setting_handles_profile_reference():
profiles = { profiles = {
"Blend": { "Blend": {