{"record":{"id":"ae70d9ed3b2df689","repo":"calesthio/OpenMontage","slug":"voice-speed-must-be-between-tts-speed-min-and-t","errorCode":null,"errorMessage":"voice_speed must be between {TTS_SPEED_MIN} and {TTS_SPEED_MAX}","messagePattern":"voice_speed must be between (.+?) and (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"tools/audio/kling_tts.py","lineNumber":211,"sourceCode":"\n    def _build_request(self, inputs: dict[str, Any]) -> dict[str, Any]:\n        text = str(inputs.get(\"text\") or \"\").strip()\n        if not text:\n            raise ValueError(\"text is required\")\n        if len(text) > 5000:\n            raise ValueError(\"text exceeds Kling TTS safety limit of 5000 characters\")\n\n        voice_id = str(inputs.get(\"voice_id\") or \"\").strip()\n        if not voice_id:\n            raise ValueError(\"voice_id is required for Kling official TTS\")\n\n        voice_language = str(inputs.get(\"voice_language\") or \"en\")\n        if voice_language not in TTS_LANGUAGES:\n            raise ValueError(f\"voice_language must be one of: {', '.join(TTS_LANGUAGES)}\")\n\n        voice_speed = float(inputs.get(\"voice_speed\", 1.0))\n        if voice_speed < TTS_SPEED_MIN or voice_speed > TTS_SPEED_MAX:\n            raise ValueError(f\"voice_speed must be between {TTS_SPEED_MIN} and {TTS_SPEED_MAX}\")\n\n        payload: dict[str, Any] = {\n            \"text\": text,\n            \"voice_id\": voice_id,\n            \"voice_language\": voice_language,\n            \"voice_speed\": voice_speed,\n        }\n        self._copy_common_task_fields(inputs, payload)\n        return {\n            \"protocol\": \"classic\",\n            \"path\": \"/v1/audio/tts\",\n            \"payload\": payload,\n            \"operation\": \"text_to_speech\",\n            \"model\": \"kling-official-tts\",\n        }\n\n    @staticmethod\n    def _create_and_collect_audios(","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/calesthio/OpenMontage/blob/95e1c3d0ab93482159818560f6a8c8e866b9139f/tools/audio/kling_tts.py#L193-L229","documentation":"Raised by kling_tts._build_request when voice_speed (default 1.0) falls outside the module constants TTS_SPEED_MIN..TTS_SPEED_MAX. The wrapper validates the range locally because Kling's API rejects out-of-range speeds server-side.","triggerScenarios":"Passing voice_speed like 0.1, 5, or a string that float() accepts but is out of range; copying a speed value calibrated for another provider's scale.","commonSituations":"Providers use different speed scales (0.25–4.0 vs 0.5–2.0); user-provided 'playbackRate' forwarded unclamped; unit confusion (percent 150 passed as 150).","solutions":["Clamp voice_speed into [TTS_SPEED_MIN, TTS_SPEED_MAX] before calling","Keep the default 1.0 unless the script explicitly needs pacing changes","If 150-style percentages come from config, divide by 100 first"],"exampleFix":"// before\ninputs = {\"text\": t, \"voice_id\": vid, \"voice_speed\": 150}  # raises\n\n// after\nfrom tools.audio.kling_tts import TTS_SPEED_MIN, TTS_SPEED_MAX\ninputs = {\"text\": t, \"voice_id\": vid, \"voice_speed\": min(max(1.5, TTS_SPEED_MIN), TTS_SPEED_MAX)}","handlingStrategy":"validation","validationCode":"from tools.audio.kling_tts import TTS_SPEED_MIN, TTS_SPEED_MAX\nspeed = float(inputs.get(\"voice_speed\", 1.0))\nif not (TTS_SPEED_MIN <= speed <= TTS_SPEED_MAX):\n    raise ValueError(f\"voice_speed must be within [{TTS_SPEED_MIN}, {TTS_SPEED_MAX}]\")","typeGuard":"def is_valid_speed(speed: float) -> bool:\n    return TTS_SPEED_MIN <= speed <= TTS_SPEED_MAX","tryCatchPattern":null,"preventionTips":["Clamp user-provided speeds to the tool's range before dispatch","Convert percentage-style values (150 → 1.5) at the config boundary","Leave speed at default 1.0 unless pacing is intentional"],"tags":["kling","tts","validation","range"],"backgroundTag":null,"analyzedSha":"95e1c3d0ab93482159818560f6a8c8e866b9139f","analyzedAt":"2026-08-15T06:31:20.014Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}