mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2025-08-26 18:09:21 +00:00
Putting all the code from the current master branch of TWBlue
This commit is contained in:
29
src/accessible_output2/outputs/speechDispatcher.py
Normal file
29
src/accessible_output2/outputs/speechDispatcher.py
Normal file
@@ -0,0 +1,29 @@
|
||||
from base import Output, OutputError
|
||||
import atexit
|
||||
|
||||
class SpeechDispatcher(Output):
|
||||
"""Supports speech dispatcher on Linux.
|
||||
Note that it will take the configuration from the speech dispatcher, the user will need configure voice, language, punctuation and rate before use this module.
|
||||
"""
|
||||
name = 'SpeechDispatcher'
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(SpeechDispatcher, self).__init__(*args, **kwargs)
|
||||
try:
|
||||
import speechd
|
||||
self.spd = speechd.SSIPClient("TWBlue")
|
||||
except ImportError:
|
||||
raise OutputError
|
||||
atexit.register(self.on_exit_event)
|
||||
|
||||
def speak(self, text, interupt=False):
|
||||
if interupt == True:
|
||||
self.spd.cancel()
|
||||
self.spd.speak(text)
|
||||
|
||||
def is_active(self):
|
||||
return True
|
||||
|
||||
def on_exit_event(self):
|
||||
self.spd.close()
|
||||
del self.spd
|
Reference in New Issue
Block a user