2016-07-13 05:15:19 -04:00
|
|
|
#!/bin/python
|
|
|
|
|
|
|
|
class outputManager():
|
|
|
|
def __init__(self):
|
|
|
|
pass
|
2016-08-10 09:30:43 -04:00
|
|
|
def presentText(self, environment, text, interrupt=True, soundIcon = ''):
|
|
|
|
if self.playSoundIcon(environment, soundIcon, interrupt):
|
2016-08-02 20:26:44 -04:00
|
|
|
return
|
2016-07-26 10:19:23 -04:00
|
|
|
self.speakText(environment, text, interrupt)
|
2016-08-08 05:07:40 -04:00
|
|
|
self.brailleText(environment, text, interrupt)
|
2016-07-14 17:00:02 -04:00
|
|
|
|
2016-07-26 10:19:23 -04:00
|
|
|
def speakText(self, environment, text, interrupt=True):
|
2016-07-14 17:00:02 -04:00
|
|
|
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'enabled'):
|
2016-07-26 10:19:23 -04:00
|
|
|
return
|
|
|
|
if environment['runtime']['speechDriver'] == None:
|
2016-07-14 17:00:02 -04:00
|
|
|
return
|
2016-07-26 10:19:23 -04:00
|
|
|
if interrupt:
|
2016-07-14 17:00:02 -04:00
|
|
|
self.interruptOutput(environment)
|
2016-07-14 17:25:33 -04:00
|
|
|
environment['runtime']['speechDriver'].setLanguage(environment['runtime']['settingsManager'].getSetting(environment, 'speech', 'language'))
|
|
|
|
environment['runtime']['speechDriver'].setVoice(environment['runtime']['settingsManager'].getSetting(environment, 'speech', 'voice'))
|
2016-08-08 05:07:40 -04:00
|
|
|
environment['runtime']['speechDriver'].setPitch(environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'speech', 'pitch'))
|
|
|
|
environment['runtime']['speechDriver'].setSpeed(environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'speech', 'rate'))
|
2016-07-14 17:25:33 -04:00
|
|
|
environment['runtime']['speechDriver'].setModule(environment['runtime']['settingsManager'].getSetting(environment, 'speech', 'module'))
|
2016-08-08 03:34:57 -04:00
|
|
|
environment['runtime']['speechDriver'].setVolume(environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'speech', 'volume'))
|
2016-07-26 10:19:23 -04:00
|
|
|
environment['runtime']['speechDriver'].speak(text)
|
2016-07-14 17:00:02 -04:00
|
|
|
|
2016-08-08 05:07:40 -04:00
|
|
|
def brailleText(self, environment, text, interrupt=True):
|
2016-07-15 10:31:19 -04:00
|
|
|
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'braille', 'enabled'):
|
2016-07-26 10:19:23 -04:00
|
|
|
return
|
2016-08-02 20:26:44 -04:00
|
|
|
if environment['runtime']['brailleDriver'] == None:
|
2016-07-26 10:19:23 -04:00
|
|
|
return
|
2016-08-08 05:07:40 -04:00
|
|
|
print('braille:'+text)
|
2016-07-14 17:00:02 -04:00
|
|
|
def interruptOutput(self, environment):
|
|
|
|
environment['runtime']['speechDriver'].cancel()
|
2016-07-26 10:19:23 -04:00
|
|
|
environment['runtime']['soundDriver'].cancel()
|
2016-07-26 17:39:22 -04:00
|
|
|
|
2016-08-10 09:30:43 -04:00
|
|
|
def playSoundIcon(self, environment, soundIcon = '', interrupt=True):
|
|
|
|
if soundIcon == '':
|
2016-08-02 20:26:44 -04:00
|
|
|
return False
|
2016-07-14 17:25:33 -04:00
|
|
|
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'sound', 'enabled'):
|
2016-08-02 20:26:44 -04:00
|
|
|
return False
|
2016-07-26 10:19:23 -04:00
|
|
|
if environment['runtime']['soundDriver'] == None:
|
2016-08-02 20:26:44 -04:00
|
|
|
return False
|
2016-07-26 09:59:27 -04:00
|
|
|
try:
|
2016-08-08 03:34:57 -04:00
|
|
|
environment['runtime']['soundDriver'].setVolume(environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'sound', 'volume'))
|
2016-08-10 09:30:43 -04:00
|
|
|
environment['runtime']['soundDriver'].playSoundFile(environment['soundIcons'][soundIcon], interrupt)
|
2016-08-02 20:26:44 -04:00
|
|
|
return True
|
2016-07-26 09:59:27 -04:00
|
|
|
except:
|
2016-08-10 09:30:43 -04:00
|
|
|
pass
|
2016-08-02 20:26:44 -04:00
|
|
|
return False
|