feat(qwen3-tts-cpp): normalize request language for flexible matching#10174
Merged
Conversation
The qwen3-tts.cpp backend honored the request `language` field only via exact lowercase two-letter codes in the C++ language_to_id table, silently defaulting to English for anything else (en-US, EN, english, ...). Add normalizeLanguage() in the Go handler: lowercase + trim, strip the region/locale suffix (en-US, pt_BR, zh-Hans -> en/pt/zh), and resolve common English full names (english -> en). The canonical codes match the existing C++ table, so no C++ change is needed. Covered by a pure-Go Ginkgo spec. Also document the language field and accepted forms under the Qwen3-TTS docs. Signed-off-by: Ettore Di Giacinto <mudler@localai.io> Assisted-by: Claude:claude-opus-4-8 [Claude Code]
mudler
approved these changes
Jun 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The
qwen3-tts.cppbackend already honored the requestlanguagefield, but only via an exact-match lowercase two-letter code lookup in the C++language_to_idtable. Anything else (en-US,EN,en_US,english, ...) silently fell back to English, and the behavior was undocumented.This adds a small normalization step in the Go handler so the field accepts the forms callers actually send:
fr,FR)fr-FR,pt_BR,zh-Hans->fr/pt/zh)english->en,Portuguese->pt)Empty input still defaults to English (handled C++-side), and an unrecognized value is passed through normalized so the existing C++ "Unknown language ... defaulting to English" log still fires.
How
normalizeLanguage()inbackend/go/qwen3-tts-cpp/goqwen3ttscpp.go, applied in theTTShandler before the value reaches the C++synthesizecall.language_to_idtable, so no C++ change and no new token IDs are needed.language_test.go) covering codes, casing, whitespace, locale stripping, full-name aliases, empty, and unknown passthrough. No model/.sorequired, so it runs in CI.docs/content/features/text-to-audio.mddocumenting the field, the supported set, the accepted forms, and the default-on-unknown behavior.Testing
go test ./backend/go/qwen3-tts-cpp/...-> green (19 specs)go vet,gofmtcleanThe C++ side is unchanged, so it was not rebuilt; verification covers the Go normalization layer.