Skip to content

Commit

Permalink
Review action #11856 (comment)
Browse files Browse the repository at this point in the history
 * New configuration setting:
     Speech > Speak all punctuations and symbols when reviewing by word
     `config.conf["speech"]["symbolLevelWord"]`
 * New constant: characterProcessing.SYMLVL_UNCHANGED = -1
  • Loading branch information
JulienCochuyt committed Dec 13, 2020
1 parent cbbbacc commit 2614f46
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 11 deletions.
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
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
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"),
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)

# 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
8 changes: 6 additions & 2 deletions source/speech/__init__.py
Expand Up @@ -1084,9 +1084,13 @@ def speakTextInfo(
return _speakWithoutPauses.speakWithoutPauses(flatSpeechGen)

speechGen = GeneratorWithReturn(speechGen)
# Force symbol level to all when moving by characters or words (#11779)
if unit in (textInfos.UNIT_CHARACTER, textInfos.UNIT_WORD):
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:
Expand Down

0 comments on commit 2614f46

Please sign in to comment.