calesthio/OpenMontage · error · ValueError
voice_language must be one of: {', '.join(TTS_LANGUAGES)}
Error message
voice_language must be one of: {', '.join(TTS_LANGUAGES)} What it means
Raised by kling_tts._build_request when voice_language (default 'en') is not in the module-level TTS_LANGUAGES whitelist. Kling TTS only supports a fixed set of language codes and the wrapper validates them client-side.
Source
Thrown at tools/audio/kling_tts.py:207
cost_usd=self.estimate_cost(inputs),
duration_seconds=round(time.time() - start, 2),
model="kling-official-tts",
)
def _build_request(self, inputs: dict[str, Any]) -> dict[str, Any]:
text = str(inputs.get("text") or "").strip()
if not text:
raise ValueError("text is required")
if len(text) > 5000:
raise ValueError("text exceeds Kling TTS safety limit of 5000 characters")
voice_id = str(inputs.get("voice_id") or "").strip()
if not voice_id:
raise ValueError("voice_id is required for Kling official TTS")
voice_language = str(inputs.get("voice_language") or "en")
if voice_language not in TTS_LANGUAGES:
raise ValueError(f"voice_language must be one of: {', '.join(TTS_LANGUAGES)}")
voice_speed = float(inputs.get("voice_speed", 1.0))
if voice_speed < TTS_SPEED_MIN or voice_speed > TTS_SPEED_MAX:
raise ValueError(f"voice_speed must be between {TTS_SPEED_MIN} and {TTS_SPEED_MAX}")
payload: dict[str, Any] = {
"text": text,
"voice_id": voice_id,
"voice_language": voice_language,
"voice_speed": voice_speed,
}
self._copy_common_task_fields(inputs, payload)
return {
"protocol": "classic",
"path": "/v1/audio/tts",
"payload": payload,
"operation": "text_to_speech",
"model": "kling-official-tts",View on GitHub (pinned to 95e1c3d0ab)
Solutions
- Use one of the codes in TTS_LANGUAGES (import it and print/join to see the exact allowed set)
- Omit voice_language to get the default 'en'
- Normalize user input (lowercase, map common aliases) before building inputs
Example fix
// before
inputs = {"text": "こんにちは", "voice_id": vid, "voice_language": "jp"} # raises
// after
inputs = {"text": "こんにちは", "voice_id": vid, "voice_language": "ja"} Defensive patterns
Strategy: validation
Validate before calling
from tools.audio.kling_tts import TTS_LANGUAGES
lang = str(inputs.get("voice_language") or "en")
if lang not in TTS_LANGUAGES:
raise ValueError(f"unsupported voice_language {lang!r}; allowed: {TTS_LANGUAGES}") Type guard
def is_supported_language(lang: str) -> bool:
return lang in TTS_LANGUAGES Prevention
- Use ISO 639-1 codes from TTS_LANGUAGES exactly
- Omit voice_language for English
- Map common aliases (jp→ja) in a normalization layer
When it happens
Trigger: Passing an unsupported code like 'jp' instead of 'ja', full names like 'english', or region-qualified codes like 'en-US' not present in TTS_LANGUAGES.
Common situations: Mapping ISO 639-1 codes incorrectly; copying language values from another provider's schema; case sensitivity ('EN' vs 'en' unless the whitelist normalizes).
Related errors
- text is required
- text exceeds Kling TTS safety limit of 5000 characters
- voice_id is required for Kling official TTS
- voice_speed must be between {TTS_SPEED_MIN} and {TTS_SPEED_M
- element_list must be a list of element ids or objects
AI-assisted analysis of calesthio/OpenMontage@95e1c3d0ab (2026-08-15).
Data as JSON: /api/errors/2842ec19e6d1c65e.
Report an issue: GitHub.