Skip to content

Commit

Permalink
use onDoneSpeaking extension point properly
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonarddeR committed Aug 1, 2023
1 parent 15291f2 commit 217372b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion addon/globalPlugins/rdAccess/handlers/remoteSpeechHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,13 @@ def _onSynthIndexReached(
self.writeMessage(protocol.SpeechCommand.INDEX_REACHED, indexBytes)

def _onSynthDoneSpeaking(self, synth: typing.Optional[synthDriverHandler.SynthDriver] = None):
self._indexesSpeaking.clear()
assert synth == self._driver
if len(self._indexesSpeaking) > 0:
self._indexesSpeaking.clear()
self.writeMessage(protocol.SpeechCommand.INDEX_REACHED, b'\x00\x00')

def _handleDriverChanged(self, synth: synthDriverHandler.SynthDriver):
self._indexesSpeaking.clear()
super()._handleDriverChanged(synth)
self._attributeSenderStore(protocol.SpeechAttribute.SUPPORTED_COMMANDS, commands=synth.supportedCommands)
self._attributeSenderStore(protocol.SpeechAttribute.LANGUAGE, language=synth.language)
6 changes: 5 additions & 1 deletion addon/synthDrivers/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,11 @@ def _get_language(self):
def _command_indexReached(self, incomingPayload: bytes):
assert len(incomingPayload) == 2
index = int.from_bytes(incomingPayload, sys.byteorder)
synthDriverHandler.synthIndexReached.notify(synth=self, index=index)
if index:
synthDriverHandler.synthIndexReached.notify(synth=self, index=index)
else:
assert index == 0
synthDriverHandler.synthDoneSpeaking.notify(synth=self)

def _handleRemoteDriverChange(self):
super()._handleRemoteDriverChange()
Expand Down

0 comments on commit 217372b

Please sign in to comment.