1 /***************************************************** vim:set ts=4 sw=4 sts=4:
2 Filter Processing class.
3 This is the interface definition for text filters.
6 (C) 2005 by Gary Cramblitt <garycramblitt@comcast.net>
8 Original author: Gary Cramblitt <garycramblitt@comcast.net>
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA.
23 ******************************************************************************/
26 // #include <kdebug.h>
28 // FilterProc includes.
29 #include "filterproc.h"
36 KttsFilterProc::KttsFilterProc( QObject
*parent
, const char *name
) :
39 // kdDebug() << "KttsFilterProc::KttsFilterProc: Running" << endl;
45 KttsFilterProc::~KttsFilterProc()
47 // kdDebug() << "KttsFilterProc::~KttsFilterProc: Running" << endl;
51 * Initialize the filter.
52 * @param config Settings object.
53 * @param configGroup Settings Group.
54 * @return False if filter is not ready to filter.
56 * Note: The parameters are for reading from kttsdrc file. Plugins may wish to maintain
57 * separate configuration files of their own.
59 bool KttsFilterProc::init(KConfig
* /*config*/, const QString
& /*configGroup*/){
60 // kdDebug() << "PlugInProc::init: Running" << endl;
65 * Returns True if this filter is a Sentence Boundary Detector.
66 * If so, the filter should implement @ref setSbRegExp() .
67 * @return True if this filter is a SBD.
69 /*virtual*/ bool KttsFilterProc::isSBD() { return false; }
72 * Returns True if the plugin supports asynchronous processing,
73 * i.e., supports asyncConvert method.
74 * @return True if this plugin supports asynchronous processing.
76 * If the plugin returns True, it must also implement @ref getState .
77 * It must also emit @ref filteringFinished when filtering is completed.
78 * If the plugin returns True, it must also implement @ref stopFiltering .
79 * It must also emit @ref filteringStopped when filtering has been stopped.
81 /*virtual*/ bool KttsFilterProc::supportsAsync() { return false; }
84 * Convert input, returning output. Runs synchronously.
85 * @param inputText Input text.
86 * @param talkerCode TalkerCode structure for the talker that KTTSD intends to
87 * use for synthing the text. Useful for extracting hints about
88 * how to filter the text. For example, languageCode.
89 * @param appId The DCOP appId of the application that queued the text.
90 * Also useful for hints about how to do the filtering.
92 /*virtual*/ QString
KttsFilterProc::convert(const QString
& inputText
, TalkerCode
* /*talkerCode*/,
93 const Q3CString
& /*appId*/)
99 * Convert input. Runs asynchronously.
100 * @param inputText Input text.
101 * @param talkerCode TalkerCode structure for the talker that KTTSD intends to
102 * use for synthing the text. Useful for extracting hints about
103 * how to filter the text. For example, languageCode.
104 * @param appId The DCOP appId of the application that queued the text.
105 * Also useful for hints about how to do the filtering.
106 * @return False if the filter cannot perform the conversion.
108 * When conversion is completed, emits signal @ref filteringFinished. Calling
109 * program may then call @ref getOutput to retrieve converted text. Calling
110 * program must call @ref ackFinished to acknowledge the conversion.
112 /*virtual*/ bool KttsFilterProc::asyncConvert(const QString
& /*inputText*/,
113 TalkerCode
* /*talkerCode*/, const Q3CString
& /*appId*/) { return false; }
116 * Waits for a previous call to asyncConvert to finish.
118 /*virtual*/ void KttsFilterProc::waitForFinished() { }
121 * Returns the state of the Filter.
123 /*virtual*/ int KttsFilterProc::getState() { return fsIdle
; }
126 * Returns the filtered output.
128 /*virtual*/ QString
KttsFilterProc::getOutput() { return QString::null
; }
131 * Acknowledges the finished filtering.
133 /*virtual*/ void KttsFilterProc::ackFinished() { }
136 * Stops filtering. The filteringStopped signal will emit when filtering
137 * has in fact stopped and state returns to fsIdle;
139 /*virtual*/ void KttsFilterProc::stopFiltering() { }
142 * Did this filter do anything? If the filter returns the input as output
143 * unmolested, it should return False when this method is called.
145 /*virtual*/ bool KttsFilterProc::wasModified() { return true; }
148 * Set Sentence Boundary Regular Expression.
149 * This method will only be called if the application overrode the default.
151 * @param re The sentence delimiter regular expression.
153 /*virtual*/ void KttsFilterProc::setSbRegExp(const QString
& /*re*/) { };
155 #include "filterproc.moc"