Merge branch 'voice'

This commit is contained in:
chrys 2019-02-26 20:47:07 +01:00
commit 16d657e761
5 changed files with 38 additions and 23 deletions

View File

@ -53,16 +53,17 @@ volume=1.0
# Module is used for Speech-dispatcher, to select the speech module you want to use.
# Consult Speech-dispatcher's configuration and help Fenrir find out which modules are available.
# The default is espeak.
# The default is specified in speechd.conf.
#module=espeak
# Voice selects the varient you want to use, for example, f5 will use the female voice #5 in Espeak,
# or if using the Espeak module in Speech-dispatcher. To find out which voices are available, consult the documentation provided with your selected synthesizer.
# Voice selects the voice you want to use, for example, en-GB-scotland will use the Scotish English voice in Espeak,
# To find out which voices are available, consult the documentation provided with your selected synthesizer.
# This also sets the voice used in the generic driver.
voice=en-us
# You can add a variant by adding +name onto the end.
# voice=en-us
# Select the language you want Fenrir to use.
#language=english-us
#language=en
# Read new text as it happens?
autoReadIncoming=True

View File

@ -135,7 +135,12 @@ class outputManager():
else:
displayText = self.getBrailleTextWithOffset(self.env['output']['messageText'], self.env['output']['messageOffset'])
self.env['runtime']['brailleDriver'].writeText('flush'+displayText)
def resetSpeechDriver(self):
try:
self.env['runtime']['speechDriver'].reset()
except Exception as e:
self.env['runtime']['debug'].writeDebugOut("reset " + str(e),debug.debugLevel.ERROR)
def getBrailleCursor(self):
if self.env['runtime']['settingsManager'].getSetting('braille', 'cursorFollowMode').upper() == 'REVIEW':
return self.env['runtime']['cursorManager'].getReviewOrTextCursor()

View File

@ -199,6 +199,7 @@ class settingsManager():
self.env['input']['scriptKey'].append(key)
def resetSettingArgDict(self):
self.settingArgDict = {}
self.env['runtime']['outputManager'].resetSpeechDriver()
def setOptionArgDict(self, section, setting, value):
#section = section.lower()
#setting = setting.lower()

View File

@ -8,6 +8,8 @@ from fenrirscreenreader.core import debug
class speechDriver():
def __init__(self):
pass
def initialize(self, environment):
self._isInitialized = False
self.language = None
self.voice = None
@ -15,14 +17,12 @@ class speechDriver():
self.pitch = None
self.rate = None
self.volume = None
def initialize(self, environment):
self.env = environment
self._isInitialized = True
self._isInitialized = True
def shutdown(self):
if self._isInitialized:
self.cancel()
self._isInitialized = False
self._isInitialized = False
def speak(self,text, queueable=True):
if not self._isInitialized:
@ -32,11 +32,11 @@ class speechDriver():
def cancel(self):
if not self._isInitialized:
return
return
def setCallback(self, callback):
if not self._isInitialized:
return
return
if not callback:
return
@ -48,7 +48,7 @@ class speechDriver():
if not self._isInitialized:
return
if voice == '':
return
return
self.voice = voice
def setPitch(self, pitch):
@ -77,16 +77,18 @@ class speechDriver():
if not isinstance(module, str):
return
if module == '':
return
return
self.module = module
def reset(self):
self.shutdown()
self.initialize(self.env)
def setLanguage(self, language):
if not self._isInitialized:
return
if not isinstance(language, str):
return
if language == '':
return
return
self.language = language
def setVolume(self, volume):
if not self._isInitialized:

View File

@ -11,10 +11,14 @@ from fenrirscreenreader.core.speechDriver import speechDriver
class driver(speechDriver):
def __init__(self):
speechDriver.__init__(self)
self._sd = None
def initialize(self, environment):
self._sd = None
self.env = environment
self._isInitialized = False
self.language = ''
self.voice = ''
self.module = ''
try:
import speechd
self._sd = speechd.SSIPClient('fenrir')
@ -29,7 +33,7 @@ class driver(speechDriver):
self.cancel()
try:
self._sd.close()
except:
except Exception as e:
pass
self._isInitialized = False
@ -44,7 +48,8 @@ class driver(speechDriver):
return
try:
self._sd.set_output_module(self.module)
if self.module != '':
self._sd.set_output_module(self.module)
except Exception as e:
self.env['runtime']['debug'].writeDebugOut('speechDriver setModule:' + str(e),debug.debugLevel.ERROR)
@ -55,9 +60,8 @@ class driver(speechDriver):
self.env['runtime']['debug'].writeDebugOut('speechDriver set_language:' + str(e),debug.debugLevel.ERROR)
try:
if self.voice:
if self.voice != '':
self._sd.set_synthesis_voice(self.voice)
if self.voice != '':
self._sd.set_synthesis_voice(self.voice)
except Exception as e:
self.env['runtime']['debug'].writeDebugOut('speechDriver setVoice:' + str(e),debug.debugLevel.ERROR)
@ -74,7 +78,9 @@ class driver(speechDriver):
def cancel(self):
if not self._isInitialized:
return
self.initialize(self.env)
if not self._isInitialized:
return
try:
self._sd.cancel()
except Exception as e: