diff options
Diffstat (limited to 'rbutil/rbutilqt/talkfile.cpp')
-rw-r--r-- | rbutil/rbutilqt/talkfile.cpp | 55 |
1 files changed, 39 insertions, 16 deletions
diff --git a/rbutil/rbutilqt/talkfile.cpp b/rbutil/rbutilqt/talkfile.cpp index 7980e7cbd0..43993be436 100644 --- a/rbutil/rbutilqt/talkfile.cpp +++ b/rbutil/rbutilqt/talkfile.cpp | |||
@@ -34,7 +34,7 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger) | |||
34 | 34 | ||
35 | QMultiMap<QString,QString> fileList; | 35 | QMultiMap<QString,QString> fileList; |
36 | QMultiMap<QString,QString> dirList; | 36 | QMultiMap<QString,QString> dirList; |
37 | QStringList toSpeakList; | 37 | QStringList toSpeakList, voicedEntries, encodedEntries; |
38 | QString errStr; | 38 | QString errStr; |
39 | 39 | ||
40 | m_logger->addItem(tr("Starting Talk file generation"),LOGINFO); | 40 | m_logger->addItem(tr("Starting Talk file generation"),LOGINFO); |
@@ -103,20 +103,19 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger) | |||
103 | } | 103 | } |
104 | } | 104 | } |
105 | 105 | ||
106 | // Voice entryies | 106 | // Voice entries |
107 | m_logger->addItem(tr("Voicing entries..."),LOGINFO); | 107 | m_logger->addItem(tr("Voicing entries..."),LOGINFO); |
108 | if(voiceList(toSpeakList,&errStr) == false) | 108 | TTSStatus voiceStatus= voiceList(toSpeakList,voicedEntries); |
109 | if(voiceStatus == FatalError) | ||
109 | { | 110 | { |
110 | m_logger->addItem(errStr,LOGERROR); | ||
111 | doAbort(toSpeakList); | 111 | doAbort(toSpeakList); |
112 | return false; | 112 | return false; |
113 | } | 113 | } |
114 | 114 | ||
115 | // Encoding Entries | 115 | // Encoding Entries |
116 | m_logger->addItem(tr("Encoding files..."),LOGINFO); | 116 | m_logger->addItem(tr("Encoding files..."),LOGINFO); |
117 | if(encodeList(toSpeakList,&errStr) == false) | 117 | if(encodeList(voicedEntries,encodedEntries) == false) |
118 | { | 118 | { |
119 | m_logger->addItem(errStr,LOGERROR); | ||
120 | doAbort(toSpeakList); | 119 | doAbort(toSpeakList); |
121 | return false; | 120 | return false; |
122 | } | 121 | } |
@@ -247,29 +246,45 @@ bool TalkFileCreator::createDirAndFileMaps(QDir startDir,QMultiMap<QString,QStri | |||
247 | //! \param toSpeak QStringList with the Entries to voice. | 246 | //! \param toSpeak QStringList with the Entries to voice. |
248 | //! \param errString pointer to where the Error cause is written | 247 | //! \param errString pointer to where the Error cause is written |
249 | //! \returns true on success, false on error or user abort | 248 | //! \returns true on success, false on error or user abort |
250 | bool TalkFileCreator::voiceList(QStringList toSpeak,QString* errString) | 249 | TTSStatus TalkFileCreator::voiceList(QStringList toSpeak,QStringList& voicedEntries) |
251 | { | 250 | { |
252 | resetProgress(toSpeak.size()); | 251 | resetProgress(toSpeak.size()); |
252 | QStringList errors; | ||
253 | 253 | ||
254 | bool warnings = false; | ||
254 | for(int i=0; i < toSpeak.size(); i++) | 255 | for(int i=0; i < toSpeak.size(); i++) |
255 | { | 256 | { |
256 | if(m_abort) | 257 | if(m_abort) |
257 | { | 258 | { |
258 | *errString = tr("Talk file creation aborted"); | 259 | m_logger->addItem(tr("Talk file creation aborted"), LOGERROR); |
259 | return false; | 260 | return FatalError; |
260 | } | 261 | } |
261 | 262 | ||
262 | QString filename = QDir::tempPath()+ "/"+ toSpeak[i] + ".wav"; | 263 | QString filename = QDir::tempPath()+ "/"+ toSpeak[i] + ".wav"; |
263 | 264 | ||
264 | if(!m_tts->voice(toSpeak[i],filename)) | 265 | QString error; |
266 | TTSStatus status = m_tts->voice(toSpeak[i],filename, &error); | ||
267 | if(status == Warning) | ||
265 | { | 268 | { |
266 | *errString =tr("Voicing of %s failed").arg(toSpeak[i]); | 269 | warnings = true; |
267 | return false; | 270 | m_logger->addItem(tr("Voicing of %1 failed: %2").arg(toSpeak[i]).arg(error), |
271 | LOGWARNING); | ||
272 | } | ||
273 | else if (status == FatalError) | ||
274 | { | ||
275 | m_logger->addItem(tr("Voicing of %1 failed: %2").arg(toSpeak[i]).arg(error), | ||
276 | LOGERROR); | ||
277 | return FatalError; | ||
268 | } | 278 | } |
279 | else | ||
280 | voicedEntries.append(toSpeak[i]); | ||
269 | m_logger->setProgressValue(++m_progress); | 281 | m_logger->setProgressValue(++m_progress); |
270 | QCoreApplication::processEvents(); | 282 | QCoreApplication::processEvents(); |
271 | } | 283 | } |
272 | return true; | 284 | if(warnings) |
285 | return Warning; | ||
286 | else | ||
287 | return NoError; | ||
273 | } | 288 | } |
274 | 289 | ||
275 | 290 | ||
@@ -279,14 +294,14 @@ bool TalkFileCreator::voiceList(QStringList toSpeak,QString* errString) | |||
279 | //! \param toSpeak QStringList with the Entries to encode. | 294 | //! \param toSpeak QStringList with the Entries to encode. |
280 | //! \param errString pointer to where the Error cause is written | 295 | //! \param errString pointer to where the Error cause is written |
281 | //! \returns true on success, false on error or user abort | 296 | //! \returns true on success, false on error or user abort |
282 | bool TalkFileCreator::encodeList(QStringList toEncode,QString* errString) | 297 | bool TalkFileCreator::encodeList(QStringList toEncode,QStringList& encodedEntries) |
283 | { | 298 | { |
284 | resetProgress(toEncode.size()); | 299 | resetProgress(toEncode.size()); |
285 | for(int i=0; i < toEncode.size(); i++) | 300 | for(int i=0; i < toEncode.size(); i++) |
286 | { | 301 | { |
287 | if(m_abort) | 302 | if(m_abort) |
288 | { | 303 | { |
289 | *errString = tr("Talk file creation aborted"); | 304 | m_logger->addItem(tr("Talk file creation aborted"), LOGERROR); |
290 | return false; | 305 | return false; |
291 | } | 306 | } |
292 | 307 | ||
@@ -295,9 +310,10 @@ bool TalkFileCreator::encodeList(QStringList toEncode,QString* errString) | |||
295 | 310 | ||
296 | if(!m_enc->encode(wavfilename,filename)) | 311 | if(!m_enc->encode(wavfilename,filename)) |
297 | { | 312 | { |
298 | *errString =tr("Encoding of %1 failed").arg(filename); | 313 | m_logger->addItem(tr("Encoding of %1 failed").arg(filename), LOGERROR); |
299 | return false; | 314 | return false; |
300 | } | 315 | } |
316 | encodedEntries.append(toEncode[i]); | ||
301 | m_logger->setProgressValue(++m_progress); | 317 | m_logger->setProgressValue(++m_progress); |
302 | QCoreApplication::processEvents(); | 318 | QCoreApplication::processEvents(); |
303 | } | 319 | } |
@@ -327,6 +343,10 @@ bool TalkFileCreator::copyTalkDirFiles(QMultiMap<QString,QString> dirMap,QString | |||
327 | } | 343 | } |
328 | 344 | ||
329 | QString source = QDir::tempPath()+ "/"+ it.value() + ".talk"; | 345 | QString source = QDir::tempPath()+ "/"+ it.value() + ".talk"; |
346 | |||
347 | if(!QFileInfo(source).exists()) | ||
348 | continue; // this file was skipped in one of the previous steps | ||
349 | |||
330 | QString target = it.key() + "/" + "_dirname.talk"; | 350 | QString target = it.key() + "/" + "_dirname.talk"; |
331 | 351 | ||
332 | // remove target if it exists, and if we should overwrite it | 352 | // remove target if it exists, and if we should overwrite it |
@@ -383,6 +403,9 @@ bool TalkFileCreator::copyTalkFileFiles(QMultiMap<QString,QString> fileMap,QStri | |||
383 | else | 403 | else |
384 | source = QDir::tempPath()+ "/"+ it.value() + ".talk"; | 404 | source = QDir::tempPath()+ "/"+ it.value() + ".talk"; |
385 | 405 | ||
406 | if(!QFileInfo(source).exists()) | ||
407 | continue; // this file was skipped in one of the previous steps | ||
408 | |||
386 | // remove target if it exists, and if we should overwrite it | 409 | // remove target if it exists, and if we should overwrite it |
387 | if(m_overwriteTalk && QFile::exists(target)) | 410 | if(m_overwriteTalk && QFile::exists(target)) |
388 | QFile::remove(target); | 411 | QFile::remove(target); |