respect speech settings

This commit is contained in:
chrys 2016-07-14 23:25:33 +02:00
parent d9f8229aa5
commit 6f6ab0c68e
7 changed files with 33 additions and 12 deletions

View File

@ -7,10 +7,11 @@ theme=default
[speech]
enabled=True
driver=speechd
rate=1
rate=100
pitch=1
module=
module=espeak
voice=de
language=de
[braille]
enabled=False

View File

@ -6,7 +6,7 @@ class command():
def run(self, environment):
if environment['screenData']['newDelta'] != environment['screenData']['oldDelta'] or \
environment['screenData']['newTTY'] != environment['screenData']['oldTTY']:
environment['runtime']['speechDriver'].speak(environment['screenData']['newDelta'])
environment['runtime']['outputManager'].speakText(environment, environment['screenData']['newDelta'])
return environment
def setCallback(self, callback):
pass

View File

@ -14,21 +14,19 @@ class inputManager():
try:
r, w, x = select(self.devices, [], [])
environment['runtime']['globalLock'].acquire(True)
currShortcut = environment['input']['currShortcut']
if r != []:
for fd in r:
for event in self.devices[fd].read():
if event.type == evdev.ecodes.EV_KEY:
if event.value != 0:
currShortcut[str(event.code)] = event.value
environment['input']['currShortcut'][str(event.code)] = event.value
else:
try:
del(currShortcut[str(event.code)])
del(environment['input']['currShortcut'][str(event.code)])
except:
pass
except:
pass
environment['input']['currShortcut'] = currShortcut
environment['input']['currShortcutString'] = self.getShortcutString(environment)
return environment

View File

@ -14,6 +14,12 @@ class outputManager():
return
if Interrupt:
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'].setModule(environment['runtime']['settingsManager'].getSetting(environment, 'speech', 'module'))
environment['runtime']['speechDriver'].speak(Text)
def brailleText(self, environment, Text):
@ -23,5 +29,7 @@ class outputManager():
def interruptOutput(self, environment):
environment['runtime']['speechDriver'].cancel()
def playSoundIcon(self, environment, Text):
pass
def playSoundIcon(self, environment, IconName):
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'sound', 'enabled'):
return
print(IconName)

View File

@ -83,6 +83,9 @@ class settingsManager():
def getSettingAsInt(self, environment, section, setting):
return int(self.getSetting( environment, section, setting))
def getSettingAsFloat(self, environment, section, setting):
return float(self.getSetting( environment, section, setting))
def getSettingAsBool(self, environment, section, setting):
return bool(self.getSetting(environment, section, setting))

View File

@ -38,7 +38,7 @@ class speech():
def setVoice(self, voice):
if not self._isInitialized:
return False
return _es.set_voice('de')
return _es.set_voice(voice)
def setPitch(self, pitch):
if not self._isInitialized:
@ -51,7 +51,13 @@ class speech():
return _es.set_parameter(espeak.Parameter.Rate, speed)
def setModule(self, module):
pass
if not self._isInitialized:
return False
def setLanguage(self, language):
if not self._isInitialized:
return False
return _es.set_voice(voice)
def shutdown(self):
pass

View File

@ -71,6 +71,11 @@ class speech():
except:
return False
def setLanguage(self, language):
if not self._isInitialized:
return False
self._sd.set_language(language)
def shutdown(self):
if not self._isInitialized:
return False