6666def ConvertSSMLTextForNVDA (text :str , language :str = "" ):
6767 # MathCAT's default rate is 180 wpm.
6868 # Assume that 0% is 80 wpm and 100% is 450 wpm and scale accordingly.
69- # log.info("Speech str: '{}'".format(text))
69+ log .info ("Speech str: '{}'" .format (text ))
7070 synth = getSynth ()
7171 wpm = synth ._percentToParam (synth .rate , 80 , 450 )
7272 breakMulti = 180.0 / wpm
7373 synthConfig = config .conf ["speech" ][synth .name ]
7474 supported_commands = synth .supportedCommands
7575 use_break = BreakCommand in supported_commands
7676 use_pitch = PitchCommand in supported_commands
77+ use_rate = RateCommand in supported_commands
78+ use_volume = VolumeCommand in supported_commands
7779 use_phoneme = PhonemeCommand in supported_commands
7880 use_character = CharacterModeCommand in supported_commands
7981 out = []
8082 if language :
8183 out .append (LangChangeCommand (language ))
82- resetProsody = set ()
84+ resetProsody = []
8385 for m in RE_MP_SPEECH .finditer (text ):
8486 if m .lastgroup == "break" :
8587 if use_break :
@@ -95,16 +97,16 @@ def ConvertSSMLTextForNVDA(text:str, language:str=""):
9597 elif m .lastgroup == "pitch" :
9698 if use_pitch :
9799 out .append (PitchCommand (multiplier = int (m .group (m .lastgroup ))))
98- resetProsody .add (PitchCommand )
100+ resetProsody .append (PitchCommand )
99101 elif m .lastgroup in PROSODY_COMMANDS :
100102 command = PROSODY_COMMANDS [m .lastgroup ]
101103 if command in supported_commands :
102104 out .append (command (multiplier = int (m .group (m .lastgroup )) / 100.0 ))
103- resetProsody .add (command )
105+ resetProsody .append (command )
104106 elif m .lastgroup == "prosodyReset" :
105- for command in resetProsody : # only supported commands were added, so no need to check
106- out . append ( command ( multiplier = 1 ) )
107- resetProsody . clear ( )
107+ # for command in resetProsody: # only supported commands were added, so no need to check
108+ command = resetProsody . pop ( )
109+ out . append ( command ( multiplier = 1 ) )
108110 elif m .lastgroup == "phonemeText" :
109111 if use_phoneme :
110112 out .append (PhonemeCommand (m .group ("ipa" ), text = m .group ("phonemeText" )))
@@ -116,7 +118,7 @@ def ConvertSSMLTextForNVDA(text:str, language:str=""):
116118 out .extend ((" " , m .group (0 ), " " ))
117119 if language :
118120 out .append (LangChangeCommand (None ))
119- # log.info("Speech commands: '{}'".format(out))
121+ log .info ("Speech commands: '{}'" .format (out ))
120122 return out
121123
122124class MathCATInteraction (mathPres .MathInteractionNVDAObject ):
0 commit comments