mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-09 05:05:20 -05:00
rbutil: added builtin rbspeex encoder. Reworked encoder configuration.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15925 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
ed047d9db1
commit
815504b449
10 changed files with 284 additions and 230 deletions
|
|
@ -23,6 +23,7 @@
|
|||
#include "autodetection.h"
|
||||
#include "ui_configurefrm.h"
|
||||
#include "browsedirtree.h"
|
||||
#include "encoders.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#if defined(Q_OS_WIN32)
|
||||
|
|
@ -75,9 +76,10 @@ Config::Config(QWidget *parent) : QDialog(parent)
|
|||
connect(ui.buttonCacheBrowse, SIGNAL(clicked()), this, SLOT(browseCache()));
|
||||
connect(ui.buttonCacheClear, SIGNAL(clicked()), this, SLOT(cacheClear()));
|
||||
connect(ui.browseTts, SIGNAL(clicked()), this, SLOT(browseTts()));
|
||||
connect(ui.browseEncoder, SIGNAL(clicked()), this, SLOT(browseEnc()));
|
||||
connect(ui.comboEncoder, SIGNAL(currentIndexChanged(int)), this, SLOT(updateEncOpts(int)));
|
||||
connect(ui.configEncoder, SIGNAL(clicked()), this, SLOT(configEnc()));
|
||||
connect(ui.comboTts, SIGNAL(currentIndexChanged(int)), this, SLOT(updateTtsOpts(int)));
|
||||
connect(ui.comboEncoder, SIGNAL(currentIndexChanged(int)), this, SLOT(updateEncState(int)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -144,20 +146,9 @@ void Config::accept()
|
|||
devices->endGroup();
|
||||
userSettings->endGroup();
|
||||
|
||||
//encoder settings
|
||||
preset = ui.comboEncoder->itemData(ui.comboEncoder->currentIndex(), Qt::UserRole).toString();
|
||||
userSettings->setValue("encpreset", preset);
|
||||
userSettings->beginGroup(preset);
|
||||
|
||||
if(QFileInfo(ui.encoderExecutable->text()).isExecutable())
|
||||
userSettings->setValue("binary", ui.encoderExecutable->text());
|
||||
userSettings->setValue("options", ui.encoderOptions->text());
|
||||
devices->beginGroup(preset);
|
||||
userSettings->setValue("template", devices->value("template").toString());
|
||||
userSettings->setValue("type", devices->value("tts").toString());
|
||||
devices->endGroup();
|
||||
userSettings->endGroup();
|
||||
|
||||
//encoder settings
|
||||
userSettings->setValue("encoder",ui.comboEncoder->currentText());
|
||||
|
||||
// sync settings
|
||||
userSettings->sync();
|
||||
this->close();
|
||||
|
|
@ -314,17 +305,19 @@ void Config::setDevices(QSettings *dev)
|
|||
ui.treeDevices->setCurrentItem(w3); // hilight old selection
|
||||
|
||||
// tts / encoder tab
|
||||
QStringList keys;
|
||||
|
||||
devices->beginGroup("encoders");
|
||||
keys = devices->allKeys();
|
||||
for(int i=0; i < keys.size();i++)
|
||||
ui.comboEncoder->addItem(devices->value(keys.at(i), "null").toString(),
|
||||
keys.at(i));
|
||||
devices->endGroup();
|
||||
|
||||
|
||||
//encoders
|
||||
ui.comboEncoder->addItems(getEncoderList());
|
||||
|
||||
//update index of combobox
|
||||
int index = ui.comboEncoder->findText(userSettings->value("encoder").toString(),Qt::MatchExactly);
|
||||
if(index < 0) index = 0;
|
||||
ui.comboEncoder->setCurrentIndex(index);
|
||||
updateEncState(index);
|
||||
|
||||
//tts
|
||||
devices->beginGroup("tts");
|
||||
keys = devices->allKeys();
|
||||
QStringList keys = devices->allKeys();
|
||||
for(int i=0; i < keys.size();i++)
|
||||
{
|
||||
devices->endGroup();
|
||||
|
|
@ -343,67 +336,13 @@ void Config::setDevices(QSettings *dev)
|
|||
}
|
||||
devices->endGroup();
|
||||
|
||||
int index;
|
||||
|
||||
index = ui.comboTts->findData(userSettings->value("ttspreset").toString(),
|
||||
Qt::UserRole, Qt::MatchExactly);
|
||||
if(index < 0) index = 0;
|
||||
ui.comboTts->setCurrentIndex(index);
|
||||
updateTtsOpts(index);
|
||||
|
||||
index = ui.comboEncoder->findData(userSettings->value("encpreset").toString(),
|
||||
Qt::UserRole, Qt::MatchExactly);
|
||||
if(index < 0) index = 0;
|
||||
ui.comboEncoder->setCurrentIndex(index);
|
||||
updateEncOpts(index);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Config::updateEncOpts(int index)
|
||||
{
|
||||
qDebug() << "updateEncOpts()";
|
||||
QString e;
|
||||
bool edit;
|
||||
QString c = ui.comboEncoder->itemData(index, Qt::UserRole).toString();
|
||||
devices->beginGroup(c);
|
||||
ui.encoderOptions->setText(devices->value("options").toString());
|
||||
edit = devices->value("edit").toBool();
|
||||
ui.encoderOptions->setEnabled(edit);
|
||||
e = devices->value("encoder").toString();
|
||||
devices->endGroup();
|
||||
|
||||
// try to autodetect encoder
|
||||
#if defined(Q_OS_LINUX) || defined(Q_OS_MACX)
|
||||
QStringList path = QString(getenv("PATH")).split(":", QString::SkipEmptyParts);
|
||||
#elif defined(Q_OS_WIN)
|
||||
QStringList path = QString(getenv("PATH")).split(";", QString::SkipEmptyParts);
|
||||
#endif
|
||||
qDebug() << path;
|
||||
ui.encoderExecutable->setEnabled(true);
|
||||
for(int i = 0; i < path.size(); i++) {
|
||||
QString executable = QDir::fromNativeSeparators(path.at(i)) + "/" + e;
|
||||
#if defined(Q_OS_WIN)
|
||||
executable += ".exe";
|
||||
QStringList ex = executable.split("\"", QString::SkipEmptyParts);
|
||||
executable = ex.join("");
|
||||
#endif
|
||||
if(QFileInfo(executable).isExecutable()) {
|
||||
qDebug() << "found:" << executable;
|
||||
ui.encoderExecutable->setText(QDir::toNativeSeparators(executable));
|
||||
// disallow changing the detected path if non-customizable profile
|
||||
if(!edit)
|
||||
ui.encoderExecutable->setEnabled(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//user settings
|
||||
userSettings->beginGroup(c);
|
||||
QString temp = userSettings->value("binary","null").toString();
|
||||
if(temp != "null") ui.encoderExecutable->setText(temp);
|
||||
temp = userSettings->value("options","null").toString();
|
||||
if(temp != "null") ui.encoderOptions->setText(temp);
|
||||
userSettings->endGroup();
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -459,6 +398,23 @@ void Config::updateTtsOpts(int index)
|
|||
userSettings->endGroup();
|
||||
}
|
||||
|
||||
void Config::updateEncState(int index)
|
||||
{
|
||||
QString encoder = ui.comboEncoder->itemText(index);
|
||||
EncBase* enc = getEncoder(encoder);
|
||||
enc->setUserCfg(userSettings);
|
||||
|
||||
if(enc->configOk())
|
||||
{
|
||||
ui.configstatus->setText("Configuration OK");
|
||||
ui.configstatusimg->setPixmap(QPixmap(QString::fromUtf8(":/icons/icons/go-next.png")));
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.configstatus->setText("Configuration INVALID");
|
||||
ui.configstatusimg->setPixmap(QPixmap(QString::fromUtf8(":/icons/icons/dialog-error.png")));
|
||||
}
|
||||
}
|
||||
|
||||
void Config::setNoProxy(bool checked)
|
||||
{
|
||||
|
|
@ -741,22 +697,11 @@ void Config::browseTts()
|
|||
}
|
||||
|
||||
|
||||
void Config::browseEnc()
|
||||
void Config::configEnc()
|
||||
{
|
||||
BrowseDirtree browser(this);
|
||||
browser.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
|
||||
|
||||
if(QFileInfo(ui.encoderExecutable->text()).isDir())
|
||||
{
|
||||
browser.setDir(ui.encoderExecutable->text());
|
||||
}
|
||||
if(browser.exec() == QDialog::Accepted)
|
||||
{
|
||||
qDebug() << browser.getSelected();
|
||||
QString exe = browser.getSelected();
|
||||
if(!QFileInfo(exe).isExecutable())
|
||||
return;
|
||||
ui.encoderExecutable->setText(exe);
|
||||
}
|
||||
|
||||
EncBase* enc =getEncoder(ui.comboEncoder->currentText());
|
||||
|
||||
enc->setUserCfg(userSettings);
|
||||
enc->showCfg();
|
||||
updateEncState(ui.comboEncoder->currentIndex());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,9 +65,9 @@ class Config : public QDialog
|
|||
void setCache(QString);
|
||||
void cacheClear(void);
|
||||
void browseTts(void);
|
||||
void browseEnc(void);
|
||||
void configEnc(void);
|
||||
void updateTtsOpts(int);
|
||||
void updateEncOpts(int);
|
||||
void updateEncState(int);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -359,7 +359,7 @@
|
|||
<iconset resource="rbutilqt.qrc" >:/icons/icons/audio-input-microphone.png</iconset>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" >
|
||||
<item row="0" column="0" colspan="2" >
|
||||
<item row="0" column="0" >
|
||||
<widget class="QGroupBox" name="groupBox_2" >
|
||||
<property name="title" >
|
||||
<string>TTS Engine</string>
|
||||
|
|
@ -427,7 +427,7 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item rowspan="2" row="1" column="0" colspan="2" >
|
||||
<item row="1" column="0" >
|
||||
<widget class="QGroupBox" name="groupBox_3" >
|
||||
<property name="title" >
|
||||
<string>Encoder Engine</string>
|
||||
|
|
@ -436,64 +436,62 @@
|
|||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="labelEncoder" >
|
||||
<property name="text" >
|
||||
<string>Select &encoder profile</string>
|
||||
<string>Select &encoder</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>comboEncoder</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="2" >
|
||||
<item row="0" column="1" colspan="3" >
|
||||
<widget class="QComboBox" name="comboEncoder" />
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QLabel" name="labelEncoderExecutable" >
|
||||
<property name="text" >
|
||||
<string>Encoder executable</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>encoderExecutable</cstring>
|
||||
<string>Configure encoder</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<widget class="QLineEdit" name="encoderExecutable" />
|
||||
<widget class="QLabel" name="configstatus" >
|
||||
<property name="text" >
|
||||
<string>Configuration invalid !</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2" >
|
||||
<widget class="QPushButton" name="browseEncoder" >
|
||||
<widget class="QLabel" name="configstatusimg" >
|
||||
<property name="text" >
|
||||
<string>B&rowse</string>
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap" >
|
||||
<pixmap resource="rbutilqt.qrc" >:/icons/icons/dialog-error.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3" >
|
||||
<widget class="QPushButton" name="configEncoder" >
|
||||
<property name="text" >
|
||||
<string>&Configure</string>
|
||||
</property>
|
||||
<property name="icon" >
|
||||
<iconset resource="rbutilqt.qrc" >:/icons/icons/edit-find.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" >
|
||||
<widget class="QLabel" name="labelEncoderOptions" >
|
||||
<property name="text" >
|
||||
<string>Encoder options</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>encoderOptions</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2" >
|
||||
<widget class="QLineEdit" name="encoderOptions" />
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" >
|
||||
<item row="2" column="0" >
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
<width>226</width>
|
||||
<height>51</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ void InstallTalkWindow::accept()
|
|||
|
||||
userSettings->sync();
|
||||
|
||||
talkcreator->setUserSettings(userSettings);
|
||||
talkcreator->setDir(QDir(folderToTalk));
|
||||
talkcreator->setMountPoint(userSettings->value("mountpoint").toString());
|
||||
talkcreator->setTTSexe(pathTTS);
|
||||
|
|
@ -121,11 +122,6 @@ void InstallTalkWindow::accept()
|
|||
talkcreator->setTTsLanguage(ttsLanguage);
|
||||
talkcreator->setTTsType(ttsType);
|
||||
talkcreator->setTTsTemplate(ttsTemplate);
|
||||
|
||||
talkcreator->setEncexe(pathEncoder);
|
||||
talkcreator->setEncOpts(encOpts);
|
||||
talkcreator->setEncTemplate(encTemplate);
|
||||
talkcreator->setEncType(encType);
|
||||
|
||||
talkcreator->setOverwriteTalk(ui.OverwriteTalk->isChecked());
|
||||
talkcreator->setOverwriteWav(ui.OverwriteWav->isChecked());
|
||||
|
|
@ -152,17 +148,16 @@ void InstallTalkWindow::setDeviceSettings(QSettings *dev)
|
|||
.arg(devices->value(profile, tr("Invalid TTS profile!")).toString()));
|
||||
qDebug() << profile;
|
||||
devices->endGroup();
|
||||
profile = userSettings->value("encpreset", "none").toString();
|
||||
devices->beginGroup("encoders");
|
||||
ui.labelEncProfile->setText(tr("Encoder Profile: <b>%1</b>")
|
||||
.arg(devices->value(profile, tr("Invalid encoder profile!")).toString()));
|
||||
qDebug() << profile;
|
||||
devices->endGroup();
|
||||
|
||||
QString encoder = userSettings->value("encoder", "none").toString();
|
||||
EncBase* enc = getEncoder(encoder);
|
||||
enc->setUserCfg(userSettings);
|
||||
if(enc->configOk())
|
||||
ui.labelEncProfile->setText(tr("Selected Encoder: <b>%1</b>").arg(encoder));
|
||||
else
|
||||
ui.labelEncProfile->setText(tr("Selected Encoder: <b>%1</b>").arg("Invalid encoder configuration!"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void InstallTalkWindow::setUserSettings(QSettings *user)
|
||||
{
|
||||
userSettings = user;
|
||||
|
|
|
|||
154
rbutil/rbutilqt/rbspeexcfgfrm.ui
Normal file
154
rbutil/rbutilqt/rbspeexcfgfrm.ui
Normal file
|
|
@ -0,0 +1,154 @@
|
|||
<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="QLabel" name="labelTitle" >
|
||||
<property name="text" >
|
||||
<string>Configure RbSpeex Encoder</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QDoubleSpinBox" name="volume" >
|
||||
<property name="value" >
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<widget class="QLabel" name="label_2" >
|
||||
<property name="text" >
|
||||
<string>Volume</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2" colspan="2" >
|
||||
<widget class="QCheckBox" name="narrowband" >
|
||||
<property name="text" >
|
||||
<string>Narrowband</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" >
|
||||
<widget class="QDoubleSpinBox" name="quality" >
|
||||
<property name="singleStep" >
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<property name="value" >
|
||||
<double>8.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" >
|
||||
<widget class="QLabel" name="label" >
|
||||
<property name="text" >
|
||||
<string>Quality</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" >
|
||||
<widget class="QSpinBox" name="complexity" >
|
||||
<property name="value" >
|
||||
<number>3</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" >
|
||||
<widget class="QLabel" name="label_3" >
|
||||
<property name="text" >
|
||||
<string>Complexity</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" 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="4" column="2" >
|
||||
<widget class="QPushButton" name="buttonOk" >
|
||||
<property name="text" >
|
||||
<string>&Ok</string>
|
||||
</property>
|
||||
<property name="icon" >
|
||||
<iconset resource="rbutilqt.qrc" >:/icons/icons/go-next.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="3" >
|
||||
<widget class="QPushButton" name="buttonCancel" >
|
||||
<property name="text" >
|
||||
<string>&Cancel</string>
|
||||
</property>
|
||||
<property name="icon" >
|
||||
<iconset resource="rbutilqt.qrc" >:/icons/icons/process-stop.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" >
|
||||
<widget class="QPushButton" name="reset" >
|
||||
<property name="text" >
|
||||
<string>Reset</string>
|
||||
</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>
|
||||
|
|
@ -378,36 +378,6 @@ resolution=132x80x16
|
|||
manualname=
|
||||
brand=Sandisk
|
||||
|
||||
[encoders]
|
||||
encpreset01 = "Lame (default)"
|
||||
encpreset02 = "Lame (user-adjusted)"
|
||||
encpreset03 = "RbSpeex (default)"
|
||||
encpreset04 = "RbSpeex (user-adjusted)"
|
||||
|
||||
[encpreset01]
|
||||
encoder = lame
|
||||
options = ""
|
||||
template = "\"%exe\" %options \"%input\" \"%output\""
|
||||
edit = false
|
||||
|
||||
[encpreset02]
|
||||
encoder = lame
|
||||
options = ""
|
||||
template = "\"%exe\" %options \"%input\" \"%output\""
|
||||
edit = true
|
||||
|
||||
[encpreset03]
|
||||
encoder = rbspeex
|
||||
options = ""
|
||||
template = "\"%exe\" %options \"%input\" \"%output\""
|
||||
edit = false
|
||||
|
||||
[encpreset04]
|
||||
encoder = rbspeex
|
||||
options = ""
|
||||
template = "\"%exe\" %options \"%input\" \"%output\""
|
||||
edit = true
|
||||
|
||||
[tts]
|
||||
ttspreset01 = "espeak (default)"
|
||||
ttspreset02 = "espeak (user-adjusted)"
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
#include "installthemes.h"
|
||||
#include "uninstallwindow.h"
|
||||
#include "browseof.h"
|
||||
#include "encoders.h"
|
||||
|
||||
#if defined(Q_OS_LINUX)
|
||||
#include <stdio.h>
|
||||
|
|
@ -119,6 +120,7 @@ RbUtilQt::RbUtilQt(QWidget *parent) : QMainWindow(parent)
|
|||
initIpodpatcher();
|
||||
initSansapatcher();
|
||||
downloadInfo();
|
||||
initEncoderList();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,8 @@ SOURCES += rbutilqt.cpp \
|
|||
uninstallwindow.cpp \
|
||||
utils.cpp \
|
||||
browseof.cpp \
|
||||
preview.cpp
|
||||
preview.cpp \
|
||||
encoders.cpp
|
||||
|
||||
HEADERS += rbutilqt.h \
|
||||
install.h \
|
||||
|
|
@ -71,11 +72,14 @@ HEADERS += rbutilqt.h \
|
|||
uninstallwindow.h \
|
||||
utils.h \
|
||||
browseof.h \
|
||||
preview.h
|
||||
preview.h \
|
||||
encoders.h
|
||||
|
||||
# Needed by QT on Win
|
||||
INCLUDEPATH = . irivertools zip zlib ../ipodpatcher ../sansapatcher
|
||||
INCLUDEPATH = . irivertools zip zlib ../ipodpatcher ../sansapatcher ../../tools/rbspeex
|
||||
|
||||
LIBS += -L../../tools/rbspeex -lrbspeex
|
||||
|
||||
TEMPLATE = app
|
||||
dbg {
|
||||
CONFIG += debug thread qt warn_on
|
||||
|
|
@ -100,7 +104,9 @@ FORMS += rbutilqtfrm.ui \
|
|||
installthemesfrm.ui \
|
||||
uninstallfrm.ui \
|
||||
browseoffrm.ui \
|
||||
previewfrm.ui
|
||||
previewfrm.ui \
|
||||
rbspeexcfgfrm.ui \
|
||||
encexescfgfrm.ui
|
||||
|
||||
RESOURCES += rbutilqt.qrc
|
||||
|
||||
|
|
|
|||
|
|
@ -24,21 +24,6 @@ TalkFileCreator::TalkFileCreator(QObject* parent): QObject(parent)
|
|||
|
||||
}
|
||||
|
||||
|
||||
bool TalkFileCreator::initEncoder()
|
||||
{
|
||||
QFileInfo enc(m_EncExec);
|
||||
if(enc.exists())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
|
||||
{
|
||||
m_abort = false;
|
||||
|
|
@ -60,12 +45,18 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
|
|||
m_logger->addItem("Init of TTS engine failed",LOGERROR);
|
||||
return false;
|
||||
}
|
||||
if(!initEncoder())
|
||||
|
||||
// Encoder
|
||||
m_enc = getEncoder(userSettings->value("encoder").toString());
|
||||
m_enc->setUserCfg(userSettings);
|
||||
|
||||
if(!m_enc->start())
|
||||
{
|
||||
m_logger->addItem("Init of encoder failed",LOGERROR);
|
||||
m_logger->addItem("Init of Encoder engine failed",LOGERROR);
|
||||
m_tts->stop();
|
||||
return false;
|
||||
}
|
||||
|
||||
QApplication::processEvents();
|
||||
|
||||
connect(logger,SIGNAL(aborted()),this,SLOT(abort()));
|
||||
|
|
@ -88,13 +79,16 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
|
|||
QString toSpeak;
|
||||
QString filename;
|
||||
QString wavfilename;
|
||||
|
||||
//! skip dotdot and .talk files
|
||||
if(fileInf.fileName() == ".." || fileInf.suffix() == "talk")
|
||||
|
||||
QString path = fileInf.filePath();
|
||||
qDebug() << path;
|
||||
|
||||
if( path.endsWith("..") || path.endsWith(".talk") )
|
||||
{
|
||||
it.next();
|
||||
continue;
|
||||
}
|
||||
|
||||
//! if it is a dir
|
||||
if(fileInf.isDir())
|
||||
{
|
||||
|
|
@ -103,9 +97,14 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
|
|||
{
|
||||
it.next();
|
||||
continue;
|
||||
}
|
||||
toSpeak = fileInf.absoluteDir().dirName();
|
||||
filename = fileInf.absolutePath() + "/_dirname.talk";
|
||||
}
|
||||
int index1 = path.lastIndexOf("/");
|
||||
int index2 = path.lastIndexOf("/",index1-1);
|
||||
|
||||
toSpeak = path.mid(index2+1,(index1-index2)-1);
|
||||
|
||||
filename = path.left(index1) + "/_dirname.talk";
|
||||
qDebug() << "toSpeak: " << toSpeak << "filename: " << filename;
|
||||
}
|
||||
else // if it is a file
|
||||
{
|
||||
|
|
@ -137,15 +136,17 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
|
|||
m_logger->addItem("Voicing of " + toSpeak + " failed",LOGERROR);
|
||||
m_logger->abort();
|
||||
m_tts->stop();
|
||||
m_enc->stop();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
m_logger->addItem("Encoding of " + toSpeak,LOGINFO);
|
||||
if(!encode(wavfilename,filename))
|
||||
if(!m_enc->encode(wavfilename,filename))
|
||||
{
|
||||
m_logger->addItem("Encoding of " + wavfilename + " failed",LOGERROR);
|
||||
m_logger->abort();
|
||||
m_tts->stop();
|
||||
m_enc->stop();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -182,21 +183,6 @@ void TalkFileCreator::abort()
|
|||
m_abort = true;
|
||||
}
|
||||
|
||||
bool TalkFileCreator::encode(QString input,QString output)
|
||||
{
|
||||
qDebug() << "encoding..";
|
||||
QString execstring = m_curEncTemplate;
|
||||
|
||||
execstring.replace("%exe",m_EncExec);
|
||||
execstring.replace("%options",m_EncOpts);
|
||||
execstring.replace("%input",input);
|
||||
execstring.replace("%output",output);
|
||||
qDebug() << execstring;
|
||||
QProcess::execute(execstring);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
bool TTSSapi::start()
|
||||
{
|
||||
QFileInfo tts(m_TTSexec);
|
||||
|
|
@ -257,7 +243,7 @@ bool TTSExes::voice(QString text,QString wavfile)
|
|||
execstring.replace("%options",m_TTSOpts);
|
||||
execstring.replace("%wavfile",wavfile);
|
||||
execstring.replace("%text",text);
|
||||
qDebug() << "voicing" << execstring;
|
||||
//qDebug() << "voicing" << execstring;
|
||||
QProcess::execute(execstring);
|
||||
return true;
|
||||
|
||||
|
|
|
|||
|
|
@ -21,8 +21,12 @@
|
|||
#ifndef TALKFILE_H
|
||||
#define TALKFILE_H
|
||||
|
||||
#include <QtGui>
|
||||
#include "progressloggerinterface.h"
|
||||
|
||||
#include "encoders.h"
|
||||
|
||||
|
||||
class TTSBase : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
@ -55,18 +59,16 @@ public:
|
|||
|
||||
bool createTalkFiles(ProgressloggerInterface* logger);
|
||||
|
||||
void setUserSettings(QSettings* setting) { userSettings = setting;}
|
||||
|
||||
void setTTSexe(QString exe){m_TTSexec=exe;}
|
||||
void setEncexe(QString exe){m_EncExec=exe;}
|
||||
|
||||
|
||||
void setTTsType(QString tts) { m_curTTS = tts; }
|
||||
void setTTsOpts(QString opts) {m_TTSOpts=opts;}
|
||||
void setTTsLanguage(QString language) {m_TTSLanguage = language;}
|
||||
void setTTsTemplate(QString t) { m_curTTSTemplate = t; }
|
||||
|
||||
void setEncType(QString enc) { m_curEnc = enc; }
|
||||
void setEncOpts(QString opts) {m_EncOpts=opts;}
|
||||
void setEncTemplate(QString t) { m_curEncTemplate = t; }
|
||||
|
||||
|
||||
void setDir(QDir dir){m_dir = dir; }
|
||||
void setMountPoint(QString mountpoint) {m_mountpoint =mountpoint; }
|
||||
|
||||
|
|
@ -83,10 +85,9 @@ private slots:
|
|||
|
||||
private:
|
||||
TTSBase* m_tts;
|
||||
bool initEncoder();
|
||||
|
||||
bool encode(QString input,QString output);
|
||||
|
||||
EncBase* m_enc;
|
||||
QSettings *userSettings;
|
||||
|
||||
QDir m_dir;
|
||||
QString m_mountpoint;
|
||||
QString m_curTTS;
|
||||
|
|
@ -95,11 +96,6 @@ private:
|
|||
QString m_TTSLanguage;
|
||||
QString m_curTTSTemplate;
|
||||
|
||||
QString m_curEnc;
|
||||
QString m_EncExec;
|
||||
QString m_EncOpts;
|
||||
QString m_curEncTemplate;
|
||||
|
||||
bool m_overwriteTalk;
|
||||
bool m_overwriteWav;
|
||||
bool m_removeWav;
|
||||
|
|
@ -137,5 +133,7 @@ private:
|
|||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue