fenrir/src/fenrir-package/core/outputManager.py

44 lines
2.3 KiB
Python
Raw Normal View History

2016-07-13 05:15:19 -04:00
#!/bin/python
class outputManager():
def __init__(self):
pass
2016-07-26 09:59:27 -04:00
def presentText(self, environment, Text, Interrupt=True, soundIconName = ''):
2016-07-14 17:00:02 -04:00
self.speakText(environment, Text, Interrupt)
self.brailleText(environment, Text)
2016-07-26 09:59:27 -04:00
self.playSoundIcon(environment, soundIconName):
2016-07-14 17:00:02 -04:00
def speakText(self, environment, Text, Interrupt=True):
if environment['runtime']['speechDriver'] == None:
return
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'enabled'):
return
if Interrupt:
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'))
environment['runtime']['speechDriver'].setPitch(environment['runtime']['settingsManager'].getSettingAsInt(environment, 'speech', 'pitch'))
environment['runtime']['speechDriver'].setSpeed(environment['runtime']['settingsManager'].getSettingAsInt(environment, 'speech', 'rate'))
environment['runtime']['speechDriver'].setModule(environment['runtime']['settingsManager'].getSetting(environment, 'speech', 'module'))
2016-07-14 18:21:23 -04:00
environment['runtime']['speechDriver'].setVolume(environment['runtime']['settingsManager'].getSettingAsInt(environment, 'speech', 'volume'))
2016-07-14 17:25:33 -04:00
2016-07-14 17:00:02 -04:00
environment['runtime']['speechDriver'].speak(Text)
2016-07-26 09:59:27 -04:00
def brailleText(self, environment, Text, Interrupt=True):
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'braille', 'enabled'):
2016-07-14 17:00:02 -04:00
return
print('braille')
def interruptOutput(self, environment):
environment['runtime']['speechDriver'].cancel()
2016-07-26 09:59:27 -04:00
def playSoundIcon(self, environment, IconName, Interrupt=True):
if soundIconName == '':
return
2016-07-14 17:25:33 -04:00
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'sound', 'enabled'):
return
print(IconName)
2016-07-26 09:59:27 -04:00
try:
print(environment['soundIcons'][IconName])
except:
print('no icon there for' + IconName)