forked from len0rd/rockbox
Rockbox Utility TTS: implement reading TTS vendor.
Support retrieving the vendor name of the TTS. This will be used by TTS string corrections. Currently no other TTS but SAPI supports this, and only correction strings for SAPI voices depend on the vendor information. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30609 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
c7c657ca92
commit
fe3eadffba
6 changed files with 33 additions and 5 deletions
|
@ -47,6 +47,7 @@ class TTSBase : public EncTtsSettingInterface
|
||||||
//! child class should stop
|
//! child class should stop
|
||||||
virtual bool stop() =0;
|
virtual bool stop() =0;
|
||||||
|
|
||||||
|
virtual QString voiceVendor(void) = 0;
|
||||||
// configuration
|
// configuration
|
||||||
//! Child class should return true, when configuration is good
|
//! Child class should return true, when configuration is good
|
||||||
virtual bool configOk()=0;
|
virtual bool configOk()=0;
|
||||||
|
@ -60,7 +61,7 @@ class TTSBase : public EncTtsSettingInterface
|
||||||
// static functions
|
// static functions
|
||||||
static TTSBase* getTTS(QObject* parent,QString ttsname);
|
static TTSBase* getTTS(QObject* parent,QString ttsname);
|
||||||
static QStringList getTTSList();
|
static QStringList getTTSList();
|
||||||
static QString getTTSName(QString tts);
|
static QString getTTSName(QString tts);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//inits the tts List
|
//inits the tts List
|
||||||
|
|
|
@ -45,6 +45,7 @@ class TTSCarbon : public TTSBase
|
||||||
bool start(QString *errStr);
|
bool start(QString *errStr);
|
||||||
//! child class should stop
|
//! child class should stop
|
||||||
bool stop() ;
|
bool stop() ;
|
||||||
|
QString voiceVendor(void) { return QString(); }
|
||||||
|
|
||||||
// configuration
|
// configuration
|
||||||
//! Child class should return true, when configuration is good
|
//! Child class should return true, when configuration is good
|
||||||
|
|
|
@ -38,6 +38,7 @@ class TTSExes : public TTSBase
|
||||||
TTSStatus voice(QString text, QString wavfile, QString *errStr);
|
TTSStatus voice(QString text, QString wavfile, QString *errStr);
|
||||||
bool start(QString *errStr);
|
bool start(QString *errStr);
|
||||||
bool stop() {return true;}
|
bool stop() {return true;}
|
||||||
|
QString voiceVendor(void) { return QString(); }
|
||||||
Capabilities capabilities();
|
Capabilities capabilities();
|
||||||
|
|
||||||
// for settings
|
// for settings
|
||||||
|
|
|
@ -42,6 +42,7 @@ class TTSFestival : public TTSBase
|
||||||
bool start(QString *errStr);
|
bool start(QString *errStr);
|
||||||
bool stop();
|
bool stop();
|
||||||
TTSStatus voice(QString text,QString wavfile, QString *errStr);
|
TTSStatus voice(QString text,QString wavfile, QString *errStr);
|
||||||
|
QString voiceVendor(void) { return QString(); }
|
||||||
Capabilities capabilities();
|
Capabilities capabilities();
|
||||||
|
|
||||||
// for settings
|
// for settings
|
||||||
|
|
|
@ -26,8 +26,9 @@ TTSSapi::TTSSapi(QObject* parent) : TTSBase(parent)
|
||||||
{
|
{
|
||||||
m_TTSTemplate = "cscript //nologo \"%exe\" /language:%lang /voice:\"%voice\""
|
m_TTSTemplate = "cscript //nologo \"%exe\" /language:%lang /voice:\"%voice\""
|
||||||
" /speed:%speed \"%options\"";
|
" /speed:%speed \"%options\"";
|
||||||
defaultLanguage ="english";
|
defaultLanguage = "english";
|
||||||
m_sapi4 =false;
|
m_sapi4 = false;
|
||||||
|
m_started = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
TTSBase::Capabilities TTSSapi::capabilities()
|
TTSBase::Capabilities TTSSapi::capabilities()
|
||||||
|
@ -138,9 +139,29 @@ bool TTSSapi::start(QString *errStr)
|
||||||
voicestream = new QTextStream(voicescript);
|
voicestream = new QTextStream(voicescript);
|
||||||
voicestream->setCodec("UTF16-LE");
|
voicestream->setCodec("UTF16-LE");
|
||||||
|
|
||||||
|
m_started = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString TTSSapi::voiceVendor(void)
|
||||||
|
{
|
||||||
|
bool keeprunning = m_started;
|
||||||
|
QString vendor;
|
||||||
|
if(!m_started) {
|
||||||
|
QString error;
|
||||||
|
start(&error);
|
||||||
|
}
|
||||||
|
*voicestream << "QUERY\tVENDOR\r\n";
|
||||||
|
voicestream->flush();
|
||||||
|
while((vendor = voicestream->readLine()).isEmpty())
|
||||||
|
QCoreApplication::processEvents();
|
||||||
|
|
||||||
|
qDebug() << "[TTSSAPI] TTS vendor:" << vendor;
|
||||||
|
if(!keeprunning) {
|
||||||
|
stop();
|
||||||
|
}
|
||||||
|
return vendor;
|
||||||
|
}
|
||||||
|
|
||||||
QStringList TTSSapi::getVoiceList(QString language)
|
QStringList TTSSapi::getVoiceList(QString language)
|
||||||
{
|
{
|
||||||
|
@ -226,6 +247,7 @@ bool TTSSapi::stop()
|
||||||
| QFile::ReadGroup | QFile::WriteGroup | QFile::ExeGroup
|
| QFile::ReadGroup | QFile::WriteGroup | QFile::ExeGroup
|
||||||
| QFile::ReadOther | QFile::WriteOther | QFile::ExeOther );
|
| QFile::ReadOther | QFile::WriteOther | QFile::ExeOther );
|
||||||
QFile::remove(QDir::tempPath() +"/sapi_voice.vbs");
|
QFile::remove(QDir::tempPath() +"/sapi_voice.vbs");
|
||||||
|
m_started = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ class TTSSapi : public TTSBase
|
||||||
TTSStatus voice(QString text,QString wavfile, QString *errStr);
|
TTSStatus voice(QString text,QString wavfile, QString *errStr);
|
||||||
bool start(QString *errStr);
|
bool start(QString *errStr);
|
||||||
bool stop();
|
bool stop();
|
||||||
|
QString voiceVendor(void);
|
||||||
Capabilities capabilities();
|
Capabilities capabilities();
|
||||||
|
|
||||||
// for settings
|
// for settings
|
||||||
|
@ -49,8 +50,8 @@ class TTSSapi : public TTSBase
|
||||||
void generateSettings();
|
void generateSettings();
|
||||||
void saveSettings();
|
void saveSettings();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updateVoiceList();
|
void updateVoiceList();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QStringList getVoiceList(QString language);
|
QStringList getVoiceList(QString language);
|
||||||
|
@ -66,6 +67,7 @@ class TTSSapi : public TTSBase
|
||||||
QString m_TTSVoice;
|
QString m_TTSVoice;
|
||||||
QString m_TTSSpeed;
|
QString m_TTSSpeed;
|
||||||
bool m_sapi4;
|
bool m_sapi4;
|
||||||
|
bool m_started;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue