mudler/LocalAI · error

Invalid language: . Available

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.

Solutions

  1. Use one of the 32 supported bare codes from the error message (e.g. 'en', 'ko', 'ja')
  2. Strip region subtags: 'en-US' -> 'en'
  3. Leave language unset so backend.go resolveLang applies its default/fallback instead of panicking
  4. 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

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


AI-assisted analysis of mudler/LocalAI@44413a9d06 (2026-08-15). Data as JSON: /api/errors/f2d9b5852e2a353b. Report an issue: GitHub.

Appendix: 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)