From f51a5967eb87936e08aa3d6388ddf945b1e04b30 Mon Sep 17 00:00:00 2001 From: chrys Date: Mon, 8 Aug 2016 11:07:40 +0200 Subject: [PATCH] unify pitch and rate with a value 0.0 - 1.0 in config --- TODO | 5 +++-- config/settings/settings.conf | 4 ++-- src/fenrir-package/core/outputManager.py | 12 ++++++------ src/fenrir-package/core/settings.py | 6 +++--- src/fenrir-package/speech/espeak.py | 4 ++-- src/fenrir-package/speech/speechd.py | 4 ++-- 6 files changed, 18 insertions(+), 17 deletions(-) diff --git a/TODO b/TODO index 15390b4e..c7514671 100644 --- a/TODO +++ b/TODO @@ -1,8 +1,6 @@ ToDos in Priority order: - try to consume shortcuts -- convert pitch to percent in config -- convert rate to percent in config - implement commands set_copy_begin_mark @@ -123,6 +121,9 @@ except KeyboardInterrupt: - performance tuning - add sound volume - convert volume to percent in config +- convert pitch to percent in config +- convert rate to percent in config + - default soundIcon theme (soundfiles) - implement commands curr_word diff --git a/config/settings/settings.conf b/config/settings/settings.conf index 63b0d4b0..cdf317e9 100644 --- a/config/settings/settings.conf +++ b/config/settings/settings.conf @@ -7,8 +7,8 @@ volume=1.0 [speech] enabled=True driver=espeak -rate=800 -pitch=50 +rate=0.75 +pitch=0.5 module=espeak voice=en-us language=en-us diff --git a/src/fenrir-package/core/outputManager.py b/src/fenrir-package/core/outputManager.py index 0a75f112..cb04aa0e 100644 --- a/src/fenrir-package/core/outputManager.py +++ b/src/fenrir-package/core/outputManager.py @@ -7,7 +7,7 @@ class outputManager(): if self.playSoundIcon(environment, soundIconName, interrupt): return self.speakText(environment, text, interrupt) - self.brailleText(environment, text) + self.brailleText(environment, text, interrupt) def speakText(self, environment, text, interrupt=True): if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'enabled'): @@ -18,23 +18,23 @@ class outputManager(): self.interruptOutput(environment) 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'].setPitch(environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'speech', 'pitch')) + environment['runtime']['speechDriver'].setSpeed(environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'speech', 'rate')) environment['runtime']['speechDriver'].setModule(environment['runtime']['settingsManager'].getSetting(environment, 'speech', 'module')) environment['runtime']['speechDriver'].setVolume(environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'speech', 'volume')) environment['runtime']['speechDriver'].speak(text) - def brailleText(self, environment, text, soundIconName = '', interrupt=True): + def brailleText(self, environment, text, interrupt=True): if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'braille', 'enabled'): return if environment['runtime']['brailleDriver'] == None: return - print('braille') + print('braille:'+text) def interruptOutput(self, environment): environment['runtime']['speechDriver'].cancel() environment['runtime']['soundDriver'].cancel() - def playSoundIcon(self, environment, soundIconName, interrupt=True): + def playSoundIcon(self, environment, soundIconName = '', interrupt=True): if soundIconName == '': return False if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'sound', 'enabled'): diff --git a/src/fenrir-package/core/settings.py b/src/fenrir-package/core/settings.py index 6e0dfe8e..4e7d750e 100644 --- a/src/fenrir-package/core/settings.py +++ b/src/fenrir-package/core/settings.py @@ -12,8 +12,8 @@ settings = { 'speech':{ 'enabled': True, 'driver':'speechd', - 'rate': 1, - 'pitch': 1, + 'rate': 0.75, + 'pitch': 0.5, 'module': '', 'voice': 'de', 'language': 'de', @@ -30,7 +30,7 @@ settings = { 'general':{ 'keyboardLayout': "desktop", 'debugLevel': debug.debugLevel.DEACTIVE, - 'punctuationLevel': 1 + 'punctuationLevel': 1, }, 'keyboard':{ 'device':"all", diff --git a/src/fenrir-package/speech/espeak.py b/src/fenrir-package/speech/espeak.py index d008cd14..37a82ee1 100644 --- a/src/fenrir-package/speech/espeak.py +++ b/src/fenrir-package/speech/espeak.py @@ -43,12 +43,12 @@ class speech(): def setPitch(self, pitch): if not self._isInitialized: return False - return self._es.set_parameter(self._es.Parameter().Pitch, pitch) + return self._es.set_parameter(self._es.Parameter().Pitch, int(pitch * 99)) def setSpeed(self, speed): if not self._isInitialized: return False - return self._es.set_parameter(self._es.Parameter().Rate, speed) + return self._es.set_parameter(self._es.Parameter().Rate, int(speed*450 + 80)) def setModule(self, module): if not self._isInitialized: diff --git a/src/fenrir-package/speech/speechd.py b/src/fenrir-package/speech/speechd.py index 7d4fbdc1..d1ed470e 100644 --- a/src/fenrir-package/speech/speechd.py +++ b/src/fenrir-package/speech/speechd.py @@ -48,7 +48,7 @@ class speech(): if not self._isInitialized: return False try: - self._sd.set_pitch(pitch) + self._sd.set_pitch(int(-100 + pitch * 200)) return True except: return False @@ -57,7 +57,7 @@ class speech(): if not self._isInitialized: return False try: - self._sd.set_rate(speed) + self._sd.set_rate(int(-100 + speed * 200)) return True except: return False