From a83ea131621e0742f03139f62bdf5a9c3a5d404d Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 18 Nov 2020 22:03:33 +0530 Subject: [PATCH] Speak aloud implementation for macOS --- src/calibre/gui2/tts/implementation.py | 4 ++-- src/calibre/gui2/tts/macos.py | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 src/calibre/gui2/tts/macos.py diff --git a/src/calibre/gui2/tts/implementation.py b/src/calibre/gui2/tts/implementation.py index 7f8c3ffe36..3f90049baa 100644 --- a/src/calibre/gui2/tts/implementation.py +++ b/src/calibre/gui2/tts/implementation.py @@ -7,7 +7,7 @@ from calibre.constants import iswindows, ismacos if iswindows: from .windows import Client elif ismacos: - pass + from .macos import Client else: from .linux import Client - Client +Client diff --git a/src/calibre/gui2/tts/macos.py b/src/calibre/gui2/tts/macos.py new file mode 100644 index 0000000000..3fee7077fa --- /dev/null +++ b/src/calibre/gui2/tts/macos.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python +# vim:fileencoding=utf-8 +# License: GPL v3 Copyright: 2020, Kovid Goyal + + +class Client: + + def __init__(self): + from calibre_extensions.cocoa import NSSpeechSynthesizer + self.nsss = NSSpeechSynthesizer() + + def __del__(self): + self.nsss = None + + def speak_simple_text(self, text): + self.nsss.speak(text)