From eb94213e06e46c9eb1b324bddd3c29458aa89d76 Mon Sep 17 00:00:00 2001 From: Leonard de Ruijter Date: Wed, 17 Jul 2019 11:19:37 +0200 Subject: [PATCH 1/3] Log never handled speech indexes, and don't make the speech queue lag behind --- source/speech/manager.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/source/speech/manager.py b/source/speech/manager.py index 78f0fad5257..66aae45257f 100644 --- a/source/speech/manager.py +++ b/source/speech/manager.py @@ -336,12 +336,15 @@ def _removeCompletedFromQueue(self, index): return False, False for seqIndex, seq in enumerate(self._curPriQueue.pendingSequences): lastCommand = seq[-1] if isinstance(seq, list) else None - if isinstance(lastCommand, IndexCommand) and index >= lastCommand.index: - endOfUtterance = isinstance(self._curPriQueue.pendingSequences[seqIndex + 1][0], EndUtteranceCommand) - if endOfUtterance: - # Remove the EndUtteranceCommand as well. - seqIndex += 1 - break # Found it! + if isinstance(lastCommand, IndexCommand): + if index > lastCommand.index: + log.debugWarning("Reached speech index %d, but index %d never handled" % (index, lastCommand.index)) + elif index == lastCommand.index: + endOfUtterance = isinstance(self._curPriQueue.pendingSequences[seqIndex + 1][0], EndUtteranceCommand) + if endOfUtterance: + # Remove the EndUtteranceCommand as well. + seqIndex += 1 + break # Found it! else: # Unknown index. Probably from a previous utterance which was cancelled. return False, False From 394fa3d1eaa3f5f736649638b0c7d0e230e7fd96 Mon Sep 17 00:00:00 2001 From: Leonard de Ruijter Date: Fri, 19 Jul 2019 14:43:36 +0200 Subject: [PATCH 2/3] Review action --- source/speech/manager.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/speech/manager.py b/source/speech/manager.py index 66aae45257f..7cd4b32eb1b 100644 --- a/source/speech/manager.py +++ b/source/speech/manager.py @@ -338,7 +338,10 @@ def _removeCompletedFromQueue(self, index): lastCommand = seq[-1] if isinstance(seq, list) else None if isinstance(lastCommand, IndexCommand): if index > lastCommand.index: - log.debugWarning("Reached speech index %d, but index %d never handled" % (index, lastCommand.index)) + log.debugWarning( + "Reached speech index {index :d}, but index {lastCommand.index :d} never handled" + .format(index=index, lastCommand=lastCommand) + ) elif index == lastCommand.index: endOfUtterance = isinstance(self._curPriQueue.pendingSequences[seqIndex + 1][0], EndUtteranceCommand) if endOfUtterance: From 4dbe05253152dc4fb958ee67bde6f4a1c73396f3 Mon Sep 17 00:00:00 2001 From: Leonard de Ruijter Date: Fri, 19 Jul 2019 14:54:46 +0200 Subject: [PATCH 3/3] Use f literal --- source/speech/manager.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/source/speech/manager.py b/source/speech/manager.py index 7cd4b32eb1b..0815c63a327 100644 --- a/source/speech/manager.py +++ b/source/speech/manager.py @@ -338,10 +338,7 @@ def _removeCompletedFromQueue(self, index): lastCommand = seq[-1] if isinstance(seq, list) else None if isinstance(lastCommand, IndexCommand): if index > lastCommand.index: - log.debugWarning( - "Reached speech index {index :d}, but index {lastCommand.index :d} never handled" - .format(index=index, lastCommand=lastCommand) - ) + log.debugWarning(f"Reached speech index {index :d}, but index {lastCommand.index :d} never handled") elif index == lastCommand.index: endOfUtterance = isinstance(self._curPriQueue.pendingSequences[seqIndex + 1][0], EndUtteranceCommand) if endOfUtterance: