Changed how speech interruptions are handled hopefully improved things being interrupted when they shouldn't be.
This commit is contained in:
@@ -3470,7 +3470,7 @@ class Script(script.Script):
|
||||
return True
|
||||
|
||||
def presentMessage(self, fullMessage, briefMessage=None, voice=None, resetStyles=True,
|
||||
force=False, interrupt=True):
|
||||
force=False, interrupt=False):
|
||||
"""Convenience method to speak a message and 'flash' it in braille.
|
||||
|
||||
Arguments:
|
||||
@@ -3484,6 +3484,8 @@ class Script(script.Script):
|
||||
the briefMessage should set briefMessage to an empty string.
|
||||
- voice: The voice to use when speaking this message. By default, the
|
||||
"system" voice will be used.
|
||||
- interrupt: If True, any current speech should be interrupted
|
||||
prior to speaking the new text. The default queues the message.
|
||||
"""
|
||||
|
||||
if not fullMessage:
|
||||
@@ -3959,7 +3961,7 @@ class Script(script.Script):
|
||||
voice = self.speechGenerator.voice(string=character)
|
||||
speech.speakCharacter(character, voice)
|
||||
|
||||
def speakMessage(self, string, voice=None, interrupt=True, resetStyles=True, force=False):
|
||||
def speakMessage(self, string, voice=None, interrupt=False, resetStyles=True, force=False):
|
||||
"""Method to speak a single string. Scripts should use this
|
||||
method rather than calling speech.speak directly.
|
||||
|
||||
@@ -3967,7 +3969,7 @@ class Script(script.Script):
|
||||
- voice: The voice to use. By default, the "system" voice will
|
||||
be used.
|
||||
- interrupt: If True, any current speech should be interrupted
|
||||
prior to speaking the new text.
|
||||
prior to speaking the new text. The default queues the message.
|
||||
"""
|
||||
|
||||
if not cthulhu.cthulhuApp.settingsManager.getSetting('enableSpeech') \
|
||||
|
||||
@@ -215,7 +215,7 @@ class Script(default.Script):
|
||||
self._clearSyntheticWebSelection()
|
||||
if oldContents:
|
||||
self.speakContents(oldContents)
|
||||
self.speakMessage(messages.TEXT_UNSELECTED, interrupt=False)
|
||||
self.speakMessage(messages.TEXT_UNSELECTED)
|
||||
return True
|
||||
|
||||
self.pointOfReference["syntheticWebSelection"] = {
|
||||
@@ -247,7 +247,7 @@ class Script(default.Script):
|
||||
|
||||
if deltaContents:
|
||||
self.speakContents(deltaContents)
|
||||
self.speakMessage(message, interrupt=False)
|
||||
self.speakMessage(message)
|
||||
|
||||
return True
|
||||
|
||||
@@ -1083,7 +1083,7 @@ class Script(default.Script):
|
||||
"""Speaks the specified contents."""
|
||||
|
||||
utterances = self.speechGenerator.generateContents(contents, **args)
|
||||
speech.speak(utterances, interrupt=args.get("interrupt", True))
|
||||
speech.speak(utterances, interrupt=args.get("interrupt", False))
|
||||
|
||||
def sayCharacter(self, obj):
|
||||
"""Speaks the character at the current caret position."""
|
||||
@@ -1504,7 +1504,6 @@ class Script(default.Script):
|
||||
|
||||
def togglePresentationMode(self, inputEvent, documentFrame=None):
|
||||
[obj, characterOffset] = self.utilities.getCaretContext(documentFrame)
|
||||
interrupt = inputEvent is not None
|
||||
if self._inFocusMode:
|
||||
parent = AXObject.get_parent(obj)
|
||||
if AXUtilities.is_list_box(parent):
|
||||
@@ -1512,7 +1511,10 @@ class Script(default.Script):
|
||||
elif AXUtilities.is_menu(parent):
|
||||
self.utilities.setCaretContext(AXObject.get_parent(parent), -1)
|
||||
if not self._loadingDocumentContent:
|
||||
self.presentMessage(messages.MODE_BROWSE, interrupt=interrupt)
|
||||
if inputEvent is not None:
|
||||
self.presentMessage(messages.MODE_BROWSE, interrupt=True)
|
||||
else:
|
||||
self.presentMessage(messages.MODE_BROWSE)
|
||||
if not self._shouldSuppressBrowseModeSound(obj, inputEvent):
|
||||
sound_theme_manager.getManager().playBrowseModeSound()
|
||||
else:
|
||||
@@ -1522,7 +1524,10 @@ class Script(default.Script):
|
||||
or inputEvent):
|
||||
self.utilities.grabFocus(obj)
|
||||
|
||||
self.presentMessage(messages.MODE_FOCUS, interrupt=interrupt)
|
||||
if inputEvent is not None:
|
||||
self.presentMessage(messages.MODE_FOCUS, interrupt=True)
|
||||
else:
|
||||
self.presentMessage(messages.MODE_FOCUS)
|
||||
sound_theme_manager.getManager().playFocusModeSound()
|
||||
self._inFocusMode = not self._inFocusMode
|
||||
self._focusModeIsSticky = False
|
||||
@@ -2689,7 +2694,7 @@ class Script(default.Script):
|
||||
debug.printTokens(debug.LEVEL_INFO, tokens, True)
|
||||
return True
|
||||
|
||||
self.presentMessage(event.any_data, interrupt=False)
|
||||
self.presentMessage(event.any_data)
|
||||
return True
|
||||
|
||||
def onNameChanged(self, event):
|
||||
|
||||
@@ -425,10 +425,11 @@ def _speak(text: str, acss: Optional[Any], interrupt: bool) -> None:
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
_speechserver.speak(text, resolvedVoice, interrupt) # type: ignore
|
||||
|
||||
def speak(content: Union[str, List[Any]], acss: Optional[Any] = None, interrupt: bool = True) -> None:
|
||||
def speak(content: Union[str, List[Any]], acss: Optional[Any] = None, interrupt: bool = False) -> None:
|
||||
"""Speaks the given content. The content can be either a simple
|
||||
string or an array of arrays of objects returned by a speech
|
||||
generator."""
|
||||
generator. Speech queues by default; callers that need to cancel
|
||||
current output should pass interrupt=True or call presentationInterrupt()."""
|
||||
|
||||
if settings.silenceSpeech:
|
||||
return
|
||||
|
||||
@@ -632,7 +632,7 @@ class SpeechServer(speechserver.SpeechServer):
|
||||
|
||||
return families
|
||||
|
||||
def speak(self, text=None, acss=None, interrupt=True):
|
||||
def speak(self, text=None, acss=None, interrupt=False):
|
||||
if not text:
|
||||
return
|
||||
|
||||
|
||||
@@ -946,7 +946,7 @@ class StructuralNavigation:
|
||||
for match in matches:
|
||||
if _isValidMatch(match):
|
||||
structuralNavigationObject.present(match, arg)
|
||||
self._script.presentMessage(wrapMessage, interrupt=False)
|
||||
self._script.presentMessage(wrapMessage)
|
||||
return
|
||||
|
||||
structuralNavigationObject.present(None, arg)
|
||||
@@ -2219,14 +2219,13 @@ class StructuralNavigation:
|
||||
if settings.speakCellCoordinates:
|
||||
[row, col] = self.getCellCoordinates(cell)
|
||||
self._script.presentMessage(
|
||||
messages.TABLE_CELL_COORDINATES % {"row": row + 1, "column": col + 1},
|
||||
interrupt=False,
|
||||
messages.TABLE_CELL_COORDINATES % {"row": row + 1, "column": col + 1}
|
||||
)
|
||||
|
||||
rowspan, colspan = self._script.utilities.rowAndColumnSpan(cell)
|
||||
spanString = messages.cellSpan(rowspan, colspan)
|
||||
if spanString and settings.speakCellSpan:
|
||||
self._script.presentMessage(spanString, interrupt=False)
|
||||
self._script.presentMessage(spanString)
|
||||
|
||||
########################
|
||||
# #
|
||||
|
||||
Reference in New Issue
Block a user