2008-01-11 23:59:12 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 by Dominik Wenger
|
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2008-01-11 23:59:12 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
2009-06-26 20:40:51 +00:00
|
|
|
#ifndef TALKGENERATOR_H
|
|
|
|
#define TALKGENERATOR_H
|
2008-01-11 23:59:12 +00:00
|
|
|
|
2008-02-10 18:25:49 +00:00
|
|
|
#include <QtCore>
|
2008-01-11 23:59:12 +00:00
|
|
|
#include "progressloggerinterface.h"
|
|
|
|
|
2012-01-06 19:19:32 +00:00
|
|
|
#include "encoderbase.h"
|
2009-10-13 19:54:27 +00:00
|
|
|
#include "ttsbase.h"
|
2008-01-11 23:59:12 +00:00
|
|
|
|
2009-06-26 20:40:51 +00:00
|
|
|
//! \brief Talk generator, generates .wav and .talk files out of a list.
|
|
|
|
class TalkGenerator :public QObject
|
2008-01-11 23:59:12 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2009-06-26 20:40:51 +00:00
|
|
|
enum Status
|
|
|
|
{
|
|
|
|
eOK,
|
|
|
|
eWARNING,
|
|
|
|
eERROR
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TalkEntry
|
|
|
|
{
|
|
|
|
QString toSpeak;
|
|
|
|
QString wavfilename;
|
|
|
|
QString talkfilename;
|
|
|
|
QString target;
|
|
|
|
bool voiced;
|
|
|
|
bool encoded;
|
2010-06-04 21:22:25 +00:00
|
|
|
|
|
|
|
/* We need the following members because
|
|
|
|
* 1) the QtConcurrent entry points are all static methods (and we
|
|
|
|
* need to communicate with the TalkGenerator)
|
|
|
|
* 2) we are not guaranteed to go through the list in any
|
|
|
|
* particular order, so we can't use the progress slot
|
|
|
|
* for error checking */
|
|
|
|
struct
|
|
|
|
{
|
2012-01-06 19:19:32 +00:00
|
|
|
EncoderBase* encoder;
|
2010-06-04 21:22:25 +00:00
|
|
|
TTSBase* tts;
|
2012-01-06 19:19:32 +00:00
|
|
|
TalkGenerator* generator;
|
2010-06-04 21:22:25 +00:00
|
|
|
int wavtrim;
|
|
|
|
} refs;
|
2009-06-26 20:40:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
TalkGenerator(QObject* parent);
|
|
|
|
Status process(QList<TalkEntry>* list,int wavtrimth = -1);
|
2011-10-01 19:48:58 +00:00
|
|
|
QString correctString(QString s);
|
2009-06-26 20:40:51 +00:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void abort();
|
2010-06-04 21:22:25 +00:00
|
|
|
void encProgress(int value);
|
|
|
|
void ttsProgress(int value);
|
2011-10-01 19:48:58 +00:00
|
|
|
void setLang(QString name);
|
2009-04-05 12:46:41 +00:00
|
|
|
|
2008-02-09 18:58:14 +00:00
|
|
|
signals:
|
2009-06-26 20:40:51 +00:00
|
|
|
void done(bool);
|
|
|
|
void logItem(QString, int); //! set logger item
|
|
|
|
void logProgress(int, int); //! set progress bar.
|
2009-04-05 12:46:41 +00:00
|
|
|
|
2008-01-11 23:59:12 +00:00
|
|
|
private:
|
2010-06-04 21:22:25 +00:00
|
|
|
QFutureWatcher<void> encFutureWatcher;
|
|
|
|
QFutureWatcher<void> ttsFutureWatcher;
|
|
|
|
void encFailEntry(const TalkEntry& entry);
|
|
|
|
void ttsFailEntry(const TalkEntry& entry, TTSStatus status, QString error);
|
|
|
|
|
2009-06-26 20:40:51 +00:00
|
|
|
Status voiceList(QList<TalkEntry>* list,int wavetrimth);
|
|
|
|
Status encodeList(QList<TalkEntry>* list);
|
2009-04-05 12:46:41 +00:00
|
|
|
|
2010-06-04 21:22:25 +00:00
|
|
|
static void encEntryPoint(TalkEntry& entry);
|
|
|
|
static void ttsEntryPoint(TalkEntry& entry);
|
|
|
|
|
2008-01-11 23:59:12 +00:00
|
|
|
TTSBase* m_tts;
|
2012-01-06 19:19:32 +00:00
|
|
|
EncoderBase* m_enc;
|
2008-01-11 23:59:12 +00:00
|
|
|
|
2010-06-04 21:22:25 +00:00
|
|
|
bool m_ttsWarnings;
|
2011-04-22 17:59:43 +00:00
|
|
|
bool m_userAborted;
|
2011-10-01 19:48:58 +00:00
|
|
|
QString m_lang;
|
|
|
|
|
|
|
|
struct CorrectionItems
|
|
|
|
{
|
|
|
|
QString search;
|
|
|
|
QString replace;
|
|
|
|
QString modifier;
|
|
|
|
};
|
|
|
|
QList<struct CorrectionItems> m_corrections;
|
2008-01-11 23:59:12 +00:00
|
|
|
};
|
2009-04-05 12:46:41 +00:00
|
|
|
|
2009-06-26 20:40:51 +00:00
|
|
|
|
2008-01-11 23:59:12 +00:00
|
|
|
#endif
|
2009-04-05 12:46:41 +00:00
|
|
|
|