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 ****************************************************************************/
22 #include "rbsettings.h"
24 TTSExes::TTSExes(QObject
* parent
) : TTSBase(parent
)
26 /* default to espeak */
28 m_capabilities
= TTSBase::CanSpeak
;
29 m_TTSTemplate
= "\"%exe\" %options -w \"%wavfile\" -- \"%text\"";
30 m_TTSSpeakTemplate
= "\"%exe\" %options -- \"%text\"";
34 TTSBase::Capabilities
TTSExes::capabilities()
36 return m_capabilities
;
39 void TTSExes::generateSettings()
42 insertSetting(eEXEPATH
, new EncTtsSetting(this, EncTtsSetting::eSTRING
,
43 tr("Path to TTS engine:"), m_TTSexec
, EncTtsSetting::eBROWSEBTN
));
44 insertSetting(eOPTIONS
, new EncTtsSetting(this, EncTtsSetting::eSTRING
,
45 tr("TTS engine options:"), m_TTSOpts
));
48 void TTSExes::saveSettings()
50 RbSettings::setSubValue(m_name
, RbSettings::TtsPath
,
51 getSetting(eEXEPATH
)->current().toString());
52 RbSettings::setSubValue(m_name
, RbSettings::TtsOptions
,
53 getSetting(eOPTIONS
)->current().toString());
58 void TTSExes::loadSettings(void)
60 m_TTSexec
= RbSettings::subValue(m_name
, RbSettings::TtsPath
).toString();
61 if(m_TTSexec
.isEmpty()) m_TTSexec
= Utils::findExecutable(m_name
);
62 m_TTSOpts
= RbSettings::subValue(m_name
, RbSettings::TtsOptions
).toString();
66 bool TTSExes::start(QString
*errStr
)
70 QFileInfo
tts(m_TTSexec
);
77 *errStr
= tr("TTS executable not found");
82 TTSStatus
TTSExes::voice(QString text
, QString wavfile
, QString
*errStr
)
86 if(wavfile
.isEmpty() && m_capabilities
& TTSBase::CanSpeak
) {
87 if(m_TTSSpeakTemplate
.isEmpty()) {
88 qDebug() << "[TTSExes] internal error: TTS announces CanSpeak "
89 "but template empty!";
92 execstring
= m_TTSSpeakTemplate
;
94 else if(wavfile
.isEmpty()) {
95 qDebug() << "[TTSExes] no output file passed to voice() "
96 "but TTS can't speak directly.";
100 execstring
= m_TTSTemplate
;
103 execstring
.replace("%exe",m_TTSexec
);
104 execstring
.replace("%options",m_TTSOpts
);
105 execstring
.replace("%wavfile",wavfile
);
106 execstring
.replace("%text",text
);
108 QProcess::execute(execstring
);
110 if(!wavfile
.isEmpty() && !QFileInfo(wavfile
).isFile()) {
111 qDebug() << "[TTSExes] output file does not exist:" << wavfile
;
118 bool TTSExes::configOk()
121 if (QFileInfo(m_TTSexec
).exists())