Skip to content

Commit 4c0fa93

Browse files
committed
Fix #29 -- makes use of the NVDA settings for pitch change, "cap" and beep.
Fix a bug where text is munged together and the spaces that MathCAT added are seemingly ignored. They are separately generated in the command list sent to the speech engine.
1 parent a1feed9 commit 4c0fa93

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

NVDA-addon/addon/globalPlugins/MathCAT/MathCAT.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from os import path # set rule dir path
1818
import re # regexp patter match
1919
import speech # speech commands
20+
import config # look up caps setting
2021
import ui # copy message
2122
from scriptHandler import script # copy MathML via ctrl-c
2223
from synthDriverHandler import getSynth # speech engine param setting
@@ -27,6 +28,7 @@
2728

2829
# speech/SSML processing borrowed from NVDA's mathPres/mathPlayer.py
2930
from speech.commands import (
31+
BeepCommand,
3032
PitchCommand,
3133
VolumeCommand,
3234
RateCommand,
@@ -65,6 +67,7 @@ def ConvertSSMLTextForNVDA(text, language=""):
6567
synth = getSynth()
6668
wpm = synth._percentToParam(synth.rate, 80, 450)
6769
breakMulti = 180.0 / wpm
70+
synthConfig = config.conf["speech"][synth.name]
6871
out = []
6972
if language:
7073
out.append(LangChangeCommand(language))
@@ -73,7 +76,17 @@ def ConvertSSMLTextForNVDA(text, language=""):
7376
if m.lastgroup == "break":
7477
out.append(BreakCommand(time=int(m.group("break")) * breakMulti))
7578
elif m.lastgroup == "char":
76-
out.extend((CharacterModeCommand(True), m.group("char"), CharacterModeCommand(False)))
79+
# get the NVDA settings for what to do for a capital char and apply them
80+
ch = m.group("char")
81+
if ch.isupper():
82+
if synthConfig["sayCapForCapitals"]:
83+
out.append(_(u"cap")) # capital letter prefix
84+
out.append(PitchCommand(multiplier=int(synthConfig["capPitchChange"])))
85+
if synthConfig["beepForCapitals"]:
86+
out.append(BeepCommand(2000, 50))
87+
out.extend((CharacterModeCommand(True), ch, CharacterModeCommand(False)))
88+
if ch.isupper():
89+
out.append(PitchCommand(multiplier=1))
7790
elif m.lastgroup == "comma":
7891
out.append(BreakCommand(time=100))
7992
elif m.lastgroup in PROSODY_COMMANDS:
@@ -87,10 +100,11 @@ def ConvertSSMLTextForNVDA(text, language=""):
87100
elif m.lastgroup == "phonemeText":
88101
out.append(PhonemeCommand(m.group("ipa"), text=m.group("phonemeText")))
89102
elif m.lastgroup == "content":
90-
# MathCAT puts out spaces between words, but the previous pattern might eat it, so we put it back if needed
91-
if not(m.group(0).startswith(" ")):
92-
out.append(" ")
103+
# MathCAT puts out spaces between words, the speak command seems to want to glom the strings together at times,
104+
# so we need to add individual " "s to the output
105+
out.append(" ")
93106
out.append(m.group(0))
107+
out.append(" ")
94108

95109
if language:
96110
out.append(LangChangeCommand(None))

0 commit comments

Comments
 (0)