Skip to content

Commit 0fa68d3

Browse files
committed
fix compatibility for NVDA 2021.1, currently in alpha version. Now speech commands and BooleanDriverSetting,NumericDriverSettingare properly imported.
merged all changes from CyrilleB79, @Mohamed00 and ultrasound1372 update buildVars.py to reflect the new version
1 parent 3908441 commit 0fa68d3

File tree

3 files changed

+39
-25
lines changed

3 files changed

+39
-25
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ addon/synthDrivers/ibmtts
77
*.mo
88
*.py[co]
99
*.nvda-addon
10+
*.code-workspace
11+
setup.cfg
1012
.sconsign.dblite

addon/synthDrivers/ibmeci.py

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,31 @@
33
# Author: David CM <dhf360@gmail.com> and others.
44
#synthDrivers/ibmeci.py
55

6-
import six, synthDriverHandler, speech, languageHandler, config, os, re
6+
import six, synthDriverHandler, languageHandler, config, os, re
7+
from synthDriverHandler import synthDoneSpeaking, SynthDriver, synthIndexReached, VoiceInfo
8+
79
from collections import OrderedDict
810
from six import string_types
9-
from synthDriverHandler import SynthDriver,VoiceInfo
1011
from logHandler import log
12+
1113
from synthDrivers import _ibmeci
12-
from synthDrivers._ibmeci import ECIVoiceParam
13-
from synthDrivers._ibmeci import isIBM
14+
from synthDrivers._ibmeci import ECIVoiceParam, isIBM
15+
16+
17+
# compatibility with nvda 2021.1 alpha versions.
18+
try:
19+
from speech.commands import BreakCommand, CharacterModeCommand, IndexCommand, LangChangeCommand, PitchCommand, RateCommand, VolumeCommand
20+
except ImportError:
21+
from speech import BreakCommand, CharacterModeCommand, IndexCommand, LangChangeCommand, PitchCommand, RateCommand, VolumeCommand
22+
23+
try:
24+
from autoSettingsUtils.driverSetting import BooleanDriverSetting,NumericDriverSetting
25+
except ImportError:
26+
from driverHandler import BooleanDriverSetting,NumericDriverSetting
27+
1428
import addonHandler
1529
addonHandler.initTranslation()
1630

17-
from driverHandler import BooleanDriverSetting,NumericDriverSetting
18-
from synthDriverHandler import synthIndexReached, synthDoneSpeaking
1931

2032
minRate=40
2133
maxRate=156
@@ -138,13 +150,13 @@ class SynthDriver(synthDriverHandler.SynthDriver):
138150
BooleanDriverSetting("shortpause", _("&Shorten pauses"), False),
139151
BooleanDriverSetting("sendParams", _("Always Send Current Speech Settings (enable to prevent some tags from sticking, disable for viavoice binary compatibility)"), False))
140152
supportedCommands = {
141-
speech.IndexCommand,
142-
speech.CharacterModeCommand,
143-
speech.LangChangeCommand,
144-
speech.BreakCommand,
145-
speech.PitchCommand,
146-
speech.RateCommand,
147-
speech.VolumeCommand
153+
IndexCommand,
154+
CharacterModeCommand,
155+
LangChangeCommand,
156+
BreakCommand,
157+
PitchCommand,
158+
RateCommand,
159+
VolumeCommand
148160
}
149161
supportedNotifications = {synthIndexReached, synthDoneSpeaking}
150162

@@ -168,9 +180,9 @@ def __init__(self):
168180
self.currentEncoding = "mbcs"
169181

170182
PROSODY_ATTRS = {
171-
speech.PitchCommand: ECIVoiceParam.eciPitchBaseline,
172-
speech.VolumeCommand: ECIVoiceParam.eciVolume,
173-
speech.RateCommand: ECIVoiceParam.eciSpeed,
183+
PitchCommand: ECIVoiceParam.eciPitchBaseline,
184+
VolumeCommand: ECIVoiceParam.eciVolume,
185+
RateCommand: ECIVoiceParam.eciSpeed,
174186
}
175187

