Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions source/speech/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,12 +466,21 @@ def _buildNextUtterance(self):
utterance.extend(seq)
lastSequenceIndexAddedToUtterance = seqIndex
# if any items are cancelled, cancel the whole utterance.
if utterance and not self._checkForCancellations(utterance):
log.error(f"Checking for cancellations failed, cancelling sequence: {utterance}")
try:
utteranceValid = len(utterance) == 0 or self._checkForCancellations(utterance)
except IndexError:
log.error(
f"Checking for cancellations failed, cancelling sequence: {utterance}",
exc_info=True
)
# Avoid infinite recursion by removing the problematic sequences:
del self._curPriQueue.pendingSequences[:lastSequenceIndexAddedToUtterance + 1]
utteranceValid = False

if utteranceValid:
return utterance
else:
return self._buildNextUtterance()
return utterance

def _checkForCancellations(self, utterance: SpeechSequence) -> bool:
"""
Expand All @@ -485,8 +494,9 @@ def _checkForCancellations(self, utterance: SpeechSequence) -> bool:
return True
utteranceIndex = self._getUtteranceIndex(utterance)
if utteranceIndex is None:
log.error("no utterance index, cant save cancellable commands")
return False
raise IndexError(
f"no utterance index({utteranceIndex}, cant save cancellable commands"
)
cancellableItems = list(
item for item in reversed(utterance) if isinstance(item, _CancellableSpeechCommand)
)
Expand Down