NSoiffer / MathCATForPython

A Python Interface and NVDA plugin to MathCAT
MIT License
6 stars 6 forks source link

Spaces omitted from MathCAT output sent to NVDA #22

Closed jasonjgw closed 2 years ago

jasonjgw commented 2 years ago

Note: This may be a MathCAT issue, in which case we can transfer it to the MathCAT repository.

One of the causes of unintelligible spoken output in the MathCAT NVDA plug-in is that spaces are omitted in some instances. Given the expression:

    <math display="block">
      <mfrac><mrow>
    <mi>a</mi><mi>c</mi>
      </mrow>
      <mrow><mi>b</mi><mi>c</mi>
      </mrow>
      </mfrac>
    </math>

The NVDA output is as follows, omitting the space between "c" and "over":

IO - speech.speech.speak (08:56:20.904) - MainThread (13156): Speaking
[CharacterModeCommand(True), LangChangeCommand ('en_US'), 'a',
CharacterModeCommand(False), '  ', CharacterModeCommand(True), 'c',
CharacterModeCommand(False), 'over ', CharacterModeCommand(True), 'b',
CharacterModeCommand(False), '  ', CharacterModeCommand(True), 'c',
CharacterModeCommand(False)]

This is only an example. My testing suggests there are other, similar situations.

NSoiffer commented 2 years ago

The input to (the now renamed ConvertSSMLTextForNVDA): Input:

text: <prosody rate='109%'><say-as interpret-as='characters'>a</say-as>   
<say-as interpret-as='characters'>c</say-as> over <say-as interpret-as='characters'>b</say-as>   
<say-as interpret-as='characters'>c</say-as></prosody>

What NVDA see/speaks:

[RateCommand(multiplier=1.09), CharacterModeCommand(True), 'a', CharacterModeCommand(False), '  ', 
CharacterModeCommand(True), 'c', CharacterModeCommand(False), 'over ', CharacterModeCommand(True), 'b', 
CharacterModeCommand(False), '  ', CharacterModeCommand(True), 'c', CharacterModeCommand(False), RateCommand()]

So the MathCAT rules are ok, but the parsing into NVDA's format is dropping the whitespace. I think it will be an easy fix as it is likely a tweak to the regular expr.

NSoiffer commented 2 years ago

Turns out, this was NVDA-specific as the regular expression for breaking about SSML was grabbing some whitespace so in some cases, there was no space between words sent to the NVDA speech engine.