Skip to content

Improve speech XML function usage#19793

Merged
SaschaCowley merged 2 commits intobetafrom
speechXmlFunction
Mar 17, 2026
Merged

Improve speech XML function usage#19793
SaschaCowley merged 2 commits intobetafrom
speechXmlFunction

Conversation

@seanbudd
Copy link
Copy Markdown
Member

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 toXmlLang and toNvdaLang utility functions from speechXml. 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("_", "-") or replace("-", "_")) with the use of toXmlLang and toNvdaLang utility functions in speech.py, _espeak.py, espeak.py, and oneCore.py to ensure consistent formatting for speech engine interoperability.

@seanbudd seanbudd added this to the 2026.1 milestone Mar 16, 2026
@seanbudd seanbudd requested a review from a team as a code owner March 16, 2026 07:15
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 with speechXml helpers.
  • 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.

Comment thread source/synthDrivers/espeak.py Outdated
Comment thread source/mathPres/MathCAT/speech.py
@seanbudd seanbudd added the conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review. label Mar 17, 2026
@SaschaCowley SaschaCowley merged commit 7c56b89 into beta Mar 17, 2026
39 checks passed
@SaschaCowley SaschaCowley deleted the speechXmlFunction branch March 17, 2026 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants