Content server: Read aloud: Fix clicking on a word to skip reading aloud to that word causing word highlighting to stop working. Fixes #2086661 [When read aloud, highlight not synchronized](https://bugs.launchpad.net/calibre/+bug/2086661)

This commit is contained in:
Kovid Goyal 2024-11-05 20:43:43 +05:30
parent 3e957aa58b
commit e17ea5203a
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -135,7 +135,10 @@ class Client:
self.onevent('pause')
def speak(self, text):
self.current_utterance = None
ut, self.current_utterance = self.current_utterance, None
if ut:
ut.onstart = ut.onpause = ut.onend = ut.onerror = ut.onresume = None
ut.removeEventListener('boundary', self.utterance_boundary_reached)
if text and text.length:
self.current_utterance = self.create_utterance(text)
window.speechSynthesis.speak(self.current_utterance)