forked from len0rd/rockbox
rbutil: added support for talkfile creation with the rockbox sapi_voice.vbs script. Also let the configure dialog remember options and paths for different tts and encoders.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14828 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
74154436a5
commit
acc70ec58d
6 changed files with 278 additions and 85 deletions
|
|
@ -128,18 +128,35 @@ void Config::accept()
|
||||||
userSettings->setValue("offline", ui.cacheOfflineMode->isChecked());
|
userSettings->setValue("offline", ui.cacheOfflineMode->isChecked());
|
||||||
|
|
||||||
// tts settings
|
// tts settings
|
||||||
if(QFileInfo(ui.ttsExecutable->text()).isExecutable())
|
|
||||||
userSettings->setValue("ttsbin", ui.ttsExecutable->text());
|
|
||||||
userSettings->setValue("ttsopts", ui.ttsOptions->text());
|
|
||||||
if(QFileInfo(ui.encoderExecutable->text()).isExecutable())
|
|
||||||
userSettings->setValue("encbin", ui.encoderExecutable->text());
|
|
||||||
userSettings->setValue("ttsopts", ui.ttsOptions->text());
|
|
||||||
QString preset;
|
QString preset;
|
||||||
preset = ui.comboEncoder->itemData(ui.comboEncoder->currentIndex(), Qt::UserRole).toString();
|
|
||||||
userSettings->setValue("encpreset", preset);
|
|
||||||
preset = ui.comboTts->itemData(ui.comboTts->currentIndex(), Qt::UserRole).toString();
|
preset = ui.comboTts->itemData(ui.comboTts->currentIndex(), Qt::UserRole).toString();
|
||||||
userSettings->setValue("ttspreset", preset);
|
userSettings->setValue("ttspreset", preset);
|
||||||
|
userSettings->beginGroup(preset);
|
||||||
|
|
||||||
|
if(QFileInfo(ui.ttsExecutable->text()).exists())
|
||||||
|
userSettings->setValue("binary", ui.ttsExecutable->text());
|
||||||
|
userSettings->setValue("options", ui.ttsOptions->text());
|
||||||
|
userSettings->setValue("language", ui.ttsLanguage->text());
|
||||||
|
devices->beginGroup(preset);
|
||||||
|
userSettings->setValue("template", devices->value("template").toString());
|
||||||
|
userSettings->setValue("type", devices->value("tts").toString());
|
||||||
|
devices->endGroup();
|
||||||
|
userSettings->endGroup();
|
||||||
|
|
||||||
|
//encoder settings
|
||||||
|
preset = ui.comboEncoder->itemData(ui.comboEncoder->currentIndex(), Qt::UserRole).toString();
|
||||||
|
userSettings->setValue("encpreset", preset);
|
||||||
|
userSettings->beginGroup(preset);
|
||||||
|
|
||||||
|
if(QFileInfo(ui.encoderExecutable->text()).isExecutable())
|
||||||
|
userSettings->setValue("binary", ui.encoderExecutable->text());
|
||||||
|
userSettings->setValue("options", ui.encoderOptions->text());
|
||||||
|
devices->beginGroup(preset);
|
||||||
|
userSettings->setValue("template", devices->value("template").toString());
|
||||||
|
userSettings->setValue("type", devices->value("tts").toString());
|
||||||
|
devices->endGroup();
|
||||||
|
userSettings->endGroup();
|
||||||
|
|
||||||
// sync settings
|
// sync settings
|
||||||
userSettings->sync();
|
userSettings->sync();
|
||||||
this->close();
|
this->close();
|
||||||
|
|
@ -302,7 +319,21 @@ void Config::setDevices(QSettings *dev)
|
||||||
devices->beginGroup("tts");
|
devices->beginGroup("tts");
|
||||||
keys = devices->allKeys();
|
keys = devices->allKeys();
|
||||||
for(int i=0; i < keys.size();i++)
|
for(int i=0; i < keys.size();i++)
|
||||||
ui.comboTts->addItem(devices->value(keys.at(i), "null").toString(), keys.at(i));
|
{
|
||||||
|
devices->endGroup();
|
||||||
|
devices->beginGroup(keys.at(i));
|
||||||
|
QString os = devices->value("os").toString();
|
||||||
|
devices->endGroup();
|
||||||
|
devices->beginGroup("tts");
|
||||||
|
|
||||||
|
if(os == "all")
|
||||||
|
ui.comboTts->addItem(devices->value(keys.at(i), "null").toString(), keys.at(i));
|
||||||
|
|
||||||
|
#if defined(Q_OS_WIN32)
|
||||||
|
if(os == "win32")
|
||||||
|
ui.comboTts->addItem(devices->value(keys.at(i), "null").toString(), keys.at(i));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
devices->endGroup();
|
devices->endGroup();
|
||||||
|
|
||||||
int index;
|
int index;
|
||||||
|
|
@ -311,14 +342,12 @@ void Config::setDevices(QSettings *dev)
|
||||||
if(index < 0) index = 0;
|
if(index < 0) index = 0;
|
||||||
ui.comboTts->setCurrentIndex(index);
|
ui.comboTts->setCurrentIndex(index);
|
||||||
updateTtsOpts(index);
|
updateTtsOpts(index);
|
||||||
ui.ttsExecutable->setText(userSettings->value("ttsbin").toString());
|
|
||||||
|
|
||||||
index = ui.comboEncoder->findData(userSettings->value("encpreset").toString(),
|
index = ui.comboEncoder->findData(userSettings->value("encpreset").toString(),
|
||||||
Qt::UserRole, Qt::MatchExactly);
|
Qt::UserRole, Qt::MatchExactly);
|
||||||
if(index < 0) index = 0;
|
if(index < 0) index = 0;
|
||||||
ui.comboEncoder->setCurrentIndex(index);
|
ui.comboEncoder->setCurrentIndex(index);
|
||||||
updateEncOpts(index);
|
updateEncOpts(index);
|
||||||
ui.encoderExecutable->setText(userSettings->value("encbin").toString());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -347,9 +376,9 @@ void Config::updateEncOpts(int index)
|
||||||
for(int i = 0; i < path.size(); i++) {
|
for(int i = 0; i < path.size(); i++) {
|
||||||
QString executable = QDir::fromNativeSeparators(path.at(i)) + "/" + e;
|
QString executable = QDir::fromNativeSeparators(path.at(i)) + "/" + e;
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
executable += ".exe";
|
executable += ".exe";
|
||||||
QStringList ex = executable.split("\"", QString::SkipEmptyParts);
|
QStringList ex = executable.split("\"", QString::SkipEmptyParts);
|
||||||
executable = ex.join("");
|
executable = ex.join("");
|
||||||
#endif
|
#endif
|
||||||
if(QFileInfo(executable).isExecutable()) {
|
if(QFileInfo(executable).isExecutable()) {
|
||||||
qDebug() << "found:" << executable;
|
qDebug() << "found:" << executable;
|
||||||
|
|
@ -360,6 +389,15 @@ void Config::updateEncOpts(int index)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//user settings
|
||||||
|
userSettings->beginGroup(c);
|
||||||
|
QString temp = userSettings->value("binary","null").toString();
|
||||||
|
if(temp != "null") ui.encoderExecutable->setText(temp);
|
||||||
|
temp = userSettings->value("options","null").toString();
|
||||||
|
if(temp != "null") ui.encoderOptions->setText(temp);
|
||||||
|
userSettings->endGroup();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -367,14 +405,18 @@ void Config::updateTtsOpts(int index)
|
||||||
{
|
{
|
||||||
bool edit;
|
bool edit;
|
||||||
QString e;
|
QString e;
|
||||||
|
bool needsLanguageCfg;
|
||||||
QString c = ui.comboTts->itemData(index, Qt::UserRole).toString();
|
QString c = ui.comboTts->itemData(index, Qt::UserRole).toString();
|
||||||
devices->beginGroup(c);
|
devices->beginGroup(c);
|
||||||
edit = devices->value("edit").toBool();
|
edit = devices->value("edit").toBool();
|
||||||
|
needsLanguageCfg = devices->value("needslanguagecfg").toBool();
|
||||||
|
ui.ttsLanguage->setVisible(needsLanguageCfg);
|
||||||
|
ui.ttsLanguageLabel->setVisible(needsLanguageCfg);
|
||||||
ui.ttsOptions->setText(devices->value("options").toString());
|
ui.ttsOptions->setText(devices->value("options").toString());
|
||||||
ui.ttsOptions->setEnabled(devices->value("edit").toBool());
|
ui.ttsOptions->setEnabled(devices->value("edit").toBool());
|
||||||
e = devices->value("tts").toString();
|
e = devices->value("tts").toString();
|
||||||
devices->endGroup();
|
devices->endGroup();
|
||||||
|
|
||||||
#if defined(Q_OS_LINUX) || defined(Q_OS_MACX)
|
#if defined(Q_OS_LINUX) || defined(Q_OS_MACX)
|
||||||
QStringList path = QString(getenv("PATH")).split(":", QString::SkipEmptyParts);
|
QStringList path = QString(getenv("PATH")).split(":", QString::SkipEmptyParts);
|
||||||
#elif defined(Q_OS_WIN)
|
#elif defined(Q_OS_WIN)
|
||||||
|
|
@ -385,11 +427,11 @@ void Config::updateTtsOpts(int index)
|
||||||
for(int i = 0; i < path.size(); i++) {
|
for(int i = 0; i < path.size(); i++) {
|
||||||
QString executable = QDir::fromNativeSeparators(path.at(i)) + "/" + e;
|
QString executable = QDir::fromNativeSeparators(path.at(i)) + "/" + e;
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
executable += ".exe";
|
executable += ".exe";
|
||||||
QStringList ex = executable.split("\"", QString::SkipEmptyParts);
|
QStringList ex = executable.split("\"", QString::SkipEmptyParts);
|
||||||
executable = ex.join("");
|
executable = ex.join("");
|
||||||
#endif
|
#endif
|
||||||
qDebug() << executable;
|
qDebug() << executable;
|
||||||
if(QFileInfo(executable).isExecutable()) {
|
if(QFileInfo(executable).isExecutable()) {
|
||||||
ui.ttsExecutable->setText(QDir::toNativeSeparators(executable));
|
ui.ttsExecutable->setText(QDir::toNativeSeparators(executable));
|
||||||
// disallow changing the detected path if non-customizable profile
|
// disallow changing the detected path if non-customizable profile
|
||||||
|
|
@ -398,6 +440,16 @@ void Config::updateTtsOpts(int index)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//user settings
|
||||||
|
userSettings->beginGroup(c);
|
||||||
|
QString temp = userSettings->value("binary","null").toString();
|
||||||
|
if(temp != "null") ui.ttsExecutable->setText(temp);
|
||||||
|
temp = userSettings->value("options","null").toString();
|
||||||
|
if(temp != "null") ui.ttsOptions->setText(temp);
|
||||||
|
temp = userSettings->value("language","null").toString();
|
||||||
|
if(temp != "null") ui.ttsLanguage->setText(temp);
|
||||||
|
userSettings->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -672,7 +724,7 @@ void Config::browseTts()
|
||||||
{
|
{
|
||||||
qDebug() << browser.getSelected();
|
qDebug() << browser.getSelected();
|
||||||
QString exe = browser.getSelected();
|
QString exe = browser.getSelected();
|
||||||
if(!QFileInfo(exe).isExecutable())
|
if(!QFileInfo(exe).exists())
|
||||||
return;
|
return;
|
||||||
ui.ttsExecutable->setText(exe);
|
ui.ttsExecutable->setText(exe);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>500</width>
|
<width>548</width>
|
||||||
<height>435</height>
|
<height>472</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle" >
|
<property name="windowTitle" >
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
<item row="1" column="0" colspan="3" >
|
<item row="1" column="0" colspan="3" >
|
||||||
<widget class="QTabWidget" name="tabConfiguration" >
|
<widget class="QTabWidget" name="tabConfiguration" >
|
||||||
<property name="currentIndex" >
|
<property name="currentIndex" >
|
||||||
<number>0</number>
|
<number>4</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tabDevice" >
|
<widget class="QWidget" name="tabDevice" >
|
||||||
<attribute name="title" >
|
<attribute name="title" >
|
||||||
|
|
@ -414,6 +414,16 @@
|
||||||
<item row="2" column="1" colspan="2" >
|
<item row="2" column="1" colspan="2" >
|
||||||
<widget class="QLineEdit" name="ttsOptions" />
|
<widget class="QLineEdit" name="ttsOptions" />
|
||||||
</item>
|
</item>
|
||||||
|
<item row="3" column="0" >
|
||||||
|
<widget class="QLabel" name="ttsLanguageLabel" >
|
||||||
|
<property name="text" >
|
||||||
|
<string>TTS Language</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1" colspan="2" >
|
||||||
|
<widget class="QLineEdit" name="ttsLanguage" />
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
||||||
|
|
@ -69,24 +69,41 @@ void InstallTalkWindow::accept()
|
||||||
connect(logger,SIGNAL(closed()),this,SLOT(close()));
|
connect(logger,SIGNAL(closed()),this,SLOT(close()));
|
||||||
|
|
||||||
QString folderToTalk = ui.lineTalkFolder->text();
|
QString folderToTalk = ui.lineTalkFolder->text();
|
||||||
QString pathEncoder = userSettings->value("encbin").toString();
|
|
||||||
QString pathTTS = userSettings->value("ttsbin").toString();
|
// tts
|
||||||
|
QString preset = userSettings->value("ttspreset").toString();
|
||||||
|
userSettings->beginGroup(preset);
|
||||||
|
QString pathTTS = userSettings->value("binary").toString();
|
||||||
|
QString ttsOpts = userSettings->value("options").toString();
|
||||||
|
QString ttsLanguage = userSettings->value("language").toString();
|
||||||
|
QString ttsTemplate = userSettings->value("template").toString();
|
||||||
|
QString ttsType =userSettings->value("type").toString();
|
||||||
|
userSettings->endGroup();
|
||||||
|
|
||||||
|
//encoder
|
||||||
|
QString encoderPreset = userSettings->value("encpreset").toString();
|
||||||
|
userSettings->beginGroup(encoderPreset);
|
||||||
|
QString pathEncoder = userSettings->value("binary").toString();
|
||||||
|
QString encOpts = userSettings->value("options").toString();
|
||||||
|
QString encTemplate = userSettings->value("template").toString();
|
||||||
|
QString encType =userSettings->value("type").toString();
|
||||||
|
userSettings->endGroup();
|
||||||
|
|
||||||
if(!QFileInfo(folderToTalk).isDir())
|
if(!QFileInfo(folderToTalk).isDir())
|
||||||
{
|
{
|
||||||
logger->addItem(tr("The Folder to Talk is wrong!"),LOGERROR);
|
logger->addItem(tr("The Folder to Talk is wrong!"),LOGERROR);
|
||||||
logger->abort();
|
logger->abort();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!QFileInfo(pathEncoder).isExecutable())
|
if(!QFileInfo(pathEncoder).isExecutable())
|
||||||
{
|
{
|
||||||
logger->addItem(tr("Path to Encoder is wrong!"),LOGERROR);
|
logger->addItem(tr("Path to Encoder is wrong!"),LOGERROR);
|
||||||
logger->abort();
|
logger->abort();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!QFileInfo(pathTTS).isExecutable())
|
if(!QFileInfo(pathTTS).exists())
|
||||||
{
|
{
|
||||||
logger->addItem(tr("Path to TTS is wrong!"),LOGERROR);
|
logger->addItem(tr("Path to TTS is wrong!"),LOGERROR);
|
||||||
logger->abort();
|
logger->abort();
|
||||||
|
|
@ -99,21 +116,16 @@ void InstallTalkWindow::accept()
|
||||||
|
|
||||||
talkcreator->setDir(folderToTalk);
|
talkcreator->setDir(folderToTalk);
|
||||||
talkcreator->setTTSexe(pathTTS);
|
talkcreator->setTTSexe(pathTTS);
|
||||||
|
talkcreator->setTTsOpts(ttsOpts);
|
||||||
|
talkcreator->setTTsLanguage(ttsLanguage);
|
||||||
|
talkcreator->setTTsType(ttsType);
|
||||||
|
talkcreator->setTTsTemplate(ttsTemplate);
|
||||||
|
|
||||||
talkcreator->setEncexe(pathEncoder);
|
talkcreator->setEncexe(pathEncoder);
|
||||||
talkcreator->setEncOpts(userSettings->value("encopts").toString());
|
talkcreator->setEncOpts(encOpts);
|
||||||
talkcreator->setTTsOpts(userSettings->value("ttsopts").toString());
|
talkcreator->setEncTemplate(encTemplate);
|
||||||
|
talkcreator->setEncType(encType);
|
||||||
devices->beginGroup(userSettings->value("ttspreset").toString());
|
|
||||||
talkcreator->setTTsType(devices->value("tts").toString());
|
|
||||||
talkcreator->setTTsOpts(devices->value("options").toString());
|
|
||||||
talkcreator->setTTsTemplate(devices->value("template").toString());
|
|
||||||
devices->endGroup();
|
|
||||||
devices->beginGroup(userSettings->value("encpreset").toString());
|
|
||||||
talkcreator->setEncType(devices->value("encoder").toString());
|
|
||||||
talkcreator->setEncOpts(devices->value("options").toString());
|
|
||||||
talkcreator->setEncTemplate(devices->value("template").toString());
|
|
||||||
devices->endGroup();
|
|
||||||
|
|
||||||
talkcreator->setOverwriteTalk(ui.OverwriteTalk->isChecked());
|
talkcreator->setOverwriteTalk(ui.OverwriteTalk->isChecked());
|
||||||
talkcreator->setOverwriteWav(ui.OverwriteWav->isChecked());
|
talkcreator->setOverwriteWav(ui.OverwriteWav->isChecked());
|
||||||
talkcreator->setRemoveWav(ui.RemoveWav->isChecked());
|
talkcreator->setRemoveWav(ui.RemoveWav->isChecked());
|
||||||
|
|
|
||||||
|
|
@ -399,27 +399,44 @@ ttspreset01 = "espeak (default)"
|
||||||
ttspreset02 = "espeak (user-adjusted)"
|
ttspreset02 = "espeak (user-adjusted)"
|
||||||
ttspreset03 = "flite (default)"
|
ttspreset03 = "flite (default)"
|
||||||
ttspreset04 = "flite (user-adjusted)"
|
ttspreset04 = "flite (user-adjusted)"
|
||||||
|
ttspreset05 = "sapi (default)"
|
||||||
|
|
||||||
[ttspreset01]
|
[ttspreset01]
|
||||||
tts = "espeak"
|
tts = "espeak"
|
||||||
options = ""
|
options = ""
|
||||||
template = "\"%exe\" %options -w \"%wavfile\" \"%text\""
|
template = "\"%exe\" %options -w \"%wavfile\" \"%text\""
|
||||||
edit = false
|
edit = false
|
||||||
|
os = all
|
||||||
|
needslanguagecfg = false
|
||||||
|
|
||||||
[ttspreset02]
|
[ttspreset02]
|
||||||
tts = "espeak"
|
tts = "espeak"
|
||||||
options = ""
|
options = ""
|
||||||
template = "\"%exe\" %options -w \"%wavfile\" \"%text\""
|
template = "\"%exe\" %options -w \"%wavfile\" \"%text\""
|
||||||
edit = true
|
edit = true
|
||||||
|
os = all
|
||||||
|
needslanguagecfg = false
|
||||||
|
|
||||||
[ttspreset03]
|
[ttspreset03]
|
||||||
tts = "flite"
|
tts = "flite"
|
||||||
options = ""
|
options = ""
|
||||||
template = "\"%exe\" %options -o \"%wavfile\" \"%text\""
|
template = "\"%exe\" %options -o \"%wavfile\" \"%text\""
|
||||||
edit = false
|
edit = false
|
||||||
|
os = all
|
||||||
|
needslanguagecfg = false
|
||||||
|
|
||||||
[ttspreset04]
|
[ttspreset04]
|
||||||
tts = "flite"
|
tts = "flite"
|
||||||
options = ""
|
options = ""
|
||||||
template = "\"%exe\" %options -o \"%wavfile\" \"%text\""
|
template = "\"%exe\" %options -o \"%wavfile\" \"%text\""
|
||||||
edit = true
|
edit = true
|
||||||
|
os = all
|
||||||
|
needslanguagecfg = false
|
||||||
|
|
||||||
|
[ttspreset05]
|
||||||
|
tts = "sapi"
|
||||||
|
options = ""
|
||||||
|
template = "cscript //nologo \"%exe\" /language:english %options"
|
||||||
|
edit = false
|
||||||
|
os = win32
|
||||||
|
needslanguagecfg = true
|
||||||
|
|
|
||||||
|
|
@ -38,26 +38,24 @@ bool TalkFileCreator::initEncoder()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TalkFileCreator::initTTS()
|
|
||||||
{
|
|
||||||
QFileInfo tts(m_TTSexec);
|
|
||||||
|
|
||||||
if(tts.exists())
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
|
bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
|
||||||
{
|
{
|
||||||
m_abort = false;
|
m_abort = false;
|
||||||
m_logger = logger;
|
m_logger = logger;
|
||||||
m_logger->addItem("Starting Talkfile generation",LOGINFO);
|
m_logger->addItem("Starting Talkfile generation",LOGINFO);
|
||||||
if(!initTTS())
|
|
||||||
|
if(m_curTTS == "sapi")
|
||||||
|
m_tts = new TTSSapi();
|
||||||
|
else
|
||||||
|
m_tts = new TTSExes();
|
||||||
|
|
||||||
|
m_tts->setTTSexe(m_TTSexec);
|
||||||
|
m_tts->setTTsOpts(m_TTSOpts);
|
||||||
|
m_tts->setTTsLanguage(m_TTSLanguage);
|
||||||
|
m_tts->setTTsTemplate(m_curTTSTemplate);
|
||||||
|
|
||||||
|
if(!m_tts->start())
|
||||||
{
|
{
|
||||||
m_logger->addItem("Init of TTS engine failed",LOGERROR);
|
m_logger->addItem("Init of TTS engine failed",LOGERROR);
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -65,6 +63,7 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
|
||||||
if(!initEncoder())
|
if(!initEncoder())
|
||||||
{
|
{
|
||||||
m_logger->addItem("Init of encoder failed",LOGERROR);
|
m_logger->addItem("Init of encoder failed",LOGERROR);
|
||||||
|
m_tts->stop();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
QApplication::processEvents();
|
QApplication::processEvents();
|
||||||
|
|
@ -80,6 +79,7 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
|
||||||
if(m_abort)
|
if(m_abort)
|
||||||
{
|
{
|
||||||
m_logger->addItem("Talkfile creation aborted",LOGERROR);
|
m_logger->addItem("Talkfile creation aborted",LOGERROR);
|
||||||
|
m_tts->stop();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -117,10 +117,11 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
|
||||||
if(!wavfilenameInf.exists() || m_overwriteWav)
|
if(!wavfilenameInf.exists() || m_overwriteWav)
|
||||||
{
|
{
|
||||||
m_logger->addItem("Voicing of " + toSpeak,LOGINFO);
|
m_logger->addItem("Voicing of " + toSpeak,LOGINFO);
|
||||||
if(!voice(toSpeak,wavfilename))
|
if(!m_tts->voice(toSpeak,wavfilename))
|
||||||
{
|
{
|
||||||
m_logger->addItem("Voicing of " + toSpeak + " failed",LOGERROR);
|
m_logger->addItem("Voicing of " + toSpeak + " failed",LOGERROR);
|
||||||
m_logger->abort();
|
m_logger->abort();
|
||||||
|
m_tts->stop();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -129,6 +130,7 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
|
||||||
{
|
{
|
||||||
m_logger->addItem("Encoding of " + wavfilename + " failed",LOGERROR);
|
m_logger->addItem("Encoding of " + wavfilename + " failed",LOGERROR);
|
||||||
m_logger->abort();
|
m_logger->abort();
|
||||||
|
m_tts->stop();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -148,6 +150,7 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
|
||||||
}
|
}
|
||||||
|
|
||||||
installlog.endGroup();
|
installlog.endGroup();
|
||||||
|
m_tts->stop();
|
||||||
m_logger->addItem("Finished creating Talkfiles",LOGOK);
|
m_logger->addItem("Finished creating Talkfiles",LOGOK);
|
||||||
m_logger->setProgressMax(1);
|
m_logger->setProgressMax(1);
|
||||||
m_logger->setProgressValue(1);
|
m_logger->setProgressValue(1);
|
||||||
|
|
@ -162,33 +165,82 @@ void TalkFileCreator::abort()
|
||||||
m_abort = true;
|
m_abort = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TalkFileCreator::voice(QString text,QString wavfile)
|
|
||||||
{
|
|
||||||
|
|
||||||
QString execstring = m_curTTSTemplate;
|
|
||||||
|
|
||||||
execstring.replace("%exe",m_TTSexec);
|
|
||||||
execstring.replace("%options",m_TTSOpts);
|
|
||||||
execstring.replace("%wavfile",wavfile);
|
|
||||||
execstring.replace("%text",text);
|
|
||||||
|
|
||||||
QProcess::execute(execstring);
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TalkFileCreator::encode(QString input,QString output)
|
bool TalkFileCreator::encode(QString input,QString output)
|
||||||
{
|
{
|
||||||
|
qDebug() << "encoding..";
|
||||||
QString execstring = m_curEncTemplate;
|
QString execstring = m_curEncTemplate;
|
||||||
|
|
||||||
execstring.replace("%exe",m_EncExec);
|
execstring.replace("%exe",m_EncExec);
|
||||||
execstring.replace("%options",m_EncOpts);
|
execstring.replace("%options",m_EncOpts);
|
||||||
execstring.replace("%input",input);
|
execstring.replace("%input",input);
|
||||||
execstring.replace("%output",output);
|
execstring.replace("%output",output);
|
||||||
|
qDebug() << execstring;
|
||||||
QProcess::execute(execstring);
|
QProcess::execute(execstring);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TTSSapi::start()
|
||||||
|
{
|
||||||
|
QFileInfo tts(m_TTSexec);
|
||||||
|
if(!tts.exists())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// create the voice process
|
||||||
|
QString execstring = m_TTSTemplate;
|
||||||
|
execstring.replace("%exe",m_TTSexec);
|
||||||
|
execstring.replace("%options",m_TTSOpts);
|
||||||
|
qDebug() << "init" << execstring;
|
||||||
|
voicescript = new QProcess(NULL);
|
||||||
|
voicescript->start(execstring);
|
||||||
|
if(!voicescript->waitForStarted())
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TTSSapi::voice(QString text,QString wavfile)
|
||||||
|
{
|
||||||
|
QString query = "SPEAK\t"+wavfile+"\t"+text+"\r\n";
|
||||||
|
qDebug() << "voicing" << query;
|
||||||
|
voicescript->write(query.toLocal8Bit());
|
||||||
|
voicescript->write("SYNC\tbla\r\n");
|
||||||
|
voicescript->waitForReadyRead();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TTSSapi::stop()
|
||||||
|
{
|
||||||
|
QString query = "QUIT\r\n";
|
||||||
|
voicescript->write(query.toLocal8Bit());
|
||||||
|
voicescript->waitForFinished();
|
||||||
|
delete voicescript;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TTSExes::start()
|
||||||
|
{
|
||||||
|
QFileInfo tts(m_TTSexec);
|
||||||
|
qDebug() << "ttsexe init";
|
||||||
|
if(tts.exists())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TTSExes::voice(QString text,QString wavfile)
|
||||||
|
{
|
||||||
|
QString execstring = m_TTSTemplate;
|
||||||
|
|
||||||
|
execstring.replace("%exe",m_TTSexec);
|
||||||
|
execstring.replace("%options",m_TTSOpts);
|
||||||
|
execstring.replace("%wavfile",wavfile);
|
||||||
|
execstring.replace("%text",text);
|
||||||
|
qDebug() << "voicing" << execstring;
|
||||||
|
QProcess::execute(execstring);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -23,6 +23,29 @@
|
||||||
|
|
||||||
#include "progressloggerinterface.h"
|
#include "progressloggerinterface.h"
|
||||||
|
|
||||||
|
class TTSBase : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
TTSBase(){}
|
||||||
|
virtual ~TTSBase(){}
|
||||||
|
virtual bool voice(QString text,QString wavfile){return false;}
|
||||||
|
virtual bool start(){return false;}
|
||||||
|
virtual bool stop(){return false;}
|
||||||
|
|
||||||
|
void setTTSexe(QString exe){m_TTSexec=exe;}
|
||||||
|
void setTTsOpts(QString opts) {m_TTSOpts=opts;}
|
||||||
|
void setTTsLanguage(QString language) {m_TTSLanguage = language;}
|
||||||
|
void setTTsTemplate(QString t) { m_TTSTemplate = t; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QString m_TTSexec;
|
||||||
|
QString m_TTSOpts;
|
||||||
|
QString m_TTSTemplate;
|
||||||
|
QString m_TTSLanguage;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class TalkFileCreator :public QObject
|
class TalkFileCreator :public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
@ -37,6 +60,7 @@ public:
|
||||||
|
|
||||||
void setTTsType(QString tts) { m_curTTS = tts; }
|
void setTTsType(QString tts) { m_curTTS = tts; }
|
||||||
void setTTsOpts(QString opts) {m_TTSOpts=opts;}
|
void setTTsOpts(QString opts) {m_TTSOpts=opts;}
|
||||||
|
void setTTsLanguage(QString language) {m_TTSLanguage = language;}
|
||||||
void setTTsTemplate(QString t) { m_curTTSTemplate = t; }
|
void setTTsTemplate(QString t) { m_curTTSTemplate = t; }
|
||||||
|
|
||||||
void setEncType(QString enc) { m_curEnc = enc; }
|
void setEncType(QString enc) { m_curEnc = enc; }
|
||||||
|
|
@ -56,19 +80,20 @@ private slots:
|
||||||
void abort();
|
void abort();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
TTSBase* m_tts;
|
||||||
bool initTTS();
|
//bool initTTS();
|
||||||
bool stopTTS();
|
//bool stopTTS();
|
||||||
bool initEncoder();
|
bool initEncoder();
|
||||||
|
|
||||||
bool encode(QString input,QString output);
|
bool encode(QString input,QString output);
|
||||||
bool voice(QString text,QString wavfile);
|
//bool voice(QString text,QString wavfile);
|
||||||
|
|
||||||
QString m_dir;
|
QString m_dir;
|
||||||
QString m_mountpoint;
|
QString m_mountpoint;
|
||||||
QString m_curTTS;
|
QString m_curTTS;
|
||||||
QString m_TTSexec;
|
QString m_TTSexec;
|
||||||
QString m_TTSOpts;
|
QString m_TTSOpts;
|
||||||
|
QString m_TTSLanguage;
|
||||||
QString m_curTTSTemplate;
|
QString m_curTTSTemplate;
|
||||||
|
|
||||||
QString m_curEnc;
|
QString m_curEnc;
|
||||||
|
|
@ -87,4 +112,29 @@ private:
|
||||||
bool m_abort;
|
bool m_abort;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class TTSSapi : public TTSBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TTSSapi() {};
|
||||||
|
virtual bool voice(QString text,QString wavfile);
|
||||||
|
virtual bool start();
|
||||||
|
virtual bool stop();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QProcess* voicescript;
|
||||||
|
};
|
||||||
|
|
||||||
|
class TTSExes : public TTSBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TTSExes() {};
|
||||||
|
virtual bool voice(QString text,QString wavfile);
|
||||||
|
virtual bool start();
|
||||||
|
virtual bool stop() {return true;}
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue