move env initialisation

This commit is contained in:
chrys 2017-10-21 17:01:02 +02:00
parent 6151533eef
commit ff1394ef7c
5 changed files with 15 additions and 6 deletions

View File

@ -36,6 +36,8 @@ enabled=True
#driver=genericDriver #driver=genericDriver
driver=espeakDriver driver=espeakDriver
# server path for emacspeak
serverPath=
# The rate selects how fast Fenrir will speak. Options range from 0, slowest, to 1.0, fastest. # The rate selects how fast Fenrir will speak. Options range from 0, slowest, to 1.0, fastest.
rate=0.35 rate=0.35

View File

@ -37,6 +37,8 @@ driver=speechdDriver
#driver=espeakDriver #driver=espeakDriver
#driver=genericDriver #driver=genericDriver
# server path for emacspeak
serverPath=/home/chrys/Projekte/emacspeak/servers/espeak
# The rate selects how fast Fenrir will speak. Options range from 0, slowest, to 1.0, fastest. # The rate selects how fast Fenrir will speak. Options range from 0, slowest, to 1.0, fastest.
rate=0.65 rate=0.65

View File

@ -32,11 +32,14 @@ genericFrequencyCommand=play -q -v fenrirVolume -n -c1 synth fenrirDuration sine
# Turn speech on or off: # Turn speech on or off:
enabled=True enabled=True
# Select speech driver, options are speechdDriver (default), genericDriver or espeakDriver: # Select speech driver, options are speechdDriver (default), genericDriver, emacspeak or espeakDriver:
driver=speechdDriver driver=speechdDriver
#driver=espeakDriver #driver=espeakDriver
#driver=genericDriver #driver=genericDriver
#driver=emacspeakDriver
# server path for emacspeak
serverPath=/home/chrys/Projekte/emacspeak/servers/espeak
# The rate selects how fast Fenrir will speak. Options range from 0, slowest, to 1.0, fastest. # The rate selects how fast Fenrir will speak. Options range from 0, slowest, to 1.0, fastest.
rate=0.65 rate=0.65

View File

@ -11,6 +11,7 @@ genericFrequencyCommand=play -q -v fenrirVolume -n -c1 synth fenrirDuration sine
enabled=True enabled=True
driver=speechdDriver driver=speechdDriver
#driver=genericDriver #driver=genericDriver
serverPath=
rate=0.95 rate=0.95
pitch=0.5 pitch=0.5
# Pitch for capital letters # Pitch for capital letters

View File

@ -15,12 +15,12 @@ class driver():
pass pass
def initialize(self, environment): def initialize(self, environment):
self._isInitialized = False self._isInitialized = False
self.env = environment
try: try:
self.server = pexpect.spawnu('tclsh /home/chrys/Projekte/emacspeak/servers/espeak') self.server = pexpect.spawnu('tclsh +' self.env['runtime']['settingsManager'].getSetting('speech', 'serverPath'))
except Exception as e: except Exception as e:
self.env['runtime']['debug'].writeDebugOut('speechDriver:initialize:' + str(e),debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut('speechDriver:initialize:' + str(e),debug.debugLevel.ERROR)
self._isInitialized = True self._isInitialized = True
self.env = environment
def shutdown(self): def shutdown(self):
if self.server: if self.server:
@ -40,6 +40,7 @@ class driver():
#self.server.sendline('tts_say ' + '\"' + text.replace('"', '\\\"') +'\"') #self.server.sendline('tts_say ' + '\"' + text.replace('"', '\\\"') +'\"')
except Exception as e: except Exception as e:
self.env['runtime']['debug'].writeDebugOut('speechDriver:speak:self.server.sendline():' + str(e),debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut('speechDriver:speak:self.server.sendline():' + str(e),debug.debugLevel.ERROR)
def cancel(self): def cancel(self):
if not self._isInitialized: if not self._isInitialized:
return return
@ -47,8 +48,9 @@ class driver():
self.server.sendline('s') self.server.sendline('s')
except Exception as e: except Exception as e:
self.env['runtime']['debug'].writeDebugOut('speechDriver:cancel:self.server.sendline():' + str(e),debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut('speechDriver:cancel:self.server.sendline():' + str(e),debug.debugLevel.ERROR)
def setCallback(self, callback): def setCallback(self, callback):
print('SpeechDummyDriver: setCallback') pass
def clear_buffer(self): def clear_buffer(self):
if not self._isInitialized: if not self._isInitialized:
@ -57,7 +59,6 @@ class driver():
def setVoice(self, voice): def setVoice(self, voice):
if not self._isInitialized: if not self._isInitialized:
return return
#self.server.sendline('s')
def setPitch(self, pitch): def setPitch(self, pitch):
pass pass
@ -69,9 +70,9 @@ class driver():
self.server.sendline('tts_set_speech_rate' + str(int(rate * 500))) self.server.sendline('tts_set_speech_rate' + str(int(rate * 500)))
except Exception as e: except Exception as e:
self.env['runtime']['debug'].writeDebugOut('speechDriver:setRate:self.server.sendline():' + str(e),debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut('speechDriver:setRate:self.server.sendline():' + str(e),debug.debugLevel.ERROR)
def setModule(self, module): def setModule(self, module):
pass pass
def setLanguage(self, language): def setLanguage(self, language):
if not self._isInitialized: if not self._isInitialized:
return return