Centralize settings for executable based TTS systems.

The configuration values for executable based TTS systems is stored in member
variables. Instead of reading them multiple times provide a function for that
and move searching the executable to the loading function.

Previously the executable was only searched in the path when opening the TTS
configuration. Having this in the loading function removes that unnecessary
step in case the TTS is in the path (and doesn't require additional
configuration).

Change-Id: I06799b55545dcb719ee3c916795b20e01c248a15
This commit is contained in:
Dominik Riebeling 2012-01-29 15:36:52 +01:00
parent 0ae49c2719
commit 4105c82e6b
2 changed files with 19 additions and 13 deletions

View file

@ -37,13 +37,11 @@ TTSBase::Capabilities TTSExes::capabilities()
void TTSExes::generateSettings() void TTSExes::generateSettings()
{ {
QString exepath =RbSettings::subValue(m_name,RbSettings::TtsPath).toString(); loadSettings();
if(exepath == "") exepath = Utils::findExecutable(m_name); insertSetting(eEXEPATH, new EncTtsSetting(this, EncTtsSetting::eSTRING,
tr("Path to TTS engine:"), m_TTSexec, EncTtsSetting::eBROWSEBTN));
insertSetting(eEXEPATH,new EncTtsSetting(this,EncTtsSetting::eSTRING, insertSetting(eOPTIONS, new EncTtsSetting(this, EncTtsSetting::eSTRING,
tr("Path to TTS engine:"),exepath,EncTtsSetting::eBROWSEBTN)); tr("TTS engine options:"), m_TTSOpts));
insertSetting(eOPTIONS,new EncTtsSetting(this,EncTtsSetting::eSTRING,
tr("TTS engine options:"),RbSettings::subValue(m_name,RbSettings::TtsOptions)));
} }
void TTSExes::saveSettings() void TTSExes::saveSettings()
@ -55,11 +53,18 @@ void TTSExes::saveSettings()
RbSettings::sync(); RbSettings::sync();
} }
bool TTSExes::start(QString *errStr)
void TTSExes::loadSettings(void)
{ {
m_TTSexec = RbSettings::subValue(m_name,RbSettings::TtsPath).toString(); m_TTSexec = RbSettings::subValue(m_name,RbSettings::TtsPath).toString();
if(m_TTSexec.isEmpty()) m_TTSexec = Utils::findExecutable(m_name);
m_TTSOpts = RbSettings::subValue(m_name,RbSettings::TtsOptions).toString(); m_TTSOpts = RbSettings::subValue(m_name,RbSettings::TtsOptions).toString();
}
bool TTSExes::start(QString *errStr)
{
loadSettings();
m_TTSTemplate = m_TemplateMap.value(m_name); m_TTSTemplate = m_TemplateMap.value(m_name);
QFileInfo tts(m_TTSexec); QFileInfo tts(m_TTSexec);
@ -96,10 +101,10 @@ TTSStatus TTSExes::voice(QString text,QString wavfile, QString *errStr)
bool TTSExes::configOk() bool TTSExes::configOk()
{ {
QString path = RbSettings::subValue(m_name,RbSettings::TtsPath).toString(); loadSettings();
if (QFileInfo(m_TTSexec).exists())
if (QFileInfo(path).exists())
return true; return true;
else
return false; return false;
} }

View file

@ -46,6 +46,7 @@ class TTSExes : public TTSBase
bool configOk(); bool configOk();
private: private:
void loadSettings(void);
QString m_name; QString m_name;
QString m_TTSexec; QString m_TTSexec;
QString m_TTSOpts; QString m_TTSOpts;