From 57bf64262f537a54bcac4c81e3f644b1249ca634 Mon Sep 17 00:00:00 2001 From: Kirill Belousov Date: Sun, 25 Dec 2022 15:10:38 +0300 Subject: [PATCH 1/3] Added python virtual environment to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 8d5b911..43b41bf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.*env/ build/ dist/' docs/_build From 2bb32093441ecd64c0b92b0a11b5a5b5799e3274 Mon Sep 17 00:00:00 2001 From: Kirill Belousov Date: Sun, 25 Dec 2022 15:19:11 +0300 Subject: [PATCH 2/3] Added NSSpeechSynthesizer output for MacOS --- accessible_output2/outputs/__init__.py | 1 + .../outputs/nsspeechsynthesizer.py | 28 +++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 accessible_output2/outputs/nsspeechsynthesizer.py diff --git a/accessible_output2/outputs/__init__.py b/accessible_output2/outputs/__init__.py index 5142a45..79b57aa 100644 --- a/accessible_output2/outputs/__init__.py +++ b/accessible_output2/outputs/__init__.py @@ -34,6 +34,7 @@ def _load_com(*names): if platform.system() == "Darwin": from . import voiceover + from . import nsspeechsynthesizer if platform.system() == "Linux": from . import speech_dispatcher diff --git a/accessible_output2/outputs/nsspeechsynthesizer.py b/accessible_output2/outputs/nsspeechsynthesizer.py new file mode 100644 index 0000000..1710b86 --- /dev/null +++ b/accessible_output2/outputs/nsspeechsynthesizer.py @@ -0,0 +1,28 @@ +from platform import system as get_current_system +from .base import Output + +class MacSpeech(Output): + + """Speech output supporting Apple MacOS NSSpeechSynthesizer.""" + + name = "MacSpeech" + priority = 101 + system_output = True + + def __init__(self, *args, **kwargs): + from AppKit import NSSpeechSynthesizer + self.synth = NSSpeechSynthesizer.alloc().init() + + def speak(self, text: str, interrupt: bool = False) -> bool: + if interrupt: + self.silence() + return self.synth.startSpeakingString_(text) + + def silence(self): + self.synth.stopSpeaking() + + def is_active(self): + return get_current_system() == "Darwin" + + +output_class = MacSpeech From e5a9df5e988994177c17e7331274d6b2a3a0c20e Mon Sep 17 00:00:00 2001 From: Kirill Belousov Date: Sun, 25 Dec 2022 15:36:27 +0300 Subject: [PATCH 3/3] Added pyobjc requirement for NSSpeechSynthesizer output method to work --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 26456e2..ede44f1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ libloader platform_utils +pyobjc; sys_platform == 'darwin'