From 843972e41259acc3e0d406e340580ce7739f7ccd Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Mon, 6 Jul 2026 15:13:55 +0800 Subject: [PATCH] fix: Fix QwenEmotion crash when json.loads returns string-valued emotion scores (#719) * Initial plan * Fix clamp_score to handle string emotion values from json.loads * Add warning log for non-numeric emotion scores in clamp_score * Raise ValueError on non-numeric emotion scores to abort TTS inference --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- indextts/infer_v2.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/indextts/infer_v2.py b/indextts/infer_v2.py index d34f01b..53e34be 100644 --- a/indextts/infer_v2.py +++ b/indextts/infer_v2.py @@ -763,6 +763,13 @@ class QwenEmotion: self.min_score = 0.0 def clamp_score(self, value): + try: + value = float(value) + except (TypeError, ValueError) as exc: + raise ValueError( + f"QwenEmotion returned a non-numeric emotion score {value!r}. " + "Please retry the request." + ) from exc return max(self.min_score, min(self.max_score, value)) def convert(self, content):