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>
This commit is contained in:
Copilot
2026-07-06 15:13:55 +08:00
committed by GitHub
parent 2d4501bcda
commit 843972e412
+7
View File
@@ -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):