Skip to content

Commit

Permalink
Attempt to fix another espeak bug that cuts off speech sometimes.
Browse files Browse the repository at this point in the history
The hack is to add a 1ms break before the close prosody tag.

Fixes #55
  • Loading branch information
NSoiffer committed Oct 31, 2023
1 parent 69a863f commit b5b6f60
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions addon/globalPlugins/MathCAT/MathCAT.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ def patched_speak(self, speechSequence: SpeechSequence): # noqa: C901
elif type(item) in self.PROSODY_ATTRS:
if prosody:
# Close previous prosody tag.
textList.append('<break time="1ms" />') # hack added for cutoff speech (github.com/NSoiffer/MathCATForPython/issues/55)
textList.append("</prosody>")
attr=self.PROSODY_ATTRS[type(item)]
if item.multiplier==1:
Expand Down Expand Up @@ -486,6 +487,7 @@ def patched_speak(self, speechSequence: SpeechSequence): # noqa: C901
text=u"".join(textList)
# Added saving old rate and then resetting to that -- work around for https://github.com/nvaccess/nvda/issues/15221
# I'm not clear why this works since _set_rate() is called before the speech is finished speaking
oldRate = getSynth()._get_rate()
synth = getSynth()
oldRate = synth._get_rate()
_espeak.speak(text)
getSynth()._set_rate(oldRate)
synth._set_rate(oldRate)

0 comments on commit b5b6f60

Please sign in to comment.