From 825688d5ee6b4680ca9b685d914f9e289f8bde7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arkadiusz=20Kozio=C5=82?= Date: Tue, 26 Nov 2019 10:09:31 +0100 Subject: [PATCH] SPeech dispatcher experimental suport instead of e_speak --- accessible_output2.egg-info/SOURCES.txt | 1 + accessible_output2/outputs/__init__.py | 3 +- .../outputs/speech_dispatcher.py | 32 +++++++++++++++++++ .../accessible_output2/outputs/__init__.py | 3 +- .../outputs/speech-dispatcher.py | 32 +++++++++++++++++++ .../outputs/speech_dispatcher.py | 32 +++++++++++++++++++ setup.py | 6 ++-- 7 files changed, 105 insertions(+), 4 deletions(-) create mode 100644 accessible_output2/outputs/speech_dispatcher.py create mode 100644 build/lib/accessible_output2/outputs/speech-dispatcher.py create mode 100644 build/lib/accessible_output2/outputs/speech_dispatcher.py diff --git a/accessible_output2.egg-info/SOURCES.txt b/accessible_output2.egg-info/SOURCES.txt index 9bebdc4..58ffb87 100644 --- a/accessible_output2.egg-info/SOURCES.txt +++ b/accessible_output2.egg-info/SOURCES.txt @@ -28,6 +28,7 @@ accessible_output2/outputs/pc_talker.py accessible_output2/outputs/sapi4.py accessible_output2/outputs/sapi5.py accessible_output2/outputs/say.py +accessible_output2/outputs/speech_dispatcher.py accessible_output2/outputs/system_access.py accessible_output2/outputs/voiceover.py accessible_output2/outputs/window_eyes.py diff --git a/accessible_output2/outputs/__init__.py b/accessible_output2/outputs/__init__.py index c34495b..937a023 100644 --- a/accessible_output2/outputs/__init__.py +++ b/accessible_output2/outputs/__init__.py @@ -15,6 +15,7 @@ from . import say if platform.system() == 'Linux': - from . import e_speak + #from . import e_speak + from . import speech_dispatcher from .import auto diff --git a/accessible_output2/outputs/speech_dispatcher.py b/accessible_output2/outputs/speech_dispatcher.py new file mode 100644 index 0000000..206638a --- /dev/null +++ b/accessible_output2/outputs/speech_dispatcher.py @@ -0,0 +1,32 @@ +from .base import Output + +try: + import speechd +except: + raise RuntimeError("Cannot find speechd. Please install python-speechd") + +class Speechdisp(Output): + """Speech output supporting Speech Dispatcher on Linux + Note this requires python-speechd to be installed + """ + name = "Linux Speech-Dispatcher" + def __init__(self): + self.client = speechd.SSIPClient('AccessibleOutput2') + self.client.set_output_module('espeak-ng') + self.client.set_punctuation(speechd.PunctuationMode.NONE) + + def is_active(self): + try: + import speechd + except: + return False + return True + + def speak(self, text, interrupt = 0): + if interrupt: + self.silence() + self.client.speak(text) + def silence(self): + self.client.stop() + +output_class = Speechdisp diff --git a/build/lib/accessible_output2/outputs/__init__.py b/build/lib/accessible_output2/outputs/__init__.py index c34495b..937a023 100644 --- a/build/lib/accessible_output2/outputs/__init__.py +++ b/build/lib/accessible_output2/outputs/__init__.py @@ -15,6 +15,7 @@ from . import say if platform.system() == 'Linux': - from . import e_speak + #from . import e_speak + from . import speech_dispatcher from .import auto diff --git a/build/lib/accessible_output2/outputs/speech-dispatcher.py b/build/lib/accessible_output2/outputs/speech-dispatcher.py new file mode 100644 index 0000000..8708f21 --- /dev/null +++ b/build/lib/accessible_output2/outputs/speech-dispatcher.py @@ -0,0 +1,32 @@ +from .base import Output + +try: + import speechd +except: + raise RuntimeError("Cannot find speechd. Please install python-speechd") + +class Speechdisp(Output): + """Speech output supporting Speech Dispatcher on Linux + Note this requires python-speechd to be installed + """ + name = "Linux Speech-Dispatcher" + def __init__(self): + self.client = speech.SSIPClient('AccessibleOutput2') + self.client.set_output_motule('espeak-ng') + self.client.set_punctuation(speech.PunctuationMode.NONE) + + def is_active(self): + try: + import speechd + except: + return False + return True + + def speak(self, text, interrupt = 0): + if interrupt: + self.silence() + self.client.speak(text) + def silence(self): + self.client.stop() + +output_class = Speechdisp diff --git a/build/lib/accessible_output2/outputs/speech_dispatcher.py b/build/lib/accessible_output2/outputs/speech_dispatcher.py new file mode 100644 index 0000000..206638a --- /dev/null +++ b/build/lib/accessible_output2/outputs/speech_dispatcher.py @@ -0,0 +1,32 @@ +from .base import Output + +try: + import speechd +except: + raise RuntimeError("Cannot find speechd. Please install python-speechd") + +class Speechdisp(Output): + """Speech output supporting Speech Dispatcher on Linux + Note this requires python-speechd to be installed + """ + name = "Linux Speech-Dispatcher" + def __init__(self): + self.client = speechd.SSIPClient('AccessibleOutput2') + self.client.set_output_module('espeak-ng') + self.client.set_punctuation(speechd.PunctuationMode.NONE) + + def is_active(self): + try: + import speechd + except: + return False + return True + + def speak(self, text, interrupt = 0): + if interrupt: + self.silence() + self.client.speak(text) + def silence(self): + self.client.stop() + +output_class = Speechdisp diff --git a/setup.py b/setup.py index 2f1cc36..7c4c21a 100644 --- a/setup.py +++ b/setup.py @@ -8,13 +8,15 @@ class PostDevelopCommand(develop): """Post-installation for development mode.""" def run(self): - check_call("pip install pywin32") + if system() == "Windows": + check_call("pip install pywin32") develop.run(self) class PostInstallCommand(install): """Post-installation for installation mode.""" def run(self): - check_call("pip install pywin32") + if system() == "Windows": + check_call("pip install pywin32") install.run(self) _system = system()