Improve error handling and logging.

- Fix a warning
- Log an error if the file to encode cannot be read.
- Adjust some log strings.
This commit is contained in:
Dominik Riebeling 2012-01-11 20:18:26 +01:00
parent b17bdb9349
commit 42fa2a8d0f
3 changed files with 19 additions and 12 deletions

View file

@ -84,7 +84,7 @@ bool EncoderLame::start()
bool EncoderLame::encode(QString input,QString output) bool EncoderLame::encode(QString input,QString output)
{ {
qDebug() << "[EncoderLame] Encoding" << input; qDebug() << "[EncoderLame] Encoding" << QDir::cleanPath(input);
if(!m_symbolsResolved) { if(!m_symbolsResolved) {
qDebug() << "[EncoderLame] Symbols not successfully resolved, cannot run!"; qDebug() << "[EncoderLame] Symbols not successfully resolved, cannot run!";
return false; return false;
@ -113,11 +113,14 @@ bool EncoderLame::encode(QString input,QString output)
m_lame_set_scale(gfp, 1.0); // scale input volume m_lame_set_scale(gfp, 1.0); // scale input volume
m_lame_set_mode(gfp, MONO); // mono output mode m_lame_set_mode(gfp, MONO); // mono output mode
m_lame_set_VBR(gfp, vbr_default); // enable default VBR mode m_lame_set_VBR(gfp, vbr_default); // enable default VBR mode
m_lame_set_VBR_quality(gfp, 9.999); // VBR quality m_lame_set_VBR_quality(gfp, 9.999f); // VBR quality
m_lame_set_VBR_max_bitrate_kbps(gfp, 64); // maximum bitrate 64kbps m_lame_set_VBR_max_bitrate_kbps(gfp, 64); // maximum bitrate 64kbps
m_lame_set_bWriteVbrTag(gfp, 0); // disable LAME tag. m_lame_set_bWriteVbrTag(gfp, 0); // disable LAME tag.
fin.open(QIODevice::ReadOnly); if(!fin.open(QIODevice::ReadOnly)) {
qDebug() << "[EncoderLame] Could not open input file" << input;
return false;
}
// read RIFF header // read RIFF header
fin.read((char*)header, 12); fin.read((char*)header, 12);

View file

@ -286,7 +286,8 @@ void TalkGenerator::encProgress(int value)
void TalkGenerator::encFailEntry(const TalkEntry& entry) void TalkGenerator::encFailEntry(const TalkEntry& entry)
{ {
emit logItem(tr("Encoding of %1 failed").arg(entry.wavfilename), LOGERROR); emit logItem(tr("Encoding of %1 failed").arg(
QFileInfo(entry.wavfilename).baseName()), LOGERROR);
abort(); abort();
} }

View file

@ -103,7 +103,7 @@ bool TTSSapi::start(QString *errStr)
QFileInfo tts(m_TTSexec); QFileInfo tts(m_TTSexec);
if(!tts.exists()) if(!tts.exists())
{ {
*errStr = tr("Could not copy the Sapi-script"); *errStr = tr("Could not copy the SAPI script");
return false; return false;
} }
// create the voice process // create the voice process
@ -117,14 +117,15 @@ bool TTSSapi::start(QString *errStr)
if(m_sapi4) if(m_sapi4)
execstring.append(" /sapi4 "); execstring.append(" /sapi4 ");
qDebug() << "init" << execstring; qDebug() << "[TTSSapi] Start:" << execstring;
voicescript = new QProcess(NULL); voicescript = new QProcess(NULL);
//connect(voicescript,SIGNAL(readyReadStandardError()),this,SLOT(error())); //connect(voicescript,SIGNAL(readyReadStandardError()),this,SLOT(error()));
voicescript->start(execstring); voicescript->start(execstring);
qDebug() << "[TTSSapi] wait for process";
if(!voicescript->waitForStarted()) if(!voicescript->waitForStarted())
{ {
*errStr = tr("Could not start the Sapi-script"); *errStr = tr("Could not start SAPI process");
qDebug() << "[TTSSapi] starting process timed out!";
return false; return false;
} }
@ -181,12 +182,14 @@ QStringList TTSSapi::getVoiceList(QString language)
if(RbSettings::value(RbSettings::TtsUseSapi4).toBool()) if(RbSettings::value(RbSettings::TtsUseSapi4).toBool())
execstring.append(" /sapi4 "); execstring.append(" /sapi4 ");
qDebug() << "init" << execstring; qDebug() << "[TTSSapi] Start:" << execstring;
voicescript = new QProcess(NULL); voicescript = new QProcess(NULL);
voicescript->start(execstring); voicescript->start(execstring);
qDebug() << "wait for started"; qDebug() << "[TTSSapi] wait for process";
if(!voicescript->waitForStarted()) if(!voicescript->waitForStarted()) {
qDebug() << "[TTSSapi] process startup timed out!";
return result; return result;
}
voicescript->closeWriteChannel(); voicescript->closeWriteChannel();
voicescript->waitForReadyRead(); voicescript->waitForReadyRead();