fix: tts tool must choose a voice (#21877)

This commit is contained in:
非法操作 2025-07-03 17:10:01 +08:00 committed by GitHub
parent 1c7404099d
commit a79f37b686
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -31,6 +31,14 @@ class TTSTool(BuiltinTool):
model_type=ModelType.TTS,
model=model,
)
if not voice:
voices = model_instance.get_tts_voices()
if voices:
voice = voices[0].get("value")
if not voice:
raise ValueError("Sorry, no voice available.")
else:
raise ValueError("Sorry, no voice available.")
tts = model_instance.invoke_tts(
content_text=tool_parameters.get("text"), # type: ignore
user=user_id,