Skip to content

Commit 7aa7bbc

Browse files
fix: correct Azure TTS locale extraction for SSML xml:lang (open-webui#22443)
The locale for Azure TTS SSML was being extracted with `split("-")[:1]`, which only takes the first segment (e.g., "en" from "en-US"). The xml:lang attribute in SSML requires a full locale like "en-US", not just a language code. This caused Azure TTS to either fail or use incorrect pronunciation rules. Changed `[:1]` to `[:2]` to properly extract the locale (e.g., "en-US"). Co-authored-by: gambletan <ethanchang32@gmail.com>
1 parent a97f5ad commit 7aa7bbc

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

backend/open_webui/routers/audio.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ async def speech(request: Request, user=Depends(get_verified_user)):
492492
region = request.app.state.config.TTS_AZURE_SPEECH_REGION or "eastus"
493493
base_url = request.app.state.config.TTS_AZURE_SPEECH_BASE_URL
494494
language = request.app.state.config.TTS_VOICE
495-
locale = "-".join(request.app.state.config.TTS_VOICE.split("-")[:1])
495+
locale = "-".join(request.app.state.config.TTS_VOICE.split("-")[:2])
496496
output_format = request.app.state.config.TTS_AZURE_SPEECH_OUTPUT_FORMAT
497497

498498
try:

0 commit comments

Comments
 (0)