Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speak all symbols when moving by words (#11779) #11856

Merged
merged 33 commits into from Jul 7, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
86592b0
Speak all symbols when moving by words (#11779)
JulienCochuyt Nov 23, 2020
cbbbacc
Merge branch 'master' into i11779-moveByWordSymbolLevel
JulienCochuyt Dec 13, 2020
2614f46
Review action https://github.com/nvaccess/nvda/pull/11856#issuecommen…
JulienCochuyt Dec 13, 2020
56d97fe
Add an unassigned global command to toggle symbolLevelWord
JulienCochuyt Dec 14, 2020
db91a19
Add missing translators comment
JulienCochuyt Dec 14, 2020
14f12ca
Merge branch 'master' into i11779-moveByWordSymbolLevel
JulienCochuyt Dec 16, 2020
7f18e8d
User Guide: SpeechSettingsSymbolLevelWord
JulienCochuyt Dec 16, 2020
b92b18a
Merge remote-tracking branch 'upstream/master' into i11779-moveByWord…
JulienCochuyt Apr 23, 2021
300e174
Merge remote-tracking branch 'upstream/master' into i11779-moveByWord…
JulienCochuyt May 7, 2021
46e8163
Merge remote-tracking branch 'upstream/master' into i11779-moveByWord…
JulienCochuyt May 19, 2021
f4b99b4
Review action https://github.com/nvaccess/nvda/pull/11856#discussion_…
JulienCochuyt May 24, 2021
30cbe69
Review action https://github.com/nvaccess/nvda/pull/11856#discussion_…
JulienCochuyt May 24, 2021
9bc1df2
Review action https://github.com/nvaccess/nvda/pull/11856#discussion_…
JulienCochuyt May 24, 2021
06cf4df
Review action https://github.com/nvaccess/nvda/pull/11856#discussion_…
JulienCochuyt May 24, 2021
576ce99
Review action https://github.com/nvaccess/nvda/pull/11856#discussion_…
JulienCochuyt May 24, 2021
bb53010
Merge remote-tracking branch 'upstream/master' into i11779-moveByWord…
JulienCochuyt May 24, 2021
698f5b7
Merge branch 'master' into i11779-moveByWordSymbolLevel
seanbudd Jun 7, 2021
d89a533
add notepad system tests for symbol level word
seanbudd Jun 7, 2021
304d940
unbreak sentence in userguide for translators
seanbudd Jun 7, 2021
2f61ca6
convert symlvl to intenum
seanbudd Jun 7, 2021
5cc726b
update changes
seanbudd Jun 7, 2021
1709685
update changes
seanbudd Jun 7, 2021
e58f0e2
Merge branch 'i11779-moveByWordSymbolLevel' of github.com:accessoluti…
seanbudd Jun 7, 2021
d4f18b8
undo speech chmod
seanbudd Jun 8, 2021
76dec02
fix typing
seanbudd Jun 8, 2021
d4ccb85
eliminate the tristate checkbox
seanbudd Jun 8, 2021
2853f5d
remove sanity check in tests
seanbudd Jun 8, 2021
5972e84
translation category
seanbudd Jun 8, 2021
9f03857
add translator comment
seanbudd Jun 9, 2021
a818141
Merge branch 'master' into i11779-moveByWordSymbolLevel
seanbudd Jun 15, 2021
c4a5ee9
Merge branch 'master' into i11779-moveByWordSymbolLevel
seanbudd Jul 7, 2021
2daaca2
fixup! Merge branch 'master' into i11779-moveByWordSymbolLevel
seanbudd Jul 7, 2021
cf1b1ed
change system tests
seanbudd Jul 7, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 6 additions & 5 deletions source/characterProcessing.py
@@ -1,8 +1,8 @@
#characterProcessing.py
#A part of NonVisual Desktop Access (NVDA)
#Copyright (C) 2010-2018 NV Access Limited, World Light Information Limited, Hong Kong Blind Union, Babbage B.V.
#This file is covered by the GNU General Public License.
#See the file COPYING for more details.
# A part of NonVisual Desktop Access (NVDA)
# Copyright (C) 2010-2020 NV Access Limited, World Light Information Limited,
# Hong Kong Blind Union, Babbage B.V., Julien Cochuyt
# This file is covered by the GNU General Public License.
# See the file COPYING for more details.

import time
import os
Expand Down Expand Up @@ -130,6 +130,7 @@ def getCharacterDescription(locale,character):
SYMLVL_MOST = 200
SYMLVL_ALL = 300
SYMLVL_CHAR = 1000
SYMLVL_UNCHANGED = -1
Copy link
Member

Choose a reason for hiding this comment

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

Can these values be turned into an IntEnum SYMLVL? Then set the old variables to maintain backwards compatibility with a note to deprecate in 2022.1. It would be good to change new code to use this enum but I don't think it's necessary to change the rest of the codebase until 2022.1.

eg

class SYMLVL(IntEnum):
    NONE = 0
    ...
    
SYMLVL_NONE = SYMLVL.NONE
...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Even if maintaining the old SYMLVL_* attributes, there would be discrepancies with CONFIGURABLE_SPEECH_SYMBOL_LEVELS, SPEECH_SYMBOL_LEVELS and SPEECH_SYMBOL_LEVEL_LABELS which would not anymore contain integers but enum members.
Would you still want me to proceed to this change anyway?
Would you please have an example of such a deprecation notice (to keep them coherent and easy to search for)?

Copy link
Member

@seanbudd seanbudd May 25, 2021

Choose a reason for hiding this comment

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

I don't think this would break any compatibility? IntEnum members behave the same as an int in most aspects, isinstance(SYMLVL.NONE, int) == True and SYMLVL.NONE == 0. We can move this to a new issue if there is risk involved / more research needed.

All that would be needed is something like:

class SYMLVL(IntEnum):
    NONE = 0
    ...
    
# The following SYMLVL_ constants are deprecated by #11779 but remain to maintain backwards compatibility.
# Remove these in 2022.1 and replace instances using them with the SYMLVL IntEnum.
SYMLVL_NONE = SYMLVL.NONE
...

Copy link
Member

Choose a reason for hiding this comment

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

I've changed this myself, pending a review from another NV Access developer.

SPEECH_SYMBOL_LEVEL_LABELS = {
# Translators: The level at which the given symbol will be spoken.
SYMLVL_NONE: pgettext("symbolLevel", "none"),
Expand Down
4 changes: 3 additions & 1 deletion source/config/configSpec.py
@@ -1,6 +1,6 @@
# -*- coding: UTF-8 -*-
# A part of NonVisual Desktop Access (NVDA)
# Copyright (C) 2006-2020 NV Access Limited, Babbage B.V., Davy Kager, Bill Dengler
# Copyright (C) 2006-2020 NV Access Limited, Babbage B.V., Davy Kager, Bill Dengler, Julien Cochuyt
# This file is covered by the GNU General Public License.
# See the file COPYING for more details.

Expand Down Expand Up @@ -31,6 +31,8 @@
# The synthesizer to use
synth = string(default=auto)
symbolLevel = integer(default=100)
# Symbol Level when reviewing by word (unchanged if -1)
symbolLevelWord = integer(default=300)
trustVoiceLanguage = boolean(default=true)
includeCLDR = boolean(default=True)
beepSpeechModePitch = integer(default=10000,min=50,max=11025)
Expand Down
21 changes: 21 additions & 0 deletions source/globalCommands.py
Expand Up @@ -781,6 +781,27 @@ def script_cycleSpeechSymbolLevel(self,gesture):
script_cycleSpeechSymbolLevel.__doc__=_("Cycles through speech symbol levels which determine what symbols are spoken")
script_cycleSpeechSymbolLevel.category=SCRCAT_SPEECH

@script(
# Translators: Input help mode message for a command.
description=_("Toggle the announce of all punctuations and symbols when reviewing by word"),
JulienCochuyt marked this conversation as resolved.
Show resolved Hide resolved
category=SCRCAT_SPEECH
)
def script_toggleSpeechSymbolLevelWordAll(self, gesture):
curLevel = config.conf["speech"]["symbolLevelWord"]
if curLevel == characterProcessing.SYMLVL_ALL:
level = characterProcessing.SYMLVL_UNCHANGED
reportedState = _("off")
seanbudd marked this conversation as resolved.
Show resolved Hide resolved
else:
level = characterProcessing.SYMLVL_ALL
reportedState = _("on")
config.conf["speech"]["symbolLevelWord"] = level
ui.message(
# Translators: Reported when toggling a speech setting
_("Speak all punctuations and symbols when reviewing by word: {state}").format(
JulienCochuyt marked this conversation as resolved.
Show resolved Hide resolved
state=reportedState
)
)

def script_moveMouseToNavigatorObject(self,gesture):
try:
p=api.getReviewPosition().pointAtStart
Expand Down
28 changes: 25 additions & 3 deletions source/gui/settingsDialogs.py
Expand Up @@ -2,7 +2,8 @@
# A part of NonVisual Desktop Access (NVDA)
# Copyright (C) 2006-2020 NV Access Limited, Peter Vágner, Aleksey Sadovoy,
# Rui Batista, Joseph Lee, Heiko Folkerts, Zahari Yurukov, Leonard de Ruijter,
# Derek Riemer, Babbage B.V., Davy Kager, Ethan Holliger, Bill Dengler, Thomas Stivers
# Derek Riemer, Babbage B.V., Davy Kager, Ethan Holliger, Bill Dengler, Thomas Stivers,
# Julien Cochuyt
# This file is covered by the GNU General Public License.
# See the file COPYING for more details.
import logging
Expand Down Expand Up @@ -1461,6 +1462,21 @@ def makeSettings(self, settingsSizer):
characterProcessing.CONFIGURABLE_SPEECH_SYMBOL_LEVELS.index(curLevel)
)

self.symbolLevelWord = settingsSizerHelper.addItem(
wx.CheckBox(
self,
# Translators: The label for a setting in the Speech category
label=_("Speak all punctuations and symbols when reviewing by &word"),
JulienCochuyt marked this conversation as resolved.
Show resolved Hide resolved
JulienCochuyt marked this conversation as resolved.
Show resolved Hide resolved
style=wx.CHK_3STATE
)
)
if config.conf["speech"]["symbolLevelWord"] == characterProcessing.SYMLVL_ALL:
self.symbolLevelWord.Set3StateValue(wx.CHK_CHECKED)
elif config.conf["speech"]["symbolLevelWord"] == characterProcessing.SYMLVL_UNCHANGED:
self.symbolLevelWord.Set3StateValue(wx.CHK_UNCHECKED)
else:
self.symbolLevelWord.Set3StateValue(wx.CHK_UNDETERMINED)

seanbudd marked this conversation as resolved.
Show resolved Hide resolved
# Translators: This is the label for a checkbox in the
# voice settings panel (if checked, text will be read using the voice for the language of the text).
trustVoiceLanguageText = _("Trust voice's language when processing characters and symbols")
Expand Down Expand Up @@ -1548,8 +1564,14 @@ def onSave(self):

config.conf["speech"]["autoLanguageSwitching"] = self.autoLanguageSwitchingCheckbox.IsChecked()
config.conf["speech"]["autoDialectSwitching"] = self.autoDialectSwitchingCheckbox.IsChecked()
config.conf["speech"]["symbolLevel"]=characterProcessing.CONFIGURABLE_SPEECH_SYMBOL_LEVELS[self.symbolLevelList.GetSelection()]
config.conf["speech"]["trustVoiceLanguage"]=self.trustVoiceLanguageCheckbox.IsChecked()
config.conf["speech"]["symbolLevel"] = characterProcessing.CONFIGURABLE_SPEECH_SYMBOL_LEVELS[
self.symbolLevelList.GetSelection()
]
if self.symbolLevelWord.Get3StateValue() == wx.CHK_CHECKED:
config.conf["speech"]["symbolLevelWord"] = characterProcessing.SYMLVL_ALL
elif self.symbolLevelWord.Get3StateValue() == wx.CHK_UNCHECKED:
config.conf["speech"]["symbolLevelWord"] = characterProcessing.SYMLVL_UNCHANGED
config.conf["speech"]["trustVoiceLanguage"] = self.trustVoiceLanguageCheckbox.IsChecked()
currentIncludeCLDR = config.conf["speech"]["includeCLDR"]
config.conf["speech"]["includeCLDR"] = newIncludeCldr = self.includeCLDRCheckbox.IsChecked()
if currentIncludeCLDR is not newIncludeCldr:
Expand Down
13 changes: 11 additions & 2 deletions source/speech/__init__.py
Expand Up @@ -1084,8 +1084,17 @@ def speakTextInfo(
return _speakWithoutPauses.speakWithoutPauses(flatSpeechGen)

speechGen = GeneratorWithReturn(speechGen)
symbolLevel = None
if unit == textInfos.UNIT_CHARACTER:
symbolLevel = characterProcessing.SYMLVL_ALL
elif unit == textInfos.UNIT_WORD:
symbolLevelWord = config.conf["speech"]["symbolLevelWord"]
if symbolLevelWord != characterProcessing.SYMLVL_UNCHANGED:
symbolLevel = symbolLevelWord
else:
symbolLevel = None
for seq in speechGen:
speak(seq, priority=priority)
speak(seq, symbolLevel=symbolLevel, priority=priority)
return speechGen.returnValue


Expand Down Expand Up @@ -1281,7 +1290,7 @@ def isControlEndFieldCommand(x):
if onlyInitialFields or (
isWordOrCharUnit
and len(textWithFields) > 0
and len(textWithFields[0].strip() if not textWithFields[0].isspace() else textWithFields[0]) == 1
and len(textWithFields[0]) == 1
and all(isControlEndFieldCommand(x) for x in itertools.islice(textWithFields, 1, None))
):
if not onlyCache:
Expand Down