Skip to content

Commit d8d5ecb

Browse files
authored
Merge c6d2bdb into 74a1998
2 parents 74a1998 + c6d2bdb commit d8d5ecb

4 files changed

Lines changed: 20 additions & 4 deletions

File tree

projectDocs/dev/developerGuide/developerGuide.t2t

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,7 @@ For examples of how to define and use new extension points, please see the code
10411041
++ speech ++[speechExtPts]
10421042
|| Type | Extension Point | Description |
10431043
| ``Action`` | ``speechCanceled`` | Triggered when speech is canceled. |
1044+
| ``Action`` | ``speechSequencePreFilter`` | Triggered when new speech sequence appears. |
10441045
| ``Filter`` | ``filter_speechSequence`` | Allows components or add-ons to filter speech sequence before it passes to the Synth driver. |
10451046

10461047
++ synthDriverHandler ++[synthDriverHandlerExtPts]

source/speech/extensions.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,20 @@
1616
Handlers are called without arguments.
1717
"""
1818

19+
post_filter_speechSequence = Action()
20+
"""
21+
Notifies when requested speech has been filtered and is ready to be passed onto the synthesizer.
22+
23+
:param value: a planned speech sequence.
24+
:type value: SpeechSequence
25+
What NVDA would speak with speech turned on and uninterrupted.
26+
A speech sequence that has been requested somewhere in NVDA,
27+
and is finished being processed or modified by external modules such as add-ons.
28+
Prepared speech may be cancelled or processed further to prepare it for the synthesizer.
29+
This extension point is useful for tracking prepared speech in NVDA.
30+
i.e. for speech viewer, capturing speech history, or mirroring speech in braille.
31+
"""
32+
1933
filter_speechSequence = Filter[SpeechSequence]()
2034
"""
2135
Filters speech sequence before it passes to synthDriver.

source/speech/speech.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import characterProcessing
2626
import languageHandler
2727
from . import manager
28-
from .extensions import filter_speechSequence, speechCanceled
28+
from .extensions import filter_speechSequence, speechCanceled, speechSequencePreFilter
2929
from .commands import (
3030
# Commands that are used in this file.
3131
BreakCommand,
@@ -960,16 +960,14 @@ def speak( # noqa: C901
960960
@param symbolLevel: The symbol verbosity level; C{None} (default) to use the user's configuration.
961961
@param priority: The speech priority.
962962
"""
963+
speechSequencePreFilter.notify(sequence=speechSequence)
963964
speechSequence = filter_speechSequence.apply(speechSequence)
964965
logBadSequenceTypes(speechSequence)
965966
# in case priority was explicitly passed in as None, set to default.
966967
priority: Spri = Spri.NORMAL if priority is None else priority
967968

968969
if not speechSequence: # Pointless - nothing to speak
969970
return
970-
import speechViewer
971-
if speechViewer.isActive:
972-
speechViewer.appendSpeechSequence(speechSequence)
973971
if _speechState.speechMode == SpeechMode.off:
974972
return
975973
elif _speechState.speechMode == SpeechMode.beeps:

source/speechViewer.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import config
1313
from logHandler import log
1414
from speech import SpeechSequence
15+
from speech.extensions import speechSequencePreFilter
1516
from gui import blockAction
1617
import gui.contextHelp
1718
from utils.security import isLockScreenModeActive, post_sessionLockStateChanged
@@ -47,6 +48,7 @@ def __init__(self, onDestroyCallBack: Callable[[], None]):
4748
style=wx.CAPTION | wx.CLOSE_BOX | wx.RESIZE_BORDER | wx.STAY_ON_TOP
4849
)
4950
post_sessionLockStateChanged.register(self.onSessionLockStateChange)
51+
speechSequencePreFilter.register(appendSpeechSequence)
5052
self._isDestroyed = False
5153
self.onDestroyCallBack = onDestroyCallBack
5254
self.Bind(wx.EVT_CLOSE, self.onClose)
@@ -128,6 +130,7 @@ def onShouldShowOnStartupChanged(self, evt: wx.CommandEvent):
128130
def onDestroy(self, evt: wx.Event):
129131
self._isDestroyed = True
130132
post_sessionLockStateChanged.unregister(self.onSessionLockStateChange)
133+
speechSequencePreFilter.unregister(appendSpeechSequence)
131134
log.debug("SpeechViewer destroyed")
132135
self.onDestroyCallBack()
133136
evt.Skip()

0 commit comments

Comments
 (0)