From 8d4bc69a8dd55bcaffc3d1b5e6f4ea1a15e2078a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 10 Dec 2020 18:24:59 +0530 Subject: [PATCH] TTS: fix inter-word punctuation being ignored --- src/calibre/gui2/tts/develop.py | 6 +++++- src/pyj/read_book/find.pyj | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/tts/develop.py b/src/calibre/gui2/tts/develop.py index d0827c1e0c..4ca6287b27 100644 --- a/src/calibre/gui2/tts/develop.py +++ b/src/calibre/gui2/tts/develop.py @@ -29,6 +29,8 @@ def add_markup(text): first = False if start: buf.append(Client.escape_marked_text(text[:start])) + elif start > last: + buf.append(Client.escape_marked_text(text[last:start])) num = next(counter) buf.append(bm.format(num)) pos_map[num] = start, end @@ -52,7 +54,7 @@ class TTSWidget(QWidget): QWidget.__init__(self, parent) self.mark_changed.connect(self.on_mark_change) self.dispatch_on_main_thread_signal.connect(self.dispatch_on_main_thread, type=Qt.ConnectionType.QueuedConnection) - self.tts = Client(self.dispatch_on_main_thread_signal.emit) + self.tts = Client({}, self.dispatch_on_main_thread_signal.emit) self.l = l = QVBoxLayout(self) self.la = la = QLabel(self) la.setTextFormat(Qt.TextFormat.RichText) @@ -81,7 +83,9 @@ itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of. ''' + self.text = 'one, two, three. one two three' self.ssml, self.pos_map = add_markup(self.text) + print(1111, self.ssml) self.current_mark = None l.addWidget(la) self.bb = bb = QDialogButtonBox(self) diff --git a/src/pyj/read_book/find.pyj b/src/pyj/read_book/find.pyj index 5fb844d87b..f1577be114 100644 --- a/src/pyj/read_book/find.pyj +++ b/src/pyj/read_book/find.pyj @@ -61,6 +61,9 @@ def tts_data(text_node, offset): first = False if start: marked_text.push(text[:start]) + elif start > last: + marked_text.push(text[last:start]) + marked_text.push(start + offset_in_flat_text) marked_text.push(match[0]) last = start + match[0].length