Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions source/config/configSpec.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@
language = string(default="")
autoRefresh = boolean(default=false)
autoRefreshInterval = integer(default=1500, min=100)
autoSayAllOnResult = boolean(default=false)

[editableText]
caretMoveTimeoutMs = integer(min=0, max=2000, default=100)
Expand Down
8 changes: 7 additions & 1 deletion source/contentRecog/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# A part of NonVisual Desktop Access (NVDA)
# Copyright (C) 2017-2023 NV Access Limited, James Teh, Leonard de Ruijter
# Copyright (C) 2017-2025 NV Access Limited, James Teh, Leonard de Ruijter, Cary-rowen
# This file is covered by the GNU General Public License.
# See the file COPYING for more details.

Expand Down Expand Up @@ -44,6 +44,12 @@ class ContentRecognizer(AutoPropertyObject):
"""
autoRefreshInterval: int = 1500
"""How often (in ms) to perform recognition."""
autoSayAllOnResult: bool = False
"""
Whether to automatically start reading the entire result after a successful recognition.
This is useful for users who want to hear the full content immediately
without needing to press additional keys.
"""

def getResizeFactor(self, width: int, height: int) -> Union[int, float]:
"""Return the factor by which an image must be resized
Expand Down
9 changes: 8 additions & 1 deletion source/contentRecog/recogUi.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# A part of NonVisual Desktop Access (NVDA)
# Copyright (C) 2017-2025 NV Access Limited, James Teh, Leonard de Ruijter, Cyrille Bougot
# Copyright (C) 2017-2025 NV Access Limited, James Teh, Leonard de Ruijter, Cyrille Bougot, Cary-rowen
# This file is covered by the GNU General Public License.
# See the file COPYING for more details.

Expand All @@ -22,6 +22,7 @@
import eventHandler
import textInfos
from logHandler import log
from speech import sayAll
import queueHandler
import core
from scriptHandler import script
Expand All @@ -45,6 +46,7 @@ class RecogResultNVDAObject(cursorManager.CursorManager, NVDAObjects.window.Wind

def __init__(self, result=None, obj=None):
self.parent = parent = api.getFocusObject()
self._shouldSayAllOnFirstFocus = False
self.result = result
if result:
self._selection = self.makeTextInfo(textInfos.POSITION_FIRST)
Expand Down Expand Up @@ -160,6 +162,8 @@ def _onFirstResult(self, result: Union[RecognitionResult, Exception]):
self._selection = self.makeTextInfo(textInfos.POSITION_FIRST)
# This method queues an event to the main thread.
self.setFocus()
if self.recognizer.autoSayAllOnResult:
self._shouldSayAllOnFirstFocus = True
if self.recognizer.allowAutoRefresh:
self._scheduleRecognize()

Expand Down Expand Up @@ -204,6 +208,9 @@ def _onResult(self, result: Union[RecognitionResult, Exception]):

def event_gainFocus(self):
super().event_gainFocus()
if self._shouldSayAllOnFirstFocus:
self._shouldSayAllOnFirstFocus = False
sayAll.SayAllHandler.readText(sayAll.CURSOR.CARET)
if self.recognizer.allowAutoRefresh:
# Make LiveText watch for and report new text.
self.startMonitoring()
Expand Down
6 changes: 5 additions & 1 deletion source/contentRecog/uwpOcr.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# A part of NonVisual Desktop Access (NVDA)
# Copyright (C) 2017-2021 NV Access Limited
# Copyright (C) 2017-2025 NV Access Limited, Cary-rowen
# This file is covered by the GNU General Public License.
# See the file COPYING for more details.

Expand Down Expand Up @@ -91,6 +91,10 @@ def _get_allowAutoRefresh(cls) -> bool:
def _get_autoRefreshInterval(cls) -> int:
return config.conf["uwpOcr"]["autoRefreshInterval"]

@classmethod
def _get_autoSayAllOnResult(cls) -> bool:
return config.conf["uwpOcr"]["autoSayAllOnResult"]

def getResizeFactor(self, width, height):
# UWP OCR performs poorly with small images, so increase their size.
if width < 100 or height < 100:
Expand Down
9 changes: 9 additions & 0 deletions source/gui/settingsDialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3763,10 +3763,19 @@ def makeSettings(self, settingsSizer):
self.bindHelpEvent("Win10OcrSettingsAutoRefresh", self.autoRefreshCheckbox)
self.autoRefreshCheckbox.SetValue(config.conf["uwpOcr"]["autoRefresh"])

# Translators: The label for a setting in OCR settings to automatically say all on result.
autoSayAllText = _("Automatically say all on result")
self.autoSayAllOnResultCheckbox = sHelper.addItem(
wx.CheckBox(self, label=autoSayAllText),
)
self.bindHelpEvent("Win10OcrSettingsAutoSayAllOnResult", self.autoSayAllOnResultCheckbox)
self.autoSayAllOnResultCheckbox.SetValue(config.conf["uwpOcr"]["autoSayAllOnResult"])

def onSave(self):
lang = self.languageCodes[self.languageChoice.Selection]
config.conf["uwpOcr"]["language"] = lang
config.conf["uwpOcr"]["autoRefresh"] = self.autoRefreshCheckbox.IsChecked()
config.conf["uwpOcr"]["autoSayAllOnResult"] = self.autoSayAllOnResultCheckbox.IsChecked()


class AdvancedPanelControls(
Expand Down
1 change: 1 addition & 0 deletions user_docs/en/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ This can be enabled using the "Report when lists support multiple selection" set
An action has been added to view the full scan results on the VirusTotal website. (#18974)
* In the Add-on Store, a new action has been added to see the latest changes for the current version of add-ons. (#14041, @josephsl, @nvdaes)
* In browse mode, the number of items in a list is now reported in braille. (#7455, @nvdaes)
* Automatically reading the entire result after a successful recognition is now possible via a new option in the Windows OCR settings. (#19150, @Cary-rowen)

### Changes

Expand Down
5 changes: 5 additions & 0 deletions user_docs/en/userGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -3309,6 +3309,11 @@ This can be very useful when you want to monitor constantly changing content, su
The refresh takes place every one and a half seconds.
This option is disabled by default.

##### Automatically say all on result {#Win10OcrSettingsAutoSayAllOnResult}

This checkbox toggles the automatic reading of all recognized content after a recognition is complete.
This option is disabled by default.

#### Set Mirror Dialog {#SetURLDialog}

This dialog allows you to specify the URL of a mirror to use when [updating NVDA](#GeneralSettingsCheckForUpdates) or [using the Add-on Store](#AddonsManager).
Expand Down