Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
7472426
Report spelling errors with a sound while reading
Apr 18, 2025
bc96c36
Change log
Apr 22, 2025
30b5b75
Pre-commit auto-fix
pre-commit-ci[bot] Apr 22, 2025
fed0575
Fix pre-commit rework - adding tailing comma
Apr 23, 2025
d42f3ef
Apply suggestions from code review
CyrilleB79 May 5, 2025
fcf6afb
Change anchor name
May 5, 2025
72b2025
Remove debug comments
May 5, 2025
ecee988
Merge branch 'master' into spellingSound
May 7, 2025
743a5a5
Merge branch 'master' into spellingSound
CyrilleB79 Jun 3, 2025
579f3b1
Merge branch 'master' into spellingSound
Jul 8, 2025
5696410
Convert to new key; feature broken in Word (UIA or legacy)
Jul 8, 2025
44f72b0
Merge branch 'master' into spellingSound
Aug 5, 2025
b88944f
Fix config latest after merge
Aug 5, 2025
70770bb
Implement aliases
Aug 5, 2025
c7905cf
Fix and document config key aliasing
Aug 6, 2025
f2fc880
Merge branch 'master' into spellingSound
Aug 6, 2025
4b7670a
Pre-commit auto-fix
pre-commit-ci[bot] Aug 6, 2025
263c027
Apply suggestions from code review
CyrilleB79 Aug 7, 2025
03f5b09
Fix type hint
Aug 7, 2025
72b3d41
Merge branch 'master' into spellingSound
Aug 8, 2025
3b5219e
Apply suggestions from code review
CyrilleB79 Aug 8, 2025
d3676cc
Added unit tests
Aug 8, 2025
bb0a58e
Pre-commit auto-fix
pre-commit-ci[bot] Aug 8, 2025
41aaecd
Merge branch 'master' into spellingSound
Aug 8, 2025
658fd7e
Pre-commit auto-fix
pre-commit-ci[bot] Aug 8, 2025
da2d886
Bump CI
Aug 8, 2025
c4e5e97
Update tests/unit/test_config.py
SaschaCowley Aug 19, 2025
660049c
Merge branch 'master' into spellingSound
CyrilleB79 Aug 28, 2025
bce05e3
Remove backward compa code since we now target 2026.1
CyrilleB79 Aug 28, 2025
cba9bfa
ReportSpellingErrors converted to DisplayStringIntFlag; usage to be u…
CyrilleB79 Aug 28, 2025
602a05e
Pre-commit auto-fix
pre-commit-ci[bot] Aug 28, 2025
aeac6b8
Convert to bitwise flag everywhere
Aug 29, 2025
0e92ea7
fix translator's comment
Aug 29, 2025
156ea3a
Update change for dev
Aug 29, 2025
1cfe185
Update User §Guide with checklist box
Aug 29, 2025
cb6d06f
Fix config upgrade
Aug 29, 2025
3a7db06
Pre-commit auto-fix
pre-commit-ci[bot] Aug 29, 2025
1f6c43d
type hint
Aug 29, 2025
e324235
Fix syntax error
Aug 29, 2025
8f5ca89
Pre-commit auto-fix
pre-commit-ci[bot] Aug 29, 2025
3008570
Fix missing import
Aug 29, 2025
7a9810e
One more attempt to fix translators comment!
Aug 29, 2025
3087fa6
Fix both reporting modes
CyrilleB79 Aug 30, 2025
5103c8b
Pre-commit auto-fix
pre-commit-ci[bot] Aug 30, 2025
d3a156e
Apply suggestions from code review
CyrilleB79 Sep 2, 2025
6a0437b
Merge branch 'master' into spellingSound
CyrilleB79 Sep 3, 2025
4c2b721
Remove unnecessary if
CyrilleB79 Sep 3, 2025
bc29cb4
Update source/config/profileUpgradeSteps.py
SaschaCowley Sep 5, 2025
94b65d9
Pre-commit auto-fix
pre-commit-ci[bot] Sep 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Report spelling errors with a sound while reading
  • Loading branch information
Cyrille Bougot
Cyrille Bougot committed Apr 22, 2025
commit 747242646fcf8fe4931bc9b2305f68b587b8e1df
26 changes: 26 additions & 0 deletions source/config/configFlags.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,32 @@ def _displayStringLabels(self):
}


@unique
class ReportSpellingErrors(DisplayStringIntEnum):
Comment thread
SaschaCowley marked this conversation as resolved.
Outdated
"""Enumeration containing the possible config values to report spelling errors while reading.

Use ReportSpellingErrors.MEMBER.value to compare with the config;
use ReportSpellingErrors.MEMBER.displayString in the UI for a translatable description of this member.
"""

