2007-12-15 13:13:57 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 by Dominik Wenger
|
2008-06-30 22:09:45 +00:00
|
|
|
* $Id$
|
2007-12-15 13:13:57 +00:00
|
|
|
*
|
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.
|
2007-12-15 13:13:57 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2009-04-29 21:27:01 +00:00
|
|
|
|
2007-12-15 13:13:57 +00:00
|
|
|
#ifndef TTS_H
|
|
|
|
#define TTS_H
|
|
|
|
|
2008-02-10 18:25:49 +00:00
|
|
|
#include <QtCore>
|
2009-03-27 19:18:14 +00:00
|
|
|
#include <QProcess>
|
|
|
|
#include <QDateTime>
|
|
|
|
#include <QRegExp>
|
|
|
|
#include <QTcpSocket>
|
2007-12-15 13:13:57 +00:00
|
|
|
|
2009-04-29 21:27:01 +00:00
|
|
|
#include "encttssettings.h"
|
2007-12-15 13:13:57 +00:00
|
|
|
|
2009-03-27 19:18:14 +00:00
|
|
|
enum TTSStatus{ FatalError, NoError, Warning };
|
2009-04-29 21:27:01 +00:00
|
|
|
|
|
|
|
class TTSBase : public EncTtsSettingInterface
|
2007-12-15 13:13:57 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2008-02-12 21:45:50 +00:00
|
|
|
public:
|
2009-04-29 21:27:01 +00:00
|
|
|
TTSBase(QObject *parent);
|
|
|
|
//! Child class should generate a clip
|
|
|
|
virtual TTSStatus voice(QString text,QString wavfile, QString* errStr) =0;
|
|
|
|
//! Child class should do startup
|
|
|
|
virtual bool start(QString *errStr) =0;
|
|
|
|
//! child class should stop
|
|
|
|
virtual bool stop() =0;
|
|
|
|
|
|
|
|
// configuration
|
|
|
|
//! Child class should return true, when configuration is good
|
|
|
|
virtual bool configOk()=0;
|
|
|
|
//! Child class should generate and insertSetting(..) its settings
|
|
|
|
virtual void generateSettings() = 0;
|
|
|
|
//! Chlid class should commit the Settings to permanent storage
|
|
|
|
virtual void saveSettings() = 0;
|
|
|
|
|
|
|
|
// static functions
|
|
|
|
static TTSBase* getTTS(QObject* parent,QString ttsname);
|
2008-02-12 21:45:50 +00:00
|
|
|
static QStringList getTTSList();
|
2009-04-29 21:27:01 +00:00
|
|
|
static QString getTTSName(QString tts);
|
2009-05-09 16:59:14 +00:00
|
|
|
|
2008-02-12 21:45:50 +00:00
|
|
|
private:
|
|
|
|
//inits the tts List
|
|
|
|
static void initTTSList();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
static QMap<QString,QString> ttsList;
|
2007-12-15 13:13:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class TTSSapi : public TTSBase
|
|
|
|
{
|
2009-04-29 21:27:01 +00:00
|
|
|
//! Enum to identify the settings
|
|
|
|
enum ESettings
|
|
|
|
{
|
|
|
|
eLANGUAGE,
|
|
|
|
eVOICE,
|
|
|
|
eSPEED,
|
|
|
|
eOPTIONS
|
|
|
|
};
|
|
|
|
|
|
|
|
Q_OBJECT
|
2008-02-12 21:45:50 +00:00
|
|
|
public:
|
2009-04-29 21:27:01 +00:00
|
|
|
TTSSapi(QObject* parent=NULL);
|
|
|
|
|
|
|
|
TTSStatus voice(QString text,QString wavfile, QString *errStr);
|
|
|
|
bool start(QString *errStr);
|
|
|
|
bool stop();
|
|
|
|
|
|
|
|
// for settings
|
|
|
|
bool configOk();
|
|
|
|
void generateSettings();
|
|
|
|
void saveSettings();
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void updateVoiceList();
|
|
|
|
|
|
|
|
private:
|
2008-02-12 21:45:50 +00:00
|
|
|
QStringList getVoiceList(QString language);
|
2009-04-29 21:27:01 +00:00
|
|
|
|
2008-02-12 21:45:50 +00:00
|
|
|
QProcess* voicescript;
|
2008-09-27 00:05:54 +00:00
|
|
|
QTextStream* voicestream;
|
2008-02-12 21:45:50 +00:00
|
|
|
QString defaultLanguage;
|
2009-04-29 21:27:01 +00:00
|
|
|
|
2008-02-12 21:45:50 +00:00
|
|
|
QString m_TTSexec;
|
|
|
|
QString m_TTSOpts;
|
|
|
|
QString m_TTSTemplate;
|
|
|
|
QString m_TTSLanguage;
|
|
|
|
QString m_TTSVoice;
|
|
|
|
QString m_TTSSpeed;
|
|
|
|
bool m_sapi4;
|
2007-12-15 13:13:57 +00:00
|
|
|
};
|
|
|
|
|
2008-02-12 21:45:50 +00:00
|
|
|
|
2007-12-15 13:13:57 +00:00
|
|
|
class TTSExes : public TTSBase
|
|
|
|
{
|
2009-04-29 21:27:01 +00:00
|
|
|
enum ESettings
|
|
|
|
{
|
|
|
|
eEXEPATH,
|
|
|
|
eOPTIONS
|
|
|
|
};
|
|
|
|
|
2008-02-12 21:45:50 +00:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2009-04-29 21:27:01 +00:00
|
|
|
TTSExes(QString name,QObject* parent=NULL);
|
|
|
|
TTSStatus voice(QString text,QString wavfile, QString *errStr);
|
|
|
|
bool start(QString *errStr);
|
|
|
|
bool stop() {return true;}
|
|
|
|
|
|
|
|
// for settings
|
|
|
|
void generateSettings();
|
|
|
|
void saveSettings();
|
|
|
|
bool configOk();
|
2009-04-05 12:46:41 +00:00
|
|
|
|
2008-02-12 21:45:50 +00:00
|
|
|
private:
|
|
|
|
QString m_name;
|
|
|
|
QString m_TTSexec;
|
|
|
|
QString m_TTSOpts;
|
|
|
|
QString m_TTSTemplate;
|
|
|
|
QMap<QString,QString> m_TemplateMap;
|
2007-12-15 13:13:57 +00:00
|
|
|
};
|
|
|
|
|
2009-03-27 19:18:14 +00:00
|
|
|
class TTSFestival : public TTSBase
|
|
|
|
{
|
2009-04-29 21:27:01 +00:00
|
|
|
enum ESettings
|
|
|
|
{
|
|
|
|
eSERVERPATH,
|
|
|
|
eCLIENTPATH,
|
|
|
|
eVOICE,
|
|
|
|
eVOICEDESC
|
|
|
|
};
|
|
|
|
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
TTSFestival(QObject* parent=NULL) :TTSBase(parent) {}
|
|
|
|
~TTSFestival();
|
|
|
|
bool start(QString *errStr);
|
|
|
|
bool stop();
|
|
|
|
TTSStatus voice(QString text,QString wavfile, QString *errStr);
|
|
|
|
|
|
|
|
// for settings
|
|
|
|
bool configOk();
|
|
|
|
void generateSettings();
|
|
|
|
void saveSettings();
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void updateVoiceList();
|
|
|
|
void updateVoiceDescription();
|
|
|
|
void clearVoiceDescription();
|
|
|
|
private:
|
|
|
|
QStringList getVoiceList(QString path ="");
|
|
|
|
QString getVoiceInfo(QString voice,QString path ="");
|
|
|
|
|
|
|
|
inline void startServer(QString path="");
|
|
|
|
inline void ensureServerRunning(QString path="");
|
|
|
|
QString queryServer(QString query, int timeout = -1,QString path="");
|
|
|
|
QProcess serverProcess;
|
|
|
|
QStringList voices;
|
|
|
|
QMap<QString, QString> voiceDescriptions;
|
2009-03-27 19:18:14 +00:00
|
|
|
};
|
|
|
|
|
2007-12-15 13:13:57 +00:00
|
|
|
#endif
|