From e17ea5203abfb6b616f8f999f014ec9f4196b3c4 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 5 Nov 2024 20:43:43 +0530 Subject: [PATCH] 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) --- src/pyj/read_book/tts.pyj | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pyj/read_book/tts.pyj b/src/pyj/read_book/tts.pyj index 6df50cde10..84f4e51b9e 100644 --- a/src/pyj/read_book/tts.pyj +++ b/src/pyj/read_book/tts.pyj @@ -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)