Skip to content

The agent that grows with you

feat(tts): pass lang_code to OpenAI-compatible TTS providers (Kokoro multilingual support)

Gabriel Anzzianic0dda61032c0
diff --git a/tools/tts_tool.py b/tools/tts_tool.py
index 6af7d9c1bab..9e10cb3ef81 100644
--- a/tools/tts_tool.py
+++ b/tools/tts_tool.py
@@ -1332,6 +1332,7 @@ def _generate_openai_tts(
if speed is None:
speed_default = tts_config.get("speed", 1.0) if isinstance(tts_config, dict) else 1.0
speed = float(oai_config.get("speed", speed_default))
+ language = oai_config.get("language")
# The managed OpenAI audio gateway only proxies MANAGED_OPENAI_TTS_MODELS.
# A model set for direct OpenAI (e.g. "tts-1-hd") 400s there with
@@ -1367,6 +1368,8 @@ def _generate_openai_tts(
create_kwargs["speed"] = max(0.25, min(4.0, speed))
if instructions:
create_kwargs["instructions"] = instructions
+ if language:
+ create_kwargs["extra_body"] = {"lang_code": language}
response = client.audio.speech.create(**create_kwargs)
response.stream_to_file(output_path)