1 | /*************************************************************************** |
2 | speech.h - description |
3 | ------------------- |
4 | begin : Son Sep 8 2002 |
5 | copyright : (C) 2002 by Gunnar Schmi Dt |
6 | email : kmouth@schmi-dt.de |
7 | ***************************************************************************/ |
8 | |
9 | /*************************************************************************** |
10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation; either version 2 of the License, or * |
14 | * (at your option) any later version. * |
15 | * * |
16 | ***************************************************************************/ |
17 | |
18 | #ifndef SPEECH_H |
19 | #define SPEECH_H |
20 | |
21 | #include <QtCore/QObject> |
22 | |
23 | #include <k3process.h> |
24 | #include <ktemporaryfile.h> |
25 | |
26 | /**This class is used internally by TextToSpeechSystem in order to do the actual speaking. |
27 | *@author Gunnar Schmi Dt |
28 | */ |
29 | |
30 | class Speech : public QObject { |
31 | Q_OBJECT |
32 | public: |
33 | enum CharacterCodec { |
34 | Local = 0, |
35 | Latin1 = 1, |
36 | Unicode = 2, |
37 | UseCodec = 3 |
38 | }; |
39 | |
40 | Speech(); |
41 | ~Speech(); |
42 | |
43 | /** |
44 | * Speaks the given text. |
45 | * @param command the program that shall be executed for speaking |
46 | * @param stdin true if the program shall receive its data via standard input |
47 | * @param text The text that shall be spoken |
48 | */ |
49 | void speak(QString command, bool use_stdin, const QString &text, const QString &language, int encoding, QTextCodec *codec); |
50 | |
51 | /** |
52 | * Prepares a command for being executed. During the preparation the |
53 | * command is parsed and occurrences of "%t" are replaced by text. |
54 | * @param command the command that shall be executed for speaking |
55 | * @param text the quoted text that can be inserted into the command |
56 | */ |
57 | QString prepareCommand (QString command, const QString &text, |
58 | const QString &filename, const QString &language); |
59 | |
60 | public slots: |
61 | void wroteStdin (K3Process *p); |
62 | void processExited (K3Process *p); |
63 | void receivedStdout (K3Process *proc, char *buffer, int buflen); |
64 | void receivedStderr (K3Process *proc, char *buffer, int buflen); |
65 | |
66 | private: |
67 | K3ShellProcess process; |
68 | QByteArray encText; |
69 | KTemporaryFile tempFile; |
70 | }; |
71 | |
72 | #endif |
73 | |