1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
9 * Copyright (C) 2007 by Dominik Wenger
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
22 #include "rbsettings.h"
24 TTSExes::TTSExes(QString name
,QObject
* parent
) : TTSBase(parent
)
28 m_TemplateMap
["espeak"] = "\"%exe\" %options -w \"%wavfile\" \"%text\"";
29 m_TemplateMap
["flite"] = "\"%exe\" %options -o \"%wavfile\" -t \"%text\"";
30 m_TemplateMap
["swift"] = "\"%exe\" %options -o \"%wavfile\" \"%text\"";
34 TTSBase::Capabilities
TTSExes::capabilities()
39 void TTSExes::generateSettings()
41 QString exepath
=RbSettings::subValue(m_name
,RbSettings::TtsPath
).toString();
42 if(exepath
== "") exepath
= Utils::findExecutable(m_name
);
44 insertSetting(eEXEPATH
,new EncTtsSetting(this,EncTtsSetting::eSTRING
,
45 tr("Path to TTS engine:"),exepath
,EncTtsSetting::eBROWSEBTN
));
46 insertSetting(eOPTIONS
,new EncTtsSetting(this,EncTtsSetting::eSTRING
,
47 tr("TTS engine options:"),RbSettings::subValue(m_name
,RbSettings::TtsOptions
)));
50 void TTSExes::saveSettings()
52 RbSettings::setSubValue(m_name
,RbSettings::TtsPath
,
53 getSetting(eEXEPATH
)->current().toString());
54 RbSettings::setSubValue(m_name
,RbSettings::TtsOptions
,
55 getSetting(eOPTIONS
)->current().toString());
59 bool TTSExes::start(QString
*errStr
)
61 m_TTSexec
= RbSettings::subValue(m_name
,RbSettings::TtsPath
).toString();
62 m_TTSOpts
= RbSettings::subValue(m_name
,RbSettings::TtsOptions
).toString();
64 m_TTSTemplate
= m_TemplateMap
.value(m_name
);
66 QFileInfo
tts(m_TTSexec
);
73 *errStr
= tr("TTS executable not found");
78 TTSStatus
TTSExes::voice(QString text
,QString wavfile
, QString
*errStr
)
81 QString execstring
= m_TTSTemplate
;
83 execstring
.replace("%exe",m_TTSexec
);
84 execstring
.replace("%options",m_TTSOpts
);
85 execstring
.replace("%wavfile",wavfile
);
86 execstring
.replace("%text",text
);
87 //qDebug() << "voicing" << execstring;
88 QProcess::execute(execstring
);
93 bool TTSExes::configOk()
95 QString path
= RbSettings::subValue(m_name
,RbSettings::TtsPath
).toString();
97 if (QFileInfo(path
).exists())