176188
def speak(self,speechSequence):
@@ -183,9 +195,9 @@ def speak(self,speechSequence):
183195
s = self.processText(item)
184196
outlist.append((_ibmeci.speak, (s,)))
185197
last = s
186-
elif isinstance(item,speech.IndexCommand):
198+
elif isinstance(item,IndexCommand):
187199
outlist.append((_ibmeci.index, (item.index,)))
188-
elif isinstance(item,speech.LangChangeCommand):
200+
elif isinstance(item,LangChangeCommand):
189201
l=None
190202
if item.lang in langsAnnotations: l = langsAnnotations[item.lang]
191203
elif item.lang and item.lang[0:2] in langsAnnotations: l = langsAnnotations[item.lang[0:2]]
@@ -197,11 +209,11 @@ def speak(self,speechSequence):
197209
else:
198210
outlist.append((_ibmeci.speak, (langsAnnotations[defaultLanguage],)))
199211
self.speakingLanguage = defaultLanguage
200-
elif isinstance(item,speech.CharacterModeCommand):
212+
elif isinstance(item,CharacterModeCommand):
201213
outlist.append((_ibmeci.speak, (b"`ts1" if item.state else b"`ts0",)))
202214
if item.state:
203215
charmode=True
204-
elif isinstance(item,speech.BreakCommand):
216+
elif isinstance(item,BreakCommand):
205217
# taken from eloquence_threshold (https://github.com/pumper42nickel/eloquence_threshold)
206218
# Eloquence doesn't respect delay time in milliseconds.
207219
# Therefore we need to adjust waiting time depending on current speech rate
@@ -232,7 +244,7 @@ def speak(self,speechSequence):
232244
outlist.append((_ibmeci.speak, (b' `p%d '%(pFactor),)))
233245
elif type(item) in self.PROSODY_ATTRS:
234246
val = max(0, min(item.newValue, 100))
235-
if type(item) == speech.RateCommand: val = self.percentToRate(val)
247+
if type(item) == RateCommand: val = self.percentToRate(val)
236248
outlist.append((_ibmeci.setProsodyParam, (self.PROSODY_ATTRS[type(item)], val)))
237249
else:
238250
log.error("Unknown speech: %s"%item)
@@ -443,4 +455,4 @@ def _onDoneSpeaking(self): synthDoneSpeaking.notify(synth=self)
443455
def resub(dct, s):
444456
for r in six.iterkeys(dct):
445457
s = r.sub(dct[r], s)
446-
return s
458+
return s

buildVars.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@
1919
# Translators: Long description to be shown for this add-on on add-on information from add-ons manager
2020
"addon_description" : _("""This is the IBMTTS synthesizer driver for NVDA."""),
2121
# version
22-
"addon_version" : "21.01-x0_personal",
22+
"addon_version" : "21.03a1",
2323
# Author(s)
2424
"addon_author" : u"David CM <dhf360@gmail.com>, x0 and others",
2525
# URL for the add-on documentation support
26-
"addon_url" : "https://github.com/ultrasound1372/NVDA-IBMTTS-Driver",
26+
"addon_url" : "https://github.com/davidacm/NVDA-IBMTTS-Driver",
2727
# Documentation file name
2828
"addon_docFileName" : "readme.html",
2929
# Minimum NVDA version supported (e.g. "2018.3.0")
3030
"addon_minimumNVDAVersion" : "2019.3.0",
3131
# Last NVDA version supported/tested (e.g. "2018.4.0", ideally more recent than minimum version)
32-
"addon_lastTestedNVDAVersion" : "2020.4.0",
32+
"addon_lastTestedNVDAVersion" : "2021.1.0",
3333
# Add-on update channel (default is stable or None)
3434
"addon_updateChannel" : None,
3535
}

0 commit comments

Comments
 (0)