1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
9 * Copyright (C) 2007 by Dominik Wenger
11 * All files in this archive are subject to the GNU General Public License.
12 * See the file COPYING in the source tree root for full license agreement.
14 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
15 * KIND, either express or implied.
17 ****************************************************************************/
21 #include "rbsettings.h"
23 TTSExes::TTSExes(QString name
,QObject
* parent
) : TTSBase(parent
)
27 m_TemplateMap
["espeak"] = "\"%exe\" %options -w \"%wavfile\" -- \"%text\"";
28 m_TemplateMap
["flite"] = "\"%exe\" %options -o \"%wavfile\" -t \"%text\"";
29 m_TemplateMap
["swift"] = "\"%exe\" %options -o \"%wavfile\" -- \"%text\"";
33 TTSBase::Capabilities
TTSExes::capabilities()
38 void TTSExes::generateSettings()
41 insertSetting(eEXEPATH
, new EncTtsSetting(this, EncTtsSetting::eSTRING
,
42 tr("Path to TTS engine:"), m_TTSexec
, EncTtsSetting::eBROWSEBTN
));
43 insertSetting(eOPTIONS
, new EncTtsSetting(this, EncTtsSetting::eSTRING
,
44 tr("TTS engine options:"), m_TTSOpts
));
47 void TTSExes::saveSettings()
49 RbSettings::setSubValue(m_name
,RbSettings::TtsPath
,
50 getSetting(eEXEPATH
)->current().toString());
51 RbSettings::setSubValue(m_name
,RbSettings::TtsOptions
,
52 getSetting(eOPTIONS
)->current().toString());
57 void TTSExes::loadSettings(void)
59 m_TTSexec
= RbSettings::subValue(m_name
,RbSettings::TtsPath
).toString();
60 if(m_TTSexec
.isEmpty()) m_TTSexec
= Utils::findExecutable(m_name
);
61 m_TTSOpts
= RbSettings::subValue(m_name
,RbSettings::TtsOptions
).toString();
65 bool TTSExes::start(QString
*errStr
)
68 m_TTSTemplate
= m_TemplateMap
.value(m_name
);
70 QFileInfo
tts(m_TTSexec
);
77 *errStr
= tr("TTS executable not found");
82 TTSStatus
TTSExes::voice(QString text
,QString wavfile
, QString
*errStr
)
85 QString execstring
= m_TTSTemplate
;
87 execstring
.replace("%exe",m_TTSexec
);
88 execstring
.replace("%options",m_TTSOpts
);
89 execstring
.replace("%wavfile",wavfile
);
90 execstring
.replace("%text",text
);
92 QProcess::execute(execstring
);
94 if(!QFileInfo(wavfile
).isFile()) {
95 qDebug() << "[TTSExes] output file does not exist:" << wavfile
;
102 bool TTSExes::configOk()
105 if (QFileInfo(m_TTSexec
).exists())