Skip to content

Commit dd712fe

Browse files
Replaced the boolean shorten pauses setting with an expanded setting that allows to shorten no pauses, pauses at utterance boundaries, or all punctuated pauses. (#101)
To implement this, the shortPause driver setting has been replaced with a choice setting called pauseMode, using logic based on that used for sample rate selection. This introduces a third pause mode, herein called utterance boundary, that will only reduce the pause at the end of a speech sequence. This has the value 1. The value 2 corresponds to the previous shorten pauses setting set to true, causing the utterance boundary to be shortened as well as the pause-related regular expressions to be applied. This does not presently load the previous shorten pauses setting and adapt to this new scheme, and the string for the utterance mode could likely do with some revision.
1 parent b37190d commit dd712fe

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

addon/synthDrivers/ibmeci.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ class SynthDriver(synthDriverHandler.SynthDriver):
209209
BooleanDriverSetting("backquoteVoiceTags", _("Enable backquote voice &tags"), False),
210210
BooleanDriverSetting("ABRDICT", _("Enable &abbreviation expansion"), False),
211211
BooleanDriverSetting("phrasePrediction", _("Enable phras&e prediction"), False),
212-
BooleanDriverSetting("shortPause", _("&Shorten pauses"), False, defaultVal=True),
212+
DriverSetting("pauseMode", _("&Pause Mode"), defaultVal="2"),
213213
BooleanDriverSetting("sendParams", _("Al&ways Send Current Speech Settings"), False, defaultVal=True),
214214
DriverSetting('sampleRate', _("Sa&mple Rate"), defaultVal='1'),
215215
)
@@ -242,6 +242,7 @@ def __init__(self):
242242
self.speakingLanguage=lang
243243
self.variant="1"
244244
self.currentEncoding = "mbcs"
245+
self._pause_mode=2
245246
self.sampleRate = '1'
246247

247248
PROSODY_ATTRS = {
@@ -329,7 +330,7 @@ def speak(self,speechSequence):
329330
if last and last[-1] not in punctuation:
330331
# check if a pitch command is at the end of the list, because p1 need to be send before this.
331332
# index -2 is because -1 always seem to be an index command.
332-
if self._shortPause:
333+
if self._pause_mode >= 1:
333334
if outlist[-2][0] == _ibmeci.setProsodyParam: outlist.insert(-2, (_ibmeci.speak, (b'`p1 ',)))
334335
else: outlist.append((_ibmeci.speak, (b'`p1 ',)))
335336
if charmode:
@@ -385,7 +386,7 @@ def processText(self,text):
385386
text = resub(german_fixes, text)
386387
if not self._backquoteVoiceTags:
387388
text=text.replace(b'`', b' ') # no embedded commands
388-
if self._shortPause:
389+
if self._pause_mode == 2:
389390
if _ibmeci.isIBM:
390391
text = ibm_pause_re.sub(br'\1 `p1\2\3\4', text) # this enforces short, JAWS-like pauses.
391392
else:
@@ -403,7 +404,7 @@ def terminate(self):
403404
_backquoteVoiceTags=False
404405
_ABRDICT=False
405406
_phrasePrediction=False
406-
_shortPause=True
407+
_pause_mode=2
407408
_sendParams=True
408409
def _get_backquoteVoiceTags(self):
409410
return self._backquoteVoiceTags
@@ -424,12 +425,6 @@ def _set_phrasePrediction(self, enable):
424425
if enable == self._phrasePrediction:
425426
return
426427
self._phrasePrediction = enable
427-
def _get_shortPause(self):
428-
return self._shortPause
429-
def _set_shortPause(self, enable):
430-
if enable == self._shortPause:
431-
return
432-
self._shortPause = enable
433428
def _get_sendParams(self):
434429
return self._sendParams
435430
def _set_sendParams(self, enable):
@@ -551,6 +546,22 @@ def _set_sampleRate(self, val):
551546
def _get_sampleRate(self):
552547
return str(self._sample_rate)
553548

549+
_pausemodes={
550+
"0": StringParameterInfo("0", "Do not shorten pauses"),
551+
"1": StringParameterInfo("1", "Shorten pauses at text boundaries (E.G. a list control and its value)"),
552+
"2": StringParameterInfo("2", "Shorten all pauses (including punctuation) similar to JAWS For Windows")
553+
}
554+
555+
def _get_availablePausemodes(self):
556+
return self._pausemodes
557+
558+
def _set_pauseMode(self, val):
559+
val = int(val)
560+
self._pause_mode = val
561+
562+
def _get_pauseMode(self):
563+
return str(self._pause_mode)
564+
554565
def _get_lastIndex(self):
555566
#fix?
556567
return _ibmeci.lastindex

0 commit comments

Comments
 (0)