OFF = 0
SPEECH = 1
SOUND = 2

@property
def _displayStringLabels(self):
Comment thread
CyrilleB79 marked this conversation as resolved.
Outdated
return {
# Translators: A choice in a combo box in the document formatting dialog to not report spelling errors.
ReportSpellingErrors.OFF: pgettext("line indentation setting", "Off"),
# Translators: A choice in a combo box in the document formatting dialog to report spelling errors
# with Speech.
Comment thread
CyrilleB79 marked this conversation as resolved.
Outdated
ReportSpellingErrors.SPEECH: pgettext("line indentation setting", "Speech"),
# Translators: A choice in a combo box in the document formatting dialog to report spelling errors
# with a sound.
ReportSpellingErrors.SOUND: pgettext("line indentation setting", "Sound"),
}


@unique
class ReportTableHeaders(DisplayStringIntEnum):
"""Enumeration containing the possible config values to report table headers.
Expand Down
5 changes: 3 additions & 2 deletions source/config/configSpec.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#: provide an upgrade step (@see profileUpgradeSteps.py). An upgrade step does not need to be added when
#: just adding a new element to (or removing from) the schema, only when old versions of the config
#: (conforming to old schema versions) will not work correctly with the new schema.
latestSchemaVersion = 17
latestSchemaVersion = 18

#: The configuration specification string
#: @type: String
Expand Down Expand Up @@ -228,7 +228,8 @@
reportAlignment = boolean(default=false)
reportLineSpacing = boolean(default=false)
reportStyle = boolean(default=false)
reportSpellingErrors = boolean(default=true)
# 0: Off, 1: Speech, 2: Sound
reportSpellingErrors = integer(0, 2, default=1)
Comment thread
CyrilleB79 marked this conversation as resolved.
Outdated
Comment thread
SaschaCowley marked this conversation as resolved.
Outdated
reportPage = boolean(default=true)
reportLineNumber = boolean(default=False)
# 0: Off, 1: Speech, 2: Tones, 3: Both Speech and Tones
Expand Down
20 changes: 20 additions & 0 deletions source/config/profileUpgradeSteps.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
OutputMode,
ReportCellBorders,
ReportLineIndentation,
ReportSpellingErrors,
ReportTableHeaders,
ShowMessages,
TetherTo,
Expand Down Expand Up @@ -577,3 +578,22 @@ def upgradeConfigFrom_16_to_17(profile: ConfigObj) -> None:
log.debug(
f"Renamed config['remote']['{sectionKey}']['{oldItemKey}'] to config['remote']['{sectionKey}']['{newItemKey}'].",
)

def upgradeConfigFrom_17_to_18(profile: ConfigObj):
"""Convert report spelling errors configurations from boolean to integer values."""

section = "documentFormatting"
key = "reportSpellingErrors"
try:
oldValue: bool = profile[section].as_bool(key)
except KeyError:
log.debug(f"'{key}' not present in config, no action taken.")
return
except ValueError:
log.error(f"'{key}' is not a boolean, got {profile[section][key]!r}. Deleting.")
del profile[section][key]
return
else:
newValue = ReportSpellingErrors.SPEECH.value if oldValue else ReportSpellingErrors.OFF.value
profile[section][key] = newValue
log.debug(f"Converted '{key}' from {oldValue!r} to {newValue} ({ReportSpellingErrors(newValue).name}).")
20 changes: 10 additions & 10 deletions source/globalCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
BrailleMode,
OutputMode,
TypingEcho,
ReportSpellingErrors,
)
from config.featureFlag import FeatureFlag
from config.featureFlagEnums import BoolFlag
Expand Down Expand Up @@ -787,19 +788,18 @@ def script_toggleReportStyle(self, gesture):

@script(
# Translators: Input help mode message for toggle report spelling errors command.
description=_("Toggles on and off the reporting of spelling errors"),
description=_("Cycles through the possible choices to report spelling errors"),
Comment thread
CyrilleB79 marked this conversation as resolved.
Outdated
category=SCRCAT_DOCUMENTFORMATTING,
)
def script_toggleReportSpellingErrors(self, gesture):
if config.conf["documentFormatting"]["reportSpellingErrors"]:
# Translators: The message announced when toggling the report spelling errors document formatting setting.
state = _("report spelling errors off")
config.conf["documentFormatting"]["reportSpellingErrors"] = False
else:
# Translators: The message announced when toggling the report spelling errors document formatting setting.
state = _("report spelling errors on")
config.conf["documentFormatting"]["reportSpellingErrors"] = True
ui.message(state)
toggleIntegerValue(
configSection="documentFormatting",
configKey="reportSpellingErrors",
enumClass=ReportSpellingErrors,
# Translators: Reported when the user cycles through the choices to report spelling errors.
# {mode} will be replaced with the mode; e.g. Off, Speech, Sound.
messageTemplate=_("Report spelling errors {mode}"),
)

@script(
# Translators: Input help mode message for toggle report pages command.
Expand Down
21 changes: 15 additions & 6 deletions source/gui/settingsDialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
TetherTo,
ParagraphStartMarker,
ReportLineIndentation,
ReportSpellingErrors,
ReportTableHeaders,
ReportCellBorders,
OutputMode,
Expand Down Expand Up @@ -2748,11 +2749,19 @@ def makeSettings(self, settingsSizer):
self.revisionsCheckBox = docInfoGroup.addItem(wx.CheckBox(docInfoBox, label=revisionsText))
self.revisionsCheckBox.SetValue(config.conf["documentFormatting"]["reportRevisions"])

# Translators: This is the label for a checkbox in the
# document formatting settings panel.
spellingErrorText = _("Spelling e&rrors")
self.spellingErrorsCheckBox = docInfoGroup.addItem(wx.CheckBox(docInfoBox, label=spellingErrorText))
self.spellingErrorsCheckBox.SetValue(config.conf["documentFormatting"]["reportSpellingErrors"])
self.spellingErrorsCombo = docInfoGroup.addLabeledControl(
# Translators: This is the label for a checkbox in the
# document formatting settings panel.
_("Spelling e&rrors"),
wx.Choice,
choices=[i.displayString for i in ReportSpellingErrors],
)
self.bindHelpEvent(
"DocumentFormattingSettingsSpellingErrors",
Comment thread
CyrilleB79 marked this conversation as resolved.
Outdated
self.spellingErrorsCombo,
)
reportSpellingErrors = config.conf["documentFormatting"]["reportSpellingErrors"]
self.spellingErrorsCombo.SetSelection(reportSpellingErrors)
Comment thread
CyrilleB79 marked this conversation as resolved.
Outdated

# Translators: This is the label for a group of document formatting options in the
# document formatting settings panel
Expand Down Expand Up @@ -2975,7 +2984,7 @@ def onSave(self):
config.conf["documentFormatting"]["reportHighlight"] = self.highlightCheckBox.IsChecked()
config.conf["documentFormatting"]["reportAlignment"] = self.alignmentCheckBox.IsChecked()
config.conf["documentFormatting"]["reportStyle"] = self.styleCheckBox.IsChecked()
config.conf["documentFormatting"]["reportSpellingErrors"] = self.spellingErrorsCheckBox.IsChecked()
config.conf["documentFormatting"]["reportSpellingErrors"] = self.spellingErrorsCombo.GetSelection()
config.conf["documentFormatting"]["reportPage"] = self.pageCheckBox.IsChecked()
config.conf["documentFormatting"]["reportLineNumber"] = self.lineNumberCheckBox.IsChecked()
config.conf["documentFormatting"]["reportLineIndentation"] = self.lineIndentationCombo.GetSelection()
Expand Down
19 changes: 13 additions & 6 deletions source/speech/speech.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
EndUtteranceCommand,
SuppressUnicodeNormalizationCommand,
CharacterModeCommand,
WaveFileCommand,
)
from .shortcutKeys import getKeyboardShortcutsSpeech

Expand All @@ -65,6 +66,7 @@
import config
from config.configFlags import (
ReportLineIndentation,
ReportSpellingErrors,
ReportTableHeaders,
ReportCellBorders,
OutputMode,
Expand Down Expand Up @@ -1491,7 +1493,7 @@ def speakTextInfo(
def getTextInfoSpeech( # noqa: C901
info: textInfos.TextInfo,
useCache: Union[bool, SpeakTextInfoState] = True,
formatConfig: Dict[str, bool] = None,
formatConfig: Dict[str, bool | int] = None,
Comment thread
CyrilleB79 marked this conversation as resolved.
Outdated
unit: Optional[str] = None,
reason: OutputReason = OutputReason.QUERY,
_prefixSpeechCommand: Optional[SpeechCommand] = None,
Expand All @@ -1516,7 +1518,7 @@ def getTextInfoSpeech( # noqa: C901
)
# For performance reasons, when navigating by paragraph or table cell, spelling errors will not be announced.
if unit in (textInfos.UNIT_PARAGRAPH, textInfos.UNIT_CELL) and reason == OutputReason.CARET:
formatConfig["reportSpellingErrors"] = False
formatConfig["reportSpellingErrors"] = ReportSpellingErrors.OFF.value

# Fetch the last controlFieldStack, or make a blank one
controlFieldStackCache = speakTextInfoState.controlFieldStackCache if speakTextInfoState else []
Expand Down Expand Up @@ -1891,7 +1893,9 @@ def _getTextInfoSpeech_considerSpelling(
speechSequence: SpeechSequence,
language: str,
) -> Generator[SpeechSequence, None, None]:
if onlyInitialFields or any(isinstance(x, str) for x in speechSequence):
# zzz Replacing if onlyInitialFields or any(isinstance(x, str) for x in speechSequence):
if onlyInitialFields or speechSequence:
# zzz replaced if onlyInitialFields or speechSequence:
Comment thread
SaschaCowley marked this conversation as resolved.
Outdated
yield speechSequence
if not onlyInitialFields:
spellingSequence = list(
Expand Down Expand Up @@ -2991,13 +2995,16 @@ def getFormatFieldSpeech( # noqa: C901
# Translators: Reported when text no longer contains a bookmark
text = _("out of bookmark")
textList.append(text)
if formatConfig["reportSpellingErrors"]:
if formatConfig["reportSpellingErrors"] != ReportSpellingErrors.OFF.value:
invalidSpelling = attrs.get("invalid-spelling")
oldInvalidSpelling = attrsCache.get("invalid-spelling") if attrsCache is not None else None
if (invalidSpelling or oldInvalidSpelling is not None) and invalidSpelling != oldInvalidSpelling:
if invalidSpelling:
# Translators: Reported when text contains a spelling error.
text = _("spelling error")
if formatConfig["reportSpellingErrors"] == ReportSpellingErrors.SPEECH.value:
# Translators: Reported when text contains a spelling error.
text = _("spelling error")
else:
text = WaveFileCommand(r"waves\textError.wav")
elif extraDetail:
# Translators: Reported when moving out of text containing a spelling error.
text = _("out of spelling error")
Expand Down
17 changes: 15 additions & 2 deletions user_docs/en/userGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -2609,7 +2609,7 @@ When enabled, NVDA will announce all non-character keys you type on the keyboard
##### Play sound for spelling errors while typing {#KeyboardSettingsAlertForSpellingErrors}

When enabled, a short buzzer sound will be played when a word you type contains a spelling error.
This option is only available if reporting of spelling errors is enabled in NVDA's [Document Formatting Settings](#DocumentFormattingSettings), found in the NVDA Settings dialog.
This option is only available if [reporting of spelling errors](#DocumentFormattingSettingsSpellingErrors) is enabled in NVDA's Document Formatting Settings.

##### Handle keys from other applications {#KeyboardSettingsHandleKeys}

Expand Down Expand Up @@ -2951,7 +2951,7 @@ You can configure reporting of:
* Comments
* Bookmarks
* Editor revisions
* Spelling errors
* Spelling errors [(Off, Speech, Sound)](#DocumentFormattingSettingsSpellingErrors)
* Pages and spacing
* Page numbers
* Line numbers
Expand Down Expand Up @@ -3000,6 +3000,19 @@ By default, NVDA will detect the formatting at the position of the System caret

Enable this option while proof reading documents in applications such as WordPad, where formatting is important.

##### Spelling errors reporting {#DocumentFormattingSettingsSpellingErrors}

This option allows you to configure how spelling errors are reported while reading text.
The "Report spelling errors" combo box has three options.
Comment thread
CyrilleB79 marked this conversation as resolved.
Outdated

* Off: NVDA will not report any spelling error
Comment thread
CyrilleB79 marked this conversation as resolved.
Outdated
* Speech: NVDA will say "spelling error" when a spelling error is encountered while reading text
* Sound: NVDA will play a short buzzer sound when a spelling error is encountered while reading text

When navigating word by word or character by character, "out of spelling error" is also reported if Speech or Sound option is selected.
Comment thread
CyrilleB79 marked this conversation as resolved.
Outdated

Due to performance limitations, spelling errors are not reported when navigating by paragraph or by cell in tables, no matter the choice selected in the combo-box.
Comment thread
CyrilleB79 marked this conversation as resolved.
Outdated

##### Line indentation reporting {#DocumentFormattingSettingsLineIndentation}

This option allows you to configure how indentation at the beginning of lines is reported.
Expand Down