Skip to content

Commit 1651803

Browse files
committed
Add PauseFactor control
1 parent c18845e commit 1651803

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ def set_ui_values(self):
9898
#set the rest of the UI elements
9999
self.m_choiceSpeechAmount.SetSelection(Speech_Verbosity.index(user_preferences["Speech"]["Verbosity"]))
100100
self.m_sliderRelativeSpeed.SetValue(user_preferences["Speech"]["MathRate"])
101+
self.m_sliderPauseFactor.SetValue(user_preferences["Speech"]["PauseFactor"])
101102
self.m_checkBoxSpeechSound.SetValue(user_preferences["Speech"]["SpeechSound"] == "Beep")
102103
self.m_choiceSpeechForChemical.SetSelection(Speech_Chemistry.index(user_preferences["Speech"]["Chemistry"]))
103104
self.m_choiceNavigationMode.SetSelection(Navigation_NavMode.index(user_preferences["Navigation"]["NavMode"]))
@@ -122,6 +123,7 @@ def get_ui_values(self):
122123
user_preferences["Speech"]["SpeechStyle"] = self.m_choiceSpeechStyle.GetStringSelection()
123124
user_preferences["Speech"]["Verbosity"] = Speech_Verbosity[self.m_choiceSpeechAmount.GetSelection()]
124125
user_preferences["Speech"]["MathRate"] = self.m_sliderRelativeSpeed.GetValue()
126+
user_preferences["Speech"]["PauseFactor"] = self.m_sliderPauseFactor.GetValue()
125127
if self.m_checkBoxSpeechSound.GetValue():
126128
user_preferences["Speech"]["SpeechSound"] = "Beep"
127129
else:
@@ -201,6 +203,8 @@ def validate_user_preferences():
201203
UserInterface.validate("Speech", "Verbosity", ["Terse", "Medium", "Verbose"], "Medium")
202204
# MathRate: 100 # Change from text speech rate (%)
203205
UserInterface.validate("Speech", "MathRate", [0,200], 100)
206+
# PauseFactor: 100 # TBC
207+
UserInterface.validate("Speech", "PauseFactor", [0,400], 100)
204208
# SpeechSound: None # make a sound when starting/ending math speech -- None, Beep
205209
UserInterface.validate("Speech", "SpeechSound", ["None", "Beep"], "None")
206210
# SpeechStyle: ClearSpeak # Any known speech style (falls back to ClearSpeak)
@@ -243,6 +247,13 @@ def OnRelativeSpeedChanged( self, event ):
243247
text = _(u"<prosody rate='XXX%'>the square root of x squared plus y squared</prosody>").replace("XXX", str(rate), 1)
244248
speak( ConvertSSMLTextForNVDA(text) )
245249

250+
def OnPauseFactorChanged( self, event ):
251+
from .MathCAT import ConvertSSMLTextForNVDA
252+
from speech import speak
253+
pausefactor = self.m_sliderPauseFactor.GetValue()
254+
text = _(f"the fraction with numerator <break time='{300*pausefactor//100}ms'/> <mark name='M63i335o-4'/> <say-as interpret-as='characters'>x</say-as> to the <mark name='M63i335o-5'/> <say-as interpret-as='characters'>n</say-as> <phoneme alphabet='ipa' ph='θ'>-th</phoneme> power <break time='{128*pausefactor//100}ms'/> <mark name='M63i335o-6'/> plus <mark name='M63i335o-7'/> 1 <break time='{300*pausefactor//100}ms'/> and denominator <mark name='M63i335o-10'/> <say-as interpret-as='characters'>x</say-as> to the <mark name='M63i335o-11'/> <say-as interpret-as='characters'>n</say-as> <phoneme alphabet='ipa' ph='θ'>-th</phoneme> power <break time='{128*pausefactor//100}ms'/> <mark name='M63i335o-12'/> minus <mark name='M63i335o-13'/> 1 <break time='{600*pausefactor//100}ms'/>end fraction <break time='{150*pausefactor//100}ms'/>")
255+
speak( ConvertSSMLTextForNVDA(text) )
256+
246257
def OnClickOK(self,event):
247258
UserInterface.get_ui_values(self)
248259
UserInterface.write_user_preferences()

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,19 @@ def __init__( self, parent ):
129129

130130
bSizer121.Add( bSizer7131, 1, wx.EXPAND, 5 )
131131

132+
bSizerPauseFactor = wx.BoxSizer( wx.HORIZONTAL )
133+
134+
self.m_staticPauseFactor = wx.StaticText( self.m_panelSpeech, wx.ID_ANY, _(u"Pause factor:"), wx.DefaultPosition, wx.DefaultSize, 0 )
135+
self.m_staticPauseFactor.Wrap( -1 )
136+
137+
bSizerPauseFactor.Add( self.m_staticPauseFactor, 0, wx.ALL, 5 )
138+
139+
self.m_sliderPauseFactor = wx.Slider( self.m_panelSpeech, wx.ID_ANY, 100, 0, 400, wx.DefaultPosition, wx.DefaultSize, wx.SL_HORIZONTAL )
140+
bSizerPauseFactor.Add( self.m_sliderPauseFactor, 0, wx.ALL, 5 )
141+
142+
143+
bSizer121.Add( bSizerPauseFactor, 1, wx.EXPAND, 5 )
144+
132145
bSizer7121 = wx.BoxSizer( wx.HORIZONTAL )
133146

134147
self.m_checkBoxSpeechSound = wx.CheckBox( self.m_panelSpeech, wx.ID_ANY, _(u"Make a sound when starting/ending math speech"), wx.DefaultPosition, wx.DefaultSize, 0 )
@@ -329,6 +342,7 @@ def __init__( self, parent ):
329342
self.m_listBoxPreferencesTopic.Bind( wx.EVT_LISTBOX, self.OnListBoxCategories )
330343
self.m_choiceLanguage.Bind( wx.EVT_CHOICE, self.OnLanguage )
331344
self.m_sliderRelativeSpeed.Bind( wx.EVT_SCROLL_CHANGED, self.OnRelativeSpeedChanged )
345+
self.m_sliderPauseFactor.Bind( wx.EVT_SCROLL_CHANGED, self.OnPauseFactorChanged )
332346
self.m_buttonOK.Bind( wx.EVT_BUTTON, self.OnClickOK )
333347
self.m_buttonCancel.Bind( wx.EVT_BUTTON, self.OnClickCancel )
334348
self.m_buttonApply.Bind( wx.EVT_BUTTON, self.OnClickApply )
@@ -355,6 +369,9 @@ def OnLanguage( self, event ):
355369
def OnRelativeSpeedChanged( self, event ):
356370
event.Skip()
357371

372+
def OnPauseFactorChanged( self, event ):
373+
event.Skip()
374+
358375
def OnClickOK( self, event ):
359376
event.Skip()
360377

0 commit comments

Comments
 (0)