[PR #22425] [CLOSED] fix: correct Azure TTS locale extraction for SSML xml:lang #130339

Closed
opened 2026-05-21 14:21:47 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/22425
Author: @alvinttang
Created: 3/8/2026
Status: Closed

Base: mainHead: fix/azure-tts-locale-truncation


📝 Commits (1)

  • 22a10f3 fix: correct Azure TTS locale extraction for SSML xml:lang

📊 Changes

1 file changed (+1 additions, -1 deletions)

View changed files

📝 backend/open_webui/routers/audio.py (+1 -1)

📄 Description

Summary

The Azure TTS SSML locale was being extracted using split("-")[:1], which only takes the first segment of the voice name (e.g., "en" from "en-US"). The xml:lang attribute in SSML requires a proper BCP-47 locale like "en-US", not just a bare language code.

This caused Azure TTS to either fail outright or use incorrect pronunciation/prosody rules because the SSML document had an invalid or overly broad language tag.

Fix

Changed [:1] to [:2] so the locale correctly extracts both language and region (e.g., "en-US", "zh-CN", "fr-FR").

Before

locale = "-".join(request.app.state.config.TTS_VOICE.split("-")[:1])
# "en-US-JennyNeural" → "en" (wrong)

After

locale = "-".join(request.app.state.config.TTS_VOICE.split("-")[:2])
# "en-US-JennyNeural" → "en-US" (correct)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/22425 **Author:** [@alvinttang](https://github.com/alvinttang) **Created:** 3/8/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/azure-tts-locale-truncation` --- ### 📝 Commits (1) - [`22a10f3`](https://github.com/open-webui/open-webui/commit/22a10f31ddb3305ffc518e37f604aab80485500b) fix: correct Azure TTS locale extraction for SSML xml:lang ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/routers/audio.py` (+1 -1) </details> ### 📄 Description ## Summary The Azure TTS SSML locale was being extracted using `split("-")[:1]`, which only takes the **first** segment of the voice name (e.g., `"en"` from `"en-US"`). The `xml:lang` attribute in SSML requires a proper BCP-47 locale like `"en-US"`, not just a bare language code. This caused Azure TTS to either fail outright or use incorrect pronunciation/prosody rules because the SSML document had an invalid or overly broad language tag. ### Fix Changed `[:1]` to `[:2]` so the locale correctly extracts both language and region (e.g., `"en-US"`, `"zh-CN"`, `"fr-FR"`). ### Before ```python locale = "-".join(request.app.state.config.TTS_VOICE.split("-")[:1]) # "en-US-JennyNeural" → "en" (wrong) ``` ### After ```python locale = "-".join(request.app.state.config.TTS_VOICE.split("-")[:2]) # "en-US-JennyNeural" → "en-US" (correct) ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-21 14:21:47 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#130339