Ignore errors in tts callbacks

This commit is contained in:
Kovid Goyal 2020-11-22 13:54:26 +05:30
parent a8cf85ca9b
commit 92ebb83ed8
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 18 additions and 3 deletions

View File

@ -88,7 +88,11 @@ class Client:
self.update_status(callback_type, index_mark)
event = self.msg_as_event(callback_type, index_mark)
if event is not None:
callback(event)
try:
callback(event)
except Exception:
import traceback
traceback.print_exc()
def cw(callback_type, index_mark=None):
self.dispatch_on_main_thread(partial(callback_wrapper, callback_type, index_mark))

View File

@ -32,7 +32,11 @@ class Client:
else:
return
if self.current_callback is not None:
self.current_callback(event)
try:
self.current_callback(event)
except Exception:
import traceback
traceback.print_exc()
def speak_simple_text(self, text):
self.current_callback = None

View File

@ -26,6 +26,7 @@ class Client:
self.current_stream_number = None
self.current_callback = None
self.dispatch_on_main_thread = dispatch_on_main_thread
self.status = {'synthesizing': False, 'paused': False}
def __del__(self):
if self.sp_voice is not None:
@ -50,12 +51,18 @@ class Client:
event = Event(EventType.mark, event_data)
elif event_type == SPEI_START_INPUT_STREAM:
event = Event(EventType.begin)
self.status = {'synthesizing': True, 'paused': False}
elif event_type == SPEI_END_INPUT_STREAM:
event = Event(EventType.end)
self.status = {'synthesizing': False, 'paused': False}
else:
continue
if c is not None and stream_number == self.current_stream_number:
c(event)
try:
c(event)
except Exception:
import traceback
traceback.print_exc()
def speak_simple_text(self, text):
from calibre_extensions.winsapi import (