From c0dda61032c0e7d77bdecb88735ceabb055a6cdd Mon Sep 17 00:00:00 2001 From: Gabriel Anzziani Date: Sun, 24 May 2026 21:53:10 +0000 Subject: [PATCH] feat(tts): pass lang_code to OpenAI-compatible TTS providers (Kokoro multilingual support) The 'language' config field in tts.openai.language was read but never passed to the API. This caused Kokoro (and other OpenAI-compatible TTS backends that support lang_code) to default to English phonemization regardless of the configured language. Now passes lang_code via extra_body when language is set in config. --- tools/tts_tool.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/tts_tool.py b/tools/tts_tool.py index 6af7d9c1babe..9e10cb3ef81d 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)