~neon/kmouth/master

1 by Gunnar Schmidt
Imported KMouth into kdeaccessibility
1
/***************************************************************************
486.1.3 by Jeremy Whiting
Updated copyright headers and add missing ones.
2
 *   Copyright (C) 2002 by Gunnar Schmi Dt <kmouth@schmi-dt.de             *
3
 *             (C) 2015 by Jeremy Whiting <jpwhiting@kde.org>              *
1 by Gunnar Schmidt
Imported KMouth into kdeaccessibility
4
 *                                                                         *
5
 *   This program is free software; you can redistribute it and/or modify  *
6
 *   it under the terms of the GNU General Public License as published by  *
7
 *   the Free Software Foundation; either version 2 of the License, or     *
8
 *   (at your option) any later version.                                   *
9
 *                                                                         *
486.1.3 by Jeremy Whiting
Updated copyright headers and add missing ones.
10
 *   This program is distributed in the hope that it will be useful,       *
11
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13
 *   GNU General Public License for more details.                          *
14
 *                                                                         *
15
 *   You should have received a copy of the GNU General Public License     *
16
 *   along with this program; if not, write to the                         *
17
 *   Free Software Foundation, Inc.,                                       *
18
 *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.          *
1 by Gunnar Schmidt
Imported KMouth into kdeaccessibility
19
 ***************************************************************************/
20
21
#ifndef SPEECH_H
22
#define SPEECH_H
23
487 by Jeremy Whiting
Initial port to kf5/qt5/QtSpeech.
24
#include <QObject>
25
#include <QProcess>
807 by Jeremy Whiting
Port KMouth from Qt5/KF5 to Qt6/KF6.
26
#include <QStringConverter>
497 by Jeremy Whiting
Port from KTemporaryFile to QTemporaryFile.
27
#include <QTemporaryFile>
1 by Gunnar Schmidt
Imported KMouth into kdeaccessibility
28
29
/**This class is used internally by TextToSpeechSystem in order to do the actual speaking.
804 by Nicolas Fella
Add and make use of ECM clang-format integration
30
 *@author Gunnar Schmi Dt
31
 */
1 by Gunnar Schmidt
Imported KMouth into kdeaccessibility
32
484.1.19 by Jeremy Whiting
Restyle with astyle as per kdelibs coding style.
33
class Speech : public QObject
34
{
35
    Q_OBJECT
1 by Gunnar Schmidt
Imported KMouth into kdeaccessibility
36
public:
804 by Nicolas Fella
Add and make use of ECM clang-format integration
37
    enum CharacterCodec { Local = 0, Latin1 = 1, Unicode = 2, UseCodec = 3 };
484.1.19 by Jeremy Whiting
Restyle with astyle as per kdelibs coding style.
38
39
    Speech();
654 by Laurent Montel
GIT_SILENT: add missing override keyword
40
    ~Speech() override;
484.1.19 by Jeremy Whiting
Restyle with astyle as per kdelibs coding style.
41
42
    /**
43
     * Speaks the given text.
44
     * @param command the program that shall be executed for speaking
45
     * @param stdin true if the program shall receive its data via standard input
46
     * @param text The text that shall be spoken
807 by Jeremy Whiting
Port KMouth from Qt5/KF5 to Qt6/KF6.
47
     * @param language the language to use when speaking
48
     * @param encoding the encoding to use to decode the text
484.1.19 by Jeremy Whiting
Restyle with astyle as per kdelibs coding style.
49
     */
807 by Jeremy Whiting
Port KMouth from Qt5/KF5 to Qt6/KF6.
50
    void speak(QString command, bool use_stdin, const QString &text, const QString &language, QStringConverter::Encoding encoding);
484.1.19 by Jeremy Whiting
Restyle with astyle as per kdelibs coding style.
51
52
    /**
53
     * Prepares a command for being executed. During the preparation the
54
     * command is parsed and occurrences of "%t" are replaced by text.
55
     * @param command the command that shall be executed for speaking
56
     * @param text the quoted text that can be inserted into the command
57
     */
804 by Nicolas Fella
Add and make use of ECM clang-format integration
58
    QString prepareCommand(const QString &command, const QString &text, const QString &filename, const QString &language);
1 by Gunnar Schmidt
Imported KMouth into kdeaccessibility
59
560 by Laurent Montel
Fix compile with KDEFrameworkCompilerSettings
60
public Q_SLOTS:
804 by Nicolas Fella
Add and make use of ECM clang-format integration
61
    // void wroteStdin(K3Process *p);
487 by Jeremy Whiting
Initial port to kf5/qt5/QtSpeech.
62
    void processExited(int exitCode, QProcess::ExitStatus exitStatus);
804 by Nicolas Fella
Add and make use of ECM clang-format integration
63
    // void receivedStdout(K3Process *proc, char *buffer, int buflen);
64
    // void receivedStderr(K3Process *proc, char *buffer, int buflen);
1 by Gunnar Schmidt
Imported KMouth into kdeaccessibility
65
66
private:
487 by Jeremy Whiting
Initial port to kf5/qt5/QtSpeech.
67
    QProcess m_process;
484.1.19 by Jeremy Whiting
Restyle with astyle as per kdelibs coding style.
68
    QByteArray encText;
497 by Jeremy Whiting
Port from KTemporaryFile to QTemporaryFile.
69
    QTemporaryFile tempFile;
1 by Gunnar Schmidt
Imported KMouth into kdeaccessibility
70
};
71
72
#endif