Skip to content

Commit

Permalink
version 19.8B3
Browse files Browse the repository at this point in the history
add support for speech change commands.
update now volume, rate and speed default parameters are send at start of speak method on ibmeci.
delete getVParam and setVParam methods from ibmeci
delete parameters sends on _ibmeci, its needed to implement speech commands correctly.
update MIN_RATE was changed from 0 to 40
update now settings are set in the base profile only.
  • Loading branch information
davidacm committed Aug 25, 2019
1 parent ab3683f commit 8daeb77
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 128 deletions.
10 changes: 5 additions & 5 deletions addon/globalPlugins/ibmtts.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def makeSettings(self, settingsSizer):
self._setValues()

def _setValues(self):
self._ttsPath.SetValue(config.conf['ibmeci']['TTSPath'])
self._dllName.SetValue(config.conf['ibmeci']['dllName'])
self._ttsPath.SetValue(config.conf.profiles[0]['ibmeci']['TTSPath'])
self._dllName.SetValue(config.conf.profiles[0]['ibmeci']['dllName'])

def _onBrowseClick(self, evt):
# Translators: The message displayed in the dialog that allows you to look for the IBMTTS library.
Expand Down Expand Up @@ -94,7 +94,7 @@ def _onSetLocalClick(self, evt):
if res:
self._ttsPath.SetValue("ibmtts")
# this parameter is saved even if the user doesn't click accept button.
config.conf['ibmeci']['TTSPath'] = self._ttsPath.GetValue()
config.conf.profiles[0]['ibmeci']['TTSPath'] = self._ttsPath.GetValue()
# Translators: The message displayed when copying IBMTTS files to Add-on was successful.
gui.messageBox(_("Successfully copied IBMTTS files. The local copy will be used after restart NVDA."),
# Translators: The title displayed when copying IBMTTS files to Add-on was successful.
Expand All @@ -118,8 +118,8 @@ def copyTtsFiles(self):
installer.tryCopyFile(sourceFilePath,destFilePath)

def onSave(self):
config.conf['ibmeci']['dllName'] = self._dllName.GetValue()
config.conf['ibmeci']['TTSPath'] = self._ttsPath.GetValue()
config.conf.profiles[0]['ibmeci']['dllName'] = self._dllName.GetValue()
config.conf.profiles[0]['ibmeci']['TTSPath'] = self._ttsPath.GetValue()


class GlobalPlugin(globalPluginHandler.GlobalPlugin):
Expand Down
1 change: 1 addition & 0 deletions addon/installTasks.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: UTF-8 -*-
#Copyright (C) 2009 - 2019 David CM, released under the GPL.
# Author: David CM <dhf360@gmail.com> and others.
# note: this file doesn't get settings from the base profile to avoid issues when updating from older versions.

from synthDrivers import _settingsDB
import config, gui, os, wx, addonHandler
Expand Down
82 changes: 43 additions & 39 deletions addon/synthDrivers/_ibmeci.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ class ECIParam:
class ECIVoiceParam:
params = range(1,8)
eciGender, eciHeadSize, eciPitchBaseline, eciPitchFluctuation, eciRoughness, eciBreathiness, eciSpeed, eciVolume = range(8)



class ECIDictVolume:
eciMainDict, eciRootDict, eciAbbvDict, eciMainDictExt = range(4)

Expand All @@ -46,59 +45,63 @@ class ECIMessage:
class ECICallbackReturn:
eciDataNotProcessed, eciDataProcessed, eciDataAbort= range(3)

# constants
samples=3300
user32 = windll.user32
WM_PROCESS = 1025
WM_SILENCE = 1026
WM_PARAM = 1027
WM_VPARAM=1028
WM_COPYVOICE=1029
WM_KILL=1030
WM_SYNTH=1031
WM_INDEX=1032

langs={
'esp': (131072, _('Castilian Spanish'), 'es_ES', 'es'),
'esm': (131073, _('Latin American Spanish'), 'es_ME', 'es_CO'),
'ptb': (458752, _('Brazilian Portuguese'), 'pt_BR', 'pt'),
'fra': (196608, _('French'), 'fr_FR', 'fr'),
'frc': (196609, _('French Canadian'), 'fr_CA', ''),
'fin': (589824, _('Finnish'), 'fi_FI', 'fi'),
'chs': (393216, _('Chinese'), 'zh_GB', 'zh'),
'jpn': (524288, _('Japanese'), 'ja_JA', 'jp'),
'kor': (655360, _('Korean'), 'ko_KO', 'ko'),
'deu': (262144, _('German'), 'de_DE', 'de'),
'ita': (327680, _('Italian'), 'it_IT', 'it'),
'enu': (65536, _('American English'), 'en_US', 'en'),
'eng': (65537, _('British English'), 'en_UK', '')
}

audioStream = BytesIO()
speaking=False
eciThread = None
callbackQueue = None
callbackThread = None
eciQueue = None
eciThreadId = None
callbackThread = None
callbackQueue = None
idleTimer = None
onIndexReached = None
onDoneSpeaking = None

samples=3300
buffer = create_string_buffer(samples*2)
idleTimer = None


stopped = threading.Event()
started = threading.Event()
param_event = threading.Event()


lastindex=0
langs={'esp': (131072, _('Castilian Spanish'), 'es_ES', 'es'),
'esm': (131073, _('Latin American Spanish'), 'es_ME', 'es_CO'),
'ptb': (458752, _('Brazilian Portuguese'), 'pt_BR', 'pt'),
'fra': (196608, _('French'), 'fr_FR', 'fr'),
'frc': (196609, _('French Canadian'), 'fr_CA', ''),
'fin': (589824, _('Finnish'), 'fi_FI', 'fi'),
'chs': (393216, _('Chinese'), 'zh_GB', 'zh'),
'jpn': (524288, _('Japanese'), 'ja_JA', 'jp'),
'kor': (655360, _('Korean'), 'ko_KO', 'ko'),
'deu': (262144, _('German'), 'de_DE', 'de'),
'ita': (327680, _('Italian'), 'it_IT', 'it'),
'enu': (65536, _('American English'), 'en_US', 'en'),
'eng': (65537, _('British English'), 'en_UK', '')}

avLangs=0
ttsPath=""
dllName=""
WM_PROCESS = 1025
WM_SILENCE = 1026
WM_PARAM = 1027
WM_VPARAM=1028
WM_COPYVOICE=1029
WM_KILL=1030
WM_SYNTH=1031
WM_INDEX=1032
params = {}
vparams = {}

#We can only have one of each in NVDA. Make this global
dll = None
handle = None

params = {}
vparams = {}


class EciThread(threading.Thread):
def run(self):
global vparams, params, speaking, endMarkersCount
Expand Down Expand Up @@ -170,13 +173,12 @@ def processEciQueue():

def eciCheck():
global ttsPath, dllName, dll
dllName = config.conf['ibmeci']['dllName']
ttsPath = config.conf['ibmeci']['TTSPath']
dllName = config.conf.profiles[0]['ibmeci']['dllName']
ttsPath = config.conf.profiles[0]['ibmeci']['TTSPath']

if not path.isabs(ttsPath):
ttsPath = path.join(path.abspath(path.dirname(__file__)), ttsPath)
if path.exists(ttsPath): iniCheck()
print (ttsPath, path.exists(ttsPath))
if not path.exists(ttsPath): return False
if dll: return True
try:
Expand Down Expand Up @@ -216,6 +218,7 @@ def eciNew():
def _callbackExec(func, *args, **kwargs):
global callbackQueue
callbackQueue.put((func, args, kwargs))

def setLast(lp):
global lastindex
lastindex = lp
Expand Down Expand Up @@ -305,9 +308,10 @@ def initialize(indexCallback, doneCallback):
callbackThread.start()

def speak(text):
#Sometimes the synth slows down for one string of text. Why?
#Trying to fix it here.
if ECIVoiceParam.eciSpeed in vparams: text = b"`vs%d%s" % (vparams[ECIVoiceParam.eciSpeed], text)
# deleted the following fix because is incompatible with NVDA's speech change command. Now send it from speak in ibmeci.py
#Sometimes the synth slows down for one string of text. Why?
#Trying to fix it here.
# if ECIVoiceParam.eciSpeed in vparams: text = b"`vs%d%s" % (vparams[ECIVoiceParam.eciSpeed], text)
dll.eciAddText(handle, text)

def index(x):
Expand Down
9 changes: 8 additions & 1 deletion addon/synthDrivers/_settingsDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,11 @@
"dllName": "string(default='eci.dll')",
"TTSPath": "string(default='ibmtts')"
}
config.conf.spec["ibmeci"]=confspec
config.conf.spec["ibmeci"]=confspec

def setConfig():
d=config.conf['ibmeci'].dict()
if 'ibmeci' not in config.conf.profiles[0]: config.conf.profiles[0]['ibmeci'] = d
if 'TTSPath' not in config.conf.profiles[0]['ibmeci']: config.conf.profiles[0]['ibmeci']['TTSPath'] = d['TTSPath']
if 'dllName' not in config.conf.profiles[0]['ibmeci']: config.conf.profiles[0]['ibmeci']['dllName'] = d['dllName']
setConfig()
Loading

0 comments on commit 8daeb77

Please sign in to comment.