SVN_SILENT made messages (.desktop file)
[kdeaccessibility.git] / kttsd / plugins / freetts / freettsproc.h
blob53dcf7b1a78bd6f3bc738d1f2560b9ca10b5dc3e
1 /******************************************************************************
2 Main speaking functions for the FreeTTS Plug in
3 -------------------
4 Copyright : (C) 2004 Paul Giannaros
5 -------------------
6 Original author: Paul Giannaros <ceruleanblaze@gmail.com>
7 Current Maintainer: Paul Giannaros <ceruleanblaze@gmail.com>
8 ******************************************************************************/
10 /*******************************************************************************
11 * *
12 * This program is free software; you can redistribute it and/or modify *
13 * it under the terms of the GNU General Public License as published by *
14 * the Free Software Foundation; version 2 of the License. *
15 * *
16 ******************************************************************************/
18 #ifndef _FREETTSPROC_H_
19 #define _FREETTSPROC_H_
21 #include <QtCore/QMutex>
23 #include <pluginproc.h>
25 class K3Process;
27 class FreeTTSProc : public PlugInProc{
28 Q_OBJECT
30 public:
31 /**
32 * Constructor
34 explicit FreeTTSProc( QObject* parent = 0, const QStringList &args = QStringList());
36 /**
37 * Destructor
39 virtual ~FreeTTSProc();
41 /**
42 * Initializate the speech engine.
43 * @param config Settings object.
44 * @param configGroup Settings group.
46 virtual bool init(KConfig *config, const QString &configGroup);
48 /**
49 * Say a text string.
50 * @param text The text to speak.
52 virtual void sayText(const QString &text);
54 /**
55 * Synthesize text into an audio file, but do not send to the audio device.
56 * @param text The text to be synthesized.
57 * @param suggestedFilename Full pathname of file to create. The plugin
58 * may ignore this parameter and choose its own
59 * filename. KTTSD will query the generated
60 * filename using getFilename().
62 * If the plugin supports asynchronous operation, it should return immediately.
64 virtual void synthText(const QString& text, const QString& suggestedFilename);
66 /**
67 * Get the generated audio filename from synthText.
68 * @return Name of the audio file the plugin generated.
69 * Null if no such file.
71 * The plugin must not re-use the filename.
73 virtual QString getFilename();
75 /**
76 * Stop current operation (saying or synthesizing text).
77 * Important: This function may be called from a thread different from the
78 * one that called sayText or synthText.
79 * If the plugin cannot stop an in-progress @ref sayText or
80 * @ref synthText operation, it must not block waiting for it to complete.
81 * Instead, return immediately.
83 * If a plugin returns before the operation has actually been stopped,
84 * the plugin must emit the @ref stopped signal when the operation has
85 * actually stopped.
87 * The plugin should change to the psIdle state after stopping the
88 * operation.
90 virtual void stopText();
92 /**
93 * Return the current state of the plugin.
94 * This function only makes sense in asynchronous mode.
95 * @return The pluginState of the plugin.
97 * @see pluginState
99 virtual pluginState getState();
102 * Acknowledges a finished state and resets the plugin state to psIdle.
104 * If the plugin is not in state psFinished, nothing happens.
105 * The plugin may use this call to do any post-processing cleanup,
106 * for example, blanking the stored filename (but do not delete the file).
107 * Calling program should call getFilename prior to ackFinished.
109 virtual void ackFinished();
112 * Returns True if the plugin supports asynchronous processing,
113 * i.e., returns immediately from sayText or synthText.
114 * @return True if this plugin supports asynchronous processing.
116 * If the plugin returns True, it must also implement @ref getState .
117 * It must also emit @ref sayFinished or @ref synthFinished signals when
118 * saying or synthesis is completed.
120 virtual bool supportsAsync();
123 * Returns True if the plugin supports synthText method,
124 * i.e., is able to synthesize text to a sound file without
125 * audibilizing the text.
126 * @return True if this plugin supports synthText method.
128 virtual bool supportsSynth();
131 * Say or Synthesize text.
132 * @param text The text to be synthesized.
133 * @param synthFilename If not Null, synthesize only to this filename, otherwise
134 * synthesize and audibilize the text.
135 * @param freettsJarPath Path to the freetts jar file.
137 void synth(
138 const QString &text,
139 const QString &synthFilename,
140 const QString &freettsJarPath);
142 private slots:
143 void slotProcessExited(K3Process* proc);
144 void slotReceivedStdout(K3Process* proc, char* buffer, int buflen);
145 void slotReceivedStderr(K3Process* proc, char* buffer, int buflen);
146 void slotWroteStdin(K3Process* proc);
148 private:
150 * Path to FreeTTS jar file (from config).
152 QString m_freettsJarPath;
155 * FreeTTS process
157 K3Process* m_freettsProc;
160 * Synthesis filename.
162 QString m_synthFilename;
165 * Plugin state.
167 pluginState m_state;
170 * True when stopText has been called. Used to force transition to psIdle when
171 * FreeTTS exits.
173 bool m_waitingStop;
176 #endif // _FREETTSPROC_H_