SVN_SILENT made messages (.desktop file)
[kdeaccessibility.git] / kttsd / plugins / festivalint / festivalintconf.h
blobaa66f1102c3f88594c8914fc8ab6ae46d0995d11
1 /***************************************************** vim:set ts=4 sw=4 sts=4:
2 Configuration widget and functions for Festival (Interactive) plug in
3 -------------------
4 Copyright:
5 (C) 2004 by Gary Cramblitt <garycramblitt@comcast.net>
6 -------------------
7 Original author: Gary Cramblitt <garycramblitt@comcast.net>
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 ******************************************************************************/
24 #ifndef _FESTIVALINTCONF_H_
25 #define _FESTIVALINTCONF_H_
27 // Qt includes.
28 #include <QtCore/QList>
30 // KDE includes.
31 #include <kconfig.h>
32 #include <kdebug.h>
34 // KTTS includes.
35 #include "pluginconf.h"
37 // FestivalInt includes.
38 #include "ui_festivalintconfwidget.h"
39 #include "festivalintproc.h"
41 class KProgressDialog;
42 class QDomNode;
44 typedef struct voiceStruct{
45 QString code; // Code as sent to Festival
46 QString name; // Name as displayed and returned in Talker Code.
47 QString languageCode; // Language code (en, es, etc)
48 QString codecName; // Character encoding codec name (eg. ISO 8859-1)
49 QString gender; // male, female, or neutral
50 bool preload; // Start Festival and load this language when KTTSD is started.
51 bool volumeAdjustable; // True if the voice supports volume adjustments.
52 bool rateAdjustable; // True if the voice supports rate adjustments.
53 bool pitchAdjustable; // True if the voice supports pitch adjustments.
54 } voice;
56 class FestivalIntConf : public PlugInConf, public Ui::FestivalIntConfWidget {
57 Q_OBJECT
59 public:
60 /** Constructor */
61 explicit FestivalIntConf( QWidget* parent = 0, const QStringList &args = QStringList());
63 /** Destructor */
64 ~FestivalIntConf();
66 /** This method is invoked whenever the module should read its
67 * configuration (most of the times from a config file) and update the
68 * user interface. This happens when the user clicks the "Reset" button in
69 * the control center, to undo all of his changes and restore the currently
70 * valid settings. NOTE that this is not called after the modules is loaded,
71 * so you probably want to call this method in the constructor.
73 void load(KConfig *config, const QString &configGroup);
75 /** This function gets called when the user wants to save the settings in
76 * the user interface, updating the config files or wherever the
77 * configuration is stored. The method is called when the user clicks "Apply"
78 * or "Ok".
80 void save(KConfig *config, const QString &configGroup);
82 /** This function is called to set the settings in the module to sensible
83 * default values. It gets called when hitting the "Default" button. The
84 * default values should probably be the same as the ones the application
85 * uses when started without a config file. */
86 void defaults();
88 /**
89 * This function informs the plugin of the desired language to be spoken
90 * by the plugin. The plugin should attempt to adapt itself to the
91 * specified language code, choosing sensible defaults if necessary.
92 * If the passed-in code is QString(), no specific language has
93 * been chosen.
94 * @param lang The desired language code or Null if none.
96 * If the plugin is unable to support the desired language, that is OK.
97 * Language codes are given by ISO 639-1 and are in lowercase.
98 * The code may also include an ISO 3166 country code in uppercase
99 * separated from the language code by underscore (_). For
100 * example, en_GB. If your plugin supports the given language, but
101 * not the given country, treat it as though the country
102 * code were not specified, i.e., adapt to the given language.
104 void setDesiredLanguage(const QString &lang);
107 * Return fully-specified talker code for the configured plugin. This code
108 * uniquely identifies the configured instance of the plugin and distinquishes
109 * one instance from another. If the plugin has not been fully configured,
110 * i.e., cannot yet synthesize, return QString().
111 * @return Fully-specified talker code.
113 QString getTalkerCode();
115 private slots:
116 /** Scan for the different voices in festivalPath/lib */
117 void scanVoices();
118 void configChanged(){
119 // kDebug() << "FestivalIntConf::configChanged: Running";
120 emit changed(true);
122 void slotTest_clicked();
123 void slotSynthFinished();
124 void slotSynthStopped();
125 void volumeBox_valueChanged(int percentValue);
126 void timeBox_valueChanged(int percentValue);
127 void frequencyBox_valueChanged(int percentValue);
128 void volumeSlider_valueChanged(int sliderValue);
129 void timeSlider_valueChanged(int sliderValue);
130 void frequencySlider_valueChanged(int sliderValue);
131 void slotFestivalPath_textChanged();
132 void slotSelectVoiceCombo_activated();
133 void slotQueryVoicesFinished(const QStringList &voiceCodes);
135 private:
136 int percentToSlider(int percentValue);
137 int sliderToPercent(int sliderValue);
140 * Given an XML node and child element name, returns the string value from the child element.
141 * If no such child element, returns def.
143 QString readXmlString(QDomNode &node, const QString &elementName, const QString &def);
146 * Given an XML node and child element name, returns the boolean value from the child element.
147 * If no such child element, returns def.
149 bool readXmlBool(QDomNode &node, const QString &elementName, bool def);
152 * Given a voice code, returns index into m_voiceList array (and voiceCombo box).
153 * -1 if not found.
155 int voiceCodeToListIndex(const QString& voiceCode) const;
158 * Chooses a default voice given scanned list of voices in m_voiceList and current
159 * language and country code, and updates controls.
160 * @param currentVoiceIndex This voice is preferred if it matches.
162 void setDefaultVoice(int currentVoiceIndex);
164 // Language code.
165 QString m_languageCode;
166 // Language country code (if any).
167 QString m_countryCode;
168 // List of voices */
169 QList<voice> m_voiceList;
170 // Festival synthesizer.
171 FestivalIntProc* m_festProc;
172 // Synthesized wave file name.
173 QString m_waveFile;
174 // Progress dialog.
175 KProgressDialog* m_progressDlg;
176 // List of voice codes supported by Festival.
177 QStringList m_supportedVoiceCodes;
178 // List of displayed codec names.
179 QStringList m_codecList;
180 // Whether Festival supports SSML or not.
181 FestivalIntProc::SupportsSSML m_supportsSSML;
183 #endif // _FESTIVALINTCONF_H_