polish sound

This commit is contained in:
Chrys 2016-08-03 02:26:44 +02:00
parent 326341f509
commit 8a3ead822a
14 changed files with 33 additions and 27 deletions

View File

@ -26,8 +26,8 @@ SpeechOff='SpeechOff.opus'
BrailleOn='BrailleOn.opus' BrailleOn='BrailleOn.opus'
BrailleOff='BrailleOff.opus' BrailleOff='BrailleOff.opus'
# SoundIcons has turned On or Off # SoundIcons has turned On or Off
SoundIconsOn='SoundIconsOn.opus' SoundOn='SoundOn.opus'
SoundIconsOff='SoundIconsOff.opus' SoundOff='SoundOff.opus'
# Set beginnig mark for copy to clipboard # Set beginnig mark for copy to clipboard
PlaceStartCopyMark='PlaceStartCopyMark.opus' PlaceStartCopyMark='PlaceStartCopyMark.opus'
# Set end mark for copy to clipboard # Set end mark for copy to clipboard

View File

@ -6,10 +6,10 @@ class command():
def run(self, environment): def run(self, environment):
if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'braille', 'enabled'): if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'braille', 'enabled'):
environment['runtime']['outputManager'].presentText(environment, "braille disabled") environment['runtime']['outputManager'].presentText(environment, "braille disabled",soundIconName='BrailleOff', interrupt=True)
environment = environment['runtime']['settingsManager'].setSetting(environment, 'braille', 'enabled', str(not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'braille', 'enabled'))) environment = environment['runtime']['settingsManager'].setSetting(environment, 'braille', 'enabled', str(not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'braille', 'enabled')))
if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'braille', 'enabled'): if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'braille', 'enabled'):
environment['runtime']['outputManager'].presentText(environment, "braille enabled") environment['runtime']['outputManager'].presentText(environment, "braille enabled",soundIconName='BrailleOn', interrupt=True)
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -7,7 +7,7 @@ class command():
if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'enabled') or \ if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'enabled') or \
environment['runtime']['settingsManager'].getSettingAsBool(environment, 'sound', 'enabled') or \ environment['runtime']['settingsManager'].getSettingAsBool(environment, 'sound', 'enabled') or \
environment['runtime']['settingsManager'].getSettingAsBool(environment, 'braille', 'enabled'): environment['runtime']['settingsManager'].getSettingAsBool(environment, 'braille', 'enabled'):
environment['runtime']['outputManager'].presentText(environment, "fenrir muted") environment['runtime']['outputManager'].presentText(environment, "fenrir muted", soundIconName='Accept', interrupt=True)
environment = environment['runtime']['settingsManager'].setSetting(environment, 'speech', 'enabled','False') environment = environment['runtime']['settingsManager'].setSetting(environment, 'speech', 'enabled','False')
environment = environment['runtime']['settingsManager'].setSetting(environment, 'sound', 'enabled','False') environment = environment['runtime']['settingsManager'].setSetting(environment, 'sound', 'enabled','False')
environment = environment['runtime']['settingsManager'].setSetting(environment, 'braille', 'enabled','False') environment = environment['runtime']['settingsManager'].setSetting(environment, 'braille', 'enabled','False')
@ -15,7 +15,7 @@ class command():
environment = environment['runtime']['settingsManager'].setSetting(environment, 'speech', 'enabled','True') environment = environment['runtime']['settingsManager'].setSetting(environment, 'speech', 'enabled','True')
environment = environment['runtime']['settingsManager'].setSetting(environment, 'sound', 'enabled','True') environment = environment['runtime']['settingsManager'].setSetting(environment, 'sound', 'enabled','True')
environment = environment['runtime']['settingsManager'].setSetting(environment, 'braille', 'enabled','True') environment = environment['runtime']['settingsManager'].setSetting(environment, 'braille', 'enabled','True')
environment['runtime']['outputManager'].presentText(environment, "fenrir unmuted") environment['runtime']['outputManager'].presentText(environment, "fenrir unmuted", soundIconName='Cancel', interrupt=True)
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -6,10 +6,11 @@ class command():
def run(self, environment): def run(self, environment):
if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'sound', 'enabled'): if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'sound', 'enabled'):
environment['runtime']['outputManager'].presentText(environment, "sound disabled") environment['runtime']['outputManager'].presentText(environment, "sound disabled",soundIconName='SoundOff', interrupt=True)
environment = environment['runtime']['settingsManager'].setSetting(environment, 'sound', 'enabled', str(not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'sound', 'enabled'))) environment = environment['runtime']['settingsManager'].setSetting(environment, 'sound', 'enabled', str(not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'sound', 'enabled')))
print(not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'sound', 'enabled'))
if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'sound', 'enabled'): if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'sound', 'enabled'):
environment['runtime']['outputManager'].presentText(environment, "sound enabled") environment['runtime']['outputManager'].presentText(environment, "sound enabled",soundIconName='SoundOn', interrupt=True)
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -5,11 +5,11 @@ class command():
pass pass
def run(self, environment): def run(self, environment):
if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'enabled'): if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'enabled',soundIconName='SpeechOff', interrupt=True):
environment['runtime']['outputManager'].presentText(environment, "speech disabled") environment['runtime']['outputManager'].presentText(environment, "speech disabled")
environment = environment['runtime']['settingsManager'].setSetting(environment, 'speech', 'enabled', str(not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'enabled'))) environment = environment['runtime']['settingsManager'].setSetting(environment, 'speech', 'enabled', str(not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'enabled')))
if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'enabled'): if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'enabled'):
environment['runtime']['outputManager'].presentText(environment, "speech enabled") environment['runtime']['outputManager'].presentText(environment, "speech enabled",soundIconName='SpeechOn', interrupt=True)
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -4,12 +4,12 @@ class command():
def __init__(self): def __init__(self):
pass pass
def run(self, environment): def run(self, environment):
#if environment['screenData']['newDelta'] != environment['screenData']['oldDelta']: if environment['screenData']['newDelta'] != environment['screenData']['oldDelta']:
# return environment return environment
if environment['screenData']['newCursor']['y'] == environment['screenData']['oldCursor']['y']: if environment['screenData']['newCursor']['y'] == environment['screenData']['oldCursor']['y']:
return environment return environment
if environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursor']['y']].strip(" \t\n") == '': if environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursor']['y']].strip(" \t\n") == '':
environment['runtime']['outputManager'].presentText(environment, "blank", True) environment['runtime']['outputManager'].presentText(environment, "blank", soundIconName='EmptyLine', interrupt=True)
else: else:
environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursor']['y']], True) environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursor']['y']], True)
return environment return environment

View File

@ -14,7 +14,7 @@ class command():
return environment return environment
if ttyChanged: if ttyChanged:
environment['runtime']['outputManager'].playSoundIcon(environment,'ChangeTTY') environment['runtime']['outputManager'].playSoundIcon(environment,'ChangeTTY')
environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newDelta'], ttyChanged) environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newDelta'], interrupt=ttyChanged)
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):

View File

@ -13,7 +13,7 @@ class command():
not ttyChanged: not ttyChanged:
return environment return environment
environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newDelta'], ttyChanged) environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newDelta'], soundIconName='', interrupt=ttyChanged)
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -4,9 +4,10 @@ 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 = ''):
if self.playSoundIcon(environment, soundIconName, interrupt):
return
self.speakText(environment, text, interrupt) self.speakText(environment, text, interrupt)
self.brailleText(environment, text) self.brailleText(environment, text)
self.playSoundIcon(environment, soundIconName)
def speakText(self, environment, text, interrupt=True): def speakText(self, environment, text, interrupt=True):
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'enabled'): if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'enabled'):
@ -23,10 +24,10 @@ class outputManager():
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, soundIconName = '', 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: if environment['runtime']['brailleDriver'] == None:
return return
print('braille') print('braille')
def interruptOutput(self, environment): def interruptOutput(self, environment):
@ -35,15 +36,14 @@ class outputManager():
def playSoundIcon(self, environment, soundIconName, interrupt=True): def playSoundIcon(self, environment, soundIconName, interrupt=True):
if soundIconName == '': if soundIconName == '':
return return False
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'sound', 'enabled'): if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'sound', 'enabled'):
return return False
if environment['runtime']['soundDriver'] == None: if environment['runtime']['soundDriver'] == None:
return return False
print(soundIconName)
environment['runtime']['soundDriver'].playSoundFile( environment['soundIcons'][soundIconName], interrupt)
try: try:
print(environment['soundIcons'][soundIconName])
environment['runtime']['soundDriver'].playSoundFile(environment['soundIcons'][soundIconName], interrupt) environment['runtime']['soundDriver'].playSoundFile(environment['soundIcons'][soundIconName], interrupt)
return True
except: except:
print('no icon there for' + soundIconName) print('no icon there for' + soundIconName)
return False

View File

@ -5,6 +5,7 @@ runtime = {
'speechDriver': None, 'speechDriver': None,
'screenDriver': None, 'screenDriver': None,
'soundDriver': None, 'soundDriver': None,
'brailleDriver': None,
'inputManager': None, 'inputManager': None,
'commandManager': None, 'commandManager': None,
'debug':None, 'debug':None,

View File

@ -4,12 +4,14 @@ screenData = {
'columns': 0, 'columns': 0,
'lines': 0, 'lines': 0,
'oldDelta': '', 'oldDelta': '',
'oldNegativeDelta': '',
'oldCursorReview':{'x':-1,'y':-1}, 'oldCursorReview':{'x':-1,'y':-1},
'oldCursor':{'x':0,'y':0}, 'oldCursor':{'x':0,'y':0},
'oldContentBytes': b'', 'oldContentBytes': b'',
'oldContentText': '', 'oldContentText': '',
'oldContentAttrib': b'', 'oldContentAttrib': b'',
'newDelta': '', 'newDelta': '',
'newNegativeDelta': '',
'newCursorReview':{'x':-1,'y':-1}, 'newCursorReview':{'x':-1,'y':-1},
'newCursor':{'x':0,'y':0}, 'newCursor':{'x':0,'y':0},
'newContentBytes': b'', 'newContentBytes': b'',

View File

@ -99,7 +99,6 @@ class settingsManager():
if validSoundIcon: if validSoundIcon:
environment['soundIcons'][soundIcon] = FilePath environment['soundIcons'][soundIcon] = FilePath
siConfig.close() siConfig.close()
print(environment['soundIcons'])
return environment return environment
def loadSettings(self, environment, settingConfigPath='../../config/settings/settings.conf'): def loadSettings(self, environment, settingConfigPath='../../config/settings/settings.conf'):

View File

@ -36,7 +36,7 @@ class screen():
environment['screenData']['oldCursor']['y'] = environment['screenData']['newCursor']['y'] environment['screenData']['oldCursor']['y'] = environment['screenData']['newCursor']['y']
environment['screenData']['oldTTY'] = environment['screenData']['newTTY'] environment['screenData']['oldTTY'] = environment['screenData']['newTTY']
environment['screenData']['oldDelta'] = environment['screenData']['newDelta'] environment['screenData']['oldDelta'] = environment['screenData']['newDelta']
environment['screenData']['oldNegativeDelta'] = environment['screenData']['newNegativeDelta']
environment['screenData']['newTTY'] = newTTY environment['screenData']['newTTY'] = newTTY
environment['screenData']['newContentBytes'] = newContentBytes environment['screenData']['newContentBytes'] = newContentBytes
# get metadata like cursor or screensize # get metadata like cursor or screensize
@ -58,6 +58,8 @@ class screen():
environment['screenData']['oldCursor']['y'] = 0 environment['screenData']['oldCursor']['y'] = 0
environment['screenData']['oldDelta'] = '' environment['screenData']['oldDelta'] = ''
environment['screenData']['newDelta'] = '' environment['screenData']['newDelta'] = ''
environment['screenData']['oldNegativeDelta'] = ''
environment['screenData']['newNegativeDelta'] = ''
# changes on the screen # changes on the screen
if (environment['screenData']['oldContentText'] != environment['screenData']['newContentText']) and \ if (environment['screenData']['oldContentText'] != environment['screenData']['newContentText']) and \
@ -75,5 +77,6 @@ class screen():
diff = difflib.ndiff(re.sub('[ \t]+', ' ', environment['screenData']['oldContentText'][diffStart:]),\ diff = difflib.ndiff(re.sub('[ \t]+', ' ', environment['screenData']['oldContentText'][diffStart:]),\
re.sub('[ \t]+', ' ', environment['screenData']['newContentText'][diffStart:])) re.sub('[ \t]+', ' ', environment['screenData']['newContentText'][diffStart:]))
environment['screenData']['newDelta'] = ''.join(x[2:] for x in diff if x.startswith('+ ')) environment['screenData']['newDelta'] = ''.join(x[2:] for x in diff if x.startswith('+ '))
environment['screenData']['newNegativeDelta'] = ''.join(x[2:] for x in diff if x.startswith('- '))
return environment return environment

View File

@ -7,7 +7,7 @@ class sound():
def playFrequence(self, frequence, duration, adjustVolume): def playFrequence(self, frequence, duration, adjustVolume):
pass pass
def playSoundFile(self, filePath, interrupt = True): def playSoundFile(self, filePath, interrupt = True):
subprocess.call("play " + filePath, shell=True) subprocess.call("play -q " + filePath, shell=True)
def cancel(self): def cancel(self):
pass pass
def setCallback(self, callback): def setCallback(self, callback):