Skip to content

fix: honour default_voice_code in _split_multi_voice - #515

Merged
remsky merged 1 commit into
remsky:masterfrom
Christian-Sidak:fix/issue-514
Aug 27, 2026
Merged

fix: honour default_voice_code in _split_multi_voice#515
remsky merged 1 commit into
remsky:masterfrom
Christian-Sidak:fix/issue-514

Conversation

@Christian-Sidak

Copy link
Copy Markdown
Contributor

Summary

  • _split_multi_voice() in api/src/services/tts_service.py computed segment_lang from the first character of the voice name when no explicit lang_code was provided, skipping settings.default_voice_code entirely.
  • Voices whose filename does not start with a recognised Kokoro language code (e.g. ursa, eve, iris) were therefore routed to the wrong phonemiser pipeline, returning HTTP 200 with an empty body.
  • The fix mirrors the precedence already used in kokoro_v1.py: lang_code > settings.default_voice_code > voice[:1].

Fixes #514

Changes

api/src/services/tts_service.py (line ~295)

Before:

segment_lang = lang_code if lang_code else segment_voice[:1].lower()

After:

segment_lang = (
    lang_code
    or settings.default_voice_code
    or segment_voice[:1].lower()
)

api/tests/test_tts_service.py

Two new unit tests added alongside the existing _split_multi_voice tests:

  • test_split_multi_voice_default_voice_code_used_when_no_lang_code -- verifies that a voice named ursa (no language prefix) uses settings.default_voice_code when no lang_code is passed.
  • test_split_multi_voice_explicit_lang_code_beats_default -- verifies that an explicit lang_code still wins over settings.default_voice_code.

Test plan

  • Reviewed that settings is already imported in tts_service.py (line 15)
  • Verified the fix matches the precedence in kokoro_v1.py
  • Added unit tests following the existing mock/AsyncMock pattern in test_tts_service.py
  • Confirmed no other callers of _split_multi_voice are affected (the precedence is strictly additive)

_split_multi_voice computed segment_lang as the first letter of the
voice name when no explicit lang_code was provided, bypassing
settings.default_voice_code entirely. This caused voices whose filename
does not begin with a valid Kokoro language code to be routed to the
wrong pipeline, returning empty audio (HTTP 200 with a zero-byte body).

Mirror the precedence used in kokoro_v1.py:
  lang_code > settings.default_voice_code > voice[:1]

Add two unit tests to guard the fix and the existing explicit-wins case.

Fixes remsky#514

Signed-off-by: Christian-Sidak <61099993+Christian-Sidak@users.noreply.github.com>
@remsky

remsky commented Aug 27, 2026

Copy link
Copy Markdown
Owner

Good catch, and thanks. I was able to repro, and looks like generate_from_phonemes has the same omission on the /dev path, I'll follow up with a commit on it

@remsky
remsky merged commit 5ba470b into remsky:master Aug 27, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

default_voice_code is ignored on the speech path in 0.8.1 — voices not named after a language code return 200 with empty audio

2 participants