Skip to content

Fix error when a synthesizer don't expose available languages#20100

Merged
seanbudd merged 3 commits into
nvaccess:masterfrom
nvdaes:normalizeLang
May 11, 2026
Merged

Fix error when a synthesizer don't expose available languages#20100
seanbudd merged 3 commits into
nvaccess:masterfrom
nvdaes:normalizeLang

Conversation

@nvdaes
Copy link
Copy Markdown
Collaborator

@nvdaes nvdaes commented May 11, 2026

Link to issue number:

Fixes #20080

Summary of the issue:

When NVDA is configured to report if the language of the text been read is supported, an error is produced if the syntesizer exposes available languages as None.

Description of user facing changes:

Fixed an error with certain syntesizers when reporting if the language of the text been read is supported.

Description of developer facing changes:

Description of development approach:

Check if available language is None.

Testing strategy:

None yet.

Known issues with pull request:

None.

Code Review Checklist:

  • Documentation:
    • Change log entry
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • API is compatible with existing add-ons.
  • Security precautions taken.

Copy link
Copy Markdown
Member

@seanbudd seanbudd left a comment

Choose a reason for hiding this comment

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

Thanks @nvdaes

@seanbudd seanbudd marked this pull request as ready for review May 11, 2026 07:40
@seanbudd seanbudd requested a review from a team as a code owner May 11, 2026 07:40
@seanbudd seanbudd requested review from SaschaCowley and Copilot May 11, 2026 07:40
@seanbudd seanbudd merged commit 567a579 into nvaccess:master May 11, 2026
36 of 38 checks passed
@github-actions github-actions Bot added this to the 2026.2 milestone May 11, 2026
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 addresses an AttributeError raised when NVDA checks whether a language is supported by the current synthesizer and the synthesizer reports an invalid/empty available language entry (notably None). This sits in the speech language-reporting path (used by language reporting / automatic language switching features), where robustness is important to avoid repeated log errors during normal speech output.

Changes:

  • Add a guard in SynthDriver.languageIsSupported to skip None entries in availableLanguages.
  • Add a changelog entry documenting the fix.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
source/synthDriverHandler.py Avoids calling language normalization on None entries when checking synthesizer language support.
user_docs/en/changes.md Documents the bug fix in the 2026.2 changelog.

Comment on lines 347 to 351
for availableLang in self.availableLanguages:
if (
if availableLang is not None and (
lang == languageHandler.normalizeLanguage(availableLang)
or lang == languageHandler.normalizeLanguage(availableLang).split("_")[0]
):
Comment on lines 340 to 350
def languageIsSupported(self, lang: str | None) -> bool:
"""Determines if the specified language is supported.
:param lang: A language code or None.
:return: ``True`` if the language is supported, ``False`` otherwise.
"""
if lang is None:
return True
for availableLang in self.availableLanguages:
if (
if availableLang is not None and (
lang == languageHandler.normalizeLanguage(availableLang)
or lang == languageHandler.normalizeLanguage(availableLang).split("_")[0]
Comment thread user_docs/en/changes.md

### Bug Fixes

* Fixed an error when a synthesizer doesn't have available languages, and NVDA tries to report if a language is supported. (#20080, @nvdaes)
@seanbudd
Copy link
Copy Markdown
Member

oops - these are all good comments. Might be worth a follow up.

seanbudd pushed a commit that referenced this pull request May 15, 2026
None. Fixup of PR #20100
Summary of the issue:

Synthesizers may return None for normalized languages, and this is not addressed in #20100.
Description of user facing changes:

None known.
Description of developer facing changes:

None.
Description of development approach:

Considered the situation where the normalized language is None, improved the function to check if a language is supported, and added unit tests for this function.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AttributeError: 'NoneType' object has no attribute 'replace' in normalizeLanguage when using a SAPI4 synthesizer (WinTalker Voice)

3 participants