mudler/LocalAI · error
Invalid language: %s. Available: %v
Error message
Invalid language: %s. Available: %v
What it means
Panic thrown in supertonic's helper.go text-preparation path when the language tag passed to the wrapping routine is not in AvailableLangs (a fixed list of 32 codes: en, ko, ja, ar, bg, cs, da, de, el, es, et, fi, fr, hi, hr, hu, id, it, lt, lv, nl, pl, pt, ro, ru, sk, sl, sv, tr, uk, vi, na). The text is wrapped in <lang>...</lang> tags for the multilingual model, so an unknown code cannot be encoded.
Source
Thrown at backend/go/supertonic/helper.go:438
for strings.Contains(text, "``") {
text = strings.ReplaceAll(text, "``", "`")
}
// Remove extra spaces
text = regexp.MustCompile(`\s+`).ReplaceAllString(text, " ")
text = strings.TrimSpace(text)
// If text doesn't end with punctuation, quotes, or closing brackets, add a period
if text != "" {
endsWithPunct := regexp.MustCompile(`[.!?;:,'"\x{201C}\x{201D}\x{2018}\x{2019})\]}…。」』】〉》›»]$`)
if !endsWithPunct.MatchString(text) {
text += "."
}
}
// Validate language
if !isValidLang(lang) {
panic(fmt.Sprintf("Invalid language: %s. Available: %v", lang, AvailableLangs))
}
// Wrap text with language tags
text = fmt.Sprintf("<%s>%s</%s>", lang, text, lang)
return text
}
func lengthToMask(lengths []int64, maxLen int) [][][]float64 {
bsz := len(lengths)
mask := make([][][]float64, bsz)
for i := 0; i < bsz; i++ {
row := make([]float64, maxLen)
for j := 0; j < maxLen; j++ {
if int64(j) < lengths[i] {
row[j] = 1.0
} else {View on GitHub (pinned to 44413a9d06)
Solutions
- Use one of the 32 supported bare codes from the error message (e.g. 'en', 'ko', 'ja')
- Strip region subtags: 'en-US' -> 'en'
- Leave language unset so backend.go resolveLang applies its default/fallback instead of panicking
- If you need an unsupported language, use a different TTS backend/model that covers it
Example fix
# before lang: "en-US" # after lang: "en"
Defensive patterns
Strategy: type-guard
Validate before calling
var available = map[string]bool{} // fill from supertonic.AvailableLangs
for _, l := range supertonic.AvailableLangs { available[l] = true }
if !available[lang] { lang = "en" } Type guard
func isValidSupertonicLang(lang string) bool {
for _, l := range supertonic.AvailableLangs {
if l == lang { return true }
}
return false
} Prevention
- Normalize user locales to bare codes before passing them down
- Rely on backend.go resolveLang to validate and fall back instead of calling the helper directly
- Offer a UI dropdown restricted to the 32 supported languages
When it happens
Trigger: Calling the internal text-wrapping helper with a language string outside the list — e.g. 'zh' (Chinese, not supported), 'en-US', 'EN' (case-sensitive), or '' — instead of a bare supported code. Reached when the request/model config supplies a language the list does not contain (backend.go's resolveLang normally validates/falls back first).
Common situations: Users configuring supertonic TTS with a BCP-47 style locale instead of the bare code; requesting Chinese which is absent from this model's language set; passing an empty language from a config with a missing lang field; direct Go API use bypassing resolveLang's fallback.
Related errors
- router/rerank: policy has empty label
- router/rerank: policy %q has no description
- router/score: policy has empty label
- router/score: policy %q has no description
- router/score: unknown score_normalization %q (want %q or %q)
AI-assisted analysis of mudler/LocalAI@44413a9d06 (2026-08-15).
Data as JSON: /api/errors/f2d9b5852e2a353b.
Report an issue: GitHub.