Update outputManager.py

This commit is contained in:
chrys87 2016-07-26 16:19:23 +02:00 committed by GitHub
parent d91509f372
commit d90ebb8932

View File

@ -3,17 +3,17 @@
class outputManager(): class outputManager():
def __init__(self): def __init__(self):
pass pass
def presentText(self, environment, Text, Interrupt=True, soundIconName = ''): def presentText(self, environment, text, interrupt=True, soundIconName = ''):
self.speakText(environment, Text, Interrupt) self.speakText(environment, text, interrupt)
self.brailleText(environment, Text) self.brailleText(environment, text)
self.playSoundIcon(environment, soundIconName): self.playSoundIcon(environment, soundIconName):
def speakText(self, environment, Text, Interrupt=True): def speakText(self, environment, text, interrupt=True):
if environment['runtime']['speechDriver'] == None:
return
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'enabled'): if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'enabled'):
return return
if Interrupt: if environment['runtime']['speechDriver'] == None:
return
if interrupt:
self.interruptOutput(environment) self.interruptOutput(environment)
environment['runtime']['speechDriver'].setLanguage(environment['runtime']['settingsManager'].getSetting(environment, 'speech', 'language')) 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'].setVoice(environment['runtime']['settingsManager'].getSetting(environment, 'speech', 'voice'))
@ -21,23 +21,28 @@ class outputManager():
environment['runtime']['speechDriver'].setSpeed(environment['runtime']['settingsManager'].getSettingAsInt(environment, 'speech', 'rate')) environment['runtime']['speechDriver'].setSpeed(environment['runtime']['settingsManager'].getSettingAsInt(environment, 'speech', 'rate'))
environment['runtime']['speechDriver'].setModule(environment['runtime']['settingsManager'].getSetting(environment, 'speech', 'module')) environment['runtime']['speechDriver'].setModule(environment['runtime']['settingsManager'].getSetting(environment, 'speech', 'module'))
environment['runtime']['speechDriver'].setVolume(environment['runtime']['settingsManager'].getSettingAsInt(environment, 'speech', 'volume')) environment['runtime']['speechDriver'].setVolume(environment['runtime']['settingsManager'].getSettingAsInt(environment, 'speech', 'volume'))
environment['runtime']['speechDriver'].speak(text)
environment['runtime']['speechDriver'].speak(Text) def brailleText(self, environment, text, interrupt=True):
def brailleText(self, environment, Text, Interrupt=True):
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'braille', 'enabled'): if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'braille', 'enabled'):
return return
if environment['runtime']['braillehDriver'] == None:
return
print('braille') print('braille')
def interruptOutput(self, environment): def interruptOutput(self, environment):
environment['runtime']['speechDriver'].cancel() environment['runtime']['speechDriver'].cancel()
environment['runtime']['soundDriver'].cancel()
def playSoundIcon(self, environment, IconName, Interrupt=True): def playSoundIcon(self, environment, iconName, interrupt=True):
if soundIconName == '': if soundIconName == '':
return return
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'sound', 'enabled'): if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'sound', 'enabled'):
return return
if environment['runtime']['soundDriver'] == None:
return
print(IconName) print(IconName)
try: try:
print(environment['soundIcons'][IconName]) print(environment['soundIcons'][iconName])
environment['runtime']['soundDriver'].playSoundFile(environment, environment['soundIcons'][iconName], interrupt)
except: except:
print('no icon there for' + IconName) print('no icon there for' + IconName)