Skip to content

Commit 793925e

Browse files
committed
Fixed #51.
I split out the rate from the pitch in the monkey-patch and that seems to stop the internal slowdown of speech for capital letters. The problem is in the espeak code, perhaps in espeak itself.
1 parent b89280a commit 793925e

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

addon/globalPlugins/MathCAT/MathCAT.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ def ConvertSSMLTextForNVDA(text: str) -> list:
153153
out.append(LangChangeCommand(language))
154154

155155
resetProsody = []
156+
# log.info(f"\ntext: {text}")
156157
for m in RE_MATHML_SPEECH.finditer(text):
157158
if m.lastgroup == "break":
158159
if use_break:
@@ -306,7 +307,7 @@ def script_navigate(self, gesture: KeyboardInputGesture):
306307
# update the braille to reflect the nav position (might be excess code, but it works)
307308
nav_node = libmathcat.GetNavigationMathMLId()
308309
braille_chars = libmathcat.GetBraille(nav_node[0])
309-
log.info(f'braille display = {config.conf["braille"]["display"]}, braille_chars: {braille_chars}')
310+
# log.info(f'braille display = {config.conf["braille"]["display"]}, braille_chars: {braille_chars}')
310311
region = braille.Region()
311312
region.rawText = braille_chars
312313
region.focusToHardLeft = True
@@ -546,7 +547,7 @@ def _monkeyPatchESpeak():
546547

547548

548549
def patched_speak(self, speechSequence: SpeechSequence): # noqa: C901
549-
# log.info(f"patched_speak input: {speechSequence}")
550+
# log.info(f"\npatched_speak input: {speechSequence}")
550551
textList: List[str] = []
551552
langChanged = False
552553
prosody: Dict[str, int] = {}
@@ -566,6 +567,11 @@ def patched_speak(self, speechSequence: SpeechSequence): # noqa: C901
566567
langChanged = True
567568
elif isinstance(item, BreakCommand):
568569
textList.append(f'<break time="{item.time}ms" />')
570+
elif isinstance(item, RateCommand):
571+
if item.multiplier == 1:
572+
textList.append('<prosody/>')
573+
else:
574+
textList.append(f"<prosody rate={int(item.multiplier * 100)}%>")
569575
elif type(item) in self.PROSODY_ATTRS:
570576
if prosody:
571577
# Close previous prosody tag.
@@ -605,7 +611,7 @@ def patched_speak(self, speechSequence: SpeechSequence): # noqa: C901
605611
if prosody:
606612
textList.append("</prosody>")
607613
text = "".join(textList)
608-
# log.info(f"\ntext={text}")
614+
# log.info(f"monkey-patched text={text}")
609615
# Added saving old rate and then resetting to that -- work around for https://github.com/nvaccess/nvda/issues/15221
610616
# I'm not clear why this works since _set_rate() is called before the speech is finished speaking
611617
synth = getSynth()

0 commit comments

Comments
 (0)