Skip to content

Commit

Permalink
make sayAll initialise with speech
Browse files Browse the repository at this point in the history
  • Loading branch information
seanbudd committed May 17, 2021
1 parent 73ad387 commit eb8d626
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
8 changes: 0 additions & 8 deletions source/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,14 +351,6 @@ def main():
import speech
log.debug("Initializing speech")
speech.initialize()
from speech import sayAll
log.debug("Initializing sayAllHandler")
sayAll.initialize(
speech.speak,
speech.speakObject,
speech.getTextInfoSpeech,
speech.SpeakTextInfoState,
)
if not globalVars.appArgs.minimal and (time.time()-globalVars.startTime)>5:
log.debugWarning("Slow starting core (%.2f sec)" % (time.time()-globalVars.startTime))
# Translators: This is spoken when NVDA is starting.
Expand Down
14 changes: 8 additions & 6 deletions source/documentBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
from baseObject import AutoPropertyObject, ScriptableObject
import config
import textInfos
import speech
import ui
import controlTypes


class TextContainerObject(AutoPropertyObject):
"""
An object that contains text which can be accessed via a call to a makeTextInfo method.
Expand Down Expand Up @@ -140,10 +139,11 @@ def _getNearestTableCell(self, tableID, startPos, origRow, origCol, origRowSpan,
raise LookupError

def _tableMovementScriptHelper(self, movement="next", axis=None):
# documentBase shouldn't depend on scriptHandler
# documentBase is a core module and should not depend on UI classes
# this function should be somewhere else or dependency injected
# documentBase is a core module and should not depend on these UI modules. (#12404)
from scriptHandler import isScriptWaiting
from speech import speakTextInfo
import ui

if isScriptWaiting():
return
formatConfig=config.conf["documentFormatting"].copy()
Expand All @@ -165,7 +165,7 @@ def _tableMovementScriptHelper(self, movement="next", axis=None):
# Retrieve the cell on which we started.
info = self._getTableCellAt(tableID, self.selection,origRow, origCol)

speech.speakTextInfo(info, formatConfig=formatConfig, reason=controlTypes.OutputReason.CARET)
speakTextInfo(info, formatConfig=formatConfig, reason=controlTypes.OutputReason.CARET)
info.collapse()
self.selection = info

Expand All @@ -190,6 +190,8 @@ def script_previousColumn(self, gesture):
script_previousColumn.__doc__ = _("moves to the previous table column")

def script_toggleIncludeLayoutTables(self,gesture):
# documentBase is a core module and should not depend on UI modules. (#12404)
import ui
if config.conf["documentFormatting"]["includeLayoutTables"]:
# Translators: The message announced when toggling the include layout tables browse mode setting.
state = _("layout tables off")
Expand Down
11 changes: 10 additions & 1 deletion source/speech/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,22 @@
import synthDriverHandler
import config
from .speech import initialize as speechInitialize
from .sayAll import initialize as sayAllInitialize


def initialize():
"""Loads and sets the synth driver configured in nvda.ini."""
""" Loads and sets the synth driver configured in nvda.ini.
Initializes the state of speech and initializes the sayAllHandler
"""
synthDriverHandler.initialize()
synthDriverHandler.setSynth(config.conf["speech"]["synth"])
speechInitialize()
sayAllInitialize(
speak,
speakObject,
getTextInfoSpeech,
SpeakTextInfoState,
)


def terminate():
Expand Down
1 change: 1 addition & 0 deletions source/speech/sayAll.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def initialize(
getTextInfoSpeech: 'getTextInfoSpeech',
SpeakTextInfoState: 'SpeakTextInfoState',
):
log.debug("Initializing sayAllHandler")
global SayAllHandler
SayAllHandler = _SayAllHandler(
SpeechWithoutPauses(speakFunc=speakFunc),
Expand Down

0 comments on commit eb8d626

Please sign in to comment.