Improve speech XML function usage#19793
Merged
SaschaCowley merged 2 commits intobetafrom Mar 17, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR standardizes language-code conversions across several synthesizer and MathCAT paths by using speechXml.toXmlLang / speechXml.toNvdaLang, along with some typing/metadata cleanups.
Changes:
- Replace ad-hoc
replace("_", "-")/replace("-", "_")language conversions withspeechXmlhelpers. - Modernize some type annotations to built-in generics / union syntax.
- Update file headers (copyright/license).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
source/synthDrivers/oneCore.py |
Uses speechXml.toNvdaLang for consistent OneCore language normalization; adds a type annotation to a helper. |
source/synthDrivers/espeak.py |
Switches to toXmlLang for language normalization and updates typing annotations / header. |
source/synthDrivers/_espeak.py |
Uses toXmlLang when setting the eSpeak voice by language; updates header. |
source/mathPres/MathCAT/speech.py |
Adds NVDA license header and uses toXmlLang when comparing current language. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
SaschaCowley
approved these changes
Mar 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to issue number:
Spawned from #19740
Summary of the issue:
It was hard to track all the different places language codes are normalized in NVDA.
Description of developer facing changes:
This pull request standardizes language code formatting across the NVDA codebase by introducing and using the
toXmlLangandtoNvdaLangutility functions fromspeechXml. This ensures consistent handling of language codes (e.g., converting between underscores and hyphens) when interacting with speech synthesis engines and related components.Description of development approach:
Replaced manual string manipulation for language codes (such as
replace("_", "-")orreplace("-", "_")) with the use oftoXmlLangandtoNvdaLangutility functions inspeech.py,_espeak.py,espeak.py, andoneCore.pyto ensure consistent formatting for speech engine interoperability.