SVN_SILENT made messages (.desktop file)
[kdeaccessibility.git] / kttsd / plugins / hadifix / hadifixproc.h
blob24f971130f993462c22f3302325b0da5073fe7ab
1 /***************************************************************************
2 hadifixproc.h - description
3 -------------------
4 begin : Mon Okt 14 2002
5 copyright : (C) 2002 by Gunnar Schmi Dt
6 email : gunnar@schmi-dt.de
7 ***************************************************************************/
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 ***************************************************************************/
18 #ifndef _HADIFIXPROC_H_
19 #define _HADIFIXPROC_H_
21 #include <QtCore/QStringList>
23 #include <pluginproc.h>
25 class K3Process;
27 class HadifixProcPrivate;
28 class HadifixProc : public PlugInProc{
29 Q_OBJECT
31 public:
32 enum VoiceGender {
33 MaleGender = 2,
34 FemaleGender = 1,
35 NoGender = 0,
36 NoVoice = -1
39 /** Constructor */
40 explicit HadifixProc( QObject* parent = 0, const QStringList &args = QStringList());
42 /** Destructor */
43 ~HadifixProc();
45 /** Initializate the speech */
46 virtual bool init (KConfig *config, const QString &configGroup);
48 /**
49 * Say a text. Synthesize and audibilize it.
50 * @param text The text to be spoken.
52 * If the plugin supports asynchronous operation, it should return immediately
53 * and emit sayFinished signal when synthesis and audibilizing is finished.
54 * It must also implement the @ref getState method, which must return
55 * psFinished, when saying is completed.
57 virtual void sayText(const QString &text);
59 /**
60 * Synthesize text into an audio file, but do not send to the audio device.
61 * @param text The text to be synthesized.
62 * @param suggestedFilename Full pathname of file to create. The plugin
63 * may ignore this parameter and choose its own
64 * filename. KTTSD will query the generated
65 * filename using getFilename().
67 * If the plugin supports asynchronous operation, it should return immediately
68 * and emit @ref synthFinished signal when synthesis is completed.
69 * It must also implement the @ref getState method, which must return
70 * psFinished, when synthesis is completed.
72 virtual void synthText(const QString &text, const QString &suggestedFilename);
74 /**
75 * Get the generated audio filename from call to @ref synthText.
76 * @return Name of the audio file the plugin generated.
77 * Null if no such file.
79 * The plugin must not re-use or delete the filename. The file may not
80 * be locked when this method is called. The file will be deleted when
81 * KTTSD is finished using it.
83 virtual QString getFilename();
85 /**
86 * Stop current operation (saying or synthesizing text).
87 * Important: This function may be called from a thread different from the
88 * one that called sayText or synthText.
89 * If the plugin cannot stop an in-progress @ref sayText or
90 * @ref synthText operation, it must not block waiting for it to complete.
91 * Instead, return immediately.
93 * If a plugin returns before the operation has actually been stopped,
94 * the plugin must emit the @ref stopped signal when the operation has
95 * actually stopped.
97 * The plugin should change to the psIdle state after stopping the
98 * operation.
100 virtual void stopText();
103 * Return the current state of the plugin.
104 * This function only makes sense in asynchronous mode.
105 * @return The pluginState of the plugin.
107 * @see pluginState
109 virtual pluginState getState();
112 * Acknowledges a finished state and resets the plugin state to psIdle.
114 * If the plugin is not in state psFinished, nothing happens.
115 * The plugin may use this call to do any post-processing cleanup,
116 * for example, blanking the stored filename (but do not delete the file).
117 * Calling program should call getFilename prior to ackFinished.
119 virtual void ackFinished();
122 * Returns True if the plugin supports asynchronous processing,
123 * i.e., returns immediately from sayText or synthText.
124 * @return True if this plugin supports asynchronous processing.
126 * If the plugin returns True, it must also implement @ref getState .
127 * It must also emit @ref sayFinished or @ref synthFinished signals when
128 * saying or synthesis is completed.
130 virtual bool supportsAsync();
133 * Returns True if the plugin supports synthText method,
134 * i.e., is able to synthesize text to a sound file without
135 * audibilizing the text.
136 * @return True if this plugin supports synthText method.
138 * If the plugin returns True, it must also implement the following methods:
139 * - @ref synthText
140 * - @ref getFilename
141 * - @ref ackFinished
143 * If the plugin returns True, it need not implement @ref sayText .
145 virtual bool supportsSynth();
148 * Synthesize text using a specified configuration.
149 * @param text The text to synthesize.
150 * @param hadifix Command to run hadifix (txt2pho).
151 * @param isMale True to use male voice.
152 * @param mbrola Command to run mbrola.
153 * @param voice Voice file for mbrola to use.
154 * @param volume Volume percent. 100 = normal
155 * @param time Speed percent. 100 = normal
156 * @param pitch Frequency. 100 = normal
157 * @param waveFilename Name of file to synthesize to.
159 void synth(QString text,
160 QString hadifix, bool isMale,
161 QString mbrola, QString voice,
162 int volume, int time, int pitch,
163 QTextCodec* codec,
164 const QString waveFilename);
167 * Static function to determine whether the voice file is male or female.
168 * @param mbrola the mbrola executable
169 * @param voice the voice file
170 * @param output the output of mbrola will be written into this QString*
171 * @return HadifixSpeech::MaleGender if the voice is male,
172 * HadifixSpeech::FemaleGender if the voice is female,
173 * HadifixSpeech::NoGender if the gender cannot be determined,
174 * HadifixSpeech::NoVoice if there is an error in the voice file
176 static VoiceGender determineGender(QString mbrola, QString voice, QString *output = 0);
179 * Returns the name of an XSLT stylesheet that will convert a valid SSML file
180 * into a format that can be processed by the synth. For example,
181 * The Festival plugin returns a stylesheet that will convert SSML into
182 * SABLE. Any tags the synth cannot handle should be stripped (leaving
183 * their text contents though). The default stylesheet strips all
184 * tags and converts the file to plain text.
185 * @return Name of the XSLT file.
187 virtual QString getSsmlXsltFilename();
189 private slots:
190 void slotProcessExited(K3Process*);
191 void slotWroteStdin(K3Process*);
193 void receivedStdout (K3Process *, char *buffer, int buflen);
194 void receivedStderr (K3Process *, char *buffer, int buflen);
196 private:
197 HadifixProcPrivate *d;
199 QString stdOut;
200 QString stdErr;
203 #endif