forked from len0rd/rockbox
rbutilqt: made the sapi TTS more configurable, you can now select a specific voice in the config dialog. Also reworked some setSetting functions, to remove depencies.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16111 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
2cffb1bf3d
commit
6b5780dae3
16 changed files with 269 additions and 97 deletions
|
@ -150,10 +150,17 @@ void Config::abort()
|
|||
this->close();
|
||||
}
|
||||
|
||||
|
||||
void Config::setUserSettings(QSettings *user)
|
||||
void Config::setSettings(QSettings* user,QSettings* device)
|
||||
{
|
||||
userSettings = user;
|
||||
devices = device;
|
||||
|
||||
setUserSettings();
|
||||
setDevices();
|
||||
}
|
||||
|
||||
void Config::setUserSettings()
|
||||
{
|
||||
// set proxy
|
||||
proxy = userSettings->value("proxy").toString();
|
||||
|
||||
|
@ -214,9 +221,9 @@ void Config::updateCacheInfo(QString path)
|
|||
}
|
||||
|
||||
|
||||
void Config::setDevices(QSettings *dev)
|
||||
void Config::setDevices()
|
||||
{
|
||||
devices = dev;
|
||||
|
||||
// setup devices table
|
||||
qDebug() << "Config::setDevices()";
|
||||
devices->beginGroup("platforms");
|
||||
|
@ -320,7 +327,7 @@ void Config::updateTtsState(int index)
|
|||
{
|
||||
QString ttsName = ui.comboTts->itemText(index);
|
||||
TTSBase* tts = getTTS(ttsName);
|
||||
tts->setUserCfg(userSettings);
|
||||
tts->setCfg(userSettings,devices);
|
||||
|
||||
if(tts->configOk())
|
||||
{
|
||||
|
@ -624,7 +631,7 @@ void Config::configTts()
|
|||
{
|
||||
TTSBase* tts =getTTS(ui.comboTts->currentText());
|
||||
|
||||
tts->setUserCfg(userSettings);
|
||||
tts->setCfg(userSettings,devices);
|
||||
tts->showCfg();
|
||||
updateTtsState(ui.comboTts->currentIndex());
|
||||
}
|
||||
|
|
|
@ -29,8 +29,7 @@ class Config : public QDialog
|
|||
Q_OBJECT
|
||||
public:
|
||||
Config(QWidget *parent = 0,int index=0);
|
||||
void setUserSettings(QSettings*);
|
||||
void setDevices(QSettings*);
|
||||
void setSettings(QSettings* user,QSettings* device);
|
||||
|
||||
signals:
|
||||
void settingsUpdated(void);
|
||||
|
@ -40,6 +39,9 @@ class Config : public QDialog
|
|||
void abort(void);
|
||||
|
||||
private:
|
||||
void setUserSettings();
|
||||
void setDevices();
|
||||
|
||||
Ui::ConfigForm ui;
|
||||
QSettings *userSettings;
|
||||
QSettings *devices;
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>637</width>
|
||||
<height>421</height>
|
||||
<width>659</width>
|
||||
<height>482</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
|
@ -94,7 +94,7 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" >
|
||||
<item row="4" column="1" >
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
|
@ -107,7 +107,7 @@
|
|||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="1" >
|
||||
<item row="5" column="1" >
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
|
@ -120,7 +120,7 @@
|
|||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="2" >
|
||||
<item row="5" column="2" >
|
||||
<layout class="QHBoxLayout" >
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonOk" >
|
||||
|
@ -144,6 +144,27 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="2" >
|
||||
<layout class="QHBoxLayout" >
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3" >
|
||||
<property name="text" >
|
||||
<string>Wavtrim Threshold</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="wavtrimthreshold" >
|
||||
<property name="maximum" >
|
||||
<number>5000</number>
|
||||
</property>
|
||||
<property name="value" >
|
||||
<number>500</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
|
|
|
@ -34,8 +34,7 @@ CreateVoiceWindow::CreateVoiceWindow(QWidget *parent) : QDialog(parent)
|
|||
void CreateVoiceWindow::change()
|
||||
{
|
||||
Config *cw = new Config(this,4);
|
||||
cw->setUserSettings(userSettings);
|
||||
cw->setDevices(devices);
|
||||
cw->setSettings(userSettings,devices);
|
||||
cw->show();
|
||||
connect(cw, SIGNAL(settingsUpdated()), this, SIGNAL(settingsUpdated()));
|
||||
}
|
||||
|
@ -48,18 +47,20 @@ void CreateVoiceWindow::accept()
|
|||
|
||||
QString platform = userSettings->value("platform").toString();
|
||||
QString lang = ui.comboLanguage->currentText();
|
||||
int wvThreshold = ui.wavtrimthreshold->value();
|
||||
|
||||
//safe selected language
|
||||
userSettings->setValue("voicelanguage",lang);
|
||||
userSettings->setValue("wavtrimthreshold",wvThreshold);
|
||||
userSettings->sync();
|
||||
|
||||
//configure voicecreator
|
||||
voicecreator->setUserSettings(userSettings);
|
||||
voicecreator->setDeviceSettings(devices);
|
||||
voicecreator->setSettings(userSettings,devices);
|
||||
voicecreator->setMountPoint(userSettings->value("mountpoint").toString());
|
||||
voicecreator->setTargetId(devices->value(platform + "/targetid").toInt());
|
||||
voicecreator->setLang(lang);
|
||||
voicecreator->setProxy(m_proxy);
|
||||
voicecreator->setWavtrimThreshold(wvThreshold);
|
||||
|
||||
//start creating
|
||||
voicecreator->createVoiceFile(logger);
|
||||
|
@ -67,9 +68,10 @@ void CreateVoiceWindow::accept()
|
|||
|
||||
|
||||
|
||||
void CreateVoiceWindow::setDeviceSettings(QSettings *dev)
|
||||
void CreateVoiceWindow::setSettings(QSettings *user,QSettings *dev)
|
||||
{
|
||||
devices = dev;
|
||||
userSettings = user;
|
||||
qDebug() << "Install::setDeviceSettings:" << devices;
|
||||
|
||||
// fill in language combobox
|
||||
|
@ -86,15 +88,10 @@ void CreateVoiceWindow::setDeviceSettings(QSettings *dev)
|
|||
ui.comboLanguage->addItems(languages);
|
||||
// set saved lang
|
||||
ui.comboLanguage->setCurrentIndex(ui.comboLanguage->findText(userSettings->value("voicelanguage").toString()));
|
||||
}
|
||||
|
||||
void CreateVoiceWindow::setUserSettings(QSettings *user)
|
||||
{
|
||||
userSettings = user;
|
||||
|
||||
QString ttsName = userSettings->value("tts", "none").toString();
|
||||
TTSBase* tts = getTTS(ttsName);
|
||||
tts->setUserCfg(userSettings);
|
||||
tts->setCfg(userSettings,devices);
|
||||
if(tts->configOk())
|
||||
ui.labelTtsProfile->setText(tr("Selected TTS engine : <b>%1</b>").arg(ttsName));
|
||||
else
|
||||
|
@ -108,7 +105,11 @@ void CreateVoiceWindow::setUserSettings(QSettings *user)
|
|||
else
|
||||
ui.labelEncProfile->setText(tr("Selected Encoder: <b>%1</b>").arg("Invalid encoder configuration!"));
|
||||
|
||||
ui.wavtrimthreshold->setValue(userSettings->value("wavtrimthreshold", 500).toInt());
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -33,8 +33,7 @@ class CreateVoiceWindow : public QDialog
|
|||
Q_OBJECT
|
||||
public:
|
||||
CreateVoiceWindow(QWidget *parent = 0);
|
||||
void setUserSettings(QSettings*);
|
||||
void setDeviceSettings(QSettings*);
|
||||
void setSettings(QSettings* user,QSettings* device);
|
||||
void setProxy(QUrl proxy){m_proxy = proxy;}
|
||||
|
||||
signals:
|
||||
|
|
|
@ -66,8 +66,7 @@ void InstallTalkWindow::setTalkFolder(QString folder)
|
|||
void InstallTalkWindow::change()
|
||||
{
|
||||
Config *cw = new Config(this,4);
|
||||
cw->setUserSettings(userSettings);
|
||||
cw->setDevices(devices);
|
||||
cw->setSettings(userSettings,devices);
|
||||
cw->show();
|
||||
connect(cw, SIGNAL(settingsUpdated()), this, SIGNAL(settingsUpdated()));
|
||||
}
|
||||
|
@ -91,7 +90,7 @@ void InstallTalkWindow::accept()
|
|||
|
||||
userSettings->sync();
|
||||
|
||||
talkcreator->setUserSettings(userSettings);
|
||||
talkcreator->setSettings(userSettings,devices);
|
||||
talkcreator->setDir(QDir(folderToTalk));
|
||||
talkcreator->setMountPoint(userSettings->value("mountpoint").toString());
|
||||
|
||||
|
@ -107,14 +106,15 @@ void InstallTalkWindow::accept()
|
|||
}
|
||||
|
||||
|
||||
void InstallTalkWindow::setDeviceSettings(QSettings *dev)
|
||||
void InstallTalkWindow::setSettings(QSettings *user,QSettings *dev)
|
||||
{
|
||||
devices = dev;
|
||||
userSettings = user;
|
||||
qDebug() << "Install::setDeviceSettings:" << devices;
|
||||
|
||||
QString ttsName = userSettings->value("tts", "none").toString();
|
||||
TTSBase* tts = getTTS(ttsName);
|
||||
tts->setUserCfg(userSettings);
|
||||
tts->setCfg(userSettings,devices);
|
||||
if(tts->configOk())
|
||||
ui.labelTtsProfile->setText(tr("Selected TTS engine : <b>%1</b>").arg(ttsName));
|
||||
else
|
||||
|
@ -127,12 +127,8 @@ void InstallTalkWindow::setDeviceSettings(QSettings *dev)
|
|||
ui.labelEncProfile->setText(tr("Selected Encoder: <b>%1</b>").arg(encoder));
|
||||
else
|
||||
ui.labelEncProfile->setText(tr("Selected Encoder: <b>%1</b>").arg("Invalid encoder configuration!"));
|
||||
}
|
||||
|
||||
void InstallTalkWindow::setUserSettings(QSettings *user)
|
||||
{
|
||||
userSettings = user;
|
||||
|
||||
setTalkFolder(userSettings->value("last_talked_folder").toString());
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -33,8 +33,7 @@ class InstallTalkWindow : public QDialog
|
|||
Q_OBJECT
|
||||
public:
|
||||
InstallTalkWindow(QWidget *parent = 0);
|
||||
void setUserSettings(QSettings*);
|
||||
void setDeviceSettings(QSettings*);
|
||||
void setSettings(QSettings* user,QSettings* device);
|
||||
|
||||
signals:
|
||||
void settingsUpdated(void);
|
||||
|
|
|
@ -253,8 +253,7 @@ void RbUtilQt::help()
|
|||
void RbUtilQt::configDialog()
|
||||
{
|
||||
Config *cw = new Config(this);
|
||||
cw->setUserSettings(userSettings);
|
||||
cw->setDevices(devices);
|
||||
cw->setSettings(userSettings,devices);
|
||||
cw->show();
|
||||
connect(cw, SIGNAL(settingsUpdated()), this, SLOT(downloadInfo()));
|
||||
connect(cw, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
|
||||
|
@ -748,8 +747,7 @@ void RbUtilQt::createTalkFiles(void)
|
|||
{
|
||||
if(chkConfig(true)) return;
|
||||
InstallTalkWindow *installWindow = new InstallTalkWindow(this);
|
||||
installWindow->setUserSettings(userSettings);
|
||||
installWindow->setDeviceSettings(devices);
|
||||
installWindow->setSettings(userSettings,devices);
|
||||
installWindow->show();
|
||||
connect(installWindow, SIGNAL(settingsUpdated()), this, SLOT(downloadInfo()));
|
||||
connect(installWindow, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
|
||||
|
@ -760,8 +758,7 @@ void RbUtilQt::createVoiceFile(void)
|
|||
{
|
||||
if(chkConfig(true)) return;
|
||||
CreateVoiceWindow *installWindow = new CreateVoiceWindow(this);
|
||||
installWindow->setUserSettings(userSettings);
|
||||
installWindow->setDeviceSettings(devices);
|
||||
installWindow->setSettings(userSettings,devices);
|
||||
installWindow->setProxy(proxy());
|
||||
|
||||
installWindow->show();
|
||||
|
|
|
@ -17,6 +17,12 @@ rbspeex.commands = @$(MAKE) -C ../../tools/rbspeex librbspeex.a
|
|||
QMAKE_EXTRA_TARGETS = rbspeex
|
||||
PRE_TARGETDEPS = rbspeex
|
||||
|
||||
# add a custom rule for makeing the translations
|
||||
lrelease.commands = lrelease rbutilqt.pro
|
||||
QMAKE_EXTRA_TARGETS += lrelease
|
||||
PRE_TARGETDEPS = lrelease
|
||||
|
||||
|
||||
SOURCES += rbutilqt.cpp \
|
||||
main.cpp \
|
||||
install.cpp \
|
||||
|
|
|
@ -18,41 +18,68 @@
|
|||
<property name="title" >
|
||||
<string>Configure TTS Engine</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" >
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2" >
|
||||
<property name="text" >
|
||||
<string>TTS options</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="ttsoptions" />
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" >
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="label_3" >
|
||||
<property name="text" >
|
||||
<string>Language</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="ttslanguage" />
|
||||
<item row="0" column="1" >
|
||||
<widget class="QComboBox" name="languagecombo" />
|
||||
</item>
|
||||
<item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QLabel" name="label" >
|
||||
<property name="text" >
|
||||
<string>Voice</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<widget class="QComboBox" name="voicecombo" />
|
||||
</item>
|
||||
<item row="2" column="0" >
|
||||
<widget class="QLabel" name="label_4" >
|
||||
<property name="text" >
|
||||
<string>Speed</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" >
|
||||
<widget class="QSpinBox" name="speed" >
|
||||
<property name="minimum" >
|
||||
<number>-10</number>
|
||||
</property>
|
||||
<property name="maximum" >
|
||||
<number>10</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" >
|
||||
<widget class="QLabel" name="label_2" >
|
||||
<property name="text" >
|
||||
<string>TTS options</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" >
|
||||
<widget class="QLineEdit" name="ttsoptions" />
|
||||
</item>
|
||||
<item row="4" column="0" colspan="2" >
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
<width>473</width>
|
||||
<height>21</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<item row="5" column="0" colspan="2" >
|
||||
<layout class="QHBoxLayout" >
|
||||
<item>
|
||||
<widget class="QPushButton" name="reset" >
|
||||
|
|
|
@ -28,15 +28,17 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
|
|||
{
|
||||
m_abort = false;
|
||||
m_logger = logger;
|
||||
m_logger->addItem("Starting Talk file generation",LOGINFO);
|
||||
m_logger->addItem(tr("Starting Talk file generation"),LOGINFO);
|
||||
|
||||
//tts
|
||||
m_tts = getTTS(userSettings->value("tts").toString());
|
||||
m_tts->setUserCfg(userSettings);
|
||||
m_tts->setCfg(userSettings,deviceSettings);
|
||||
|
||||
if(!m_tts->start())
|
||||
QString errStr;
|
||||
if(!m_tts->start(&errStr))
|
||||
{
|
||||
m_logger->addItem("Init of TTS engine failed",LOGERROR);
|
||||
m_logger->addItem(errStr,LOGERROR);
|
||||
m_logger->addItem(tr("Init of TTS engine failed"),LOGERROR);
|
||||
m_logger->abort();
|
||||
return false;
|
||||
}
|
||||
|
@ -47,7 +49,7 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
|
|||
|
||||
if(!m_enc->start())
|
||||
{
|
||||
m_logger->addItem("Init of Encoder engine failed",LOGERROR);
|
||||
m_logger->addItem(tr("Init of Encoder engine failed"),LOGERROR);
|
||||
m_logger->abort();
|
||||
m_tts->stop();
|
||||
return false;
|
||||
|
@ -65,7 +67,7 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
|
|||
{
|
||||
if(m_abort)
|
||||
{
|
||||
m_logger->addItem("Talk file creation aborted",LOGERROR);
|
||||
m_logger->addItem(tr("Talk file creation aborted"),LOGERROR);
|
||||
m_logger->abort();
|
||||
m_tts->stop();
|
||||
return false;
|
||||
|
@ -127,10 +129,10 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
|
|||
{
|
||||
if(!wavfilenameInf.exists() || m_overwriteWav)
|
||||
{
|
||||
m_logger->addItem("Voicing of " + toSpeak,LOGINFO);
|
||||
m_logger->addItem(tr("Voicing of %1").arg(toSpeak),LOGINFO);
|
||||
if(!m_tts->voice(toSpeak,wavfilename))
|
||||
{
|
||||
m_logger->addItem("Voicing of " + toSpeak + " failed",LOGERROR);
|
||||
m_logger->addItem(tr("Voicing of %s failed").arg(toSpeak),LOGERROR);
|
||||
m_logger->abort();
|
||||
m_tts->stop();
|
||||
m_enc->stop();
|
||||
|
@ -138,10 +140,10 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
|
|||
}
|
||||
QApplication::processEvents();
|
||||
}
|
||||
m_logger->addItem("Encoding of " + toSpeak,LOGINFO);
|
||||
m_logger->addItem(tr("Encoding of %1").arg(toSpeak),LOGINFO);
|
||||
if(!m_enc->encode(wavfilename,filename))
|
||||
{
|
||||
m_logger->addItem("Encoding of " + wavfilename + " failed",LOGERROR);
|
||||
m_logger->addItem(tr("Encoding of %1 failed").arg(wavfilename),LOGERROR);
|
||||
m_logger->abort();
|
||||
m_tts->stop();
|
||||
m_enc->stop();
|
||||
|
@ -168,7 +170,7 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
|
|||
|
||||
installlog.endGroup();
|
||||
m_tts->stop();
|
||||
m_logger->addItem("Finished creating Talk files",LOGOK);
|
||||
m_logger->addItem(tr("Finished creating Talk files"),LOGOK);
|
||||
m_logger->setProgressMax(1);
|
||||
m_logger->setProgressValue(1);
|
||||
m_logger->abort();
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
|
||||
bool createTalkFiles(ProgressloggerInterface* logger);
|
||||
|
||||
void setUserSettings(QSettings* setting) { userSettings = setting;}
|
||||
void setSettings(QSettings* uSettings,QSettings* dSettings) { userSettings = uSettings; deviceSettings = dSettings;}
|
||||
|
||||
void setDir(QDir dir){m_dir = dir; }
|
||||
void setMountPoint(QString mountpoint) {m_mountpoint =mountpoint; }
|
||||
|
@ -56,6 +56,7 @@ private:
|
|||
TTSBase* m_tts;
|
||||
EncBase* m_enc;
|
||||
QSettings *userSettings;
|
||||
QSettings *deviceSettings;
|
||||
|
||||
QDir m_dir;
|
||||
QString m_mountpoint;
|
||||
|
|
|
@ -104,7 +104,7 @@ TTSExes::TTSExes(QString name,QWidget *parent) : TTSBase(parent)
|
|||
connect(ui.browse,SIGNAL(clicked()),this,SLOT(browse()));
|
||||
}
|
||||
|
||||
bool TTSExes::start()
|
||||
bool TTSExes::start(QString *errStr)
|
||||
{
|
||||
userSettings->beginGroup(m_name);
|
||||
m_TTSexec = userSettings->value("ttspath","").toString();
|
||||
|
@ -120,6 +120,7 @@ bool TTSExes::start()
|
|||
}
|
||||
else
|
||||
{
|
||||
*errStr = tr("TTS executable not found");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -244,40 +245,109 @@ void TTSExes::browse()
|
|||
**********************************************************************/
|
||||
TTSSapi::TTSSapi(QWidget *parent) : TTSBase(parent)
|
||||
{
|
||||
m_TTSTemplate = "cscript //nologo \"%exe\" /language:%lang \"%options\"";
|
||||
m_TTSTemplate = "cscript //nologo \"%exe\" /language:%lang /voice:\"%voice\" /speed:%speed \"%options\"";
|
||||
defaultLanguage ="english";
|
||||
ui.setupUi(this);
|
||||
this->hide();
|
||||
connect(ui.reset,SIGNAL(clicked()),this,SLOT(reset()));
|
||||
connect(ui.languagecombo,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateVoices(QString)));
|
||||
}
|
||||
|
||||
|
||||
bool TTSSapi::start()
|
||||
bool TTSSapi::start(QString *errStr)
|
||||
{
|
||||
|
||||
userSettings->beginGroup("sapi");
|
||||
m_TTSOpts = userSettings->value("ttsoptions","").toString();
|
||||
m_TTSLanguage =userSettings->value("ttslanguage","").toString();
|
||||
m_TTSVoice=userSettings->value("ttsvoice","").toString();
|
||||
m_TTSSpeed=userSettings->value("ttsspeed","").toString();
|
||||
userSettings->endGroup();
|
||||
|
||||
QFile::remove(QDir::tempPath() +"/sapi_voice.vbs");
|
||||
QFile::copy(":/builtin/sapi_voice.vbs",QDir::tempPath() + "/sapi_voice.vbs");
|
||||
m_TTSexec = QDir::tempPath() +"/sapi_voice.vbs";
|
||||
|
||||
QFileInfo tts(m_TTSexec);
|
||||
if(!tts.exists())
|
||||
{
|
||||
*errStr = tr("Could not copy the Sapi-script");
|
||||
return false;
|
||||
}
|
||||
// create the voice process
|
||||
QString execstring = m_TTSTemplate;
|
||||
execstring.replace("%exe",m_TTSexec);
|
||||
execstring.replace("%options",m_TTSOpts);
|
||||
execstring.replace("%lang",m_TTSLanguage);
|
||||
execstring.replace("%voice",m_TTSVoice);
|
||||
execstring.replace("%speed",m_TTSSpeed);
|
||||
|
||||
qDebug() << "init" << execstring;
|
||||
voicescript = new QProcess(NULL);
|
||||
//connect(voicescript,SIGNAL(readyReadStandardError()),this,SLOT(error()));
|
||||
|
||||
voicescript->start(execstring);
|
||||
if(!voicescript->waitForStarted())
|
||||
{
|
||||
*errStr = tr("Could not start the Sapi-script");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!voicescript->waitForReadyRead(100))
|
||||
{
|
||||
*errStr = voicescript->readAllStandardError();
|
||||
if(*errStr != "")
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
QStringList TTSSapi::getVoiceList(QString language)
|
||||
{
|
||||
QStringList result;
|
||||
|
||||
QFile::copy(":/builtin/sapi_voice.vbs",QDir::tempPath() + "/sapi_voice.vbs");
|
||||
m_TTSexec = QDir::tempPath() +"/sapi_voice.vbs";
|
||||
|
||||
QFileInfo tts(m_TTSexec);
|
||||
if(!tts.exists())
|
||||
return false;
|
||||
return result;
|
||||
|
||||
// create the voice process
|
||||
QString execstring = m_TTSTemplate;
|
||||
QString execstring = "cscript //nologo \"%exe\" /language:%lang /listvoices";;
|
||||
execstring.replace("%exe",m_TTSexec);
|
||||
execstring.replace("%options",m_TTSOpts);
|
||||
execstring.replace("%lang",m_TTSLanguage);
|
||||
execstring.replace("%lang",language);
|
||||
qDebug() << "init" << execstring;
|
||||
voicescript = new QProcess(NULL);
|
||||
voicescript->start(execstring);
|
||||
if(!voicescript->waitForStarted())
|
||||
return false;
|
||||
return true;
|
||||
return result;
|
||||
|
||||
voicescript->waitForReadyRead();
|
||||
|
||||
QString dataRaw = voicescript->readAllStandardError().data();
|
||||
result = dataRaw.split(",",QString::SkipEmptyParts);
|
||||
result.sort();
|
||||
result.removeFirst();
|
||||
|
||||
delete voicescript;
|
||||
QFile::setPermissions(QDir::tempPath() +"/sapi_voice.vbs",QFile::ReadOwner |QFile::WriteOwner|QFile::ExeOwner
|
||||
|QFile::ReadUser| QFile::WriteUser| QFile::ExeUser
|
||||
|QFile::ReadGroup |QFile::WriteGroup |QFile::ExeGroup
|
||||
|QFile::ReadOther |QFile::WriteOther |QFile::ExeOther );
|
||||
QFile::remove(QDir::tempPath() +"/sapi_voice.vbs");
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void TTSSapi::updateVoices(QString language)
|
||||
{
|
||||
QStringList Voices = getVoiceList(language);
|
||||
ui.voicecombo->clear();
|
||||
ui.voicecombo->addItems(Voices);
|
||||
|
||||
|
||||
}
|
||||
|
||||
bool TTSSapi::voice(QString text,QString wavfile)
|
||||
|
@ -296,6 +366,11 @@ bool TTSSapi::stop()
|
|||
voicescript->write(query.toUtf8());
|
||||
voicescript->waitForFinished();
|
||||
delete voicescript;
|
||||
QFile::setPermissions(QDir::tempPath() +"/sapi_voice.vbs",QFile::ReadOwner |QFile::WriteOwner|QFile::ExeOwner
|
||||
|QFile::ReadUser| QFile::WriteUser| QFile::ExeUser
|
||||
|QFile::ReadGroup |QFile::WriteGroup |QFile::ExeGroup
|
||||
|QFile::ReadOther |QFile::WriteOther |QFile::ExeOther );
|
||||
QFile::remove(QDir::tempPath() +"/sapi_voice.vbs");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -303,7 +378,7 @@ bool TTSSapi::stop()
|
|||
void TTSSapi::reset()
|
||||
{
|
||||
ui.ttsoptions->setText("");
|
||||
ui.ttslanguage->setText(defaultLanguage);
|
||||
ui.languagecombo->setCurrentIndex(ui.languagecombo->findText(defaultLanguage));
|
||||
}
|
||||
|
||||
void TTSSapi::showCfg()
|
||||
|
@ -311,9 +386,35 @@ void TTSSapi::showCfg()
|
|||
// try to get config from settings
|
||||
userSettings->beginGroup("sapi");
|
||||
ui.ttsoptions->setText(userSettings->value("ttsoptions","").toString());
|
||||
ui.ttslanguage->setText(userSettings->value("ttslanguage",defaultLanguage).toString());
|
||||
QString selLang = userSettings->value("ttslanguage",defaultLanguage).toString();
|
||||
QString selVoice = userSettings->value("ttsvoice","").toString();
|
||||
ui.speed->setValue(userSettings->value("ttsspeed",0).toInt());
|
||||
userSettings->endGroup();
|
||||
|
||||
// fill in language combobox
|
||||
|
||||
deviceSettings->beginGroup("languages");
|
||||
QStringList keys = deviceSettings->allKeys();
|
||||
QStringList languages;
|
||||
for(int i =0 ; i < keys.size();i++)
|
||||
{
|
||||
languages << deviceSettings->value(keys.at(i)).toString();
|
||||
}
|
||||
deviceSettings->endGroup();
|
||||
|
||||
languages.sort();
|
||||
ui.languagecombo->clear();
|
||||
ui.languagecombo->addItems(languages);
|
||||
|
||||
// set saved lang
|
||||
ui.languagecombo->setCurrentIndex(ui.languagecombo->findText(selLang));
|
||||
|
||||
// fill in voice combobox
|
||||
updateVoices(selLang);
|
||||
|
||||
// set saved lang
|
||||
ui.voicecombo->setCurrentIndex(ui.voicecombo->findText(selVoice));
|
||||
|
||||
//show dialog
|
||||
this->exec();
|
||||
|
||||
|
@ -326,7 +427,9 @@ void TTSSapi::accept(void)
|
|||
//save settings in user config
|
||||
userSettings->beginGroup("sapi");
|
||||
userSettings->setValue("ttsoptions",ui.ttsoptions->text());
|
||||
userSettings->setValue("ttslanguage",ui.ttslanguage->text());
|
||||
userSettings->setValue("ttslanguage",ui.languagecombo->currentText());
|
||||
userSettings->setValue("ttsvoice",ui.voicecombo->currentText());
|
||||
userSettings->setValue("ttsspeed",QString("%1").arg(ui.speed->value()));
|
||||
userSettings->endGroup();
|
||||
// sync settings
|
||||
userSettings->sync();
|
||||
|
|
|
@ -42,12 +42,12 @@ class TTSBase : public QDialog
|
|||
public:
|
||||
TTSBase(QWidget *parent );
|
||||
virtual bool voice(QString text,QString wavfile) {return false;}
|
||||
virtual bool start(){return false;}
|
||||
virtual bool start(QString *errStr){return false;}
|
||||
virtual bool stop(){return false;}
|
||||
virtual void showCfg(){}
|
||||
virtual bool configOk(){return false;}
|
||||
|
||||
void setUserCfg(QSettings *uSettings){userSettings = uSettings;}
|
||||
void setCfg(QSettings *uSettings, QSettings *dSettings){userSettings = uSettings;deviceSettings = dSettings;}
|
||||
|
||||
public slots:
|
||||
virtual void accept(void){}
|
||||
|
@ -56,6 +56,8 @@ public slots:
|
|||
|
||||
protected:
|
||||
QSettings *userSettings;
|
||||
QSettings *deviceSettings;
|
||||
|
||||
};
|
||||
|
||||
class TTSSapi : public TTSBase
|
||||
|
@ -64,7 +66,7 @@ class TTSSapi : public TTSBase
|
|||
public:
|
||||
TTSSapi(QWidget *parent = NULL);
|
||||
virtual bool voice(QString text,QString wavfile);
|
||||
virtual bool start();
|
||||
virtual bool start(QString *errStr);
|
||||
virtual bool stop();
|
||||
virtual void showCfg();
|
||||
virtual bool configOk();
|
||||
|
@ -74,7 +76,10 @@ public slots:
|
|||
virtual void reject(void);
|
||||
virtual void reset(void);
|
||||
|
||||
void updateVoices(QString language);
|
||||
private:
|
||||
QStringList getVoiceList(QString language);
|
||||
|
||||
Ui::SapiCfgFrm ui;
|
||||
QProcess* voicescript;
|
||||
|
||||
|
@ -84,6 +89,9 @@ private:
|
|||
QString m_TTSOpts;
|
||||
QString m_TTSTemplate;
|
||||
QString m_TTSLanguage;
|
||||
QString m_TTSVoice;
|
||||
QString m_TTSSpeed;
|
||||
|
||||
};
|
||||
|
||||
class TTSExes : public TTSBase
|
||||
|
@ -92,7 +100,7 @@ class TTSExes : public TTSBase
|
|||
public:
|
||||
TTSExes(QString name,QWidget *parent = NULL);
|
||||
virtual bool voice(QString text,QString wavfile);
|
||||
virtual bool start();
|
||||
virtual bool start(QString *errStr);
|
||||
virtual bool stop() {return true;}
|
||||
virtual void showCfg();
|
||||
virtual bool configOk();
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
VoiceFileCreator::VoiceFileCreator(QObject* parent) :QObject(parent)
|
||||
{
|
||||
|
||||
m_wavtrimThreshold=500;
|
||||
}
|
||||
|
||||
void VoiceFileCreator::abort()
|
||||
|
@ -147,10 +147,12 @@ void VoiceFileCreator::downloadDone(bool error)
|
|||
|
||||
//tts
|
||||
m_tts = getTTS(userSettings->value("tts").toString());
|
||||
m_tts->setUserCfg(userSettings);
|
||||
m_tts->setCfg(userSettings,deviceSettings);
|
||||
|
||||
if(!m_tts->start())
|
||||
QString errStr;
|
||||
if(!m_tts->start(&errStr))
|
||||
{
|
||||
m_logger->addItem(errStr,LOGERROR);
|
||||
m_logger->addItem(tr("Init of TTS engine failed"),LOGERROR);
|
||||
m_logger->abort();
|
||||
return;
|
||||
|
@ -249,7 +251,7 @@ void VoiceFileCreator::downloadDone(bool error)
|
|||
// todo strip
|
||||
char buffer[255];
|
||||
|
||||
wavtrim((char*)qPrintable(wavname),500,buffer,255);
|
||||
wavtrim((char*)qPrintable(wavname),m_wavtrimThreshold,buffer,255);
|
||||
|
||||
// encode wav
|
||||
m_enc->encode(wavname,encodedname);
|
||||
|
|
|
@ -44,12 +44,12 @@ public:
|
|||
bool createVoiceFile(ProgressloggerInterface* logger);
|
||||
|
||||
// set infos
|
||||
void setUserSettings(QSettings* setting) { userSettings = setting;}
|
||||
void setDeviceSettings(QSettings* setting) { deviceSettings = setting;}
|
||||
void setSettings(QSettings* uSettings,QSettings* dSettings) { userSettings = uSettings;deviceSettings = dSettings;}
|
||||
|
||||
void setMountPoint(QString mountpoint) {m_mountpoint =mountpoint; }
|
||||
void setTargetId(int id){m_targetid = id;}
|
||||
void setLang(QString name){m_lang =name;}
|
||||
void setWavtrimThreshold(int th){m_wavtrimThreshold = th;}
|
||||
void setProxy(QUrl proxy){m_proxy = proxy;}
|
||||
|
||||
private slots:
|
||||
|
@ -75,6 +75,7 @@ private:
|
|||
QString m_path; //path where the wav and mp3 files are stored to
|
||||
int m_targetid; //the target id
|
||||
QString m_lang; // the language which will be spoken
|
||||
int m_wavtrimThreshold;
|
||||
|
||||
ProgressloggerInterface* m_logger;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue