Skip to content

Report the language of the text been read#17685

Merged
seanbudd merged 218 commits into
nvaccess:masterfrom
nvdaes:reportSwitchLang
Jun 24, 2025
Merged

Report the language of the text been read#17685
seanbudd merged 218 commits into
nvaccess:masterfrom
nvdaes:reportSwitchLang

Conversation

@nvdaes

@nvdaes nvdaes commented Feb 8, 2025

Copy link
Copy Markdown
Collaborator

Link to issue number:

Fixes #17664

Summary of the issue:

Users may want to know the language of the text been read, and if the current synthesizer can switch to that language.

Description of user facing changes

  • In the speech settings panel, a checkbox can be used to determine if the language of the read text should be reported when language detection is enabled.
  • In the speech settings panel, a combo box is added to choose if NVDA should report if the language is supported by the current synthesizer. Available options are: off, beep or speech.
  • Added an unassigned command in the caret system category to know the language of the character positioned at the caret.

Description of development approach

  • In speech/__init__.py, a function is registered (and unregistered) with the filter_speechSequence extension point, to insert the language description (or language code if the description is not available), when a langChangeCommand is found in the sequence to be spoken. The language description won't be inserted if the language command is the last item of the speech sequence, or if lang is None, or if it's the last reported language, or if reportLanguage and reportNotSupportedLanguage options are False. A SpeechSequence member has been added to the SpeechState class to track the last reported language, as well as another function to check and report if the language is supported by the current synthesizer.
  • LangChangeCommand has methods to determine if the language should be processed by NVDA or the synthesizer.
  • A new languageHandling.py file has been added to speech to filter speech sequences, adding language descriptions or beep commands to report language as appropriate.
  • In globalCommands.py, a script has been added to report the language of the character at caret.

Testing strategy:

Tested locally and in the Codepen sample provided in this PR.

Known issues with pull request:

If beep option is chosen to report not supported languages, Occasionally, it's possible to hear beeps when focus changes in web browsers without been notified about the not supported language, though this is not happening after restarting the computer

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.

@coderabbitai summary

@nvdaes nvdaes changed the title Reportthe language switched to Report the language switched to Feb 8, 2025
Comment thread source/globalCommands.py Outdated
Comment thread source/globalCommands.py Outdated
Comment thread source/speech/speech.py Outdated
Comment thread source/speech/speech.py Outdated
nvdaes and others added 2 commits February 8, 2025 23:16
Co-authored-by: Cyrille Bougot <cyrille.bougot2@laposte.net>
@nvdaes

nvdaes commented Feb 8, 2025

Copy link
Copy Markdown
Collaborator Author

Seems that, when pressing c to go to the combo box in the old add-ons website, the preferences word is in English but, if it's not spoken, the lastReportedLanguage is set to English, and this causes that the language of the word English in the combo box is not reported. I don't know if this may be fixed with the pre_speech extension point in some way.

@CyrilleB79

Copy link
Copy Markdown
Contributor

@nvdaes, regarding language translations I guess it would be interesting to list all the specific / corner cases. Then you will be able to determine if they should be handled separately or if they can be ignored.

For example I have the following questions:

  • zh_CN = Chinese (simplified) and zh_TW = Chinese (Traditional) would be both reported as "Chinese", I guess. Is it OK (cc @cary-rowen)
  • the language would be reported in the system's language; this would make a difference if you run NVDA in another language than "Windows". Maybe not a big problem, but it's worth informing of this limitation in the PR.
  • languageHandler.getLanguageDescription('sr'): on my system, it reports (in French): "Serbe (latin)". To be double checked if Serbian tagged webpages are tagged with "sr" or something else and if they are written in Cyrillic or in latin.

@nvdaes

nvdaes commented Feb 10, 2025

Copy link
Copy Markdown
Collaborator Author

@CyrilleB79 , should the corner cases be addressed in languageHandler.getLanguageDescription?
I'm concerned about the issue regarding pressing c on the add-ons website, since in this case English language may not be reported. So I'm blocked with this.

@CyrilleB79

Copy link
Copy Markdown
Contributor

@CyrilleB79 , should the corner cases be addressed in languageHandler.getLanguageDescription?

Maybe not; just mentioning in case everyone is aware of it so to decide what to do (accept as is or fix).

@nvdaes

nvdaes commented Feb 10, 2025

Copy link
Copy Markdown
Collaborator Author

Let's way for comments on this about corner cases, to see how to document it, or if saying that the language description would be reported is enough.
Hope someone can provide ideas to fix the error when jumping to some parts of webpages using quick navigation characters like c to move to combo boxes.

@nvdaes

nvdaes commented Feb 18, 2025

Copy link
Copy Markdown
Collaborator Author

I think that the experience when using this feature with quick navigation or moving the focus with tab is not good, when the language description is reported, then for example the text of a heading and a link, and then the link state like "visited link". In this case "visited link" is pronnounced with a bad entonation, tested with eSpeak-NG. And also, listening the language description for each element, since "visited link" is pronnounced in the default language, is too much.
I think that this should be disabled for quick navigation, unless someone can provide better ideas.

@nvdaes

nvdaes commented Feb 20, 2025

Copy link
Copy Markdown
Collaborator Author

Now for me the user experience is acceptable, not perfect, since in say all NVDA can report the language for new paragraphs. See [In-Process 7th February 2025](https://www.nvaccess.org/post/in-process-7th-february-2025/

Copy control+shift+cClose).
If we move the caret to the ending dot of the paragraph with right arrow, and then we make NVDA to say all, this issue seems not to happen.

@seanbudd

seanbudd commented Mar 4, 2025

Copy link
Copy Markdown
Member

Please mark this as a ready for review if it's ready

@nvdaes

nvdaes commented Mar 5, 2025

Copy link
Copy Markdown
Collaborator Author

Thanks, I plan to continue working on this the next weekend. I stopped working on this since this was not labelled with concept approved, so I thought that this was not prioritized.

@seanbudd

seanbudd commented Mar 5, 2025

Copy link
Copy Markdown
Member

Ah, we are waiting on the implementation to develop

@AppVeyorBot

Copy link
Copy Markdown

See test results for failed build of commit c059805765

@nvdaes

nvdaes commented Jun 17, 2025

Copy link
Copy Markdown
Collaborator Author

Now we use getLanguageDescription from languageHandler and all seem to be right.

@AppVeyorBot

Copy link
Copy Markdown

See test results for failed build of commit 3699afdc8f

@AppVeyorBot

Copy link
Copy Markdown

See test results for failed build of commit b8c1f2666f

@nvdaes

nvdaes commented Jun 17, 2025

Copy link
Copy Markdown
Collaborator Author

@seanbudd , I think that these tests take more than 15 minutes, and that these chrome cases, though don't cover all possible configuration, consider relevant situations:

  • Report when the current'synthesizer doesn't support a language if NVDA is set to do it.
    • Don't report dialects.
  • Report languages with dialects.
  • Don't report languages at all.

I don't think we should add all the possible combinations of configurations.
Please let me know if I should add some other tests before marking this as ready for review.

@seanbudd seanbudd marked this pull request as ready for review June 18, 2025 07:04
Comment thread tests/system/libraries/SystemTestSpy/speechSpyGlobalPlugin.py Outdated
)


def test_reportNotSupportedLanguageWithoutOtherLanguages():

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

#17685 (comment)

I think we need just one more test - report language changes on and report not supported set to speech.

If you are concerned around system test time length, I would encourage moving this to a separate test suite i.e. new python/robot file. You might have to factor out some stuff from chrome tests to it's own more generic module.
Or turn chromeTests into a submodule with multiple python test suites corresponding to separate robot files.
This means in GitHub actions we can parallelize it.
I really think we should avoid adding to chromeTests, as we need to modularize it. But I don't want the burden of this work to be on you, i.e. this part is an optional PR review comment.

@seanbudd seanbudd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @nvdaes for all your work

@nvdaes

nvdaes commented Jun 24, 2025

Copy link
Copy Markdown
Collaborator Author

Thank you @seanbudd . Since you approved this, I think it's better to split tests in a different issue/PR. So for now I won't perform this work.

@Qchristensen Qchristensen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good, just two small changes (been -> being)

Comment thread user_docs/en/changes.md Outdated
Comment thread user_docs/en/changes.md Outdated
seanbudd and others added 2 commits June 24, 2025 15:16
Co-authored-by: Quentin Christensen <quentin@nvaccess.org>
Co-authored-by: Quentin Christensen <quentin@nvaccess.org>

@Qchristensen Qchristensen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Great work!

@seanbudd seanbudd dismissed a stale review June 24, 2025 05:31

Spam

@AppVeyorBot

Copy link
Copy Markdown

See test results for failed build of commit 43f030d6e9

@seanbudd seanbudd merged commit 60586b8 into nvaccess:master Jun 24, 2025
16 of 17 checks passed
@github-actions github-actions Bot added this to the 2025.2 milestone Jun 24, 2025
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.

Add option to report when switching languages (and possibly to report when a language is not supported)

10 participants