summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2012-09-09 11:20:33 +0200
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2012-09-09 12:07:51 +0200
commit6be7dabdd952ef114941affca0e16ce8470595d3 (patch)
treec3a64a0b7092df7ee5d4ec1abef6ee604ad580fc
parent4a9ba12ca79a2b5cf13499821b84ba5b64defbe7 (diff)
downloadrockbox-6be7dabdd952ef114941affca0e16ce8470595d3.tar.gz
rockbox-6be7dabdd952ef114941affca0e16ce8470595d3.tar.bz2
rockbox-6be7dabdd952ef114941affca0e16ce8470595d3.zip
Make SAPI implementation more parametrizable.
Move command line template for listing voices and generation into protected member variables and initialize them in the constructor. This allows derived classes to overwrite these, allowing to change the command line call. Make the name used for storing the classes values to the configuration parametrize at all. Remove SAPI4 support, this will be handled in a derived class later. Change-Id: Ib5a261c56cdf93a44fffdfa6edea409d89fd84ba
-rw-r--r--rbutil/rbutilqt/base/ttssapi.cpp62
-rw-r--r--rbutil/rbutilqt/base/ttssapi.h7
2 files changed, 35 insertions, 34 deletions
diff --git a/rbutil/rbutilqt/base/ttssapi.cpp b/rbutil/rbutilqt/base/ttssapi.cpp
index 666b101266..603e7c5559 100644
--- a/rbutil/rbutilqt/base/ttssapi.cpp
+++ b/rbutil/rbutilqt/base/ttssapi.cpp
@@ -23,10 +23,11 @@
TTSSapi::TTSSapi(QObject* parent) : TTSBase(parent)
{
- m_TTSTemplate = "cscript //nologo \"%exe\" /language:%lang /voice:\"%voice\""
- " /speed:%speed \"%options\"";
+ m_TTSTemplate = "cscript //nologo \"%exe\" /language:%lang "
+ "/voice:\"%voice\" /speed:%speed \"%options\"";
+ m_TTSVoiceTemplate = "cscript //nologo \"%exe\" /language:%lang /listvoices";
+ m_TTSType = "sapi";
defaultLanguage = "english";
- m_sapi4 = false;
m_started = false;
}
@@ -43,40 +44,44 @@ void TTSSapi::generateSettings()
for(int i = 0; i < languages.values().size(); ++i) {
langs.append(languages.values().at(i).at(0));
}
- EncTtsSetting* setting =new EncTtsSetting(this,EncTtsSetting::eSTRINGLIST,
- tr("Language:"),RbSettings::subValue("sapi",RbSettings::TtsLanguage),
- langs);
+ EncTtsSetting* setting = new EncTtsSetting(this,
+ EncTtsSetting::eSTRINGLIST, tr("Language:"),
+ RbSettings::subValue(m_TTSType, RbSettings::TtsLanguage),
+ langs);
connect(setting,SIGNAL(dataChanged()),this,SLOT(updateVoiceList()));
insertSetting(eLANGUAGE,setting);
// voice
- setting = new EncTtsSetting(this,EncTtsSetting::eSTRINGLIST,
- tr("Voice:"),RbSettings::subValue("sapi",RbSettings::TtsVoice),
- getVoiceList(RbSettings::subValue("sapi",RbSettings::TtsLanguage).toString()),
- EncTtsSetting::eREFRESHBTN);
+ setting = new EncTtsSetting(this,
+ EncTtsSetting::eSTRINGLIST, tr("Voice:"),
+ RbSettings::subValue(m_TTSType, RbSettings::TtsVoice),
+ getVoiceList(RbSettings::subValue(m_TTSType,
+ RbSettings::TtsLanguage).toString()),
+ EncTtsSetting::eREFRESHBTN);
connect(setting,SIGNAL(refresh()),this,SLOT(updateVoiceList()));
insertSetting(eVOICE,setting);
//speed
- int speed = RbSettings::subValue("sapi", RbSettings::TtsSpeed).toInt();
+ int speed = RbSettings::subValue(m_TTSType, RbSettings::TtsSpeed).toInt();
if(speed > 10 || speed < -10)
speed = 0;
- insertSetting(eSPEED, new EncTtsSetting(this, EncTtsSetting::eINT,
- tr("Speed:"), speed, -10, 10));
+ insertSetting(eSPEED, new EncTtsSetting(this,
+ EncTtsSetting::eINT, tr("Speed:"), speed, -10, 10));
// options
- insertSetting(eOPTIONS,new EncTtsSetting(this,EncTtsSetting::eSTRING,
- tr("Options:"),RbSettings::subValue("sapi",RbSettings::TtsOptions)));
+ insertSetting(eOPTIONS, new EncTtsSetting(this,
+ EncTtsSetting::eSTRING, tr("Options:"),
+ RbSettings::subValue(m_TTSType, RbSettings::TtsOptions)));
}
void TTSSapi::saveSettings()
{
//save settings in user config
- RbSettings::setSubValue("sapi",RbSettings::TtsLanguage,
+ RbSettings::setSubValue(m_TTSType, RbSettings::TtsLanguage,
getSetting(eLANGUAGE)->current().toString());
- RbSettings::setSubValue("sapi",RbSettings::TtsVoice,
+ RbSettings::setSubValue(m_TTSType, RbSettings::TtsVoice,
getSetting(eVOICE)->current().toString());
- RbSettings::setSubValue("sapi",RbSettings::TtsSpeed,
+ RbSettings::setSubValue(m_TTSType, RbSettings::TtsSpeed,
getSetting(eSPEED)->current().toInt());
- RbSettings::setSubValue("sapi",RbSettings::TtsOptions,
+ RbSettings::setSubValue(m_TTSType, RbSettings::TtsOptions,
getSetting(eOPTIONS)->current().toString());
RbSettings::sync();
@@ -94,11 +99,10 @@ void TTSSapi::updateVoiceList()
bool TTSSapi::start(QString *errStr)
{
- m_TTSOpts = RbSettings::subValue("sapi",RbSettings::TtsOptions).toString();
- m_TTSLanguage =RbSettings::subValue("sapi",RbSettings::TtsLanguage).toString();
- m_TTSVoice=RbSettings::subValue("sapi",RbSettings::TtsVoice).toString();
- m_TTSSpeed=RbSettings::subValue("sapi",RbSettings::TtsSpeed).toString();
- m_sapi4 = RbSettings::subValue("sapi",RbSettings::TtsUseSapi4).toBool();
+ m_TTSOpts = RbSettings::subValue(m_TTSType, RbSettings::TtsOptions).toString();
+ m_TTSLanguage =RbSettings::subValue(m_TTSType, RbSettings::TtsLanguage).toString();
+ m_TTSVoice=RbSettings::subValue(m_TTSType, RbSettings::TtsVoice).toString();
+ m_TTSSpeed=RbSettings::subValue(m_TTSType, RbSettings::TtsSpeed).toString();
QFile::remove(QDir::tempPath() +"/sapi_voice.vbs");
QFile::copy(":/builtin/sapi_voice.vbs",QDir::tempPath() + "/sapi_voice.vbs");
@@ -118,9 +122,6 @@ bool TTSSapi::start(QString *errStr)
execstring.replace("%voice",m_TTSVoice);
execstring.replace("%speed",m_TTSSpeed);
- if(m_sapi4)
- execstring.append(" /sapi4 ");
-
qDebug() << "[TTSSapi] Start:" << execstring;
voicescript = new QProcess(NULL);
//connect(voicescript,SIGNAL(readyReadStandardError()),this,SLOT(error()));
@@ -179,13 +180,10 @@ QStringList TTSSapi::getVoiceList(QString language)
return result;
// create the voice process
- QString execstring = "cscript //nologo \"%exe\" /language:%lang /listvoices";
+ QString execstring = m_TTSVoiceTemplate;
execstring.replace("%exe",m_TTSexec);
execstring.replace("%lang",language);
- if(RbSettings::value(RbSettings::TtsUseSapi4).toBool())
- execstring.append(" /sapi4 ");
-
qDebug() << "[TTSSapi] Start:" << execstring;
voicescript = new QProcess(NULL);
voicescript->start(execstring);
@@ -263,7 +261,7 @@ bool TTSSapi::stop()
bool TTSSapi::configOk()
{
- if(RbSettings::subValue("sapi",RbSettings::TtsVoice).toString().isEmpty())
+ if(RbSettings::subValue(m_TTSType, RbSettings::TtsVoice).toString().isEmpty())
return false;
return true;
}
diff --git a/rbutil/rbutilqt/base/ttssapi.h b/rbutil/rbutilqt/base/ttssapi.h
index 98f6f4255a..f645774852 100644
--- a/rbutil/rbutilqt/base/ttssapi.h
+++ b/rbutil/rbutilqt/base/ttssapi.h
@@ -61,12 +61,15 @@ class TTSSapi : public TTSBase
QString m_TTSexec;
QString m_TTSOpts;
- QString m_TTSTemplate;
QString m_TTSLanguage;
QString m_TTSVoice;
QString m_TTSSpeed;
- bool m_sapi4;
bool m_started;
+
+ protected:
+ QString m_TTSTemplate;
+ QString m_TTSVoiceTemplate;
+ QString m_TTSType;
};