From 0e973b6f1d9023ed6943bbdf705879b7e17210a2 Mon Sep 17 00:00:00 2001 From: chrys Date: Mon, 8 Aug 2016 09:34:57 +0200 Subject: [PATCH] add autoReadIncomming, add sound volume, convert volume to 0.0 - 1.0 factor for unification --- TODO | 6 +++++- config/settings/settings.conf | 5 ++++- .../commands/onScreenChanged/70000-incomming.py | 4 ++-- src/fenrir-package/core/outputManager.py | 3 ++- src/fenrir-package/core/settings.py | 5 ++++- src/fenrir-package/core/settingsManager.py | 2 +- src/fenrir-package/sound/gstreamer.py | 4 +++- src/fenrir-package/sound/sox.py | 6 ++++-- src/fenrir-package/speech/espeak.py | 2 +- src/fenrir-package/speech/speechd.py | 2 +- 10 files changed, 27 insertions(+), 12 deletions(-) diff --git a/TODO b/TODO index ae5a104d..6cbdd356 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,9 @@ ToDos in Priority order: - try to consume shortcuts +- convert volume to percent in config +- convert pitch to percent in config +- convert rate to percent in config - implement commands 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 - add the debugging to core -- performance tuning - make screenUpdate rate configurable - configuration should be overwriteable with parameter and alternative paths - write settings - menue for settings configuration - translateable +- dictonary for special chars and string replacements - 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 @@ -118,6 +121,7 @@ except KeyboardInterrupt: http://www.saltycrane.com/blog/2010/04/monitoring-filesystem-python-and-pyinotify/ - soundIcons +- performance tuning - default soundIcon theme (soundfiles) - implement commands diff --git a/config/settings/settings.conf b/config/settings/settings.conf index 7ee045d7..63b0d4b0 100644 --- a/config/settings/settings.conf +++ b/config/settings/settings.conf @@ -2,6 +2,7 @@ enabled=True driver=sox theme=default +volume=1.0 [speech] enabled=True @@ -11,7 +12,8 @@ pitch=50 module=espeak voice=en-us language=en-us -volume=200 +volume=1.0 +autoReadIncomming=True [braille] enabled=False @@ -21,6 +23,7 @@ layout=en driver=linux [keyboard] +device=all keyboardLayout=desktop charEcho=False charDeleteEcho=True diff --git a/src/fenrir-package/commands/onScreenChanged/70000-incomming.py b/src/fenrir-package/commands/onScreenChanged/70000-incomming.py index 9eb83367..2fb5f690 100644 --- a/src/fenrir-package/commands/onScreenChanged/70000-incomming.py +++ b/src/fenrir-package/commands/onScreenChanged/70000-incomming.py @@ -4,8 +4,8 @@ class command(): def __init__(self): pass def run(self, environment): - #if environment['screenData']['newCursor']['x'] > environment['screenData']['oldCursor']['x']: - # return environment + if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'autoReadIncomming'): + return environment if environment['screenData']['newTTY'] != environment['screenData']['oldTTY']: return environment diff --git a/src/fenrir-package/core/outputManager.py b/src/fenrir-package/core/outputManager.py index d26d9993..0a75f112 100644 --- a/src/fenrir-package/core/outputManager.py +++ b/src/fenrir-package/core/outputManager.py @@ -21,7 +21,7 @@ class outputManager(): 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')) - 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) def brailleText(self, environment, text, soundIconName = '', interrupt=True): @@ -42,6 +42,7 @@ class outputManager(): if environment['runtime']['soundDriver'] == None: return False try: + environment['runtime']['soundDriver'].setVolume(environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'sound', 'volume')) environment['runtime']['soundDriver'].playSoundFile(environment['soundIcons'][soundIconName], interrupt) return True except: diff --git a/src/fenrir-package/core/settings.py b/src/fenrir-package/core/settings.py index 5c3fec4e..6e0dfe8e 100644 --- a/src/fenrir-package/core/settings.py +++ b/src/fenrir-package/core/settings.py @@ -7,6 +7,7 @@ settings = { 'enabled': False, 'driver': 'sox', 'theme': 'default', + 'volume':1.0, }, 'speech':{ 'enabled': True, @@ -16,7 +17,8 @@ settings = { 'module': '', 'voice': 'de', 'language': 'de', - 'volume': 100 + 'volume': 1.0, + 'autoReadIncomming':True, }, 'braille':{ 'enabled': False, @@ -31,6 +33,7 @@ settings = { 'punctuationLevel': 1 }, 'keyboard':{ + 'device':"all", 'keyboardLayout': "desktop", 'charEcho':False, 'charDeleteEcho':True, diff --git a/src/fenrir-package/core/settingsManager.py b/src/fenrir-package/core/settingsManager.py index a07318cc..50a1fc7a 100644 --- a/src/fenrir-package/core/settingsManager.py +++ b/src/fenrir-package/core/settingsManager.py @@ -116,7 +116,7 @@ class settingsManager(): try: value = environment['settings'].get(section, setting) except: - value = self.settings[section][setting] + value = str(self.settings[section][setting]) return value def getSettingAsInt(self, environment, section, setting): diff --git a/src/fenrir-package/sound/gstreamer.py b/src/fenrir-package/sound/gstreamer.py index f6906bb5..d9912c85 100644 --- a/src/fenrir-package/sound/gstreamer.py +++ b/src/fenrir-package/sound/gstreamer.py @@ -15,6 +15,7 @@ class sound: self._initialized = False self._source = None self._sink = None + self.volume = 1 if not _gstreamerAvailable: return self.init() @@ -89,7 +90,8 @@ class sound: return self._player.set_state(Gst.State.NULL) self._pipeline.set_state(Gst.State.NULL) - + def setVolume(self, volume): + self.volume = volume def shutdown(self): global _gstreamerAvailable if not _gstreamerAvailable: diff --git a/src/fenrir-package/sound/sox.py b/src/fenrir-package/sound/sox.py index 3a3eca5f..24cec2fe 100644 --- a/src/fenrir-package/sound/sox.py +++ b/src/fenrir-package/sound/sox.py @@ -3,14 +3,16 @@ import subprocess class sound(): def __init__(self): - pass + self.volume = 1.0; def playFrequence(self, frequence, duration, adjustVolume): pass 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): pass def setCallback(self, callback): pass + def setVolume(self, volume): + self.volume = volume def shutdown(self): pass diff --git a/src/fenrir-package/speech/espeak.py b/src/fenrir-package/speech/espeak.py index 1386d201..d008cd14 100644 --- a/src/fenrir-package/speech/espeak.py +++ b/src/fenrir-package/speech/espeak.py @@ -62,7 +62,7 @@ class speech(): def setVolume(self, volume): if not self._isInitialized: 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): pass diff --git a/src/fenrir-package/speech/speechd.py b/src/fenrir-package/speech/speechd.py index 7a7c7802..7d4fbdc1 100644 --- a/src/fenrir-package/speech/speechd.py +++ b/src/fenrir-package/speech/speechd.py @@ -79,7 +79,7 @@ class speech(): def setVolume(self, volume): if not self._isInitialized: return False - self._sd.set_volume(volume) + self._sd.set_volume(int(-100 + volume * 200)) def shutdown(self): if not self._isInitialized: