mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-09 13:15:18 -05:00
rbutil: completely rework how tts and encoders are configured. (FS#10070)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20824 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
3d2e42ab4c
commit
5b85ef6006
27 changed files with 1274 additions and 2029 deletions
|
|
@ -130,6 +130,35 @@ qulonglong filesystemFree(QString path)
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! \brief searches for a Executable in the Environement Path
|
||||||
|
QString findExecutable(QString name)
|
||||||
|
{
|
||||||
|
QString exepath;
|
||||||
|
//try autodetect tts
|
||||||
|
#if defined(Q_OS_LINUX) || defined(Q_OS_MACX) || defined(Q_OS_OPENBSD)
|
||||||
|
QStringList path = QString(getenv("PATH")).split(":", QString::SkipEmptyParts);
|
||||||
|
#elif defined(Q_OS_WIN)
|
||||||
|
QStringList path = QString(getenv("PATH")).split(";", QString::SkipEmptyParts);
|
||||||
|
#endif
|
||||||
|
qDebug() << path;
|
||||||
|
for(int i = 0; i < path.size(); i++)
|
||||||
|
{
|
||||||
|
QString executable = QDir::fromNativeSeparators(path.at(i)) + "/" + name;
|
||||||
|
#if defined(Q_OS_WIN)
|
||||||
|
executable += ".exe";
|
||||||
|
QStringList ex = executable.split("\"", QString::SkipEmptyParts);
|
||||||
|
executable = ex.join("");
|
||||||
|
#endif
|
||||||
|
qDebug() << executable;
|
||||||
|
if(QFileInfo(executable).isExecutable())
|
||||||
|
{
|
||||||
|
return QDir::toNativeSeparators(executable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
RockboxInfo::RockboxInfo(QString mountpoint)
|
RockboxInfo::RockboxInfo(QString mountpoint)
|
||||||
{
|
{
|
||||||
m_path = mountpoint +"/.rockbox/rockbox-info.txt";
|
m_path = mountpoint +"/.rockbox/rockbox-info.txt";
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@
|
||||||
bool recRmdir( const QString &dirName );
|
bool recRmdir( const QString &dirName );
|
||||||
QString resolvePathCase(QString path);
|
QString resolvePathCase(QString path);
|
||||||
qulonglong filesystemFree(QString path);
|
qulonglong filesystemFree(QString path);
|
||||||
|
QString findExecutable(QString name);
|
||||||
|
|
||||||
class RockboxInfo
|
class RockboxInfo
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@
|
||||||
#include "encoders.h"
|
#include "encoders.h"
|
||||||
#include "tts.h"
|
#include "tts.h"
|
||||||
#include "detect.h"
|
#include "detect.h"
|
||||||
|
#include "encttscfggui.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#if defined(Q_OS_WIN32)
|
#if defined(Q_OS_WIN32)
|
||||||
|
|
@ -356,7 +357,7 @@ void Config::setDevices()
|
||||||
void Config::updateTtsState(int index)
|
void Config::updateTtsState(int index)
|
||||||
{
|
{
|
||||||
QString ttsName = ui.comboTts->itemData(index).toString();
|
QString ttsName = ui.comboTts->itemData(index).toString();
|
||||||
TTSBase* tts = TTSBase::getTTS(ttsName);
|
TTSBase* tts = TTSBase::getTTS(this,ttsName);
|
||||||
tts->setCfg(settings);
|
tts->setCfg(settings);
|
||||||
|
|
||||||
if(tts->configOk())
|
if(tts->configOk())
|
||||||
|
|
@ -386,7 +387,7 @@ void Config::updateEncState()
|
||||||
ui.encoderName->setText(EncBase::getEncoderName(settings->value(RbSettings::CurEncoder).toString()));
|
ui.encoderName->setText(EncBase::getEncoderName(settings->value(RbSettings::CurEncoder).toString()));
|
||||||
settings->setValue(RbSettings::Platform, olddevice);
|
settings->setValue(RbSettings::Platform, olddevice);
|
||||||
|
|
||||||
EncBase* enc = EncBase::getEncoder(encoder);
|
EncBase* enc = EncBase::getEncoder(this,encoder);
|
||||||
enc->setCfg(settings);
|
enc->setCfg(settings);
|
||||||
|
|
||||||
if(enc->configOk())
|
if(enc->configOk())
|
||||||
|
|
@ -666,19 +667,36 @@ void Config::cacheClear()
|
||||||
void Config::configTts()
|
void Config::configTts()
|
||||||
{
|
{
|
||||||
int index = ui.comboTts->currentIndex();
|
int index = ui.comboTts->currentIndex();
|
||||||
TTSBase* tts = TTSBase::getTTS(ui.comboTts->itemData(index).toString());
|
TTSBase* tts = TTSBase::getTTS(this,ui.comboTts->itemData(index).toString());
|
||||||
|
|
||||||
tts->setCfg(settings);
|
tts->setCfg(settings);
|
||||||
tts->showCfg();
|
EncTtsCfgGui gui(this,tts,TTSBase::getTTSName(settings->value(RbSettings::Tts).toString()));
|
||||||
|
gui.exec();
|
||||||
updateTtsState(ui.comboTts->currentIndex());
|
updateTtsState(ui.comboTts->currentIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Config::configEnc()
|
void Config::configEnc()
|
||||||
{
|
{
|
||||||
EncBase* enc = EncBase::getEncoder(settings->value(RbSettings::CurEncoder).toString());
|
// FIXME: this is a workaround to make the encoder follow the device selection
|
||||||
|
// even with the settings (and thus the device) being saved. Needs to be redone
|
||||||
|
// properly later by extending the settings object
|
||||||
|
if(ui.treeDevices->selectedItems().size() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
QString devname = ui.treeDevices->selectedItems().at(0)->data(0, Qt::UserRole).toString();
|
||||||
|
QString olddevice = settings->value(RbSettings::CurrentPlatform).toString();
|
||||||
|
settings->setValue(RbSettings::CurrentPlatform,devname);
|
||||||
|
QString encoder = settings->value(RbSettings::CurEncoder).toString();
|
||||||
|
ui.encoderName->setText(EncBase::getEncoderName(settings->value(RbSettings::CurEncoder).toString()));
|
||||||
|
settings->setValue(RbSettings::CurrentPlatform,olddevice);
|
||||||
|
|
||||||
|
|
||||||
|
EncBase* enc = EncBase::getEncoder(this,encoder);
|
||||||
|
|
||||||
enc->setCfg(settings);
|
enc->setCfg(settings);
|
||||||
enc->showCfg();
|
EncTtsCfgGui gui(this,enc,EncBase::getEncoderName(encoder));
|
||||||
|
gui.exec();
|
||||||
|
|
||||||
updateEncState();
|
updateEncState();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ void CreateVoiceWindow::updateSettings(void)
|
||||||
ui.comboLanguage->setCurrentIndex(sel);
|
ui.comboLanguage->setCurrentIndex(sel);
|
||||||
|
|
||||||
QString ttsName = settings->value(RbSettings::Tts).toString();
|
QString ttsName = settings->value(RbSettings::Tts).toString();
|
||||||
TTSBase* tts = TTSBase::getTTS(ttsName);
|
TTSBase* tts = TTSBase::getTTS(this,ttsName);
|
||||||
tts->setCfg(settings);
|
tts->setCfg(settings);
|
||||||
if(tts->configOk())
|
if(tts->configOk())
|
||||||
ui.labelTtsProfile->setText(tr("Selected TTS engine: <b>%1</b>")
|
ui.labelTtsProfile->setText(tr("Selected TTS engine: <b>%1</b>")
|
||||||
|
|
@ -109,7 +109,7 @@ void CreateVoiceWindow::updateSettings(void)
|
||||||
|
|
||||||
QString encoder = settings->value(RbSettings::CurEncoder).toString();
|
QString encoder = settings->value(RbSettings::CurEncoder).toString();
|
||||||
// only proceed if encoder setting is set
|
// only proceed if encoder setting is set
|
||||||
EncBase* enc = EncBase::getEncoder(encoder);
|
EncBase* enc = EncBase::getEncoder(this,encoder);
|
||||||
if(enc != NULL) {
|
if(enc != NULL) {
|
||||||
enc->setCfg(settings);
|
enc->setCfg(settings);
|
||||||
if(enc->configOk())
|
if(enc->configOk())
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ class CreateVoiceWindow : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
CreateVoiceWindow(QWidget *parent = 0);
|
CreateVoiceWindow(QWidget *parent);
|
||||||
void setSettings(RbSettings* sett);
|
void setSettings(RbSettings* sett);
|
||||||
void setProxy(QUrl proxy){m_proxy = proxy;}
|
void setProxy(QUrl proxy){m_proxy = proxy;}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,18 +18,17 @@
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "encoders.h"
|
#include "encoders.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
#ifndef CONSOLE
|
/*********************************************************************
|
||||||
#include "encodersgui.h"
|
* Encoder Base
|
||||||
#include "browsedirtree.h"
|
**********************************************************************/
|
||||||
#else
|
|
||||||
#include "encodersguicli.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
QMap<QString,QString> EncBase::encoderList;
|
QMap<QString,QString> EncBase::encoderList;
|
||||||
QMap<QString,EncBase*> EncBase::encoderCache;
|
|
||||||
|
|
||||||
|
EncBase::EncBase(QObject *parent): EncTtsSettingInterface(parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// initialize list of encoders
|
// initialize list of encoders
|
||||||
void EncBase::initEncodernamesList()
|
void EncBase::initEncodernamesList()
|
||||||
|
|
@ -49,23 +48,17 @@ QString EncBase::getEncoderName(QString encoder)
|
||||||
|
|
||||||
|
|
||||||
// get a specific encoder object
|
// get a specific encoder object
|
||||||
EncBase* EncBase::getEncoder(QString encoder)
|
EncBase* EncBase::getEncoder(QObject* parent,QString encoder)
|
||||||
{
|
{
|
||||||
// check cache
|
|
||||||
if(encoderCache.contains(encoder))
|
|
||||||
return encoderCache.value(encoder);
|
|
||||||
|
|
||||||
EncBase* enc;
|
EncBase* enc;
|
||||||
if(encoder == "lame")
|
if(encoder == "lame")
|
||||||
{
|
{
|
||||||
enc = new EncExes(encoder);
|
enc = new EncExes(encoder,parent);
|
||||||
encoderCache[encoder] = enc;
|
|
||||||
return enc;
|
return enc;
|
||||||
}
|
}
|
||||||
else // rbspeex is default
|
else // rbspeex is default
|
||||||
{
|
{
|
||||||
enc = new EncRbSpeex();
|
enc = new EncRbSpeex(parent);
|
||||||
encoderCache[encoder] = enc;
|
|
||||||
return enc;
|
return enc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -79,14 +72,6 @@ QStringList EncBase::getEncoderList()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************
|
|
||||||
* Encoder Base
|
|
||||||
**********************************************************************/
|
|
||||||
EncBase::EncBase(QObject *parent): QObject(parent)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
* GEneral Exe Encoder
|
* GEneral Exe Encoder
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
@ -95,6 +80,25 @@ EncExes::EncExes(QString name,QObject *parent) : EncBase(parent)
|
||||||
m_name = name;
|
m_name = name;
|
||||||
|
|
||||||
m_TemplateMap["lame"] = "\"%exe\" %options \"%input\" \"%output\"";
|
m_TemplateMap["lame"] = "\"%exe\" %options \"%input\" \"%output\"";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void EncExes::generateSettings()
|
||||||
|
{
|
||||||
|
QString exepath =settings->subValue(m_name,RbSettings::EncoderPath).toString();
|
||||||
|
if(exepath == "") exepath = findExecutable(m_name);
|
||||||
|
|
||||||
|
insertSetting(eEXEPATH,new EncTtsSetting(this,EncTtsSetting::eSTRING,"Path to Encoder:",exepath,EncTtsSetting::eBROWSEBTN));
|
||||||
|
insertSetting(eEXEOPTIONS,new EncTtsSetting(this,EncTtsSetting::eSTRING,"Encoder options:",settings->subValue(m_name,RbSettings::EncoderOptions)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void EncExes::saveSettings()
|
||||||
|
{
|
||||||
|
settings->setSubValue(m_name,RbSettings::EncoderPath,getSetting(eEXEPATH)->current().toString());
|
||||||
|
settings->setSubValue(m_name,RbSettings::EncoderOptions,getSetting(eEXEOPTIONS)->current().toString());
|
||||||
|
settings->sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EncExes::start()
|
bool EncExes::start()
|
||||||
|
|
@ -130,18 +134,6 @@ bool EncExes::encode(QString input,QString output)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void EncExes::showCfg()
|
|
||||||
{
|
|
||||||
#ifndef CONSOLE
|
|
||||||
EncExesGui gui;
|
|
||||||
#else
|
|
||||||
EncExesGuiCli gui;
|
|
||||||
#endif
|
|
||||||
gui.setCfg(settings);
|
|
||||||
gui.showCfg(m_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool EncExes::configOk()
|
bool EncExes::configOk()
|
||||||
{
|
{
|
||||||
QString path = settings->subValue(m_name, RbSettings::EncoderPath).toString();
|
QString path = settings->subValue(m_name, RbSettings::EncoderPath).toString();
|
||||||
|
|
@ -152,20 +144,32 @@ bool EncExes::configOk()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
* RB SPEEX ENCODER
|
* RB SPEEX ENCODER
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
EncRbSpeex::EncRbSpeex(QObject *parent) : EncBase(parent)
|
EncRbSpeex::EncRbSpeex(QObject *parent) : EncBase(parent)
|
||||||
{
|
{
|
||||||
|
|
||||||
defaultQuality = 8.f;
|
|
||||||
defaultVolume = 1.f;
|
|
||||||
defaultComplexity = 10;
|
|
||||||
defaultBand = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EncRbSpeex::generateSettings()
|
||||||
|
{
|
||||||
|
insertSetting(eVOLUME,new EncTtsSetting(this,EncTtsSetting::eDOUBLE,"Volume:",settings->subValue("rbspeex",RbSettings::EncoderVolume),1.0,10.0));
|
||||||
|
insertSetting(eQUALITY,new EncTtsSetting(this,EncTtsSetting::eDOUBLE,"Quality:",settings->subValue("rbspeex",RbSettings::EncoderQuality),0,10.0));
|
||||||
|
insertSetting(eCOMPLEXITY,new EncTtsSetting(this,EncTtsSetting::eINT,"Complexity:",settings->subValue("rbspeex",RbSettings::EncoderComplexity),0,10));
|
||||||
|
insertSetting(eNARROWBAND,new EncTtsSetting(this,EncTtsSetting::eBOOL,"Use Narrowband:",settings->subValue("rbspeex",RbSettings::EncoderNarrowBand)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void EncRbSpeex::saveSettings()
|
||||||
|
{
|
||||||
|
//save settings in user config
|
||||||
|
settings->setSubValue("rbspeex",RbSettings::EncoderVolume,getSetting(eVOLUME)->current().toDouble());
|
||||||
|
settings->setSubValue("rbspeex",RbSettings::EncoderQuality,getSetting(eQUALITY)->current().toDouble());
|
||||||
|
settings->setSubValue("rbspeex",RbSettings::EncoderComplexity,getSetting(eCOMPLEXITY)->current().toInt());
|
||||||
|
settings->setSubValue("rbspeex",RbSettings::EncoderNarrowBand,getSetting(eNARROWBAND)->current().toBool());
|
||||||
|
|
||||||
|
settings->sync();
|
||||||
|
}
|
||||||
|
|
||||||
bool EncRbSpeex::start()
|
bool EncRbSpeex::start()
|
||||||
{
|
{
|
||||||
|
|
@ -210,18 +214,6 @@ bool EncRbSpeex::encode(QString input,QString output)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EncRbSpeex::showCfg()
|
|
||||||
{
|
|
||||||
#ifndef CONSOLE
|
|
||||||
EncRbSpeexGui gui;
|
|
||||||
#else
|
|
||||||
EncRbSpeexGuiCli gui;
|
|
||||||
#endif
|
|
||||||
gui.setCfg(settings);
|
|
||||||
gui.showCfg(defaultQuality,defaultVolume,defaultComplexity,defaultBand);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool EncRbSpeex::configOk()
|
bool EncRbSpeex::configOk()
|
||||||
{
|
{
|
||||||
bool result=true;
|
bool result=true;
|
||||||
|
|
|
||||||
|
|
@ -25,32 +25,38 @@
|
||||||
#include <QtCore>
|
#include <QtCore>
|
||||||
|
|
||||||
#include "rbsettings.h"
|
#include "rbsettings.h"
|
||||||
|
#include "encttssettings.h"
|
||||||
#include "rbspeex.h"
|
#include "rbspeex.h"
|
||||||
|
|
||||||
|
|
||||||
class EncBase : public QObject
|
class EncBase : public EncTtsSettingInterface
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
EncBase(QObject *parent );
|
EncBase(QObject *parent );
|
||||||
|
|
||||||
virtual bool encode(QString input,QString output)
|
//! Child class should encode a wav file
|
||||||
{(void)input; (void)output; return false;}
|
virtual bool encode(QString input,QString output) =0;
|
||||||
virtual bool start(){return false;}
|
//! Child class should do startup
|
||||||
virtual bool stop(){return false;}
|
virtual bool start()=0;
|
||||||
virtual void showCfg(){}
|
//! Child class should stop
|
||||||
virtual bool configOk(){return false;}
|
virtual bool stop()=0;
|
||||||
|
|
||||||
void setCfg(RbSettings *sett){settings = sett;}
|
// settings
|
||||||
static QString getEncoderName(QString);
|
//! Child class should return true when configuration is ok
|
||||||
static EncBase* getEncoder(QString);
|
virtual bool configOk()=0;
|
||||||
|
//! Child class should fill in the setttingsList
|
||||||
|
virtual void generateSettings() = 0;
|
||||||
|
//! Chlid class should commit the from SettingsList to permanent storage
|
||||||
|
virtual void saveSettings() = 0;
|
||||||
|
|
||||||
|
// static functions
|
||||||
|
static QString getEncoderName(QString name);
|
||||||
|
static EncBase* getEncoder(QObject* parent,QString name);
|
||||||
static QStringList getEncoderList(void);
|
static QStringList getEncoderList(void);
|
||||||
|
|
||||||
public slots:
|
//set the config. users of Encoder classes, always have to call this first
|
||||||
virtual void accept(void){}
|
void setCfg(RbSettings *sett){settings = sett;}
|
||||||
virtual void reject(void){}
|
|
||||||
virtual void reset(void){}
|
|
||||||
private:
|
private:
|
||||||
static void initEncodernamesList(void);
|
static void initEncodernamesList(void);
|
||||||
|
|
||||||
|
|
@ -58,21 +64,28 @@ class EncBase : public QObject
|
||||||
RbSettings* settings;
|
RbSettings* settings;
|
||||||
|
|
||||||
static QMap<QString,QString> encoderList;
|
static QMap<QString,QString> encoderList;
|
||||||
static QMap<QString,EncBase*> encoderCache;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class EncExes : public EncBase
|
class EncExes : public EncBase
|
||||||
{
|
{
|
||||||
|
enum ESettings
|
||||||
|
{
|
||||||
|
eEXEPATH,
|
||||||
|
eEXEOPTIONS
|
||||||
|
};
|
||||||
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
EncExes(QString name,QObject *parent = NULL);
|
EncExes(QString name,QObject *parent = NULL);
|
||||||
virtual bool encode(QString input,QString output);
|
bool encode(QString input,QString output);
|
||||||
virtual bool start();
|
bool start();
|
||||||
virtual bool stop() {return true;}
|
bool stop() {return true;}
|
||||||
virtual void showCfg();
|
|
||||||
virtual bool configOk();
|
// setting
|
||||||
|
bool configOk();
|
||||||
|
void generateSettings();
|
||||||
|
void saveSettings();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_name;
|
QString m_name;
|
||||||
|
|
@ -84,14 +97,25 @@ private:
|
||||||
|
|
||||||
class EncRbSpeex : public EncBase
|
class EncRbSpeex : public EncBase
|
||||||
{
|
{
|
||||||
|
enum ESettings
|
||||||
|
{
|
||||||
|
eVOLUME,
|
||||||
|
eQUALITY,
|
||||||
|
eCOMPLEXITY,
|
||||||
|
eNARROWBAND
|
||||||
|
};
|
||||||
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
EncRbSpeex(QObject *parent = NULL);
|
EncRbSpeex(QObject *parent = NULL);
|
||||||
virtual bool encode(QString input,QString output);
|
bool encode(QString input,QString output);
|
||||||
virtual bool start();
|
bool start();
|
||||||
virtual bool stop() {return true;}
|
bool stop() {return true;}
|
||||||
virtual void showCfg();
|
|
||||||
virtual bool configOk();
|
// for settings view
|
||||||
|
bool configOk();
|
||||||
|
void generateSettings();
|
||||||
|
void saveSettings();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float quality;
|
float quality;
|
||||||
|
|
|
||||||
|
|
@ -1,171 +0,0 @@
|
||||||
/***************************************************************************
|
|
||||||
* __________ __ ___.
|
|
||||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
||||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
||||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
||||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
||||||
* \/ \/ \/ \/ \/
|
|
||||||
*
|
|
||||||
* Copyright (C) 2007 by Dominik Wenger
|
|
||||||
* $Id$
|
|
||||||
*
|
|
||||||
* All files in this archive are subject to the GNU General Public License.
|
|
||||||
* See the file COPYING in the source tree root for full license agreement.
|
|
||||||
*
|
|
||||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
||||||
* KIND, either express or implied.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include "encodersgui.h"
|
|
||||||
|
|
||||||
#include "rbsettings.h"
|
|
||||||
#include "browsedirtree.h"
|
|
||||||
|
|
||||||
EncExesGui::EncExesGui(QDialog* parent) : QDialog(parent)
|
|
||||||
{
|
|
||||||
ui.setupUi(this);
|
|
||||||
this->hide();
|
|
||||||
connect(ui.reset,SIGNAL(clicked()),this,SLOT(reset()));
|
|
||||||
connect(ui.browse,SIGNAL(clicked()),this,SLOT(browse()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void EncExesGui::showCfg(QString name)
|
|
||||||
{
|
|
||||||
m_name = name;
|
|
||||||
// try to get config from settings
|
|
||||||
QString exepath =settings->subValue(m_name, RbSettings::EncoderPath).toString();
|
|
||||||
ui.encoderoptions->setText(settings->subValue(m_name, RbSettings::EncoderOptions).toString());
|
|
||||||
|
|
||||||
if(exepath == "")
|
|
||||||
{
|
|
||||||
|
|
||||||
// try to autodetect encoder
|
|
||||||
#if defined(Q_OS_LINUX) || defined(Q_OS_MACX) || defined(Q_OS_OPENBSD)
|
|
||||||
QStringList path = QString(getenv("PATH")).split(":", QString::SkipEmptyParts);
|
|
||||||
#elif defined(Q_OS_WIN)
|
|
||||||
QStringList path = QString(getenv("PATH")).split(";", QString::SkipEmptyParts);
|
|
||||||
#endif
|
|
||||||
qDebug() << path;
|
|
||||||
|
|
||||||
for(int i = 0; i < path.size(); i++)
|
|
||||||
{
|
|
||||||
QString executable = QDir::fromNativeSeparators(path.at(i)) + "/" + m_name;
|
|
||||||
#if defined(Q_OS_WIN)
|
|
||||||
executable += ".exe";
|
|
||||||
QStringList ex = executable.split("\"", QString::SkipEmptyParts);
|
|
||||||
executable = ex.join("");
|
|
||||||
#endif
|
|
||||||
if(QFileInfo(executable).isExecutable())
|
|
||||||
{
|
|
||||||
qDebug() << "found:" << executable;
|
|
||||||
exepath = QDir::toNativeSeparators(executable);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ui.encoderpath->setText(exepath);
|
|
||||||
|
|
||||||
//show dialog
|
|
||||||
this->exec();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void EncExesGui::accept(void)
|
|
||||||
{
|
|
||||||
//save settings in user config
|
|
||||||
settings->setSubValue(m_name, RbSettings::EncoderPath, ui.encoderpath->text());
|
|
||||||
settings->setSubValue(m_name, RbSettings::EncoderOptions, ui.encoderoptions->text());
|
|
||||||
|
|
||||||
// sync settings
|
|
||||||
settings->sync();
|
|
||||||
this->done(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void EncExesGui::reject(void)
|
|
||||||
{
|
|
||||||
this->done(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void EncExesGui::reset()
|
|
||||||
{
|
|
||||||
ui.encoderpath->setText("");
|
|
||||||
ui.encoderoptions->setText("");
|
|
||||||
}
|
|
||||||
|
|
||||||
void EncExesGui::browse()
|
|
||||||
{
|
|
||||||
BrowseDirtree browser(this);
|
|
||||||
browser.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
|
|
||||||
|
|
||||||
if(QFileInfo(ui.encoderpath->text()).isDir())
|
|
||||||
{
|
|
||||||
browser.setDir(ui.encoderpath->text());
|
|
||||||
}
|
|
||||||
if(browser.exec() == QDialog::Accepted)
|
|
||||||
{
|
|
||||||
qDebug() << browser.getSelected();
|
|
||||||
QString exe = browser.getSelected();
|
|
||||||
if(!QFileInfo(exe).isExecutable())
|
|
||||||
return;
|
|
||||||
ui.encoderpath->setText(exe);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
EncRbSpeexGui::EncRbSpeexGui(QDialog* parent) : QDialog(parent)
|
|
||||||
{
|
|
||||||
ui.setupUi(this);
|
|
||||||
this->hide();
|
|
||||||
connect(ui.reset,SIGNAL(clicked()),this,SLOT(reset()));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void EncRbSpeexGui::showCfg(float defQ,float defV,int defC, bool defB)
|
|
||||||
{
|
|
||||||
defaultQuality =defQ;
|
|
||||||
defaultVolume = defV;
|
|
||||||
defaultComplexity = defC;
|
|
||||||
defaultBand =defB;
|
|
||||||
|
|
||||||
//fill in the usersettings
|
|
||||||
ui.volume->setValue(settings->subValue("rbspeex", RbSettings::EncoderVolume).toDouble());
|
|
||||||
ui.quality->setValue(settings->subValue("rbspeex", RbSettings::EncoderQuality).toDouble());
|
|
||||||
ui.complexity->setValue(settings->subValue("rbspeex", RbSettings::EncoderComplexity).toInt());
|
|
||||||
|
|
||||||
if(settings->subValue("rbspeex", RbSettings::EncoderNarrowBand).toBool())
|
|
||||||
ui.narrowband->setCheckState(Qt::Checked);
|
|
||||||
else
|
|
||||||
ui.narrowband->setCheckState(Qt::Unchecked);
|
|
||||||
|
|
||||||
//show dialog
|
|
||||||
this->exec();
|
|
||||||
}
|
|
||||||
|
|
||||||
void EncRbSpeexGui::accept(void)
|
|
||||||
{
|
|
||||||
//save settings in user config
|
|
||||||
settings->setSubValue("rbspeex", RbSettings::EncoderVolume, ui.volume->value());
|
|
||||||
settings->setSubValue("rbspeex", RbSettings::EncoderQuality, ui.quality->value());
|
|
||||||
settings->setSubValue("rbspeex", RbSettings::EncoderComplexity, ui.complexity->value());
|
|
||||||
settings->setSubValue("rbspeex", RbSettings::EncoderNarrowBand, ui.narrowband->isChecked() ? true : false);
|
|
||||||
|
|
||||||
// sync settings
|
|
||||||
settings->sync();
|
|
||||||
this->done(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void EncRbSpeexGui::reject(void)
|
|
||||||
{
|
|
||||||
this->done(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void EncRbSpeexGui::reset()
|
|
||||||
{
|
|
||||||
ui.volume->setValue(defaultVolume);
|
|
||||||
ui.quality->setValue(defaultQuality);
|
|
||||||
ui.complexity->setValue(defaultComplexity);
|
|
||||||
ui.narrowband->setChecked(Qt::Unchecked);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,79 +0,0 @@
|
||||||
/***************************************************************************
|
|
||||||
* __________ __ ___.
|
|
||||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
||||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
||||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
||||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
||||||
* \/ \/ \/ \/ \/
|
|
||||||
*
|
|
||||||
* Copyright (C) 2007 by Dominik Wenger
|
|
||||||
* $Id$
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
||||||
* KIND, either express or implied.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef ENCODERSGUI_H
|
|
||||||
#define ENCODERSGUI_H
|
|
||||||
|
|
||||||
#include <QtGui>
|
|
||||||
|
|
||||||
class RbSettings;
|
|
||||||
|
|
||||||
#include "ui_rbspeexcfgfrm.h"
|
|
||||||
#include "ui_encexescfgfrm.h"
|
|
||||||
|
|
||||||
|
|
||||||
class EncExesGui : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
EncExesGui(QDialog* parent = NULL);
|
|
||||||
|
|
||||||
void showCfg(QString m_name);
|
|
||||||
void setCfg(RbSettings* sett){settings = sett;}
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
virtual void accept(void);
|
|
||||||
virtual void reject(void);
|
|
||||||
virtual void reset(void);
|
|
||||||
void browse(void);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::EncExesCfgFrm ui;
|
|
||||||
RbSettings* settings;
|
|
||||||
QString m_name;
|
|
||||||
};
|
|
||||||
|
|
||||||
class EncRbSpeexGui : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
EncRbSpeexGui(QDialog* parent = NULL);
|
|
||||||
|
|
||||||
void showCfg(float defQ,float defV,int defC, bool defB);
|
|
||||||
void setCfg(RbSettings* sett){settings = sett;}
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
virtual void accept(void);
|
|
||||||
virtual void reject(void);
|
|
||||||
virtual void reset(void);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::RbSpeexCfgFrm ui;
|
|
||||||
RbSettings* settings;
|
|
||||||
float defaultQuality;
|
|
||||||
float defaultVolume;
|
|
||||||
int defaultComplexity;
|
|
||||||
bool defaultBand;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
361
rbutil/rbutilqt/encttscfggui.cpp
Normal file
361
rbutil/rbutilqt/encttscfggui.cpp
Normal file
|
|
@ -0,0 +1,361 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* __________ __ ___.
|
||||||
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||||
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||||
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
|
* \/ \/ \/ \/ \/
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007 by Dominik Wenger
|
||||||
|
* $Id: encoders.h 17902 2008-06-30 22:09:45Z bluebrother $
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
|
* KIND, either express or implied.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "encttscfggui.h"
|
||||||
|
#include "browsedirtree.h"
|
||||||
|
|
||||||
|
EncTtsCfgGui::EncTtsCfgGui(QDialog* parent,EncTtsSettingInterface* interface,QString name) : QDialog(parent)
|
||||||
|
{
|
||||||
|
m_settingInterface = interface;
|
||||||
|
|
||||||
|
m_busyCnt=0;
|
||||||
|
// create a busy Dialog
|
||||||
|
m_busyDlg= new QProgressDialog(tr(""), tr(""), 0, 0,this);
|
||||||
|
m_busyDlg->setWindowTitle(tr("Waiting for engine..."));
|
||||||
|
m_busyDlg->setModal(true);
|
||||||
|
m_busyDlg->setLabel(0);
|
||||||
|
m_busyDlg->setCancelButton(0);
|
||||||
|
m_busyDlg->hide();
|
||||||
|
connect(interface,SIGNAL(busy()),this,SLOT(showBusy()));
|
||||||
|
connect(interface,SIGNAL(busyEnd()),this,SLOT(hideBusy()));
|
||||||
|
|
||||||
|
//setup the window
|
||||||
|
setWindowTitle(name);
|
||||||
|
setUpWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
void EncTtsCfgGui::setUpWindow()
|
||||||
|
{
|
||||||
|
m_settingsList = m_settingInterface->getSettings();
|
||||||
|
|
||||||
|
//layout
|
||||||
|
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||||
|
|
||||||
|
// groupbox
|
||||||
|
QGroupBox *groupBox = new QGroupBox(this);
|
||||||
|
QFormLayout *formlayout = new QFormLayout;
|
||||||
|
// setting widgets
|
||||||
|
for(int i = 0; i < m_settingsList.size(); i++)
|
||||||
|
{
|
||||||
|
formlayout->addRow(m_settingsList.at(i)->name(),createWidgets(m_settingsList.at(i)));
|
||||||
|
}
|
||||||
|
groupBox->setLayout(formlayout);
|
||||||
|
mainLayout->addWidget(groupBox);
|
||||||
|
|
||||||
|
// connect browse btn
|
||||||
|
connect(&m_browseBtnMap,SIGNAL(mapped(QObject*)),this,SLOT(browse(QObject*)));
|
||||||
|
|
||||||
|
// ok - cancel buttons
|
||||||
|
QPushButton* okBtn = new QPushButton(tr("Ok"),this);
|
||||||
|
okBtn->setDefault(true);
|
||||||
|
okBtn->setIcon(QIcon(":icons/go-next.png"));
|
||||||
|
QPushButton* cancelBtn = new QPushButton(tr("Cancel"),this);
|
||||||
|
cancelBtn->setIcon(QIcon(":icons/process-stop.png"));
|
||||||
|
connect(okBtn,SIGNAL(clicked()),this,SLOT(accept()));
|
||||||
|
connect(cancelBtn,SIGNAL(clicked()),this,SLOT(reject()));
|
||||||
|
|
||||||
|
QHBoxLayout *btnbox = new QHBoxLayout;
|
||||||
|
btnbox->addWidget(okBtn);
|
||||||
|
btnbox->addWidget(cancelBtn);
|
||||||
|
btnbox->insertStretch(0,1);
|
||||||
|
|
||||||
|
mainLayout->addLayout(btnbox);
|
||||||
|
|
||||||
|
this->setLayout(mainLayout);
|
||||||
|
}
|
||||||
|
|
||||||
|
QLayout* EncTtsCfgGui::createWidgets(EncTtsSetting* setting)
|
||||||
|
{
|
||||||
|
// value display
|
||||||
|
QWidget* value = NULL;
|
||||||
|
switch(setting->type())
|
||||||
|
{
|
||||||
|
case EncTtsSetting::eDOUBLE:
|
||||||
|
{
|
||||||
|
QDoubleSpinBox *spinBox = new QDoubleSpinBox(this);
|
||||||
|
spinBox->setMinimum(setting->min().toDouble());
|
||||||
|
spinBox->setMaximum(setting->max().toDouble());
|
||||||
|
spinBox->setSingleStep(0.01);
|
||||||
|
spinBox->setValue(setting->current().toDouble());
|
||||||
|
connect(spinBox,SIGNAL(valueChanged(double)),this,SLOT(updateSetting()));
|
||||||
|
value = spinBox;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case EncTtsSetting::eINT:
|
||||||
|
{
|
||||||
|
QSpinBox *spinBox = new QSpinBox(this);
|
||||||
|
spinBox->setMinimum(setting->min().toInt());
|
||||||
|
spinBox->setMaximum(setting->max().toInt());
|
||||||
|
spinBox->setValue(setting->current().toInt());
|
||||||
|
connect(spinBox,SIGNAL(valueChanged(int)),this,SLOT(updateSetting()));
|
||||||
|
value = spinBox;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case EncTtsSetting::eSTRING:
|
||||||
|
{
|
||||||
|
QLineEdit *lineEdit = new QLineEdit(this);
|
||||||
|
lineEdit->setText(setting->current().toString());
|
||||||
|
connect(lineEdit,SIGNAL(textChanged(QString)),this,SLOT(updateSetting()));
|
||||||
|
value = lineEdit;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case EncTtsSetting::eREADONLYSTRING:
|
||||||
|
{
|
||||||
|
value = new QLabel(setting->current().toString(),this);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case EncTtsSetting::eSTRINGLIST:
|
||||||
|
{
|
||||||
|
QComboBox *comboBox = new QComboBox(this);
|
||||||
|
comboBox->addItems(setting->list());
|
||||||
|
int index = comboBox->findText(setting->current().toString());
|
||||||
|
comboBox->setCurrentIndex(index);
|
||||||
|
connect(comboBox,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateSetting()));
|
||||||
|
value = comboBox;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case EncTtsSetting::eBOOL:
|
||||||
|
{
|
||||||
|
QCheckBox *checkbox = new QCheckBox(this);
|
||||||
|
checkbox->setCheckState(setting->current().toBool() == true ? Qt::Checked : Qt::Unchecked);
|
||||||
|
connect(checkbox,SIGNAL(stateChanged(int)),this,SLOT(updateSetting()));
|
||||||
|
value = checkbox;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
qDebug() << "Warning: unknown EncTTsSetting type" << setting->type();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// remeber widget
|
||||||
|
if(value != NULL)
|
||||||
|
{
|
||||||
|
m_settingsWidgetsMap.insert(setting,value);
|
||||||
|
connect(setting,SIGNAL(updateGui()),this,SLOT(updateWidget()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// buttons ?
|
||||||
|
QWidget* btn = createButton(setting);
|
||||||
|
|
||||||
|
// add to layout
|
||||||
|
QHBoxLayout *hbox = new QHBoxLayout;
|
||||||
|
if(value != NULL)hbox->addWidget(value);
|
||||||
|
if(btn != NULL) hbox->addWidget(btn);
|
||||||
|
|
||||||
|
return hbox;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget* EncTtsCfgGui::createButton(EncTtsSetting* setting)
|
||||||
|
{
|
||||||
|
if(setting->button() == EncTtsSetting::eBROWSEBTN)
|
||||||
|
{
|
||||||
|
QPushButton* browsebtn = new QPushButton(tr("Browse"),this);
|
||||||
|
browsebtn->setFixedWidth(50); //all buttons the same size, or it looks ugly
|
||||||
|
m_browseBtnMap.setMapping(browsebtn,setting);
|
||||||
|
connect(browsebtn,SIGNAL(clicked()),&m_browseBtnMap,SLOT(map()));
|
||||||
|
return browsebtn;
|
||||||
|
}
|
||||||
|
else if(setting->button() == EncTtsSetting::eREFRESHBTN)
|
||||||
|
{
|
||||||
|
QPushButton* refreshbtn = new QPushButton(tr("Refresh"),this);
|
||||||
|
refreshbtn->setFixedWidth(50); //all buttons the same size, or it looks ugly
|
||||||
|
connect(refreshbtn,SIGNAL(clicked()),setting,SIGNAL(refresh()));
|
||||||
|
return refreshbtn;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EncTtsCfgGui::updateSetting()
|
||||||
|
{
|
||||||
|
//cast and get the sender widget
|
||||||
|
QWidget* widget = qobject_cast<QWidget*>(QObject::sender());
|
||||||
|
if(widget == NULL) return;
|
||||||
|
// get the corresponding setting
|
||||||
|
EncTtsSetting* setting = m_settingsWidgetsMap.key(widget);
|
||||||
|
|
||||||
|
// update widget based on setting type
|
||||||
|
switch(setting->type())
|
||||||
|
{
|
||||||
|
case EncTtsSetting::eDOUBLE:
|
||||||
|
{
|
||||||
|
setting->setCurrent(((QDoubleSpinBox*)widget)->value(),false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case EncTtsSetting::eINT:
|
||||||
|
{
|
||||||
|
setting->setCurrent(((QSpinBox*)widget)->value(),false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case EncTtsSetting::eSTRING:
|
||||||
|
{
|
||||||
|
setting->setCurrent(((QLineEdit*)widget)->text(),false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case EncTtsSetting::eREADONLYSTRING:
|
||||||
|
{
|
||||||
|
setting->setCurrent(((QLabel*)widget)->text(),false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case EncTtsSetting::eSTRINGLIST:
|
||||||
|
{
|
||||||
|
setting->setCurrent(((QComboBox*)widget)->currentText(),false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case EncTtsSetting::eBOOL:
|
||||||
|
{
|
||||||
|
setting->setCurrent(((QCheckBox*)widget)->isChecked(),false);
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
qDebug() << "unknown Settingtype !!";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EncTtsCfgGui::updateWidget()
|
||||||
|
{
|
||||||
|
// get sender setting
|
||||||
|
EncTtsSetting* setting = qobject_cast<EncTtsSetting*>(QObject::sender());
|
||||||
|
if(setting == NULL) return;
|
||||||
|
// get corresponding widget
|
||||||
|
QWidget* widget = m_settingsWidgetsMap.value(setting);
|
||||||
|
|
||||||
|
// update Widget based on setting type
|
||||||
|
switch(setting->type())
|
||||||
|
{
|
||||||
|
case EncTtsSetting::eDOUBLE:
|
||||||
|
{
|
||||||
|
QDoubleSpinBox* spinbox = (QDoubleSpinBox*) widget;
|
||||||
|
spinbox->setMinimum(setting->min().toDouble());
|
||||||
|
spinbox->setMaximum(setting->max().toDouble());
|
||||||
|
spinbox->blockSignals(true);
|
||||||
|
spinbox->setValue(setting->current().toDouble());
|
||||||
|
spinbox->blockSignals(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case EncTtsSetting::eINT:
|
||||||
|
{
|
||||||
|
QSpinBox* spinbox = (QSpinBox*) widget;
|
||||||
|
spinbox->setMinimum(setting->min().toInt());
|
||||||
|
spinbox->setMaximum(setting->max().toInt());
|
||||||
|
spinbox->blockSignals(true);
|
||||||
|
spinbox->setValue(setting->current().toInt());
|
||||||
|
spinbox->blockSignals(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case EncTtsSetting::eSTRING:
|
||||||
|
{
|
||||||
|
QLineEdit* lineedit = (QLineEdit*) widget;
|
||||||
|
|
||||||
|
lineedit->blockSignals(true);
|
||||||
|
lineedit->setText(setting->current().toString());
|
||||||
|
lineedit->blockSignals(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case EncTtsSetting::eREADONLYSTRING:
|
||||||
|
{
|
||||||
|
QLabel* label = (QLabel*) widget;
|
||||||
|
|
||||||
|
label->blockSignals(true);
|
||||||
|
label->setText(setting->current().toString());
|
||||||
|
label->blockSignals(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case EncTtsSetting::eSTRINGLIST:
|
||||||
|
{
|
||||||
|
QComboBox* combobox = (QComboBox*) widget;
|
||||||
|
|
||||||
|
combobox->blockSignals(true);
|
||||||
|
combobox->clear();
|
||||||
|
combobox->addItems(setting->list());
|
||||||
|
int index = combobox->findText(setting->current().toString());
|
||||||
|
combobox->setCurrentIndex(index);
|
||||||
|
combobox->blockSignals(false);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case EncTtsSetting::eBOOL:
|
||||||
|
{
|
||||||
|
QCheckBox* checkbox = (QCheckBox*) widget;
|
||||||
|
|
||||||
|
checkbox->blockSignals(true);
|
||||||
|
checkbox->setCheckState(setting->current().toBool() == true ? Qt::Checked : Qt::Unchecked);
|
||||||
|
checkbox->blockSignals(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
qDebug() << "unknown EncTTsSetting";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EncTtsCfgGui::showBusy()
|
||||||
|
{
|
||||||
|
if(m_busyCnt == 0) m_busyDlg->show();
|
||||||
|
|
||||||
|
m_busyCnt++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EncTtsCfgGui::hideBusy()
|
||||||
|
{
|
||||||
|
m_busyCnt--;
|
||||||
|
|
||||||
|
if(m_busyCnt == 0) m_busyDlg->hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void EncTtsCfgGui::accept(void)
|
||||||
|
{
|
||||||
|
m_settingInterface->saveSettings();
|
||||||
|
this->done(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EncTtsCfgGui::reject(void)
|
||||||
|
{
|
||||||
|
this->done(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! takes a QObject because of QsignalMapper
|
||||||
|
void EncTtsCfgGui::browse(QObject* settingObj)
|
||||||
|
{
|
||||||
|
// cast top setting
|
||||||
|
EncTtsSetting* setting= qobject_cast<EncTtsSetting*>(settingObj);
|
||||||
|
if(setting == NULL) return;
|
||||||
|
|
||||||
|
//current path
|
||||||
|
QString curPath = setting->current().toString();
|
||||||
|
// show file dialog
|
||||||
|
QString exe = QFileDialog::getOpenFileName(this, tr("Select excutable"), curPath, "*");
|
||||||
|
if(!QFileInfo(exe).isExecutable())
|
||||||
|
return;
|
||||||
|
// set new value, gui will update automatically
|
||||||
|
setting->setCurrent(exe);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
78
rbutil/rbutilqt/encttscfggui.h
Normal file
78
rbutil/rbutilqt/encttscfggui.h
Normal file
|
|
@ -0,0 +1,78 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* __________ __ ___.
|
||||||
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||||
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||||
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
|
* \/ \/ \/ \/ \/
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007 by Dominik Wenger
|
||||||
|
* $Id: encoders.h 17902 2008-06-30 22:09:45Z bluebrother $
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
|
* KIND, either express or implied.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef ENCTTSCFGGUI_H
|
||||||
|
#define ENCTTSCFGGUI_H
|
||||||
|
|
||||||
|
#include <QtGui>
|
||||||
|
#include "encttssettings.h"
|
||||||
|
|
||||||
|
//! \brief Shows and manages a configuration gui for encoders and tts enignes
|
||||||
|
//!
|
||||||
|
class EncTtsCfgGui: public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
//! Creates the UI. give it a endoer or tts engine with already set config. uses show() or exec() to show it.
|
||||||
|
EncTtsCfgGui(QDialog* parent, EncTtsSettingInterface* interface,QString name);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
//! accept current configuration values and close window
|
||||||
|
void accept(void);
|
||||||
|
//! close window and dont save configuration
|
||||||
|
void reject(void);
|
||||||
|
//! updates the corresponding setting from the sending Widget
|
||||||
|
void updateSetting();
|
||||||
|
//! updates corresponding Widget from the sending Setting.
|
||||||
|
void updateWidget();
|
||||||
|
//! shows a busy dialog. counts calls.
|
||||||
|
void showBusy();
|
||||||
|
//! hides the busy dialog, counts calls
|
||||||
|
void hideBusy();
|
||||||
|
//! used via the SignalMapper for all Browse buttons
|
||||||
|
void browse(QObject*);
|
||||||
|
|
||||||
|
private:
|
||||||
|
//! creates all dynamic window content
|
||||||
|
void setUpWindow();
|
||||||
|
//! creates the Widgets needed for one setting. returns a Layout with the widgets
|
||||||
|
QLayout* createWidgets(EncTtsSetting* setting);
|
||||||
|
//! creates a button when needed by the setting.
|
||||||
|
QWidget* createButton(EncTtsSetting* setting);
|
||||||
|
//! name of the Encoder or TTS for which this UI is
|
||||||
|
QString m_name;
|
||||||
|
//! the interface pointer to the TTS or encoder
|
||||||
|
EncTtsSettingInterface* m_settingInterface;
|
||||||
|
//! Dialog, shown when enc or tts is busy
|
||||||
|
QProgressDialog* m_busyDlg;
|
||||||
|
//! List of settings from the TTS or Encoder
|
||||||
|
QList<EncTtsSetting*> m_settingsList;
|
||||||
|
//! Maps settings and the correspondig Widget
|
||||||
|
QMap<EncTtsSetting*,QWidget*> m_settingsWidgetsMap;
|
||||||
|
//! Maps all browse buttons to the corresponding Setting
|
||||||
|
QSignalMapper m_browseBtnMap;
|
||||||
|
//! counter how often busyShow() is called,
|
||||||
|
int m_busyCnt;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
70
rbutil/rbutilqt/encttssettings.cpp
Normal file
70
rbutil/rbutilqt/encttssettings.cpp
Normal file
|
|
@ -0,0 +1,70 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* __________ __ ___.
|
||||||
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||||
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||||
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
|
* \/ \/ \/ \/ \/
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007 by Dominik Wenger
|
||||||
|
* $Id: encoders.h 17902 2008-06-30 22:09:45Z bluebrother $
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
|
* KIND, either express or implied.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "encttssettings.h"
|
||||||
|
|
||||||
|
|
||||||
|
EncTtsSetting::EncTtsSetting(QObject* parent,ESettingType type,QString name,QVariant current, EButton btn)
|
||||||
|
{
|
||||||
|
m_btn = btn;
|
||||||
|
m_name =name;
|
||||||
|
m_type =type;
|
||||||
|
m_currentValue = current;
|
||||||
|
}
|
||||||
|
|
||||||
|
EncTtsSetting::EncTtsSetting(QObject* parent,ESettingType type,QString name,QVariant current,QStringList list,EButton btn)
|
||||||
|
{
|
||||||
|
m_btn = btn;
|
||||||
|
m_name =name;
|
||||||
|
m_type =type;
|
||||||
|
m_currentValue = current;
|
||||||
|
m_list = list;
|
||||||
|
}
|
||||||
|
|
||||||
|
EncTtsSetting::EncTtsSetting(QObject* parent,ESettingType type,QString name,QVariant current,QVariant min,QVariant max, EButton btn)
|
||||||
|
{
|
||||||
|
m_btn = btn;
|
||||||
|
m_name =name;
|
||||||
|
m_type =type;
|
||||||
|
m_currentValue = current;
|
||||||
|
m_minValue = min;
|
||||||
|
m_maxValue = max;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EncTtsSetting::setCurrent(QVariant current,bool noticeGui)
|
||||||
|
{
|
||||||
|
m_currentValue = current;
|
||||||
|
emit dataChanged();
|
||||||
|
|
||||||
|
if(noticeGui) emit updateGui();
|
||||||
|
}
|
||||||
|
|
||||||
|
//! insert a setting
|
||||||
|
void EncTtsSettingInterface::insertSetting(int id,EncTtsSetting* setting)
|
||||||
|
{
|
||||||
|
settingsList.insert(id,setting);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! retrieve a specific setting
|
||||||
|
EncTtsSetting* EncTtsSettingInterface::getSetting(int id)
|
||||||
|
{
|
||||||
|
return settingsList.at(id);
|
||||||
|
}
|
||||||
129
rbutil/rbutilqt/encttssettings.h
Normal file
129
rbutil/rbutilqt/encttssettings.h
Normal file
|
|
@ -0,0 +1,129 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* __________ __ ___.
|
||||||
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||||
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||||
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
|
* \/ \/ \/ \/ \/
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007 by Dominik Wenger
|
||||||
|
* $Id: encoders.h 17902 2008-06-30 22:09:45Z bluebrother $
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
|
* KIND, either express or implied.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef ENCTTSSETTINGS_H
|
||||||
|
#define ENCTTSSETTINGS_H
|
||||||
|
|
||||||
|
#include <QtCore>
|
||||||
|
|
||||||
|
//! \brief This class stores everything needed to display a Setting.
|
||||||
|
//!
|
||||||
|
class EncTtsSetting : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
enum ESettingType
|
||||||
|
{
|
||||||
|
eBASE,
|
||||||
|
eBOOL,
|
||||||
|
eDOUBLE,
|
||||||
|
eINT,
|
||||||
|
eSTRING,
|
||||||
|
eREADONLYSTRING,
|
||||||
|
eSTRINGLIST,
|
||||||
|
};
|
||||||
|
enum EButton
|
||||||
|
{
|
||||||
|
eNOBTN,
|
||||||
|
eBROWSEBTN,
|
||||||
|
eREFRESHBTN
|
||||||
|
};
|
||||||
|
|
||||||
|
//! constructor for a String or Bool setting
|
||||||
|
EncTtsSetting(QObject* parent,ESettingType type,QString name,QVariant current,EButton btn = eNOBTN);
|
||||||
|
//! contructor for a Stringlist setting, ie a enumeration
|
||||||
|
EncTtsSetting(QObject* parent,ESettingType type,QString name,QVariant current,QStringList list,EButton btn = eNOBTN);
|
||||||
|
//! constructor for a setting with a min-max range
|
||||||
|
EncTtsSetting(QObject* parent,ESettingType type,QString name,QVariant current,QVariant min,QVariant max,EButton = eNOBTN);
|
||||||
|
|
||||||
|
//! get currentValue
|
||||||
|
QVariant current() {return m_currentValue;}
|
||||||
|
//! set currentValue
|
||||||
|
void setCurrent(QVariant current,bool noticeGui=true);
|
||||||
|
|
||||||
|
//! get name of the Setting
|
||||||
|
QString name() {return m_name;}
|
||||||
|
//! get the type of the setting
|
||||||
|
ESettingType type() {return m_type;}
|
||||||
|
//! get what type of button this setting needs
|
||||||
|
EButton button() {return m_btn;}
|
||||||
|
//! get the minValue (only valid for a range setting, ie eDOUBLE or eINT)
|
||||||
|
QVariant min() {return m_minValue; }
|
||||||
|
//! get the maxValue (only valid for a range setting, ie eDOUBLE or eINT)
|
||||||
|
QVariant max() {return m_maxValue; }
|
||||||
|
//! get the enumerationlist (only valid for eSTRINGLIST settings)
|
||||||
|
QStringList list() {return m_list;}
|
||||||
|
//! set the enumeration list
|
||||||
|
void setList(QStringList list){m_list = list;}
|
||||||
|
|
||||||
|
signals:
|
||||||
|
//! connect to this signal if you want to get noticed when the data changes
|
||||||
|
void dataChanged();
|
||||||
|
//! connect to this if you want to react on refresh button
|
||||||
|
void refresh();
|
||||||
|
//! will be emited when the gui should update this setting
|
||||||
|
void updateGui();
|
||||||
|
|
||||||
|
private:
|
||||||
|
ESettingType m_type;
|
||||||
|
EButton m_btn;
|
||||||
|
QString m_name;
|
||||||
|
QVariant m_currentValue;
|
||||||
|
QVariant m_minValue;
|
||||||
|
QVariant m_maxValue;
|
||||||
|
QStringList m_list;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//! \brief this class is the Interface for Encoder and TTS engines, to display settings
|
||||||
|
//! It wraps nearly everything needed, only updateModel() and commitModel() needs to be reimplemented
|
||||||
|
//!
|
||||||
|
class EncTtsSettingInterface : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
EncTtsSettingInterface(QObject* parent) : QObject(parent) {}
|
||||||
|
|
||||||
|
//! get the Settings list
|
||||||
|
QList<EncTtsSetting*> getSettings() {generateSettings(); return settingsList;}
|
||||||
|
|
||||||
|
//! Chlid class should commit the from SettingsList to permanent storage
|
||||||
|
virtual void saveSettings() = 0;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void busy(); // emit this if a operation takes time
|
||||||
|
void busyEnd(); // emit this at the end of a busy section
|
||||||
|
|
||||||
|
protected:
|
||||||
|
//! Child class should fill in the setttingsList
|
||||||
|
virtual void generateSettings() = 0;
|
||||||
|
|
||||||
|
//! insert a setting
|
||||||
|
void insertSetting(int id,EncTtsSetting* setting);
|
||||||
|
//! retrieve a specific setting
|
||||||
|
EncTtsSetting* getSetting(int id);
|
||||||
|
|
||||||
|
private:
|
||||||
|
//! The setting storage.
|
||||||
|
QList<EncTtsSetting*> settingsList;
|
||||||
|
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
@ -116,7 +116,7 @@ void InstallTalkWindow::setSettings(RbSettings* sett)
|
||||||
void InstallTalkWindow::updateSettings(void)
|
void InstallTalkWindow::updateSettings(void)
|
||||||
{
|
{
|
||||||
QString ttsName = settings->value(RbSettings::Tts).toString();
|
QString ttsName = settings->value(RbSettings::Tts).toString();
|
||||||
TTSBase* tts = TTSBase::getTTS(ttsName);
|
TTSBase* tts = TTSBase::getTTS(this,ttsName);
|
||||||
tts->setCfg(settings);
|
tts->setCfg(settings);
|
||||||
if(tts->configOk())
|
if(tts->configOk())
|
||||||
ui.labelTtsProfile->setText(tr("Selected TTS engine: <b>%1</b>")
|
ui.labelTtsProfile->setText(tr("Selected TTS engine: <b>%1</b>")
|
||||||
|
|
@ -126,7 +126,7 @@ void InstallTalkWindow::updateSettings(void)
|
||||||
.arg("Invalid TTS configuration!"));
|
.arg("Invalid TTS configuration!"));
|
||||||
|
|
||||||
QString encoder = settings->value(RbSettings::CurEncoder).toString();
|
QString encoder = settings->value(RbSettings::CurEncoder).toString();
|
||||||
EncBase* enc = EncBase::getEncoder(encoder);
|
EncBase* enc = EncBase::getEncoder(this,encoder);
|
||||||
if(enc != NULL) {
|
if(enc != NULL) {
|
||||||
enc->setCfg(settings);
|
enc->setCfg(settings);
|
||||||
if(enc->configOk())
|
if(enc->configOk())
|
||||||
|
|
|
||||||
|
|
@ -1,171 +0,0 @@
|
||||||
<ui version="4.0" >
|
|
||||||
<class>RbSpeexCfgFrm</class>
|
|
||||||
<widget class="QDialog" name="RbSpeexCfgFrm" >
|
|
||||||
<property name="geometry" >
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>408</width>
|
|
||||||
<height>173</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle" >
|
|
||||||
<string>Configuration</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QGridLayout" >
|
|
||||||
<item row="0" column="0" colspan="4" >
|
|
||||||
<widget class="QGroupBox" name="groupBox" >
|
|
||||||
<property name="title" >
|
|
||||||
<string>Configure RbSpeex Encoder</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QGridLayout" >
|
|
||||||
<item row="0" column="0" >
|
|
||||||
<widget class="QDoubleSpinBox" name="volume" >
|
|
||||||
<property name="maximum" >
|
|
||||||
<double>10.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
<property name="singleStep" >
|
|
||||||
<double>0.010000000000000</double>
|
|
||||||
</property>
|
|
||||||
<property name="value" >
|
|
||||||
<double>1.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1" >
|
|
||||||
<widget class="QLabel" name="label_2" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Volume</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="2" >
|
|
||||||
<widget class="QCheckBox" name="narrowband" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Narrowband</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0" >
|
|
||||||
<widget class="QDoubleSpinBox" name="quality" >
|
|
||||||
<property name="decimals" >
|
|
||||||
<number>1</number>
|
|
||||||
</property>
|
|
||||||
<property name="maximum" >
|
|
||||||
<double>10.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
<property name="singleStep" >
|
|
||||||
<double>1.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
<property name="value" >
|
|
||||||
<double>8.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1" colspan="2" >
|
|
||||||
<widget class="QLabel" name="label" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Quality</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0" >
|
|
||||||
<widget class="QSpinBox" name="complexity" >
|
|
||||||
<property name="maximum" >
|
|
||||||
<number>10</number>
|
|
||||||
</property>
|
|
||||||
<property name="value" >
|
|
||||||
<number>10</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="1" colspan="2" >
|
|
||||||
<widget class="QLabel" name="label_3" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Complexity</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0" >
|
|
||||||
<widget class="QPushButton" name="reset" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Reset</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1" >
|
|
||||||
<spacer>
|
|
||||||
<property name="orientation" >
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" >
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="2" >
|
|
||||||
<widget class="QPushButton" name="buttonOk" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>&Ok</string>
|
|
||||||
</property>
|
|
||||||
<property name="icon" >
|
|
||||||
<iconset resource="rbutilqt.qrc" >:/icons/go-next.png</iconset>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="3" >
|
|
||||||
<widget class="QPushButton" name="buttonCancel" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>&Cancel</string>
|
|
||||||
</property>
|
|
||||||
<property name="icon" >
|
|
||||||
<iconset resource="rbutilqt.qrc" >:/icons/process-stop.png</iconset>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources>
|
|
||||||
<include location="rbutilqt.qrc" />
|
|
||||||
</resources>
|
|
||||||
<connections>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonOk</sender>
|
|
||||||
<signal>clicked()</signal>
|
|
||||||
<receiver>RbSpeexCfgFrm</receiver>
|
|
||||||
<slot>accept()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel" >
|
|
||||||
<x>253</x>
|
|
||||||
<y>147</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel" >
|
|
||||||
<x>203</x>
|
|
||||||
<y>86</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonCancel</sender>
|
|
||||||
<signal>clicked()</signal>
|
|
||||||
<receiver>RbSpeexCfgFrm</receiver>
|
|
||||||
<slot>reject()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel" >
|
|
||||||
<x>352</x>
|
|
||||||
<y>147</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel" >
|
|
||||||
<x>203</x>
|
|
||||||
<y>86</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
|
||||||
|
|
@ -64,9 +64,9 @@ SOURCES += rbutilqt.cpp \
|
||||||
base/utils.cpp \
|
base/utils.cpp \
|
||||||
preview.cpp \
|
preview.cpp \
|
||||||
encoders.cpp \
|
encoders.cpp \
|
||||||
encodersgui.cpp \
|
encttscfggui.cpp \
|
||||||
|
encttssettings.cpp \
|
||||||
tts.cpp \
|
tts.cpp \
|
||||||
ttsgui.cpp \
|
|
||||||
../../tools/wavtrim.c \
|
../../tools/wavtrim.c \
|
||||||
../../tools/voicefont.c \
|
../../tools/voicefont.c \
|
||||||
voicefile.cpp \
|
voicefile.cpp \
|
||||||
|
|
@ -116,9 +116,9 @@ HEADERS += rbutilqt.h \
|
||||||
base/utils.h \
|
base/utils.h \
|
||||||
preview.h \
|
preview.h \
|
||||||
encoders.h \
|
encoders.h \
|
||||||
encodersgui.h \
|
encttscfggui.h \
|
||||||
|
encttssettings.h \
|
||||||
tts.h \
|
tts.h \
|
||||||
ttsgui.h \
|
|
||||||
../../tools/wavtrim.h \
|
../../tools/wavtrim.h \
|
||||||
../../tools/voicefont.h \
|
../../tools/voicefont.h \
|
||||||
voicefile.h \
|
voicefile.h \
|
||||||
|
|
@ -167,11 +167,6 @@ FORMS += rbutilqtfrm.ui \
|
||||||
themesinstallfrm.ui \
|
themesinstallfrm.ui \
|
||||||
uninstallfrm.ui \
|
uninstallfrm.ui \
|
||||||
previewfrm.ui \
|
previewfrm.ui \
|
||||||
rbspeexcfgfrm.ui \
|
|
||||||
encexescfgfrm.ui \
|
|
||||||
ttsexescfgfrm.ui \
|
|
||||||
sapicfgfrm.ui \
|
|
||||||
ttsfestivalcfgform.ui \
|
|
||||||
createvoicefrm.ui \
|
createvoicefrm.ui \
|
||||||
sysinfofrm.ui
|
sysinfofrm.ui
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,175 +0,0 @@
|
||||||
<ui version="4.0" >
|
|
||||||
<class>SapiCfgFrm</class>
|
|
||||||
<widget class="QDialog" name="SapiCfgFrm" >
|
|
||||||
<property name="geometry" >
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>511</width>
|
|
||||||
<height>242</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle" >
|
|
||||||
<string>Configuration</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QHBoxLayout" >
|
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="groupBox" >
|
|
||||||
<property name="title" >
|
|
||||||
<string>Configure TTS Engine</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QGridLayout" >
|
|
||||||
<item row="0" column="0" >
|
|
||||||
<widget class="QLabel" name="label_3" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Language</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1" >
|
|
||||||
<widget class="QComboBox" name="languagecombo" />
|
|
||||||
</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="5" column="0" colspan="2" >
|
|
||||||
<spacer>
|
|
||||||
<property name="orientation" >
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" >
|
|
||||||
<size>
|
|
||||||
<width>473</width>
|
|
||||||
<height>21</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item row="6" column="0" colspan="2" >
|
|
||||||
<layout class="QHBoxLayout" >
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="reset" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Reset</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer>
|
|
||||||
<property name="orientation" >
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" >
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="buttonOk" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>&Ok</string>
|
|
||||||
</property>
|
|
||||||
<property name="icon" >
|
|
||||||
<iconset resource="rbutilqt.qrc" >:/icons/go-next.png</iconset>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="buttonCancel" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>&Cancel</string>
|
|
||||||
</property>
|
|
||||||
<property name="icon" >
|
|
||||||
<iconset resource="rbutilqt.qrc" >:/icons/process-stop.png</iconset>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="0" colspan="2" >
|
|
||||||
<widget class="QCheckBox" name="usesapi4" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Use Sapi 4</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources>
|
|
||||||
<include location="rbutilqt.qrc" />
|
|
||||||
</resources>
|
|
||||||
<connections>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonOk</sender>
|
|
||||||
<signal>clicked()</signal>
|
|
||||||
<receiver>SapiCfgFrm</receiver>
|
|
||||||
<slot>accept()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel" >
|
|
||||||
<x>253</x>
|
|
||||||
<y>147</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel" >
|
|
||||||
<x>203</x>
|
|
||||||
<y>86</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonCancel</sender>
|
|
||||||
<signal>clicked()</signal>
|
|
||||||
<receiver>SapiCfgFrm</receiver>
|
|
||||||
<slot>reject()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel" >
|
|
||||||
<x>352</x>
|
|
||||||
<y>147</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel" >
|
|
||||||
<x>203</x>
|
|
||||||
<y>86</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
|
||||||
|
|
@ -40,7 +40,7 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
|
||||||
m_logger->addItem(tr("Starting Talk file generation"),LOGINFO);
|
m_logger->addItem(tr("Starting Talk file generation"),LOGINFO);
|
||||||
|
|
||||||
//tts
|
//tts
|
||||||
m_tts = TTSBase::getTTS(settings->value(RbSettings::Tts).toString());
|
m_tts = TTSBase::getTTS(this,settings->value(RbSettings::Tts).toString());
|
||||||
m_tts->setCfg(settings);
|
m_tts->setCfg(settings);
|
||||||
|
|
||||||
if(!m_tts->start(&errStr))
|
if(!m_tts->start(&errStr))
|
||||||
|
|
@ -52,7 +52,7 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Encoder
|
// Encoder
|
||||||
m_enc = EncBase::getEncoder(settings->value(RbSettings::CurEncoder).toString());
|
m_enc = EncBase::getEncoder(this,settings->value(RbSettings::CurEncoder).toString());
|
||||||
m_enc->setCfg(settings);
|
m_enc->setCfg(settings);
|
||||||
|
|
||||||
if(!m_enc->start())
|
if(!m_enc->start())
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ class TalkFileCreator :public QObject
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TalkFileCreator(QObject* parent=0);
|
TalkFileCreator(QObject* parent);
|
||||||
|
|
||||||
bool createTalkFiles(ProgressloggerInterface* logger);
|
bool createTalkFiles(ProgressloggerInterface* logger);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,16 @@
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "tts.h"
|
#include "tts.h"
|
||||||
|
#include "utils.h"
|
||||||
|
/*********************************************************************
|
||||||
// static variables
|
* TTS Base
|
||||||
|
**********************************************************************/
|
||||||
QMap<QString,QString> TTSBase::ttsList;
|
QMap<QString,QString> TTSBase::ttsList;
|
||||||
QMap<QString,TTSBase*> TTSBase::ttsCache;
|
|
||||||
|
TTSBase::TTSBase(QObject* parent): EncTtsSettingInterface(parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// static functions
|
// static functions
|
||||||
void TTSBase::initTTSList()
|
void TTSBase::initTTSList()
|
||||||
|
|
@ -39,18 +44,14 @@ void TTSBase::initTTSList()
|
||||||
}
|
}
|
||||||
|
|
||||||
// function to get a specific encoder
|
// function to get a specific encoder
|
||||||
TTSBase* TTSBase::getTTS(QString ttsName)
|
TTSBase* TTSBase::getTTS(QObject* parent,QString ttsName)
|
||||||
{
|
{
|
||||||
// check cache
|
|
||||||
if(ttsCache.contains(ttsName))
|
|
||||||
return ttsCache.value(ttsName);
|
|
||||||
|
|
||||||
TTSBase* tts;
|
TTSBase* tts;
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
if(ttsName == "sapi")
|
if(ttsName == "sapi")
|
||||||
{
|
{
|
||||||
tts = new TTSSapi();
|
tts = new TTSSapi(parent);
|
||||||
ttsCache[ttsName] = tts;
|
|
||||||
return tts;
|
return tts;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -58,16 +59,14 @@ TTSBase* TTSBase::getTTS(QString ttsName)
|
||||||
#if defined(Q_OS_LINUX)
|
#if defined(Q_OS_LINUX)
|
||||||
if (ttsName == "festival")
|
if (ttsName == "festival")
|
||||||
{
|
{
|
||||||
tts = new TTSFestival();
|
tts = new TTSFestival(parent);
|
||||||
ttsCache[ttsName] = tts;
|
return tts;
|
||||||
return tts;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
if (true) // fix for OS other than WIN or LINUX
|
if (true) // fix for OS other than WIN or LINUX
|
||||||
{
|
{
|
||||||
tts = new TTSExes(ttsName);
|
tts = new TTSExes(ttsName,parent);
|
||||||
ttsCache[ttsName] = tts;
|
|
||||||
return tts;
|
return tts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -90,18 +89,11 @@ QString TTSBase::getTTSName(QString tts)
|
||||||
return ttsList.value(tts);
|
return ttsList.value(tts);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************
|
|
||||||
* TTS Base
|
|
||||||
**********************************************************************/
|
|
||||||
TTSBase::TTSBase(): QObject()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
* General TTS Exes
|
* General TTS Exes
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
TTSExes::TTSExes(QString name) : TTSBase()
|
TTSExes::TTSExes(QString name,QObject* parent) : TTSBase(parent)
|
||||||
{
|
{
|
||||||
m_name = name;
|
m_name = name;
|
||||||
|
|
||||||
|
|
@ -111,47 +103,26 @@ TTSExes::TTSExes(QString name) : TTSBase()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TTSExes::setCfg(RbSettings* sett)
|
void TTSExes::generateSettings()
|
||||||
{
|
{
|
||||||
// call function of base class
|
QString exepath =settings->subValue(m_name,RbSettings::TtsPath).toString();
|
||||||
TTSBase::setCfg(sett);
|
if(exepath == "") exepath = findExecutable(m_name);
|
||||||
|
|
||||||
// if the config isnt OK, try to autodetect
|
insertSetting(eEXEPATH,new EncTtsSetting(this,EncTtsSetting::eSTRING,"Path to TTS engine:",exepath,EncTtsSetting::eBROWSEBTN));
|
||||||
if(!configOk())
|
insertSetting(eOPTIONS,new EncTtsSetting(this,EncTtsSetting::eSTRING,"TTS enginge options:",settings->subValue(m_name,RbSettings::TtsOptions)));
|
||||||
{
|
}
|
||||||
QString exepath;
|
|
||||||
//try autodetect tts
|
|
||||||
#if defined(Q_OS_LINUX) || defined(Q_OS_MACX) || defined(Q_OS_OPENBSD)
|
|
||||||
QStringList path = QString(getenv("PATH")).split(":", QString::SkipEmptyParts);
|
|
||||||
#elif defined(Q_OS_WIN)
|
|
||||||
QStringList path = QString(getenv("PATH")).split(";", QString::SkipEmptyParts);
|
|
||||||
#endif
|
|
||||||
qDebug() << path;
|
|
||||||
for(int i = 0; i < path.size(); i++)
|
|
||||||
{
|
|
||||||
QString executable = QDir::fromNativeSeparators(path.at(i)) + "/" + m_name;
|
|
||||||
#if defined(Q_OS_WIN)
|
|
||||||
executable += ".exe";
|
|
||||||
QStringList ex = executable.split("\"", QString::SkipEmptyParts);
|
|
||||||
executable = ex.join("");
|
|
||||||
#endif
|
|
||||||
qDebug() << executable;
|
|
||||||
if(QFileInfo(executable).isExecutable())
|
|
||||||
{
|
|
||||||
exepath= QDir::toNativeSeparators(executable);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
settings->setSubValue(m_name, RbSettings::TtsPath, exepath);
|
|
||||||
settings->sync();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
void TTSExes::saveSettings()
|
||||||
|
{
|
||||||
|
settings->setSubValue(m_name,RbSettings::TtsPath,getSetting(eEXEPATH)->current().toString());
|
||||||
|
settings->setSubValue(m_name,RbSettings::TtsOptions,getSetting(eOPTIONS)->current().toString());
|
||||||
|
settings->sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TTSExes::start(QString *errStr)
|
bool TTSExes::start(QString *errStr)
|
||||||
{
|
{
|
||||||
m_TTSexec = settings->subValue(m_name, RbSettings::TtsPath).toString();
|
m_TTSexec = settings->subValue(m_name,RbSettings::TtsPath).toString();
|
||||||
m_TTSOpts = settings->subValue(m_name, RbSettings::TtsOptions).toString();
|
m_TTSOpts = settings->subValue(m_name,RbSettings::TtsOptions).toString();
|
||||||
|
|
||||||
m_TTSTemplate = m_TemplateMap.value(m_name);
|
m_TTSTemplate = m_TemplateMap.value(m_name);
|
||||||
|
|
||||||
|
|
@ -169,7 +140,7 @@ bool TTSExes::start(QString *errStr)
|
||||||
|
|
||||||
TTSStatus TTSExes::voice(QString text,QString wavfile, QString *errStr)
|
TTSStatus TTSExes::voice(QString text,QString wavfile, QString *errStr)
|
||||||
{
|
{
|
||||||
(void) errStr;
|
(void) errStr;
|
||||||
QString execstring = m_TTSTemplate;
|
QString execstring = m_TTSTemplate;
|
||||||
|
|
||||||
execstring.replace("%exe",m_TTSexec);
|
execstring.replace("%exe",m_TTSexec);
|
||||||
|
|
@ -182,20 +153,9 @@ TTSStatus TTSExes::voice(QString text,QString wavfile, QString *errStr)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TTSExes::showCfg()
|
|
||||||
{
|
|
||||||
#ifndef CONSOLE
|
|
||||||
TTSExesGui gui;
|
|
||||||
#else
|
|
||||||
TTSExesGuiCli gui;
|
|
||||||
#endif
|
|
||||||
gui.setCfg(settings);
|
|
||||||
gui.showCfg(m_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TTSExes::configOk()
|
bool TTSExes::configOk()
|
||||||
{
|
{
|
||||||
QString path = settings->subValue(m_name, RbSettings::TtsPath).toString();
|
QString path = settings->subValue(m_name,RbSettings::TtsPath).toString();
|
||||||
|
|
||||||
if (QFileInfo(path).exists())
|
if (QFileInfo(path).exists())
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -206,22 +166,60 @@ bool TTSExes::configOk()
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
* TTS Sapi
|
* TTS Sapi
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
TTSSapi::TTSSapi() : TTSBase()
|
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\"";
|
||||||
defaultLanguage ="english";
|
defaultLanguage ="english";
|
||||||
m_sapi4 =false;
|
m_sapi4 =false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TTSSapi::generateSettings()
|
||||||
|
{
|
||||||
|
// language
|
||||||
|
QStringList languages = settings->languages();
|
||||||
|
languages.sort();
|
||||||
|
EncTtsSetting* setting =new EncTtsSetting(this,EncTtsSetting::eSTRINGLIST,"Language:",settings->subValue("sapi",RbSettings::TtsLanguage),languages);
|
||||||
|
connect(setting,SIGNAL(dataChanged()),this,SLOT(updateVoiceList()));
|
||||||
|
insertSetting(eLANGUAGE,setting);
|
||||||
|
// voice
|
||||||
|
setting = new EncTtsSetting(this,EncTtsSetting::eSTRINGLIST,"Voice:",settings->subValue("sapi",RbSettings::TtsVoice),getVoiceList(settings->subValue("sapi",RbSettings::TtsLanguage).toString()),EncTtsSetting::eREFRESHBTN);
|
||||||
|
connect(setting,SIGNAL(refresh()),this,SLOT(updateVoiceList()));
|
||||||
|
insertSetting(eVOICE,setting);
|
||||||
|
//speed
|
||||||
|
insertSetting(eSPEED,new EncTtsSetting(this,EncTtsSetting::eINT,"Speed:",settings->subValue("sapi",RbSettings::TtsSpeed),-10,10));
|
||||||
|
// options
|
||||||
|
insertSetting(eOPTIONS,new EncTtsSetting(this,EncTtsSetting::eSTRING,"Options:",settings->subValue("sapi",RbSettings::TtsOptions)));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void TTSSapi::saveSettings()
|
||||||
|
{
|
||||||
|
//save settings in user config
|
||||||
|
settings->setSubValue("sapi",RbSettings::TtsLanguage,getSetting(eLANGUAGE)->current().toString());
|
||||||
|
settings->setSubValue("sapi",RbSettings::TtsVoice,getSetting(eVOICE)->current().toString());
|
||||||
|
settings->setSubValue("sapi",RbSettings::TtsSpeed,getSetting(eSPEED)->current().toInt());
|
||||||
|
settings->setSubValue("sapi",RbSettings::TtsOptions,getSetting(eOPTIONS)->current().toString());
|
||||||
|
|
||||||
|
settings->sync();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TTSSapi::updateVoiceList()
|
||||||
|
{
|
||||||
|
qDebug() << "update voiceList";
|
||||||
|
QStringList voiceList = getVoiceList(getSetting(eLANGUAGE)->current().toString());
|
||||||
|
getSetting(eVOICE)->setList(voiceList);
|
||||||
|
if(voiceList.size() > 0) getSetting(eVOICE)->setCurrent(voiceList.at(0));
|
||||||
|
else getSetting(eVOICE)->setCurrent("");
|
||||||
|
}
|
||||||
|
|
||||||
bool TTSSapi::start(QString *errStr)
|
bool TTSSapi::start(QString *errStr)
|
||||||
{
|
{
|
||||||
|
|
||||||
m_TTSOpts = settings->subValue("sapi", RbSettings::TtsOptions).toString();
|
m_TTSOpts = settings->subValue("sapi",RbSettings::TtsOptions).toString();
|
||||||
m_TTSLanguage =settings->subValue("sapi", RbSettings::TtsLanguage).toString();
|
m_TTSLanguage =settings->subValue("sapi",RbSettings::TtsLanguage).toString();
|
||||||
m_TTSVoice=settings->subValue("sapi", RbSettings::TtsVoice).toString();
|
m_TTSVoice=settings->subValue("sapi",RbSettings::TtsVoice).toString();
|
||||||
m_TTSSpeed=QString("%1").arg(settings->subValue("sapi", RbSettings::TtsSpeed).toInt());
|
m_TTSSpeed=settings->subValue("sapi",RbSettings::TtsSpeed).toString();
|
||||||
m_sapi4 = settings->value(RbSettings::TtsUseSapi4).toBool();
|
m_sapi4 = settings->subValue("sapi",RbSettings::TtsUseSapi4).toBool();
|
||||||
|
|
||||||
QFile::remove(QDir::tempPath() +"/sapi_voice.vbs");
|
QFile::remove(QDir::tempPath() +"/sapi_voice.vbs");
|
||||||
QFile::copy(":/builtin/sapi_voice.vbs",QDir::tempPath() + "/sapi_voice.vbs");
|
QFile::copy(":/builtin/sapi_voice.vbs",QDir::tempPath() + "/sapi_voice.vbs");
|
||||||
|
|
@ -299,22 +297,22 @@ QStringList TTSSapi::getVoiceList(QString language)
|
||||||
|
|
||||||
QString dataRaw = voicescript->readAllStandardError().data();
|
QString dataRaw = voicescript->readAllStandardError().data();
|
||||||
result = dataRaw.split(",",QString::SkipEmptyParts);
|
result = dataRaw.split(",",QString::SkipEmptyParts);
|
||||||
result.sort();
|
if(result.size() > 0)
|
||||||
result.removeFirst();
|
|
||||||
for(int i = 0; i< result.size();i++)
|
|
||||||
{
|
{
|
||||||
result[i] = result.at(i).simplified();
|
result.sort();
|
||||||
|
result.removeFirst();
|
||||||
|
for(int i = 0; i< result.size();i++)
|
||||||
|
{
|
||||||
|
result[i] = result.at(i).simplified();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
delete voicescript;
|
delete voicescript;
|
||||||
QFile::setPermissions(QDir::tempPath() +"/sapi_voice.vbs",
|
QFile::setPermissions(QDir::tempPath() +"/sapi_voice.vbs",QFile::ReadOwner |QFile::WriteOwner|QFile::ExeOwner
|
||||||
QFile::ReadOwner |QFile::WriteOwner |QFile::ExeOwner
|
|QFile::ReadUser| QFile::WriteUser| QFile::ExeUser
|
||||||
|QFile::ReadUser |QFile::WriteUser |QFile::ExeUser
|
|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");
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -322,7 +320,7 @@ QStringList TTSSapi::getVoiceList(QString language)
|
||||||
|
|
||||||
TTSStatus TTSSapi::voice(QString text,QString wavfile, QString *errStr)
|
TTSStatus TTSSapi::voice(QString text,QString wavfile, QString *errStr)
|
||||||
{
|
{
|
||||||
(void) errStr;
|
(void) errStr;
|
||||||
QString query = "SPEAK\t"+wavfile+"\t"+text+"\r\n";
|
QString query = "SPEAK\t"+wavfile+"\t"+text+"\r\n";
|
||||||
qDebug() << "voicing" << query;
|
qDebug() << "voicing" << query;
|
||||||
*voicestream << query;
|
*voicestream << query;
|
||||||
|
|
@ -340,30 +338,17 @@ bool TTSSapi::stop()
|
||||||
voicescript->waitForFinished();
|
voicescript->waitForFinished();
|
||||||
delete voicestream;
|
delete voicestream;
|
||||||
delete voicescript;
|
delete voicescript;
|
||||||
QFile::setPermissions(QDir::tempPath() +"/sapi_voice.vbs",
|
QFile::setPermissions(QDir::tempPath() +"/sapi_voice.vbs",QFile::ReadOwner |QFile::WriteOwner|QFile::ExeOwner
|
||||||
QFile::ReadOwner |QFile::WriteOwner |QFile::ExeOwner
|
|QFile::ReadUser| QFile::WriteUser| QFile::ExeUser
|
||||||
|QFile::ReadUser |QFile::WriteUser |QFile::ExeUser
|
|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");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TTSSapi::showCfg()
|
|
||||||
{
|
|
||||||
#ifndef CONSOLE
|
|
||||||
TTSSapiGui gui(this);
|
|
||||||
#else
|
|
||||||
TTSSapiGuiCli gui(this);
|
|
||||||
#endif
|
|
||||||
gui.setCfg(settings);
|
|
||||||
gui.showCfg();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TTSSapi::configOk()
|
bool TTSSapi::configOk()
|
||||||
{
|
{
|
||||||
if(settings->subValue("sapi", RbSettings::TtsVoice).toString().isEmpty())
|
if(settings->subValue("sapi",RbSettings::TtsVoice).toString().isEmpty())
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -372,252 +357,300 @@ bool TTSSapi::configOk()
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
TTSFestival::~TTSFestival()
|
TTSFestival::~TTSFestival()
|
||||||
{
|
{
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TTSFestival::startServer()
|
void TTSFestival::generateSettings()
|
||||||
{
|
{
|
||||||
if(!configOk())
|
// server path
|
||||||
return;
|
QString exepath = settings->subValue("festival-server",RbSettings::TtsPath).toString();
|
||||||
|
if(exepath == "" ) exepath = findExecutable("festival");
|
||||||
|
insertSetting(eSERVERPATH,new EncTtsSetting(this,EncTtsSetting::eSTRING,"Path to Festival server:",exepath,EncTtsSetting::eBROWSEBTN));
|
||||||
|
|
||||||
QStringList paths = settings->subValue("festival", RbSettings::TtsPath).toString().split(":");
|
// client path
|
||||||
|
QString clientpath = settings->subValue("festival-client",RbSettings::TtsPath).toString();
|
||||||
|
if(clientpath == "" ) clientpath = findExecutable("festival_client");
|
||||||
|
insertSetting(eCLIENTPATH,new EncTtsSetting(this,EncTtsSetting::eSTRING,"Path to Festival client:",clientpath,EncTtsSetting::eBROWSEBTN));
|
||||||
|
|
||||||
serverProcess.start(QString("%1 --server").arg(paths[0]));
|
// voice
|
||||||
serverProcess.waitForStarted();
|
EncTtsSetting* setting = new EncTtsSetting(this,EncTtsSetting::eSTRINGLIST,"Voice:",settings->subValue("festival",RbSettings::TtsVoice),getVoiceList(exepath),EncTtsSetting::eREFRESHBTN);
|
||||||
|
connect(setting,SIGNAL(refresh()),this,SLOT(updateVoiceList()));
|
||||||
|
connect(setting,SIGNAL(dataChanged()),this,SLOT(clearVoiceDescription()));
|
||||||
|
insertSetting(eVOICE,setting);
|
||||||
|
|
||||||
queryServer("(getpid)");
|
//voice description
|
||||||
if(serverProcess.state() == QProcess::Running)
|
setting = new EncTtsSetting(this,EncTtsSetting::eREADONLYSTRING,"Voice description:","",EncTtsSetting::eREFRESHBTN);
|
||||||
qDebug() << "Festival is up and running";
|
connect(setting,SIGNAL(refresh()),this,SLOT(updateVoiceDescription()));
|
||||||
else
|
insertSetting(eVOICEDESC,setting);
|
||||||
qDebug() << "Festival failed to start";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TTSFestival::ensureServerRunning()
|
void TTSFestival::saveSettings()
|
||||||
{
|
{
|
||||||
if(serverProcess.state() != QProcess::Running)
|
//save settings in user config
|
||||||
{
|
settings->setSubValue("festival-server",RbSettings::TtsPath,getSetting(eSERVERPATH)->current().toString());
|
||||||
// least common denominator for all the server startup code paths
|
settings->setSubValue("festival-client",RbSettings::TtsPath,getSetting(eCLIENTPATH)->current().toString());
|
||||||
QProgressDialog progressDialog(tr(""), tr(""), 0, 0);
|
settings->setSubValue("festival",RbSettings::TtsVoice,getSetting(eVOICE)->current().toString());
|
||||||
progressDialog.setWindowTitle(tr("Starting festival"));
|
|
||||||
progressDialog.setModal(true);
|
|
||||||
progressDialog.setLabel(0);
|
|
||||||
progressDialog.setCancelButton(0);
|
|
||||||
progressDialog.show();
|
|
||||||
|
|
||||||
QApplication::processEvents(); // actually show the dialog
|
settings->sync();
|
||||||
|
}
|
||||||
|
|
||||||
startServer();
|
void TTSFestival::updateVoiceDescription()
|
||||||
|
{
|
||||||
|
// get voice Info with current voice and path
|
||||||
|
QString info = getVoiceInfo(getSetting(eVOICE)->current().toString(),getSetting(eSERVERPATH)->current().toString());
|
||||||
|
getSetting(eVOICEDESC)->setCurrent(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TTSFestival::clearVoiceDescription()
|
||||||
|
{
|
||||||
|
getSetting(eVOICEDESC)->setCurrent("");
|
||||||
|
}
|
||||||
|
|
||||||
|
void TTSFestival::updateVoiceList()
|
||||||
|
{
|
||||||
|
QStringList voiceList = getVoiceList(getSetting(eSERVERPATH)->current().toString());
|
||||||
|
getSetting(eVOICE)->setList(voiceList);
|
||||||
|
if(voiceList.size() > 0) getSetting(eVOICE)->setCurrent(voiceList.at(0));
|
||||||
|
else getSetting(eVOICE)->setCurrent("");
|
||||||
|
}
|
||||||
|
|
||||||
|
void TTSFestival::startServer(QString path)
|
||||||
|
{
|
||||||
|
if(!configOk())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(path == "")
|
||||||
|
path = settings->subValue("festival-server",RbSettings::TtsPath).toString();
|
||||||
|
|
||||||
|
serverProcess.start(QString("%1 --server").arg(path));
|
||||||
|
serverProcess.waitForStarted();
|
||||||
|
|
||||||
|
queryServer("(getpid)",300,path);
|
||||||
|
if(serverProcess.state() == QProcess::Running)
|
||||||
|
qDebug() << "Festival is up and running";
|
||||||
|
else
|
||||||
|
qDebug() << "Festival failed to start";
|
||||||
|
}
|
||||||
|
|
||||||
|
void TTSFestival::ensureServerRunning(QString path)
|
||||||
|
{
|
||||||
|
if(serverProcess.state() != QProcess::Running)
|
||||||
|
{
|
||||||
|
startServer(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TTSFestival::start(QString* errStr)
|
bool TTSFestival::start(QString* errStr)
|
||||||
{
|
{
|
||||||
(void) errStr;
|
(void) errStr;
|
||||||
ensureServerRunning();
|
ensureServerRunning();
|
||||||
if (!settings->subValue("festival", RbSettings::TtsVoice).toString().isEmpty())
|
if (!settings->subValue("festival",RbSettings::TtsVoice).toString().isEmpty())
|
||||||
queryServer(QString("(voice.select '%1)")
|
queryServer(QString("(voice.select '%1)")
|
||||||
.arg(settings->subValue("festival", RbSettings::TtsVoice).toString()));
|
.arg(settings->subValue("festival", RbSettings::TtsVoice).toString()));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TTSFestival::stop()
|
bool TTSFestival::stop()
|
||||||
{
|
{
|
||||||
serverProcess.terminate();
|
serverProcess.terminate();
|
||||||
serverProcess.kill();
|
serverProcess.kill();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
TTSStatus TTSFestival::voice(QString text, QString wavfile, QString* errStr)
|
TTSStatus TTSFestival::voice(QString text, QString wavfile, QString* errStr)
|
||||||
{
|
{
|
||||||
qDebug() << text << "->" << wavfile;
|
qDebug() << text << "->" << wavfile;
|
||||||
|
|
||||||
QStringList paths = settings->subValue("festival", RbSettings::TtsPath).toString().split(":");
|
QString path = settings->subValue("festival-client",RbSettings::TtsPath).toString();
|
||||||
QString cmd = QString("%1 --server localhost --otype riff --ttw --withlisp --output \"%2\" - ").arg(paths[1]).arg(wavfile);
|
QString cmd = QString("%1 --server localhost --otype riff --ttw --withlisp --output \"%2\" - ").arg(path).arg(wavfile);
|
||||||
qDebug() << cmd;
|
qDebug() << cmd;
|
||||||
|
|
||||||
QProcess clientProcess;
|
QProcess clientProcess;
|
||||||
clientProcess.start(cmd);
|
clientProcess.start(cmd);
|
||||||
clientProcess.write(QString("%1.\n").arg(text).toAscii());
|
clientProcess.write(QString("%1.\n").arg(text).toAscii());
|
||||||
clientProcess.waitForBytesWritten();
|
clientProcess.waitForBytesWritten();
|
||||||
clientProcess.closeWriteChannel();
|
clientProcess.closeWriteChannel();
|
||||||
clientProcess.waitForReadyRead();
|
clientProcess.waitForReadyRead();
|
||||||
QString response = clientProcess.readAll();
|
QString response = clientProcess.readAll();
|
||||||
response = response.trimmed();
|
response = response.trimmed();
|
||||||
if(!response.contains("Utterance"))
|
if(!response.contains("Utterance"))
|
||||||
{
|
{
|
||||||
qDebug() << "Could not voice string: " << response;
|
qDebug() << "Could not voice string: " << response;
|
||||||
*errStr = tr("engine could not voice string");
|
*errStr = tr("engine could not voice string");
|
||||||
return Warning;
|
return Warning;
|
||||||
/* do not stop the voicing process because of a single string
|
/* do not stop the voicing process because of a single string
|
||||||
TODO: needs proper settings */
|
TODO: needs proper settings */
|
||||||
}
|
}
|
||||||
clientProcess.closeReadChannel(QProcess::StandardError);
|
clientProcess.closeReadChannel(QProcess::StandardError);
|
||||||
clientProcess.closeReadChannel(QProcess::StandardOutput);
|
clientProcess.closeReadChannel(QProcess::StandardOutput);
|
||||||
clientProcess.terminate();
|
clientProcess.terminate();
|
||||||
clientProcess.kill();
|
clientProcess.kill();
|
||||||
|
|
||||||
return NoError;
|
return NoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TTSFestival::configOk()
|
bool TTSFestival::configOk()
|
||||||
{
|
{
|
||||||
QStringList paths = settings->subValue("festival", RbSettings::TtsPath).toString().split(":");
|
QString serverPath = settings->subValue("festival-server",RbSettings::TtsPath).toString();
|
||||||
if(paths.size() != 2)
|
QString clientPath = settings->subValue("festival-client",RbSettings::TtsVoice).toString();
|
||||||
return false;
|
|
||||||
bool ret = QFileInfo(paths[0]).isExecutable() &&
|
bool ret = QFileInfo(serverPath).isExecutable() &&
|
||||||
QFileInfo(paths[1]).isExecutable();
|
QFileInfo(clientPath).isExecutable();
|
||||||
if(settings->subValue("festival", RbSettings::TtsVoice).toString().size() > 0
|
if(settings->subValue("festival",RbSettings::TtsVoice).toString().size() > 0 && voices.size() > 0)
|
||||||
&& voices.size() > 0)
|
ret = ret && (voices.indexOf(settings->subValue("festival",RbSettings::TtsVoice).toString()) != -1);
|
||||||
ret = ret && (voices.indexOf(settings->subValue("festival",
|
return ret;
|
||||||
RbSettings::TtsVoice).toString()) != -1);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TTSFestival::showCfg()
|
QStringList TTSFestival::getVoiceList(QString path)
|
||||||
{
|
{
|
||||||
#ifndef CONSOLE
|
if(!configOk())
|
||||||
TTSFestivalGui gui(this);
|
return QStringList();
|
||||||
#endif
|
|
||||||
gui.setCfg(settings);
|
if(voices.size() > 0)
|
||||||
gui.showCfg();
|
{
|
||||||
|
qDebug() << "Using voice cache";
|
||||||
|
return voices;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString response = queryServer("(voice.list)",3000,path);
|
||||||
|
|
||||||
|
// get the 2nd line. It should be (<voice_name>, <voice_name>)
|
||||||
|
response = response.mid(response.indexOf('\n') + 1, -1);
|
||||||
|
response = response.left(response.indexOf('\n')).trimmed();
|
||||||
|
|
||||||
|
voices = response.mid(1, response.size()-2).split(' ');
|
||||||
|
|
||||||
|
voices.sort();
|
||||||
|
if (voices.size() == 1 && voices[0].size() == 0)
|
||||||
|
voices.removeAt(0);
|
||||||
|
if (voices.size() > 0)
|
||||||
|
qDebug() << "Voices: " << voices;
|
||||||
|
else
|
||||||
|
qDebug() << "No voices.";
|
||||||
|
|
||||||
|
return voices;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList TTSFestival::getVoiceList()
|
QString TTSFestival::getVoiceInfo(QString voice,QString path)
|
||||||
{
|
{
|
||||||
if(!configOk())
|
if(!configOk())
|
||||||
return QStringList();
|
return "";
|
||||||
|
|
||||||
if(voices.size() > 0)
|
if(!getVoiceList().contains(voice))
|
||||||
{
|
return "";
|
||||||
qDebug() << "Using voice cache";
|
|
||||||
return voices;
|
|
||||||
}
|
|
||||||
QString response = queryServer("(voice.list)");
|
|
||||||
|
|
||||||
// get the 2nd line. It should be (<voice_name>, <voice_name>)
|
if(voiceDescriptions.contains(voice))
|
||||||
response = response.mid(response.indexOf('\n') + 1, -1);
|
return voiceDescriptions[voice];
|
||||||
response = response.left(response.indexOf('\n')).trimmed();
|
|
||||||
|
|
||||||
voices = response.mid(1, response.size()-2).split(' ');
|
QString response = queryServer(QString("(voice.description '%1)").arg(voice), 3000,path);
|
||||||
|
|
||||||
voices.sort();
|
if (response == "")
|
||||||
if (voices.size() == 1 && voices[0].size() == 0)
|
{
|
||||||
voices.removeAt(0);
|
voiceDescriptions[voice]=tr("No description available");
|
||||||
if (voices.size() > 0)
|
}
|
||||||
qDebug() << "Voices: " << voices;
|
else
|
||||||
else
|
{
|
||||||
qDebug() << "No voices.";
|
response = response.remove(QRegExp("(description \"*\")", Qt::CaseInsensitive, QRegExp::Wildcard));
|
||||||
return voices;
|
qDebug() << "voiceInfo w/o descr: " << response;
|
||||||
|
response = response.remove(')');
|
||||||
|
QStringList responseLines = response.split('(', QString::SkipEmptyParts);
|
||||||
|
responseLines.removeAt(0); // the voice name itself
|
||||||
|
|
||||||
|
QString description;
|
||||||
|
foreach(QString line, responseLines)
|
||||||
|
{
|
||||||
|
line = line.remove('(');
|
||||||
|
line = line.simplified();
|
||||||
|
|
||||||
|
line[0] = line[0].toUpper(); // capitalize the key
|
||||||
|
|
||||||
|
int firstSpace = line.indexOf(' ');
|
||||||
|
if (firstSpace > 0)
|
||||||
|
{
|
||||||
|
line = line.insert(firstSpace, ':'); // add a colon between the key and the value
|
||||||
|
line[firstSpace+2] = line[firstSpace+2].toUpper(); // capitalize the value
|
||||||
|
}
|
||||||
|
|
||||||
|
description += line + "\n";
|
||||||
|
}
|
||||||
|
voiceDescriptions[voice] = description.trimmed();
|
||||||
|
}
|
||||||
|
|
||||||
|
return voiceDescriptions[voice];
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TTSFestival::getVoiceInfo(QString voice)
|
QString TTSFestival::queryServer(QString query, int timeout,QString path)
|
||||||
{
|
{
|
||||||
if(!configOk())
|
if(!configOk())
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
if(!getVoiceList().contains(voice))
|
// this operation could take some time
|
||||||
return "";
|
emit busy();
|
||||||
|
|
||||||
if(voiceDescriptions.contains(voice))
|
ensureServerRunning(path);
|
||||||
return voiceDescriptions[voice];
|
|
||||||
|
|
||||||
QString response = queryServer(QString("(voice.description '%1)").arg(voice), 3000);
|
qDebug() << "queryServer with " << query;
|
||||||
|
QString response;
|
||||||
|
|
||||||
if (response == "")
|
QDateTime endTime;
|
||||||
{
|
if(timeout > 0)
|
||||||
voiceDescriptions[voice]=tr("No description available");
|
endTime = QDateTime::currentDateTime().addMSecs(timeout);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
response = response.remove(QRegExp("(description \"*\")", Qt::CaseInsensitive, QRegExp::Wildcard));
|
|
||||||
qDebug() << "voiceInfo w/o descr: " << response;
|
|
||||||
response = response.remove(')');
|
|
||||||
QStringList responseLines = response.split('(', QString::SkipEmptyParts);
|
|
||||||
responseLines.removeAt(0); // the voice name itself
|
|
||||||
|
|
||||||
QString description;
|
/* Festival is *extremely* unreliable. Although at this
|
||||||
foreach(QString line, responseLines)
|
* point we are sure that SIOD is accepting commands,
|
||||||
|
* we might end up with an empty response. Hence, the loop.
|
||||||
|
*/
|
||||||
|
while(true)
|
||||||
|
{
|
||||||
|
QCoreApplication::processEvents(QEventLoop::AllEvents, 50);
|
||||||
|
QTcpSocket socket;
|
||||||
|
|
||||||
|
socket.connectToHost("localhost", 1314);
|
||||||
|
socket.waitForConnected();
|
||||||
|
|
||||||
|
if(socket.state() == QAbstractSocket::ConnectedState)
|
||||||
|
{
|
||||||
|
socket.write(QString("%1\n").arg(query).toAscii());
|
||||||
|
socket.waitForBytesWritten();
|
||||||
|
socket.waitForReadyRead();
|
||||||
|
|
||||||
|
response = socket.readAll().trimmed();
|
||||||
|
|
||||||
|
if (response != "LP" && response != "")
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
socket.abort();
|
||||||
|
socket.disconnectFromHost();
|
||||||
|
|
||||||
|
if(timeout > 0 && QDateTime::currentDateTime() >= endTime)
|
||||||
{
|
{
|
||||||
line = line.remove('(');
|
emit busyEnd();
|
||||||
line = line.simplified();
|
return "";
|
||||||
|
|
||||||
line[0] = line[0].toUpper(); // capitalize the key
|
|
||||||
|
|
||||||
int firstSpace = line.indexOf(' ');
|
|
||||||
if (firstSpace > 0)
|
|
||||||
{
|
|
||||||
line = line.insert(firstSpace, ':'); // add a colon between the key and the value
|
|
||||||
line[firstSpace+2] = line[firstSpace+2].toUpper(); // capitalize the value
|
|
||||||
}
|
|
||||||
|
|
||||||
description += line + "\n";
|
|
||||||
}
|
}
|
||||||
voiceDescriptions[voice] = description.trimmed();
|
/* make sure we wait a little as we don't want to flood the server with requests */
|
||||||
}
|
QDateTime tmpEndTime = QDateTime::currentDateTime().addMSecs(500);
|
||||||
return voiceDescriptions[voice];
|
while(QDateTime::currentDateTime() < tmpEndTime)
|
||||||
}
|
QCoreApplication::processEvents(QEventLoop::AllEvents);
|
||||||
|
}
|
||||||
QString TTSFestival::queryServer(QString query, int timeout)
|
if(response == "nil")
|
||||||
{
|
|
||||||
if(!configOk())
|
|
||||||
return "";
|
|
||||||
|
|
||||||
ensureServerRunning();
|
|
||||||
|
|
||||||
qDebug() << "queryServer with " << query;
|
|
||||||
QString response;
|
|
||||||
|
|
||||||
QDateTime endTime;
|
|
||||||
if(timeout > 0)
|
|
||||||
endTime = QDateTime::currentDateTime().addMSecs(timeout);
|
|
||||||
|
|
||||||
/* Festival is *extremely* unreliable. Although at this
|
|
||||||
* point we are sure that SIOD is accepting commands,
|
|
||||||
* we might end up with an empty response. Hence, the loop.
|
|
||||||
*/
|
|
||||||
while(true)
|
|
||||||
{
|
{
|
||||||
QApplication::processEvents(QEventLoop::AllEvents, 50);
|
emit busyEnd();
|
||||||
QTcpSocket socket;
|
return "";
|
||||||
|
|
||||||
socket.connectToHost("localhost", 1314);
|
|
||||||
socket.waitForConnected();
|
|
||||||
|
|
||||||
if(socket.state() == QAbstractSocket::ConnectedState)
|
|
||||||
{
|
|
||||||
socket.write(QString("%1\n").arg(query).toAscii());
|
|
||||||
socket.waitForBytesWritten();
|
|
||||||
socket.waitForReadyRead();
|
|
||||||
|
|
||||||
response = socket.readAll().trimmed();
|
|
||||||
|
|
||||||
if (response != "LP" && response != "")
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
socket.abort();
|
|
||||||
socket.disconnectFromHost();
|
|
||||||
|
|
||||||
if(timeout > 0 && QDateTime::currentDateTime() >= endTime)
|
|
||||||
return "";
|
|
||||||
|
|
||||||
/* make sure we wait a little as we don't want to flood the server with requests */
|
|
||||||
QDateTime tmpEndTime = QDateTime::currentDateTime().addMSecs(500);
|
|
||||||
while(QDateTime::currentDateTime() < tmpEndTime)
|
|
||||||
QApplication::processEvents(QEventLoop::AllEvents);
|
|
||||||
}
|
}
|
||||||
if(response == "nil")
|
|
||||||
return "";
|
|
||||||
|
|
||||||
QStringList lines = response.split('\n');
|
QStringList lines = response.split('\n');
|
||||||
if(lines.size() > 2)
|
if(lines.size() > 2)
|
||||||
{
|
{
|
||||||
lines.removeFirst();
|
lines.removeFirst();
|
||||||
lines.removeLast();
|
lines.removeLast();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
qDebug() << "Response too short: " << response;
|
qDebug() << "Response too short: " << response;
|
||||||
|
|
||||||
|
emit busyEnd();
|
||||||
return lines.join("\n");
|
return lines.join("\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,44 +26,41 @@
|
||||||
#include "rbsettings.h"
|
#include "rbsettings.h"
|
||||||
#include <QtCore>
|
#include <QtCore>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QProgressDialog>
|
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QRegExp>
|
#include <QRegExp>
|
||||||
#include <QTcpSocket>
|
#include <QTcpSocket>
|
||||||
|
|
||||||
#ifndef CONSOLE
|
#include "encttssettings.h"
|
||||||
#include "ttsgui.h"
|
|
||||||
#else
|
|
||||||
#include "ttsguicli.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
enum TTSStatus{ FatalError, NoError, Warning };
|
enum TTSStatus{ FatalError, NoError, Warning };
|
||||||
class TTSSapi;
|
|
||||||
#if defined(Q_OS_LINUX)
|
class TTSBase : public EncTtsSettingInterface
|
||||||
class TTSFestival;
|
|
||||||
#endif
|
|
||||||
class TTSBase : public QObject
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
TTSBase();
|
TTSBase(QObject *parent);
|
||||||
virtual TTSStatus voice(QString text,QString wavfile, QString* errStr)
|
//! Child class should generate a clip
|
||||||
{ (void) text; (void) wavfile; (void) errStr; return FatalError;}
|
virtual TTSStatus voice(QString text,QString wavfile, QString* errStr) =0;
|
||||||
virtual bool start(QString *errStr) { (void)errStr; return false; }
|
//! Child class should do startup
|
||||||
virtual bool stop() { return false; }
|
virtual bool start(QString *errStr) =0;
|
||||||
virtual void showCfg(){}
|
//! child class should stop
|
||||||
virtual bool configOk() { return false; }
|
virtual bool stop() =0;
|
||||||
|
|
||||||
virtual void setCfg(RbSettings* sett) { settings = sett; }
|
// configuration
|
||||||
|
//! Child class should return true, when configuration is good
|
||||||
|
virtual bool configOk()=0;
|
||||||
|
//! Child class should generate and insertSetting(..) its settings
|
||||||
|
virtual void generateSettings() = 0;
|
||||||
|
//! Chlid class should commit the Settings to permanent storage
|
||||||
|
virtual void saveSettings() = 0;
|
||||||
|
|
||||||
static TTSBase* getTTS(QString ttsname);
|
// static functions
|
||||||
|
static TTSBase* getTTS(QObject* parent,QString ttsname);
|
||||||
static QStringList getTTSList();
|
static QStringList getTTSList();
|
||||||
static QString getTTSName(QString tts);
|
static QString getTTSName(QString tts);
|
||||||
|
|
||||||
public slots:
|
// sets the config. Users of TTS classes, always have to call this first
|
||||||
virtual void accept(void){}
|
void setCfg(RbSettings* sett) { settings = sett; }
|
||||||
virtual void reject(void){}
|
|
||||||
virtual void reset(void){}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//inits the tts List
|
//inits the tts List
|
||||||
|
|
@ -72,22 +69,38 @@ class TTSBase : public QObject
|
||||||
protected:
|
protected:
|
||||||
RbSettings* settings;
|
RbSettings* settings;
|
||||||
static QMap<QString,QString> ttsList;
|
static QMap<QString,QString> ttsList;
|
||||||
static QMap<QString,TTSBase*> ttsCache;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class TTSSapi : public TTSBase
|
class TTSSapi : public TTSBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
//! Enum to identify the settings
|
||||||
public:
|
enum ESettings
|
||||||
TTSSapi();
|
{
|
||||||
virtual TTSStatus voice(QString text,QString wavfile, QString *errStr);
|
eLANGUAGE,
|
||||||
virtual bool start(QString *errStr);
|
eVOICE,
|
||||||
virtual bool stop();
|
eSPEED,
|
||||||
virtual void showCfg();
|
eOPTIONS
|
||||||
virtual bool configOk();
|
};
|
||||||
|
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
TTSSapi(QObject* parent=NULL);
|
||||||
|
|
||||||
|
TTSStatus voice(QString text,QString wavfile, QString *errStr);
|
||||||
|
bool start(QString *errStr);
|
||||||
|
bool stop();
|
||||||
|
|
||||||
|
// for settings
|
||||||
|
bool configOk();
|
||||||
|
void generateSettings();
|
||||||
|
void saveSettings();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void updateVoiceList();
|
||||||
|
|
||||||
QStringList getVoiceList(QString language);
|
|
||||||
private:
|
private:
|
||||||
|
QStringList getVoiceList(QString language);
|
||||||
|
|
||||||
QProcess* voicescript;
|
QProcess* voicescript;
|
||||||
QTextStream* voicestream;
|
QTextStream* voicestream;
|
||||||
QString defaultLanguage;
|
QString defaultLanguage;
|
||||||
|
|
@ -104,16 +117,23 @@ class TTSSapi : public TTSBase
|
||||||
|
|
||||||
class TTSExes : public TTSBase
|
class TTSExes : public TTSBase
|
||||||
{
|
{
|
||||||
|
enum ESettings
|
||||||
|
{
|
||||||
|
eEXEPATH,
|
||||||
|
eOPTIONS
|
||||||
|
};
|
||||||
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
TTSExes(QString name);
|
TTSExes(QString name,QObject* parent=NULL);
|
||||||
virtual TTSStatus voice(QString text,QString wavfile, QString *errStr);
|
TTSStatus voice(QString text,QString wavfile, QString *errStr);
|
||||||
virtual bool start(QString *errStr);
|
bool start(QString *errStr);
|
||||||
virtual bool stop() {return true;}
|
bool stop() {return true;}
|
||||||
virtual void showCfg();
|
|
||||||
virtual bool configOk();
|
|
||||||
|
|
||||||
virtual void setCfg(RbSettings* sett);
|
// for settings
|
||||||
|
void generateSettings();
|
||||||
|
void saveSettings();
|
||||||
|
bool configOk();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_name;
|
QString m_name;
|
||||||
|
|
@ -125,24 +145,41 @@ class TTSExes : public TTSBase
|
||||||
|
|
||||||
class TTSFestival : public TTSBase
|
class TTSFestival : public TTSBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
enum ESettings
|
||||||
public:
|
{
|
||||||
~TTSFestival();
|
eSERVERPATH,
|
||||||
virtual bool configOk();
|
eCLIENTPATH,
|
||||||
virtual bool start(QString *errStr);
|
eVOICE,
|
||||||
virtual bool stop();
|
eVOICEDESC
|
||||||
virtual void showCfg();
|
};
|
||||||
virtual TTSStatus voice(QString text,QString wavfile, QString *errStr);
|
|
||||||
|
|
||||||
QStringList getVoiceList();
|
Q_OBJECT
|
||||||
QString getVoiceInfo(QString voice);
|
public:
|
||||||
private:
|
TTSFestival(QObject* parent=NULL) :TTSBase(parent) {}
|
||||||
inline void startServer();
|
~TTSFestival();
|
||||||
inline void ensureServerRunning();
|
bool start(QString *errStr);
|
||||||
QString queryServer(QString query, int timeout = -1);
|
bool stop();
|
||||||
QProcess serverProcess;
|
TTSStatus voice(QString text,QString wavfile, QString *errStr);
|
||||||
QStringList voices;
|
|
||||||
QMap<QString, QString> voiceDescriptions;
|
// for settings
|
||||||
|
bool configOk();
|
||||||
|
void generateSettings();
|
||||||
|
void saveSettings();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void updateVoiceList();
|
||||||
|
void updateVoiceDescription();
|
||||||
|
void clearVoiceDescription();
|
||||||
|
private:
|
||||||
|
QStringList getVoiceList(QString path ="");
|
||||||
|
QString getVoiceInfo(QString voice,QString path ="");
|
||||||
|
|
||||||
|
inline void startServer(QString path="");
|
||||||
|
inline void ensureServerRunning(QString path="");
|
||||||
|
QString queryServer(QString query, int timeout = -1,QString path="");
|
||||||
|
QProcess serverProcess;
|
||||||
|
QStringList voices;
|
||||||
|
QMap<QString, QString> voiceDescriptions;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,158 +0,0 @@
|
||||||
<ui version="4.0" >
|
|
||||||
<class>TTSExesCfgFrm</class>
|
|
||||||
<widget class="QDialog" name="TTSExesCfgFrm" >
|
|
||||||
<property name="geometry" >
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>463</width>
|
|
||||||
<height>214</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle" >
|
|
||||||
<string>Configuration</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QHBoxLayout" >
|
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="groupBox" >
|
|
||||||
<property name="title" >
|
|
||||||
<string>Configure TTS Engine</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" >
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label" >
|
|
||||||
<property name="sizePolicy" >
|
|
||||||
<sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>255</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="text" >
|
|
||||||
<string>Path to TTS Engine</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" >
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="ttspath" />
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="browse" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>&Browse</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<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>
|
|
||||||
<spacer>
|
|
||||||
<property name="orientation" >
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" >
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>40</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" >
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="reset" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Reset</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer>
|
|
||||||
<property name="orientation" >
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" >
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="buttonOk" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>&Ok</string>
|
|
||||||
</property>
|
|
||||||
<property name="icon" >
|
|
||||||
<iconset resource="rbutilqt.qrc" >:/icons/go-next.png</iconset>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="buttonCancel" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>&Cancel</string>
|
|
||||||
</property>
|
|
||||||
<property name="icon" >
|
|
||||||
<iconset resource="rbutilqt.qrc" >:/icons/process-stop.png</iconset>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources>
|
|
||||||
<include location="rbutilqt.qrc" />
|
|
||||||
</resources>
|
|
||||||
<connections>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonOk</sender>
|
|
||||||
<signal>clicked()</signal>
|
|
||||||
<receiver>TTSExesCfgFrm</receiver>
|
|
||||||
<slot>accept()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel" >
|
|
||||||
<x>253</x>
|
|
||||||
<y>147</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel" >
|
|
||||||
<x>203</x>
|
|
||||||
<y>86</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonCancel</sender>
|
|
||||||
<signal>clicked()</signal>
|
|
||||||
<receiver>TTSExesCfgFrm</receiver>
|
|
||||||
<slot>reject()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel" >
|
|
||||||
<x>352</x>
|
|
||||||
<y>147</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel" >
|
|
||||||
<x>203</x>
|
|
||||||
<y>86</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
|
||||||
|
|
@ -1,322 +0,0 @@
|
||||||
<ui version="4.0" >
|
|
||||||
<class>TTSFestivalCfgFrm</class>
|
|
||||||
<widget class="QDialog" name="TTSFestivalCfgFrm" >
|
|
||||||
<property name="geometry" >
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>340</width>
|
|
||||||
<height>316</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle" >
|
|
||||||
<string>Configuration</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QGridLayout" name="gridLayout_4" >
|
|
||||||
<item row="3" column="1" >
|
|
||||||
<widget class="QDialogButtonBox" name="buttonBox" >
|
|
||||||
<property name="sizePolicy" >
|
|
||||||
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="orientation" >
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="standardButtons" >
|
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
|
||||||
</property>
|
|
||||||
<property name="centerButtons" >
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0" colspan="2" >
|
|
||||||
<widget class="QGroupBox" name="execsBox" >
|
|
||||||
<property name="sizePolicy" >
|
|
||||||
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
|
|
||||||
<horstretch>1</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="title" >
|
|
||||||
<string>Executables</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QGridLayout" name="gridLayout_2" >
|
|
||||||
<property name="topMargin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="spacing" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item row="0" column="0" >
|
|
||||||
<layout class="QGridLayout" name="gridLayout" >
|
|
||||||
<property name="sizeConstraint" >
|
|
||||||
<enum>QLayout::SetMinimumSize</enum>
|
|
||||||
</property>
|
|
||||||
<property name="horizontalSpacing" >
|
|
||||||
<number>6</number>
|
|
||||||
</property>
|
|
||||||
<property name="verticalSpacing" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item row="0" column="0" colspan="2" >
|
|
||||||
<widget class="QLabel" name="label" >
|
|
||||||
<property name="sizePolicy" >
|
|
||||||
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="text" >
|
|
||||||
<string>Path to Festival server</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0" >
|
|
||||||
<widget class="QLineEdit" name="serverPath" >
|
|
||||||
<property name="sizePolicy" >
|
|
||||||
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
|
|
||||||
<horstretch>1</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize" >
|
|
||||||
<size>
|
|
||||||
<width>215</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1" >
|
|
||||||
<widget class="QPushButton" name="serverButton" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Browse</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0" colspan="2" >
|
|
||||||
<widget class="QLabel" name="label_2" >
|
|
||||||
<property name="sizePolicy" >
|
|
||||||
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="text" >
|
|
||||||
<string>Path to Festival client</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="0" >
|
|
||||||
<widget class="QLineEdit" name="clientPath" >
|
|
||||||
<property name="sizePolicy" >
|
|
||||||
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
|
|
||||||
<horstretch>1</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize" >
|
|
||||||
<size>
|
|
||||||
<width>215</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="1" >
|
|
||||||
<widget class="QPushButton" name="clientButton" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Browse</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="0" >
|
|
||||||
<spacer name="horizontalSpacer" >
|
|
||||||
<property name="orientation" >
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0" >
|
|
||||||
<size>
|
|
||||||
<width>70</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0" >
|
|
||||||
<spacer name="verticalSpacer" >
|
|
||||||
<property name="orientation" >
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0" >
|
|
||||||
<size>
|
|
||||||
<width>153</width>
|
|
||||||
<height>43</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0" colspan="2" >
|
|
||||||
<widget class="QGroupBox" name="groupBox2" >
|
|
||||||
<property name="sizePolicy" >
|
|
||||||
<sizepolicy vsizetype="Minimum" hsizetype="Expanding" >
|
|
||||||
<horstretch>1</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize" >
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="title" >
|
|
||||||
<string>Server voice</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QGridLayout" name="gridLayout_3" >
|
|
||||||
<property name="leftMargin" >
|
|
||||||
<number>6</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin" >
|
|
||||||
<number>6</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin" >
|
|
||||||
<number>6</number>
|
|
||||||
</property>
|
|
||||||
<property name="horizontalSpacing" >
|
|
||||||
<number>6</number>
|
|
||||||
</property>
|
|
||||||
<property name="verticalSpacing" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item row="0" column="0" colspan="2" >
|
|
||||||
<widget class="QLabel" name="voiceLabel" >
|
|
||||||
<property name="sizePolicy" >
|
|
||||||
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="text" >
|
|
||||||
<string>Select a voice</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0" >
|
|
||||||
<widget class="QPushButton" name="refreshButton" >
|
|
||||||
<property name="sizePolicy" >
|
|
||||||
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="text" >
|
|
||||||
<string>&Refresh</string>
|
|
||||||
</property>
|
|
||||||
<property name="icon" >
|
|
||||||
<iconset resource="rbutilqt.qrc" >
|
|
||||||
<normaloff>:/icons/view-refresh.png</normaloff>:/icons/view-refresh.png</iconset>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1" >
|
|
||||||
<widget class="QComboBox" name="voicesBox" >
|
|
||||||
<property name="sizePolicy" >
|
|
||||||
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
|
|
||||||
<horstretch>1</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize" >
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="1" >
|
|
||||||
<widget class="QLabel" name="descriptionLabel" >
|
|
||||||
<property name="sizePolicy" >
|
|
||||||
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="text" >
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="1" >
|
|
||||||
<widget class="QCheckBox" name="showDescriptionCheckbox" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Show voice description</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
<zorder>buttonBox</zorder>
|
|
||||||
<zorder>execsBox</zorder>
|
|
||||||
<zorder>horizontalSpacer</zorder>
|
|
||||||
<zorder>verticalSpacer</zorder>
|
|
||||||
<zorder>groupBox2</zorder>
|
|
||||||
</widget>
|
|
||||||
<tabstops>
|
|
||||||
<tabstop>serverPath</tabstop>
|
|
||||||
<tabstop>serverButton</tabstop>
|
|
||||||
<tabstop>clientPath</tabstop>
|
|
||||||
<tabstop>clientButton</tabstop>
|
|
||||||
<tabstop>refreshButton</tabstop>
|
|
||||||
<tabstop>voicesBox</tabstop>
|
|
||||||
<tabstop>buttonBox</tabstop>
|
|
||||||
</tabstops>
|
|
||||||
<resources>
|
|
||||||
<include location="rbutilqt.qrc" />
|
|
||||||
</resources>
|
|
||||||
<connections>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>accepted()</signal>
|
|
||||||
<receiver>TTSFestivalCfgFrm</receiver>
|
|
||||||
<slot>accept()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel" >
|
|
||||||
<x>248</x>
|
|
||||||
<y>254</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel" >
|
|
||||||
<x>157</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>rejected()</signal>
|
|
||||||
<receiver>TTSFestivalCfgFrm</receiver>
|
|
||||||
<slot>reject()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel" >
|
|
||||||
<x>316</x>
|
|
||||||
<y>260</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel" >
|
|
||||||
<x>286</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
|
||||||
|
|
@ -1,341 +0,0 @@
|
||||||
/***************************************************************************
|
|
||||||
* __________ __ ___.
|
|
||||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
||||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
||||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
||||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
||||||
* \/ \/ \/ \/ \/
|
|
||||||
*
|
|
||||||
* Copyright (C) 2007 by Dominik Wenger
|
|
||||||
* $Id$
|
|
||||||
*
|
|
||||||
* All files in this archive are subject to the GNU General Public License.
|
|
||||||
* See the file COPYING in the source tree root for full license agreement.
|
|
||||||
*
|
|
||||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
||||||
* KIND, either express or implied.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include "ttsgui.h"
|
|
||||||
|
|
||||||
#include "rbsettings.h"
|
|
||||||
#include "tts.h"
|
|
||||||
#include "browsedirtree.h"
|
|
||||||
|
|
||||||
TTSSapiGui::TTSSapiGui(TTSSapi* sapi,QDialog* parent) : QDialog(parent)
|
|
||||||
{
|
|
||||||
m_sapi= sapi;
|
|
||||||
ui.setupUi(this);
|
|
||||||
this->hide();
|
|
||||||
connect(ui.reset,SIGNAL(clicked()),this,SLOT(reset()));
|
|
||||||
connect(ui.languagecombo,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateVoices(QString)));
|
|
||||||
connect(ui.usesapi4,SIGNAL(stateChanged(int)),this,SLOT(useSapi4Changed(int)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void TTSSapiGui::showCfg()
|
|
||||||
{
|
|
||||||
// try to get config from settings
|
|
||||||
ui.ttsoptions->setText(settings->subValue("sapi", RbSettings::TtsOptions).toString());
|
|
||||||
QString selLang = settings->subValue("sapi", RbSettings::TtsLanguage).toString();
|
|
||||||
QString selVoice = settings->subValue("sapi", RbSettings::TtsVoice).toString();
|
|
||||||
ui.speed->setValue(settings->subValue("sapi", RbSettings::TtsSpeed).toInt());
|
|
||||||
if(settings->value(RbSettings::TtsUseSapi4).toBool())
|
|
||||||
ui.usesapi4->setCheckState(Qt::Checked);
|
|
||||||
else
|
|
||||||
ui.usesapi4->setCheckState(Qt::Unchecked);
|
|
||||||
|
|
||||||
// fill in language combobox
|
|
||||||
QStringList languages = settings->languages();
|
|
||||||
|
|
||||||
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();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void TTSSapiGui::reset()
|
|
||||||
{
|
|
||||||
ui.ttsoptions->setText("");
|
|
||||||
ui.languagecombo->setCurrentIndex(ui.languagecombo->findText("english"));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void TTSSapiGui::accept(void)
|
|
||||||
{
|
|
||||||
//save settings in user config
|
|
||||||
settings->setSubValue("sapi", RbSettings::TtsOptions, ui.ttsoptions->text());
|
|
||||||
settings->setSubValue("sapi", RbSettings::TtsLanguage, ui.languagecombo->currentText());
|
|
||||||
settings->setSubValue("sapi", RbSettings::TtsVoice, ui.voicecombo->currentText());
|
|
||||||
settings->setSubValue("sapi", RbSettings::TtsSpeed, ui.speed->value());
|
|
||||||
if(ui.usesapi4->checkState() == Qt::Checked)
|
|
||||||
settings->setValue(RbSettings::TtsUseSapi4, true);
|
|
||||||
else
|
|
||||||
settings->setValue(RbSettings::TtsUseSapi4, false);
|
|
||||||
// sync settings
|
|
||||||
settings->sync();
|
|
||||||
|
|
||||||
this->done(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TTSSapiGui::reject(void)
|
|
||||||
{
|
|
||||||
this->done(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TTSSapiGui::updateVoices(QString language)
|
|
||||||
{
|
|
||||||
QStringList Voices = m_sapi->getVoiceList(language);
|
|
||||||
ui.voicecombo->clear();
|
|
||||||
ui.voicecombo->addItems(Voices);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void TTSSapiGui::useSapi4Changed(int)
|
|
||||||
{
|
|
||||||
if(ui.usesapi4->checkState() == Qt::Checked)
|
|
||||||
settings->setValue(RbSettings::TtsUseSapi4, true);
|
|
||||||
else
|
|
||||||
settings->setValue(RbSettings::TtsUseSapi4, false);
|
|
||||||
// sync settings
|
|
||||||
settings->sync();
|
|
||||||
updateVoices(ui.languagecombo->currentText());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
TTSExesGui::TTSExesGui(QDialog* parent) : QDialog(parent)
|
|
||||||
{
|
|
||||||
ui.setupUi(this);
|
|
||||||
this->hide();
|
|
||||||
connect(ui.reset,SIGNAL(clicked()),this,SLOT(reset()));
|
|
||||||
connect(ui.browse,SIGNAL(clicked()),this,SLOT(browse()));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void TTSExesGui::reset()
|
|
||||||
{
|
|
||||||
ui.ttspath->setText("");
|
|
||||||
ui.ttsoptions->setText("");
|
|
||||||
}
|
|
||||||
|
|
||||||
void TTSExesGui::showCfg(QString name)
|
|
||||||
{
|
|
||||||
m_name = name;
|
|
||||||
// try to get config from settings
|
|
||||||
QString exepath =settings->subValue(m_name, RbSettings::TtsPath).toString();
|
|
||||||
ui.ttsoptions->setText(settings->subValue(m_name, RbSettings::TtsOptions).toString());
|
|
||||||
ui.ttspath->setText(exepath);
|
|
||||||
|
|
||||||
//show dialog
|
|
||||||
this->exec();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void TTSExesGui::accept(void)
|
|
||||||
{
|
|
||||||
//save settings in user config
|
|
||||||
settings->setSubValue(m_name, RbSettings::TtsPath, ui.ttspath->text());
|
|
||||||
settings->setSubValue(m_name, RbSettings::TtsOptions, ui.ttsoptions->text());
|
|
||||||
// sync settings
|
|
||||||
settings->sync();
|
|
||||||
|
|
||||||
this->done(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TTSExesGui::reject(void)
|
|
||||||
{
|
|
||||||
this->done(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void TTSExesGui::browse()
|
|
||||||
{
|
|
||||||
BrowseDirtree browser(this);
|
|
||||||
browser.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
|
|
||||||
|
|
||||||
if(QFileInfo(ui.ttspath->text()).isDir())
|
|
||||||
{
|
|
||||||
browser.setDir(ui.ttspath->text());
|
|
||||||
}
|
|
||||||
if(browser.exec() == QDialog::Accepted)
|
|
||||||
{
|
|
||||||
qDebug() << browser.getSelected();
|
|
||||||
QString exe = browser.getSelected();
|
|
||||||
if(!QFileInfo(exe).isExecutable())
|
|
||||||
return;
|
|
||||||
ui.ttspath->setText(exe);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TTSFestivalGui::TTSFestivalGui(TTSFestival* api, QDialog* parent) :
|
|
||||||
QDialog(parent), festival(api)
|
|
||||||
{
|
|
||||||
ui.setupUi(this);
|
|
||||||
this->setModal(true);
|
|
||||||
this->setDisabled(true);
|
|
||||||
this->show();
|
|
||||||
|
|
||||||
connect(ui.clientButton, SIGNAL(clicked()), this, SLOT(onBrowseClient()));
|
|
||||||
connect(ui.serverButton, SIGNAL(clicked()), this, SLOT(onBrowseServer()));
|
|
||||||
|
|
||||||
connect(ui.refreshButton, SIGNAL(clicked()), this, SLOT(onRefreshButton()));
|
|
||||||
connect(ui.voicesBox, SIGNAL(activated(QString)), this, SLOT(updateDescription(QString)));
|
|
||||||
connect(ui.showDescriptionCheckbox, SIGNAL(stateChanged(int)), this, SLOT(onShowDescription(int)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void TTSFestivalGui::showCfg()
|
|
||||||
{
|
|
||||||
qDebug() << "show\tpaths: " << settings->subValue("festival", RbSettings::TtsPath) << "\n"
|
|
||||||
<< "\tvoice: " << settings->subValue("festival", RbSettings::TtsVoice);
|
|
||||||
|
|
||||||
// will populate the voices if the paths are correct,
|
|
||||||
// otherwise, it will require the user to press Refresh
|
|
||||||
updateVoices();
|
|
||||||
|
|
||||||
// try to get config from settings
|
|
||||||
QStringList paths = settings->subValue("festival", RbSettings::TtsPath).toString().split(":");
|
|
||||||
if(paths.size() == 2)
|
|
||||||
{
|
|
||||||
ui.serverPath->setText(paths[0]);
|
|
||||||
ui.clientPath->setText(paths[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
this->setEnabled(true);
|
|
||||||
this->exec();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TTSFestivalGui::accept(void)
|
|
||||||
{
|
|
||||||
//save settings in user config
|
|
||||||
QString newPath = QString("%1:%2").arg(ui.serverPath->text().trimmed()).arg(ui.clientPath->text().trimmed());
|
|
||||||
qDebug() << "set\tpaths: " << newPath << "\n\tvoice: " << ui.voicesBox->currentText();
|
|
||||||
settings->setSubValue("festival", RbSettings::TtsPath, newPath);
|
|
||||||
settings->setSubValue("festival", RbSettings::TtsVoice, ui.voicesBox->currentText());
|
|
||||||
|
|
||||||
settings->sync();
|
|
||||||
|
|
||||||
this->done(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TTSFestivalGui::reject(void)
|
|
||||||
{
|
|
||||||
this->done(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TTSFestivalGui::onBrowseClient()
|
|
||||||
{
|
|
||||||
BrowseDirtree browser(this);
|
|
||||||
browser.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
|
|
||||||
|
|
||||||
QFileInfo currentPath(ui.clientPath->text().trimmed());
|
|
||||||
if(currentPath.isDir())
|
|
||||||
{
|
|
||||||
browser.setDir(ui.clientPath->text());
|
|
||||||
}
|
|
||||||
else if (currentPath.isFile())
|
|
||||||
{
|
|
||||||
browser.setDir(currentPath.dir().absolutePath());
|
|
||||||
}
|
|
||||||
if(browser.exec() == QDialog::Accepted)
|
|
||||||
{
|
|
||||||
qDebug() << browser.getSelected();
|
|
||||||
QString exe = browser.getSelected();
|
|
||||||
if(!QFileInfo(exe).isExecutable())
|
|
||||||
return;
|
|
||||||
ui.clientPath->setText(exe);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TTSFestivalGui::onBrowseServer()
|
|
||||||
{
|
|
||||||
BrowseDirtree browser(this);
|
|
||||||
browser.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
|
|
||||||
|
|
||||||
QFileInfo currentPath(ui.serverPath->text().trimmed());
|
|
||||||
if(currentPath.isDir())
|
|
||||||
{
|
|
||||||
browser.setDir(ui.serverPath->text());
|
|
||||||
}
|
|
||||||
else if (currentPath.isFile())
|
|
||||||
{
|
|
||||||
browser.setDir(currentPath.dir().absolutePath());
|
|
||||||
}
|
|
||||||
if(browser.exec() == QDialog::Accepted)
|
|
||||||
{
|
|
||||||
qDebug() << browser.getSelected();
|
|
||||||
QString exe = browser.getSelected();
|
|
||||||
if(!QFileInfo(exe).isExecutable())
|
|
||||||
return;
|
|
||||||
ui.serverPath->setText(exe);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TTSFestivalGui::onRefreshButton()
|
|
||||||
{
|
|
||||||
/* Temporarily commit the settings so that we get the new path when we check for voices */
|
|
||||||
QString newPath = QString("%1:%2").arg(ui.serverPath->text().trimmed()).arg(ui.clientPath->text().trimmed());
|
|
||||||
QString oldPath = settings->subValue("festival", RbSettings::TtsPath).toString();
|
|
||||||
qDebug() << "new path: " << newPath << "\n" << "old path: " << oldPath << "\nuse new: " << (newPath != oldPath);
|
|
||||||
|
|
||||||
if(newPath != oldPath)
|
|
||||||
{
|
|
||||||
qDebug() << "Using new paths for getVoiceList";
|
|
||||||
settings->setSubValue("festival", RbSettings::TtsPath, newPath);
|
|
||||||
settings->sync();
|
|
||||||
}
|
|
||||||
|
|
||||||
updateVoices();
|
|
||||||
|
|
||||||
if(newPath != oldPath)
|
|
||||||
{
|
|
||||||
settings->setSubValue("festival", RbSettings::TtsPath, oldPath);
|
|
||||||
settings->sync();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TTSFestivalGui::onShowDescription(int state)
|
|
||||||
{
|
|
||||||
if(state == Qt::Unchecked)
|
|
||||||
ui.descriptionLabel->setText("");
|
|
||||||
else
|
|
||||||
updateDescription(ui.voicesBox->currentText());
|
|
||||||
}
|
|
||||||
|
|
||||||
void TTSFestivalGui::updateVoices()
|
|
||||||
{
|
|
||||||
ui.voicesBox->clear();
|
|
||||||
ui.voicesBox->addItem(tr("Loading.."));
|
|
||||||
|
|
||||||
QStringList voiceList = festival->getVoiceList();
|
|
||||||
ui.voicesBox->clear();
|
|
||||||
ui.voicesBox->addItems(voiceList);
|
|
||||||
|
|
||||||
ui.voicesBox->setCurrentIndex(ui.voicesBox->findText(
|
|
||||||
settings->subValue("festival", RbSettings::TtsVoice).toString()));
|
|
||||||
|
|
||||||
updateDescription(settings->subValue("festival", RbSettings::TtsVoice).toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
void TTSFestivalGui::updateDescription(QString value)
|
|
||||||
{
|
|
||||||
if(ui.showDescriptionCheckbox->checkState() == Qt::Checked)
|
|
||||||
{
|
|
||||||
ui.descriptionLabel->setText(tr("Querying festival"));
|
|
||||||
ui.descriptionLabel->setText(festival->getVoiceInfo(value));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,105 +0,0 @@
|
||||||
/***************************************************************************
|
|
||||||
* __________ __ ___.
|
|
||||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
||||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
||||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
||||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
||||||
* \/ \/ \/ \/ \/
|
|
||||||
*
|
|
||||||
* Copyright (C) 2007 by Dominik Wenger
|
|
||||||
* $Id$
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
||||||
* KIND, either express or implied.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef TTSGUI_H
|
|
||||||
#define TTSGUI_H
|
|
||||||
|
|
||||||
#include <QtGui>
|
|
||||||
|
|
||||||
#include "ui_ttsexescfgfrm.h"
|
|
||||||
#include "ui_sapicfgfrm.h"
|
|
||||||
#include "ui_ttsfestivalcfgform.h"
|
|
||||||
|
|
||||||
class RbSettings;
|
|
||||||
class TTSSapi;
|
|
||||||
class TTSFestival;
|
|
||||||
|
|
||||||
class TTSSapiGui : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
TTSSapiGui(TTSSapi* sapi,QDialog* parent = NULL);
|
|
||||||
|
|
||||||
void showCfg();
|
|
||||||
void setCfg(RbSettings* sett){settings = sett;}
|
|
||||||
public slots:
|
|
||||||
|
|
||||||
virtual void accept(void);
|
|
||||||
virtual void reject(void);
|
|
||||||
virtual void reset(void);
|
|
||||||
void updateVoices(QString language);
|
|
||||||
void useSapi4Changed(int);
|
|
||||||
private:
|
|
||||||
Ui::SapiCfgFrm ui;
|
|
||||||
RbSettings* settings;
|
|
||||||
TTSSapi* m_sapi;
|
|
||||||
};
|
|
||||||
|
|
||||||
class TTSExesGui : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
TTSExesGui(QDialog* parent = NULL);
|
|
||||||
|
|
||||||
void showCfg(QString m_name);
|
|
||||||
void setCfg(RbSettings* sett){settings = sett;}
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
virtual void accept(void);
|
|
||||||
virtual void reject(void);
|
|
||||||
virtual void reset(void);
|
|
||||||
void browse(void);
|
|
||||||
private:
|
|
||||||
Ui::TTSExesCfgFrm ui;
|
|
||||||
RbSettings* settings;
|
|
||||||
QString m_name;
|
|
||||||
};
|
|
||||||
|
|
||||||
class TTSFestivalGui : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
TTSFestivalGui(TTSFestival* festival, QDialog* parent = NULL);
|
|
||||||
|
|
||||||
void showCfg();
|
|
||||||
void setCfg(RbSettings* sett){settings = sett;}
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
virtual void accept(void);
|
|
||||||
virtual void reject(void);
|
|
||||||
//virtual void reset(void);
|
|
||||||
|
|
||||||
void onRefreshButton();
|
|
||||||
void onShowDescription(int state);
|
|
||||||
void onBrowseServer();
|
|
||||||
void onBrowseClient();
|
|
||||||
private:
|
|
||||||
Ui::TTSFestivalCfgFrm ui;
|
|
||||||
RbSettings* settings;
|
|
||||||
TTSFestival* festival;
|
|
||||||
|
|
||||||
void updateVoices();
|
|
||||||
private slots:
|
|
||||||
void updateDescription(QString value);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
@ -128,7 +128,7 @@ void VoiceFileCreator::downloadDone(bool error)
|
||||||
}
|
}
|
||||||
|
|
||||||
//tts
|
//tts
|
||||||
m_tts = TTSBase::getTTS(settings->value(RbSettings::Tts).toString());
|
m_tts = TTSBase::getTTS(this,settings->value(RbSettings::Tts).toString());
|
||||||
m_tts->setCfg(settings);
|
m_tts->setCfg(settings);
|
||||||
|
|
||||||
QString errStr;
|
QString errStr;
|
||||||
|
|
@ -142,7 +142,7 @@ void VoiceFileCreator::downloadDone(bool error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Encoder
|
// Encoder
|
||||||
m_enc = EncBase::getEncoder(settings->value(RbSettings::CurEncoder).toString());
|
m_enc = EncBase::getEncoder(this,settings->value(RbSettings::CurEncoder).toString());
|
||||||
m_enc->setCfg(settings);
|
m_enc->setCfg(settings);
|
||||||
|
|
||||||
if(!m_enc->start())
|
if(!m_enc->start())
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ class VoiceFileCreator :public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
VoiceFileCreator(QObject* parent=0);
|
VoiceFileCreator(QObject* parent);
|
||||||
|
|
||||||
//start creation
|
//start creation
|
||||||
bool createVoiceFile(ProgressloggerInterface* logger);
|
bool createVoiceFile(ProgressloggerInterface* logger);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue