add autoReadIncomming, add sound volume, convert volume to 0.0 - 1.0 factor for unification

This commit is contained in:
chrys 2016-08-08 09:34:57 +02:00
parent 152453c232
commit 0e973b6f1d
10 changed files with 27 additions and 12 deletions

6
TODO
View File

@ -1,6 +1,9 @@
ToDos in Priority order: ToDos in Priority order:
- try to consume shortcuts - try to consume shortcuts
- convert volume to percent in config
- convert pitch to percent in config
- convert rate to percent in config
- implement commands - implement commands
set_copy_begin_mark set_copy_begin_mark
@ -23,12 +26,12 @@ https://git.gnome.org/browse/orca/tree/src/orca/braille.py
https://wiki.gnome.org/Attic/LSR/ScratchPad/Braille/BrlAPI https://wiki.gnome.org/Attic/LSR/ScratchPad/Braille/BrlAPI
- add the debugging to core - add the debugging to core
- performance tuning
- make screenUpdate rate configurable - make screenUpdate rate configurable
- configuration should be overwriteable with parameter and alternative paths - configuration should be overwriteable with parameter and alternative paths
- write settings - write settings
- menue for settings configuration - menue for settings configuration
- translateable - translateable
- dictonary for special chars and string replacements
- implement speechdriver generic (say) - implement speechdriver generic (say)
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/System_Administrators_Guide/sect-Managing_Services_with_systemd-Unit_Files.html https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/System_Administrators_Guide/sect-Managing_Services_with_systemd-Unit_Files.html
@ -118,6 +121,7 @@ except KeyboardInterrupt:
http://www.saltycrane.com/blog/2010/04/monitoring-filesystem-python-and-pyinotify/ http://www.saltycrane.com/blog/2010/04/monitoring-filesystem-python-and-pyinotify/
- soundIcons - soundIcons
- performance tuning
- default soundIcon theme (soundfiles) - default soundIcon theme (soundfiles)
- implement commands - implement commands

View File

@ -2,6 +2,7 @@
enabled=True enabled=True
driver=sox driver=sox
theme=default theme=default
volume=1.0
[speech] [speech]
enabled=True enabled=True
@ -11,7 +12,8 @@ pitch=50
module=espeak module=espeak
voice=en-us voice=en-us
language=en-us language=en-us
volume=200 volume=1.0
autoReadIncomming=True
[braille] [braille]
enabled=False enabled=False
@ -21,6 +23,7 @@ layout=en
driver=linux driver=linux
[keyboard] [keyboard]
device=all
keyboardLayout=desktop keyboardLayout=desktop
charEcho=False charEcho=False
charDeleteEcho=True charDeleteEcho=True

View File

@ -4,8 +4,8 @@ class command():
def __init__(self): def __init__(self):
pass pass
def run(self, environment): def run(self, environment):
#if environment['screenData']['newCursor']['x'] > environment['screenData']['oldCursor']['x']: if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'autoReadIncomming'):
# return environment return environment
if environment['screenData']['newTTY'] != environment['screenData']['oldTTY']: if environment['screenData']['newTTY'] != environment['screenData']['oldTTY']:
return environment return environment

View File

@ -21,7 +21,7 @@ class outputManager():
environment['runtime']['speechDriver'].setPitch(environment['runtime']['settingsManager'].getSettingAsInt(environment, 'speech', 'pitch')) 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'].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'].getSettingAsFloat(environment, 'speech', 'volume'))
environment['runtime']['speechDriver'].speak(text) environment['runtime']['speechDriver'].speak(text)
def brailleText(self, environment, text, soundIconName = '', interrupt=True): def brailleText(self, environment, text, soundIconName = '', interrupt=True):
@ -42,6 +42,7 @@ class outputManager():
if environment['runtime']['soundDriver'] == None: if environment['runtime']['soundDriver'] == None:
return False return False
try: try:
environment['runtime']['soundDriver'].setVolume(environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'sound', 'volume'))
environment['runtime']['soundDriver'].playSoundFile(environment['soundIcons'][soundIconName], interrupt) environment['runtime']['soundDriver'].playSoundFile(environment['soundIcons'][soundIconName], interrupt)
return True return True
except: except:

View File

@ -7,6 +7,7 @@ settings = {
'enabled': False, 'enabled': False,
'driver': 'sox', 'driver': 'sox',
'theme': 'default', 'theme': 'default',
'volume':1.0,
}, },
'speech':{ 'speech':{
'enabled': True, 'enabled': True,
@ -16,7 +17,8 @@ settings = {
'module': '', 'module': '',
'voice': 'de', 'voice': 'de',
'language': 'de', 'language': 'de',
'volume': 100 'volume': 1.0,
'autoReadIncomming':True,
}, },
'braille':{ 'braille':{
'enabled': False, 'enabled': False,
@ -31,6 +33,7 @@ settings = {
'punctuationLevel': 1 'punctuationLevel': 1
}, },
'keyboard':{ 'keyboard':{
'device':"all",
'keyboardLayout': "desktop", 'keyboardLayout': "desktop",
'charEcho':False, 'charEcho':False,
'charDeleteEcho':True, 'charDeleteEcho':True,

View File

@ -116,7 +116,7 @@ class settingsManager():
try: try:
value = environment['settings'].get(section, setting) value = environment['settings'].get(section, setting)
except: except:
value = self.settings[section][setting] value = str(self.settings[section][setting])
return value return value
def getSettingAsInt(self, environment, section, setting): def getSettingAsInt(self, environment, section, setting):

View File

@ -15,6 +15,7 @@ class sound:
self._initialized = False self._initialized = False
self._source = None self._source = None
self._sink = None self._sink = None
self.volume = 1
if not _gstreamerAvailable: if not _gstreamerAvailable:
return return
self.init() self.init()
@ -89,7 +90,8 @@ class sound:
return return
self._player.set_state(Gst.State.NULL) self._player.set_state(Gst.State.NULL)
self._pipeline.set_state(Gst.State.NULL) self._pipeline.set_state(Gst.State.NULL)
def setVolume(self, volume):
self.volume = volume
def shutdown(self): def shutdown(self):
global _gstreamerAvailable global _gstreamerAvailable
if not _gstreamerAvailable: if not _gstreamerAvailable:

View File

@ -3,14 +3,16 @@ import subprocess
class sound(): class sound():
def __init__(self): def __init__(self):
pass self.volume = 1.0;
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):
self.proc = subprocess.Popen("play -q " + filePath, shell=True) self.proc = subprocess.Popen("play -q -v " + str(self.volume ) + ' ' + filePath, shell=True)
def cancel(self): def cancel(self):
pass pass
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def setVolume(self, volume):
self.volume = volume
def shutdown(self): def shutdown(self):
pass pass

View File

@ -62,7 +62,7 @@ class speech():
def setVolume(self, volume): def setVolume(self, volume):
if not self._isInitialized: if not self._isInitialized:
return False return False
return self._es.set_parameter(self._es.Parameter().Volume, volume) return self._es.set_parameter(self._es.Parameter().Volume, int(volume * 200))
def shutdown(self): def shutdown(self):
pass pass

View File

@ -79,7 +79,7 @@ class speech():
def setVolume(self, volume): def setVolume(self, volume):
if not self._isInitialized: if not self._isInitialized:
return False return False
self._sd.set_volume(volume) self._sd.set_volume(int(-100 + volume * 200))
def shutdown(self): def shutdown(self):
if not self._isInitialized: if not self._isInitialized: