Implement simple speech for the browser viewer

This commit is contained in:
Kovid Goyal 2020-11-18 10:37:44 +05:30
parent 85bf7f823e
commit d9592d090b
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -113,6 +113,12 @@ class ReadUI:
window.navigator.clipboard.writeText(text or '').then(def (): pass;, def(): window.navigator.clipboard.writeText(text or '').then(def (): pass;, def():
error_dialog(_('Could not copy to clipboard'), _('No permission to write to clipboard')) error_dialog(_('Could not copy to clipboard'), _('No permission to write to clipboard'))
) )
ui_operations.speak_simple_text = def (text):
if not window.speechSynthesis:
return error_dialog(_('No speech support'), _(
'Your browser does not have support for Speech'))
ut = new SpeechSynthesisUtterance(text) # noqa
window.speechSynthesis.speak(ut)
def on_resize(self): def on_resize(self):
self.view.on_resize() self.view.on_resize()