diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 00bb99ac80741fc50ef8a289719373032f2391eb (patch) | |
tree | 3a5a9bf72f942784b38bf77dd66c534662fab5f2 /kttsd/plugins/festivalint | |
download | tdeaccessibility-00bb99ac80741fc50ef8a289719373032f2391eb.tar.gz tdeaccessibility-00bb99ac80741fc50ef8a289719373032f2391eb.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeaccessibility@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kttsd/plugins/festivalint')
-rw-r--r-- | kttsd/plugins/festivalint/Makefile.am | 27 | ||||
-rw-r--r-- | kttsd/plugins/festivalint/README | 9 | ||||
-rw-r--r-- | kttsd/plugins/festivalint/SSMLtoSable.xsl | 272 | ||||
-rw-r--r-- | kttsd/plugins/festivalint/configure.in.bot | 16 | ||||
-rw-r--r-- | kttsd/plugins/festivalint/configure.in.in | 22 | ||||
-rw-r--r-- | kttsd/plugins/festivalint/festivalintconf.cpp | 730 | ||||
-rw-r--r-- | kttsd/plugins/festivalint/festivalintconf.h | 187 | ||||
-rw-r--r-- | kttsd/plugins/festivalint/festivalintconfwidget.ui | 598 | ||||
-rw-r--r-- | kttsd/plugins/festivalint/festivalintplugin.cpp | 31 | ||||
-rw-r--r-- | kttsd/plugins/festivalint/festivalintproc.cpp | 662 | ||||
-rw-r--r-- | kttsd/plugins/festivalint/festivalintproc.h | 361 | ||||
-rw-r--r-- | kttsd/plugins/festivalint/kttsd_festivalintplugin.desktop | 72 | ||||
-rw-r--r-- | kttsd/plugins/festivalint/sabletowave.scm | 92 | ||||
-rw-r--r-- | kttsd/plugins/festivalint/voices | 738 |
14 files changed, 3817 insertions, 0 deletions
diff --git a/kttsd/plugins/festivalint/Makefile.am b/kttsd/plugins/festivalint/Makefile.am new file mode 100644 index 0000000..7c6ca0e --- /dev/null +++ b/kttsd/plugins/festivalint/Makefile.am @@ -0,0 +1,27 @@ +INCLUDES = \ + -I$(top_srcdir)/kttsd/libkttsd -I$(top_builddir)/kttsd/libkttsd \ + $(all_includes) + +METASOURCES = AUTO + +kde_module_LTLIBRARIES = libkttsd_festivalintplugin.la + +libkttsd_festivalintplugin_la_SOURCES = \ + festivalintconfwidget.ui \ + festivalintconf.cpp \ + festivalintproc.cpp \ + festivalintplugin.cpp +libkttsd_festivalintplugin_la_LDFLAGS = $(KDE_PLUGIN) $(all_libraries) +libkttsd_festivalintplugin_la_LIBADD = $(top_builddir)/kttsd/libkttsd/libkttsd.la + +services_DATA = kttsd_festivalintplugin.desktop +servicesdir = $(kde_servicesdir) + +# Install data files. +festivalintdatadir = $(kde_datadir)/kttsd/festivalint/ +festivalintdata_DATA = voices sabletowave.scm + +festivalintxsltdatadir = $(kde_datadir)/kttsd/festivalint/xslt/ +festivalintxsltdata_DATA = SSMLtoSable.xsl + +noinst_HEADERS = festivalintconfwidget.h diff --git a/kttsd/plugins/festivalint/README b/kttsd/plugins/festivalint/README new file mode 100644 index 0000000..3903dd0 --- /dev/null +++ b/kttsd/plugins/festivalint/README @@ -0,0 +1,9 @@ +This is the directory containing the Festival (Interactive) plug in. +This plugin is developed and maintained by Gary Cramblitt. +<garycramblitt@comcast.net> + +Make sure that Festival has write access to the audio device + + chmod a+rw /dev/dsp* + + diff --git a/kttsd/plugins/festivalint/SSMLtoSable.xsl b/kttsd/plugins/festivalint/SSMLtoSable.xsl new file mode 100644 index 0000000..48c2fd0 --- /dev/null +++ b/kttsd/plugins/festivalint/SSMLtoSable.xsl @@ -0,0 +1,272 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- *********************************************************************** + SSMLtoSable.xsl + Stylesheet for transforming SSML into SABLE markup. + ============ + Copyright : (C) 2004 by Paul Giannaros + ============ + Original author: Paul Giannaros <ceruleanblaze@gmail.com> + *************************************************************************** + + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; version 2 of the License. * + * * + *************************************************************************** --> +<!-- @todo create a doc detailing which parts of SSML this sheet can handle --> + +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> +<xsl:output method="html" indent="no"/> + +<!-- speak: Indicates SSML markup. --> +<xsl:template match="/speak"> + <SABLE><xsl:apply-templates/></SABLE> +</xsl:template> + +<!-- sub: The word that the text sounds like as abbreviations + can be pronounced differently. For example, + <sub alias="doctor">Dr.</sub> smith lives at 32 johnson <sub alias="drive">dr.</sub> --> +<xsl:template match="//sub"> + <xsl:choose> + <xsl:when test="@alias"> + <xsl:value-of select="@alias"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="."/> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<!-- p: Indicate a paragraph of text --> +<xsl:template match="//p"> + <DIV TYPE="paragraph"><xsl:apply-templates/></DIV> +</xsl:template> +<!-- s: Forceefully indicate a sentence (Does not need to be used + if full stops are present) --> +<xsl:template match="//s"> + <DIV TYPE="sentence"><xsl:apply-templates/></DIV> +</xsl:template> + +<!-- emphasis: Emphasize a word or group of words. --> +<xsl:template match="//emphasis"> + <!-- SSML and SABLE both take the same values for their attributes - + strong, moderate, none, reduced --> + <EM TYPE="{@level}"><xsl:apply-templates/></EM> +</xsl:template> + +<xsl:template match="//voice"> + <!-- This is turned off because if Festival lacks an installed voice to match a gender + or voice name, it bombs out. argh! + <xsl:call-template name="voice"><xsl:with-param name="a" select="@*" /></xsl:call-template> --> + <xsl:apply-templates/> +</xsl:template> + +<xsl:template name="voice"> + <xsl:param name="a" /> + <!-- Get the name of the tag we're creating and convert to a SABLE tag. --> + <xsl:variable name="tag"> + <xsl:choose> + <xsl:when test="name($a[1])='gender'">SPEAKER</xsl:when> + <xsl:when test="name($a[1])='age'">SPEAKER</xsl:when> + <xsl:when test="name($a[1])='name'">SPEAKER</xsl:when> + <xsl:otherwise><xsl:value-of select="$a[1]"/></xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:element name="{$tag}"> + <!-- Create the right attribute to go with element $tag. --> + + <xsl:choose> + <!-- gender: + The gender of the voice. + Values such as male, female, and neutral are supported. --> + <xsl:when test="name($a[1])='gender' and $a[1]='male'"> + <xsl:attribute name="GENDER">male1</xsl:attribute> + </xsl:when> + <xsl:when test="name($a[1])='gender' and $a[1]='female'"> + <xsl:attribute name="GENDER">female1</xsl:attribute> + </xsl:when> + <!-- If none of the above match, take the users selected value. --> + <xsl:when test="name($a[1])='gender'"> + <xsl:attribute name="GENDER"><xsl:value-of select=" $a[1]"/></xsl:attribute> + </xsl:when> + + <!-- age: + The age of the voice. + Positive integer values are supported. --> + <xsl:when test="name($a[1])='age' and number($a[1]) < 10"> + <xsl:attribute name="AGE">child</xsl:attribute> + </xsl:when> + <xsl:when test="name($a[1])='age' and number($a[1]) < 20"> + <xsl:attribute name="AGE">teen</xsl:attribute> + </xsl:when> + <xsl:when test="name($a[1])='age' and number($a[1]) < 30"> + <xsl:attribute name="AGE">younger</xsl:attribute> + </xsl:when> + <xsl:when test="name($a[1])='age' and number($a[1]) < 50"> + <xsl:attribute name="AGE">middle</xsl:attribute> + </xsl:when> + <xsl:when test="name($a[1])='age'"> + <xsl:attribute name="AGE">older</xsl:attribute> + </xsl:when> + + <!-- name: + Voice name. Synth dependent. --> + <xsl:when test="name($a[1])='name'"> + <xsl:attribute name="NAME"><xsl:value-of select=" $a[1]"/></xsl:attribute> + </xsl:when> + </xsl:choose> + + <!-- Recursively call ourself. --> + <xsl:choose> + <xsl:when test="$a[2]"> + <xsl:call-template name="voice"><xsl:with-param name="a" select="$a[position()>1]" /></xsl:call-template> + </xsl:when> + <xsl:otherwise> + <xsl:apply-templates/> + </xsl:otherwise> + </xsl:choose> + + </xsl:element> +</xsl:template> + +<xsl:template match="prosody"> + <!-- contour and duration not supported. --> + <xsl:call-template name="prosody"><xsl:with-param name="a" + select="@pitch|@rate|@volume|@range" /> + </xsl:call-template> +</xsl:template> + +<xsl:template name="prosody"> + <xsl:param name="a" /> + <!-- Get the name of the tag we're creating and convert to a SABLE tag. --> + <xsl:variable name="tag"> + <xsl:choose> + <xsl:when test="name($a[1])='pitch'">PITCH</xsl:when> + <xsl:when test="name($a[1])='rate'">RATE</xsl:when> + <xsl:when test="name($a[1])='volume'">VOLUME</xsl:when> + <xsl:when test="name($a[1])='range'">PITCH</xsl:when> + <xsl:otherwise><xsl:value-of select="$a[1]"/></xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:element name="{$tag}"> + <!-- Create the right attribute to go with element $tag. --> + + <xsl:choose> + <!-- pitch: + The pitch with which the text is spoken. + Values such as x-high, high, low, etc. and percentages (+ or -) + are supported. --> + <xsl:when test="name($a[1])='pitch' and $a[1]='x-high'"> + <xsl:attribute name="BASE">70%</xsl:attribute> + </xsl:when> + <xsl:when test="name($a[1])='pitch' and $a[1]='high'"> + <xsl:attribute name="BASE">40%</xsl:attribute> + </xsl:when> + <xsl:when test="name($a[1])='pitch' and $a[1]='medium'"> + <xsl:attribute name="BASE">0%</xsl:attribute> + </xsl:when> + <xsl:when test="name($a[1])='pitch' and $a[1]='low'"> + <xsl:attribute name="BASE">-40%</xsl:attribute> + </xsl:when> + <xsl:when test="name($a[1])='pitch' and $a[1]='x-low'"> + <xsl:attribute name="BASE">-70%</xsl:attribute> + </xsl:when> + <!-- If none of the above match, take the users selected value. --> + <xsl:when test="name($a[1])='pitch'"> + <xsl:attribute name="BASE"><xsl:value-of select=" $a[1]"/></xsl:attribute> + </xsl:when> + + <!-- rate: + The speed at which the text is spoken. + Values such as x-fast, fast, slow, etc. and percentages (+ or -) + are supported. --> + <xsl:when test="name($a[1])='rate' and $a[1]='x-fast'"> + <xsl:attribute name="SPEED">70%</xsl:attribute> + </xsl:when> + <xsl:when test="name($a[1])='rate' and $a[1]='fast'"> + <xsl:attribute name="SPEED">40%</xsl:attribute> + </xsl:when> + <xsl:when test="name($a[1])='rate' and $a[1]='medium'"> + <xsl:attribute name="SPEED">0%</xsl:attribute> + </xsl:when> + <xsl:when test="name($a[1])='rate' and $a[1]='slow'"> + <xsl:attribute name="SPEED">-40%</xsl:attribute> + </xsl:when> + <xsl:when test="name($a[1])='rate' and $a[1]='x-slow'"> + <xsl:attribute name="SPEED">-70%</xsl:attribute> + </xsl:when> + <xsl:when test="name($a[1])='rate'"> + <xsl:attribute name="SPEED"><xsl:value-of select=" $a[1]"/></xsl:attribute> + </xsl:when> + + <!-- volume: + The volume at which the text is spoken. + Values such as x-loud, loud, quiet, etc. and percentages (+ or -) + are supported. --> + <xsl:when test="name($a[1])='volume' and $a[1]='x-loud'"> + <xsl:attribute name="LEVEL">70%</xsl:attribute> + </xsl:when> + <xsl:when test="name($a[1])='volume' and $a[1]='loud'"> + <xsl:attribute name="LEVEL">50%</xsl:attribute> + </xsl:when> + <xsl:when test="name($a[1])='volume' and $a[1]='medium'"> + <xsl:attribute name="LEVEL">0%</xsl:attribute> + </xsl:when> + <xsl:when test="name($a[1])='volume' and $a[1]='soft'"> + <xsl:attribute name="LEVEL">-50%</xsl:attribute> + </xsl:when> + <xsl:when test="name($a[1])='volume' and $a[1]='x-soft'"> + <xsl:attribute name="LEVEL">-70%</xsl:attribute> + </xsl:when> + <xsl:when test="name($a[1])='volume' and $a[1]='silent'"> + <xsl:attribute name="LEVEL">-100%</xsl:attribute> + </xsl:when> + <xsl:when test="name($a[1])='volume'"> + <xsl:attribute name="LEVEL"><xsl:value-of select=" $a[1]"/></xsl:attribute> + </xsl:when> + + <!-- range: + The volume at which the text is spoken. + Values such as x-high, high, medium, low, x-low, etc. and percentages (+ or -) + are supported. --> + <xsl:when test="name($a[1])='range' and $a[1]='x-high'"> + <xsl:attribute name="RANGE">70%</xsl:attribute> + </xsl:when> + <xsl:when test="name($a[1])='range' and $a[1]='high'"> + <xsl:attribute name="RANGE">40%</xsl:attribute> + </xsl:when> + <xsl:when test="name($a[1])='range' and $a[1]='medium'"> + <xsl:attribute name="RANGE">0%</xsl:attribute> + </xsl:when> + <xsl:when test="name($a[1])='range' and $a[1]='low'"> + <xsl:attribute name="RANGE">-40%</xsl:attribute> + </xsl:when> + <xsl:when test="name($a[1])='range' and $a[1]='x-low'"> + <xsl:attribute name="RANGE">-70%</xsl:attribute> + </xsl:when> + <!-- If none of the above match, take the users selected value. --> + <xsl:when test="name($a[1])='range'"> + <xsl:attribute name="RANGE"><xsl:value-of select=" $a[1]"/></xsl:attribute> + </xsl:when> + + </xsl:choose> + + <!-- Recursively call ourself. --> + <xsl:choose> + <xsl:when test="$a[2]"> + <xsl:call-template name="prosody"><xsl:with-param name="a" select="$a[position()>1]" /></xsl:call-template> + </xsl:when> + <xsl:otherwise> + <xsl:apply-templates/> + </xsl:otherwise> + </xsl:choose> + </xsl:element> +</xsl:template> + +</xsl:stylesheet> + diff --git a/kttsd/plugins/festivalint/configure.in.bot b/kttsd/plugins/festivalint/configure.in.bot new file mode 100644 index 0000000..fee52df --- /dev/null +++ b/kttsd/plugins/festivalint/configure.in.bot @@ -0,0 +1,16 @@ +if test "x$festival_bindir" = "xno"; then + if test "$compile_festivalint_plugin" = "yes"; then + echo "" + echo "======================================================" + echo "The festival program does not appear to be installed" + echo "on this system. The Festival Interactive plugin will" + echo "be built, but you need to install festival before you" + echo "can use it. Festival comes on most Linux distribution" + echo "CDs, or you can get it at" + echo " http://www.cstr.ed.ac.uk/projects/festival/" + echo "Debian users: apt-get install festival" + echo "=====================================================" + all_tests=bad + fi +fi + diff --git a/kttsd/plugins/festivalint/configure.in.in b/kttsd/plugins/festivalint/configure.in.in new file mode 100644 index 0000000..c22f422 --- /dev/null +++ b/kttsd/plugins/festivalint/configure.in.in @@ -0,0 +1,22 @@ +dnl ============================== +dnl checks for FestivalInt Plug In +dnl ============================== + +AC_ARG_ENABLE(kttsd-festivalint, + AC_HELP_STRING([--enable-kttsd-festivalint], + [build KTTSD Festival Interactive plugin [default=yes]]), + festivalint_plugin=$enableval, + festivalint_plugin=yes) + +compile_festivalint_plugin="yes" + +if test "x$festivalint_plugin" = "xno"; then + compile_festivalint_plugin="no" +fi + +dnl Check for festival executable. +dnl Note that Festival Interactive plugin is always built +dnl whether binary is found or not, unless user overrides with -disable-festivalint. +AC_PATH_PROG(festival_bindir, "festival", "no") + +AM_CONDITIONAL(include_kttsd_festivalint, test "x$compile_festivalint_plugin" = "xyes") diff --git a/kttsd/plugins/festivalint/festivalintconf.cpp b/kttsd/plugins/festivalint/festivalintconf.cpp new file mode 100644 index 0000000..91cd24f --- /dev/null +++ b/kttsd/plugins/festivalint/festivalintconf.cpp @@ -0,0 +1,730 @@ +/***************************************************** vim:set ts=4 sw=4 sts=4: + Configuration widget and functions for Festival (Interactive) plug in + ------------------- + Copyright: + (C) 2004 by Gary Cramblitt <garycramblitt@comcast.net> + ------------------- + Original author: Gary Cramblitt <garycramblitt@comcast.net> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + ******************************************************************************/ + +// C++ includes. +#include <math.h> + +// Qt includes. +#include <qlayout.h> +#include <qlabel.h> +#include <qstring.h> +#include <qstringlist.h> +#include <qcheckbox.h> +#include <qdir.h> +#include <qslider.h> +#include <qdom.h> +#include <qtextcodec.h> + +// KDE includes. +#include <kdialog.h> +#include <kdebug.h> +#include <klocale.h> +#include <kcombobox.h> +#include <kglobal.h> +#include <ktempfile.h> +#include <kstandarddirs.h> +#include <knuminput.h> +#include <kprocio.h> +#include <kprogress.h> +#include <kiconloader.h> + +// KTTS includes. +#include "testplayer.h" + +// FestivalInt includes. +#include "festivalintproc.h" +#include "festivalintconf.h" +#include "festivalintconf.moc" + +/** Constructor */ +FestivalIntConf::FestivalIntConf( QWidget* parent, const char* name, const QStringList& /*args*/) : + PlugInConf(parent, name) +{ + // kdDebug() << "FestivalIntConf::FestivalIntConf: Running" << endl; + m_festProc = 0; + m_progressDlg = 0; + m_supportsSSML = FestivalIntProc::ssUnknown; + + QVBoxLayout *layout = new QVBoxLayout(this, KDialog::marginHint(), + KDialog::spacingHint(), "FestivalIntConfigWidgetLayout"); + layout->setAlignment (Qt::AlignTop); + m_widget = new FestivalIntConfWidget(this, "FestivalIntConfigWidget"); + layout->addWidget(m_widget); + + m_widget->festivalPath->setMode(KFile::File | KFile::ExistingOnly); + m_widget->festivalPath->setFilter("*"); + + // Build codec list and fill combobox. + m_codecList = PlugInProc::buildCodecList(); + m_widget->characterCodingBox->clear(); + m_widget->characterCodingBox->insertStringList(m_codecList); + + // defaults(); + + connect(m_widget->festivalPath, SIGNAL(textChanged(const QString&)), + this, SLOT(slotFestivalPath_textChanged())); + connect(m_widget->selectVoiceCombo, SIGNAL(activated(const QString&)), + this, SLOT(slotSelectVoiceCombo_activated())); + connect(m_widget->selectVoiceCombo, SIGNAL(activated(const QString&)), + this, SLOT(configChanged())); + connect(m_widget->testButton, SIGNAL(clicked()), this, SLOT(slotTest_clicked())); + connect(m_widget->rescan, SIGNAL(clicked()), this, SLOT(scanVoices())); + connect(m_widget->volumeBox, SIGNAL(valueChanged(int)), + this, SLOT(volumeBox_valueChanged(int))); + connect(m_widget->timeBox, SIGNAL(valueChanged(int)), + this, SLOT(timeBox_valueChanged(int))); + connect(m_widget->frequencyBox, SIGNAL(valueChanged(int)), + this, SLOT(frequencyBox_valueChanged(int))); + connect(m_widget->volumeSlider, SIGNAL(valueChanged(int)), + this, SLOT(volumeSlider_valueChanged(int))); + connect(m_widget->timeSlider, SIGNAL(valueChanged(int)), + this, SLOT(timeSlider_valueChanged(int))); + connect(m_widget->frequencySlider, SIGNAL(valueChanged(int)), + this, SLOT(frequencySlider_valueChanged(int))); + connect(m_widget->volumeBox, SIGNAL(valueChanged(int)), this, SLOT(configChanged())); + connect(m_widget->volumeSlider, SIGNAL(valueChanged(int)), this, SLOT(configChanged())); + connect(m_widget->timeBox, SIGNAL(valueChanged(int)), this, SLOT(configChanged())); + connect(m_widget->timeSlider, SIGNAL(valueChanged(int)), this, SLOT(configChanged())); + connect(m_widget->frequencyBox, SIGNAL(valueChanged(int)), this, SLOT(configChanged())); + connect(m_widget->frequencySlider, SIGNAL(valueChanged(int)), this, SLOT(configChanged())); + connect(m_widget->preloadCheckBox, SIGNAL(clicked()), this, SLOT(configChanged())); + connect(m_widget->characterCodingBox, SIGNAL(textChanged(const QString&)), + this, SLOT(configChanged())); + connect(m_widget->characterCodingBox, SIGNAL(activated(const QString&)), + this, SLOT(configChanged())); +} + +/** Destructor */ +FestivalIntConf::~FestivalIntConf(){ + // kdDebug() << "FestivalIntConf::~FestivalIntConf: Running" << endl; + if (!m_waveFile.isNull()) QFile::remove(m_waveFile); + delete m_festProc; + delete m_progressDlg; +} + +/** +* Given a voice code, returns index into m_voiceList array (and voiceCombo box). +* -1 if not found. +*/ +int FestivalIntConf::voiceCodeToListIndex(const QString& voiceCode) const +{ + const int voiceListCount = m_voiceList.count(); + for(int index = 0; index < voiceListCount; ++index){ + // kdDebug() << "Testing: " << voiceCode << " == " << m_voiceList[index].code << endl; + if(voiceCode == m_voiceList[index].code) + return index; + } + return -1; +} + +void FestivalIntConf::load(KConfig *config, const QString &configGroup){ + //kdDebug() << "FestivalIntConf::load: Running" << endl; + config->setGroup("FestivalInt"); + QString exePath = config->readEntry("FestivalExecutablePath", "festival"); + QString exeLocation = getLocation(exePath); + if (!exeLocation.isEmpty()) exePath = exeLocation; + exePath = realFilePath(exePath); + config->setGroup(configGroup); + m_widget->festivalPath->setURL(config->readEntry("FestivalExecutablePath", exePath)); + m_widget->preloadCheckBox->setChecked(false); + scanVoices(); + QString voiceSelected(config->readEntry("Voice")); + int index = voiceCodeToListIndex(voiceSelected); + if (index >= 0) + { + m_widget->selectVoiceCombo->setCurrentItem(index); + m_widget->preloadCheckBox->setChecked(m_voiceList[index].preload); + } + m_widget->volumeBox->setValue(config->readNumEntry("volume", 100)); + m_widget->timeBox->setValue(config->readNumEntry("time", 100)); + m_widget->frequencyBox->setValue(config->readNumEntry("pitch", 100)); + m_widget->preloadCheckBox->setChecked(config->readBoolEntry( + "Preload", m_widget->preloadCheckBox->isChecked())); + m_languageCode = config->readEntry("LanguageCode", m_languageCode); + m_supportsSSML = static_cast<FestivalIntProc::SupportsSSML>( + config->readNumEntry("SupportsSSML", FestivalIntProc::ssUnknown)); + QString codecName = PlugInProc::codecIndexToCodecName( + m_widget->characterCodingBox->currentItem(), m_codecList); + codecName = config->readEntry("Codec", codecName); + int codecNdx = PlugInProc::codecNameToListIndex(codecName, m_codecList); + m_widget->characterCodingBox->setCurrentItem(codecNdx); +} + +void FestivalIntConf::save(KConfig *config, const QString &configGroup){ + // kdDebug() << "FestivalIntConf::save: Running" << endl; + config->setGroup("FestivalInt"); + config->writeEntry("FestivalExecutablePath", realFilePath(m_widget->festivalPath->url())); + config->setGroup(configGroup); + config->writeEntry("FestivalExecutablePath", realFilePath(m_widget->festivalPath->url())); + config->writeEntry("Voice", m_voiceList[m_widget->selectVoiceCombo->currentItem()].code); + config->writeEntry("volume", m_widget->volumeBox->value()); + config->writeEntry("time", m_widget->timeBox->value()); + config->writeEntry("pitch", m_widget->frequencyBox->value()); + config->writeEntry("Preload", m_widget->preloadCheckBox->isChecked()); + config->writeEntry("LanguageCode", m_voiceList[m_widget->selectVoiceCombo->currentItem()].languageCode); + config->writeEntry("SupportsSSML", m_supportsSSML); + int codec = m_widget->characterCodingBox->currentItem(); + config->writeEntry("Codec", PlugInProc::codecIndexToCodecName(codec, m_codecList)); +} + +void FestivalIntConf::defaults(){ + // kdDebug() << "FestivalIntConf::defaults: Running" << endl; + m_widget->festivalPath->setURL("festival"); + m_widget->timeBox->setValue(100); + timeBox_valueChanged(100); + m_widget->volumeBox->setValue(100); + volumeBox_valueChanged(100); + m_widget->frequencyBox->setValue(100); + frequencyBox_valueChanged(100); + m_widget->preloadCheckBox->setChecked(false); + m_widget->characterCodingBox->setCurrentItem( + PlugInProc::codecNameToListIndex("ISO 8859-1", m_codecList)); + scanVoices(); +} + +void FestivalIntConf::setDesiredLanguage(const QString &lang) +{ + // kdDebug() << "FestivalIntConf::setDesiredLanguage: Running" << endl; + m_languageCode = splitLanguageCode(lang, m_countryCode); +} + +QString FestivalIntConf::getTalkerCode() +{ + if (!m_widget->selectVoiceCombo->isEnabled()) return QString::null; + QString exePath = realFilePath(m_widget->festivalPath->url()); + if (exePath.isEmpty()) return QString::null; + if (getLocation(exePath).isEmpty()) return QString::null; + if (m_voiceList.count() == 0) return QString::null; + QString normalTalkerCode; + voiceStruct voiceTemp = m_voiceList[m_widget->selectVoiceCombo->currentItem()]; + // Determine volume attribute. soft < 75% <= medium <= 125% < loud. + QString volume = "medium"; + if (m_widget->volumeBox->value() < 75) volume = "soft"; + if (m_widget->volumeBox->value() > 125) volume = "loud"; + // Determine rate attribute. slow < 75% <= medium <= 125% < fast. + QString rate = "medium"; + if (m_widget->timeBox->value() < 75) rate = "slow"; + if (m_widget->timeBox->value() > 125) rate = "fast"; + normalTalkerCode = QString( + "<voice lang=\"%1\" name=\"%2\" gender=\"%3\" />" + "<prosody volume=\"%4\" rate=\"%5\" />" + "<kttsd synthesizer=\"%6\" />") + .arg(voiceTemp.languageCode) + .arg(voiceTemp.code) + .arg(voiceTemp.gender) + .arg(volume) + .arg(rate) + .arg("Festival Interactive"); + return normalTalkerCode; +} + +/** + * Chooses a default voice given scanned list of voices in m_voiceList and current + * language and country code, and updates controls. + * @param currentVoiceIndex This voice is preferred if it matches. + */ +void FestivalIntConf::setDefaultVoice(int currentVoiceIndex) +{ + // kdDebug() << "FestivalIntCont::setDefaultVoice: Running" << endl; + // If language code is known, auto pick first voice that matches the language code. + if (!m_languageCode.isEmpty()) + { + bool found = false; + // First search for a match on both language code and country code. + QString languageCode = m_languageCode; + if (!m_countryCode.isNull()) languageCode += "_" + m_countryCode; + // kdDebug() << "FestivalIntConf::setDefaultVoice:: looking for default voice to match language code " << languageCode << endl; + uint index = 0; + // Prefer existing voice if it matches. + if (currentVoiceIndex >= 0) + { + QString vlCode = m_voiceList[currentVoiceIndex].languageCode.left(languageCode.length()); + if (languageCode == vlCode) + { + found = true; + index = currentVoiceIndex; + } + } + if (!found) + { + for(index = 0 ; index < m_voiceList.count(); ++index) + { + QString vlCode = m_voiceList[index].languageCode.left(languageCode.length()); + // kdDebug() << "FestivalIntConf::setDefaultVoice: testing " << vlCode << endl; + if(languageCode == vlCode) + { + found = true; + break; + } + } + } + // If not found, search for a match on just the language code. + if (!found) + { + languageCode = m_languageCode; + // Prefer existing voice if it matches. + if (currentVoiceIndex >= 0) + { + QString vlCode = m_voiceList[currentVoiceIndex].languageCode.left(languageCode.length()); + if (languageCode == vlCode) + { + found = true; + index = currentVoiceIndex; + } + } + if (!found) + { + for(index = 0 ; index < m_voiceList.count(); ++index) + { + QString vlCode = m_voiceList[index].languageCode.left(languageCode.length()); + // kdDebug() << "FestivalIntConf::setDefaultVoice: testing " << vlCode << endl; + if(languageCode == vlCode) + { + found = true; + break; + } + } + } + } + // If not found, pick first voice that is not "Unknown". + if (!found) + { + for(index = 0 ; index < m_voiceList.count(); ++index) + { + if (m_voiceList[index].name != i18n("Unknown")) + { + found = true; + break; + } + } + } + if (found) + { + // kdDebug() << "FestivalIntConf::setDefaultVoice: auto picking voice code " << m_voiceList[index].code << endl; + m_widget->selectVoiceCombo->setCurrentItem(index); + m_widget->preloadCheckBox->setChecked(m_voiceList[index].preload); + QString codecName = m_voiceList[index].codecName; + int codecNdx = PlugInProc::codecNameToListIndex(codecName, m_codecList); + m_widget->characterCodingBox->setCurrentItem(codecNdx); + if (m_voiceList[index].volumeAdjustable) + { + m_widget->volumeBox->setEnabled(true); + m_widget->volumeSlider->setEnabled(true); + } + else + { + m_widget->volumeBox->setValue(100); + volumeBox_valueChanged(100); + m_widget->volumeBox->setEnabled(false); + m_widget->volumeSlider->setEnabled(false); + } + if (m_voiceList[index].rateAdjustable) + { + m_widget->timeBox->setEnabled(true); + m_widget->timeSlider->setEnabled(true); + } + else + { + m_widget->timeBox->setValue(100); + timeBox_valueChanged(100); + m_widget->timeBox->setEnabled(false); + m_widget->timeSlider->setEnabled(false); + } + if (m_voiceList[index].pitchAdjustable) + { + m_widget->frequencyBox->setEnabled(true); + m_widget->frequencySlider->setEnabled(true); + } + else + { + m_widget->frequencyBox->setValue(100); + frequencyBox_valueChanged(100); + m_widget->frequencyBox->setEnabled(false); + m_widget->frequencySlider->setEnabled(false); + } + if ((int)index != currentVoiceIndex) configChanged(); + } + } +} + +/** + * Given an XML node and child element name, returns the string value from the child element. + * If no such child element, returns def. + */ +QString FestivalIntConf::readXmlString(QDomNode &node, const QString &elementName, const QString &def) +{ + QDomNode childNode = node.namedItem(elementName); + if (!childNode.isNull()) + return childNode.toElement().text(); + else + return def; +} + +/** + * Given an XML node and child element name, returns the boolean value from the child element. + * If no such child element, returns def. + */ +bool FestivalIntConf::readXmlBool(QDomNode &node, const QString &elementName, bool def) +{ + QDomNode childNode = node.namedItem(elementName); + if (!childNode.isNull()) + return (childNode.toElement().text() == "true"); + else + return def; +} + +void FestivalIntConf::scanVoices() +{ + // kdDebug() << "FestivalIntConf::scanVoices: Running" << endl; + // Get existing voice code (if any). + QString currentVoiceCode; + int index = m_widget->selectVoiceCombo->currentItem(); + if (index < (int)m_voiceList.count()) currentVoiceCode = m_voiceList[index].code; + + m_voiceList.clear(); + m_widget->selectVoiceCombo->clear(); + m_widget->selectVoiceCombo->insertItem(i18n("Scanning... Please wait.")); + + // Save current state of selectVoiceCombo box and disable. + bool selectVoiceComboEnabled = m_widget->selectVoiceCombo->isEnabled(); + m_widget->selectVoiceCombo->setEnabled(false); + + // Clear existing list of supported voice codes. + // m_supportedVoiceCodes.clear(); + m_widget->selectVoiceCombo->clear(); + + QString exePath = realFilePath(m_widget->festivalPath->url()); + if (!getLocation(exePath).isEmpty()) + { + // Set up a progress dialog. + m_progressDlg = new KProgressDialog(m_widget, "kttsmgr_queryvoices", + i18n("Query Voices"), + i18n("Querying Festival for available voices. This could take up to 15 seconds."), + true); + m_progressDlg->progressBar()->hide(); + m_progressDlg->setAllowCancel(true); + + // Create Festival process and request a list of voice codes. + if (m_festProc) + m_festProc->stopText(); + else + { + m_festProc = new FestivalIntProc(); + connect (m_festProc, SIGNAL(stopped()), this, SLOT(slotSynthStopped())); + } + connect (m_festProc, SIGNAL(queryVoicesFinished(const QStringList&)), + this, SLOT(slotQueryVoicesFinished(const QStringList&))); + m_festProc->queryVoices(exePath); + + // Display progress dialog modally. + m_progressDlg->exec(); + // kdDebug() << "FestivalIntConf::scanVoices: back from progressDlg->exec()" << endl; + + // Processing continues until either user clicks Cancel button, or until + // Festival responds with the list. When Festival responds with list, + // the progress dialog is closed. + + disconnect (m_festProc, SIGNAL(queryVoicesFinished(const QStringList&)), + this, SLOT(slotQueryVoicesFinished(const QStringList&))); + if (!m_progressDlg->wasCancelled()) m_festProc->stopText(); + delete m_progressDlg; + m_progressDlg = 0; + m_supportsSSML = m_festProc->supportsSSML(); + } + + if (!m_supportedVoiceCodes.isEmpty()) + { + // User's desktop language setting. + QString desktopLanguageCode = KGlobal::locale()->language(); + QString twoAlpha; + QString countryCode; + QString charSet; + KGlobal::locale()->splitLocale(desktopLanguageCode, twoAlpha, countryCode, charSet); + desktopLanguageCode = twoAlpha.lower(); + + // Festival known voices list. + QString voicesFilename = KGlobal::dirs()->resourceDirs("data").last() + "/kttsd/festivalint/voices"; + QDomDocument voicesDoc("Festival Voices"); + QFile voicesFile(voicesFilename); + if (voicesFile.open(IO_ReadOnly)) voicesDoc.setContent(&voicesFile); + voicesFile.close(); + QDomNodeList voices = voicesDoc.elementsByTagName("voice"); + uint voicesCount = voices.count(); + if (voicesCount == 0) + kdDebug() << "FestivalIntConf::scanVoices: Unable to open " << voicesFilename << ". Is KDEDIR defined?" << endl; + + // Iterate thru list of voice codes returned by Festival, + // find matching entry in voices.xml file, and add to list of supported voices. + QPixmap maleIcon = KGlobal::iconLoader()->loadIcon("male", KIcon::Small); + QPixmap femaleIcon = KGlobal::iconLoader()->loadIcon("female", KIcon::Small); + QStringList::ConstIterator itEnd = m_supportedVoiceCodes.constEnd(); + for(QStringList::ConstIterator it = m_supportedVoiceCodes.begin(); it != itEnd; ++it ) + { + QString code = *it; + bool found = false; + for (uint index=0; index < voicesCount; ++index) + { + QDomNode voiceNode = voices.item(index); + QString voiceCode = readXmlString(voiceNode, "code", QString::null); + // kdDebug() << "FestivalIntConf::scanVoices: Comparing code " << code << " to " << voiceCode << endl; + if (voiceCode == code) + { + found = true; + voiceStruct voiceTemp; + voiceTemp.code = code; + voiceTemp.name = i18n("FestivalVoiceName", + readXmlString(voiceNode, "name", "Unknown").utf8()); + voiceTemp.languageCode = readXmlString(voiceNode, "language", m_languageCode); + voiceTemp.codecName = readXmlString(voiceNode, "codec", "ISO 8859-1"); + voiceTemp.gender = readXmlString(voiceNode, "gender", "neutral"); + voiceTemp.preload = readXmlBool(voiceNode, "preload", false); + voiceTemp.volumeAdjustable = readXmlBool(voiceNode, "volume-adjustable", true); + voiceTemp.rateAdjustable = readXmlBool(voiceNode, "rate-adjustable", true); + voiceTemp.pitchAdjustable = readXmlBool(voiceNode, "pitch-adjustable", true); + m_voiceList.append(voiceTemp); + QString voiceDisplayName = voiceTemp.name + " (" + voiceTemp.code + ")"; + if (voiceTemp.gender == "male") + m_widget->selectVoiceCombo->insertItem(maleIcon, voiceDisplayName); + else if (voiceTemp.gender == "female") + m_widget->selectVoiceCombo->insertItem(femaleIcon, voiceDisplayName); + else + m_widget->selectVoiceCombo->insertItem(voiceDisplayName); + break; + } + } + if (!found) + { + voiceStruct voiceTemp; + voiceTemp.code = code; + voiceTemp.name = i18n("Unknown"); + voiceTemp.languageCode = m_languageCode; + voiceTemp.codecName = "ISO 8858-1"; + voiceTemp.gender = "neutral"; + voiceTemp.preload = false; + voiceTemp.volumeAdjustable = true; + voiceTemp.rateAdjustable = true; + voiceTemp.pitchAdjustable = true; + m_voiceList.append(voiceTemp); + m_widget->selectVoiceCombo->insertItem(voiceTemp.name + " (" + voiceTemp.code + ")"); + } + } + m_widget->selectVoiceCombo->setEnabled(true); + } else kdDebug() << "FestivalIntConf::scanVoices: No voices found" << endl; + setDefaultVoice(voiceCodeToListIndex(currentVoiceCode)); + // Emit configChanged if the enabled state of the selectVoiceCombo has changed. + // This occurs when user changes Festival EXE path, then clicks Rescan. + if (selectVoiceComboEnabled != m_widget->selectVoiceCombo->isEnabled()) configChanged(); +} + +void FestivalIntConf::slotQueryVoicesFinished(const QStringList &voiceCodes) +{ + // kdDebug() << "FestivalIntConf::slotQueryVoicesFinished: voiceCodes.count() = " << voiceCodes.count() << endl; + m_supportedVoiceCodes = voiceCodes; + if (m_progressDlg) m_progressDlg->close(); +} + +void FestivalIntConf::slotTest_clicked() +{ + // kdDebug() << "FestivalIntConf::slotTest_clicked: Running " << endl; + // If currently synthesizing, stop it. + if (m_festProc) + m_festProc->stopText(); + else + { + m_festProc = new FestivalIntProc(); + connect (m_festProc, SIGNAL(stopped()), this, SLOT(slotSynthStopped())); + } + // Create a temp file name for the wave file. + KTempFile tempFile (locateLocal("tmp", "festivalintplugin-"), ".wav"); + QString tmpWaveFile = tempFile.file()->name(); + tempFile.close(); + + // Get the code for the selected voice. + QString voiceCode = m_voiceList[m_widget->selectVoiceCombo->currentItem()].code; + + // Get language code for the selected voice. + QString languageCode = m_voiceList[m_widget->selectVoiceCombo->currentItem()].languageCode; + + // Get test message in the language of the voice. + QString testMsg = testMessage(languageCode); + + // Get codec. + QTextCodec* codec = PlugInProc::codecIndexToCodec( + m_widget->characterCodingBox->currentItem(), m_codecList); + + // Tell user to wait. + m_progressDlg = new KProgressDialog(m_widget, "ktts_festivalint_testdlg", + i18n("Testing"), + i18n("Testing. MultiSyn voices require several seconds to load. Please be patient."), + true); + m_progressDlg->progressBar()->hide(); + m_progressDlg->setAllowCancel(true); + + // kdDebug() << "FestivalIntConf::slotTest_clicked: calling synth with voiceCode: " << voiceCode << " time percent: " << m_widget->timeBox->value() << endl; + connect (m_festProc, SIGNAL(synthFinished()), this, SLOT(slotSynthFinished())); + m_festProc->synth( + realFilePath(m_widget->festivalPath->url()), + testMsg, + tmpWaveFile, + voiceCode, + m_widget->timeBox->value(), + m_widget->frequencyBox->value(), + m_widget->volumeBox->value(), + languageCode, + codec); + + // Display progress dialog modally. Processing continues when plugin signals synthFinished, + // or if user clicks Cancel button. + m_progressDlg->exec(); + disconnect (m_festProc, SIGNAL(synthFinished()), this, SLOT(slotSynthFinished())); + if (m_progressDlg->wasCancelled()) m_festProc->stopText(); + delete m_progressDlg; + m_progressDlg = 0; +} + +void FestivalIntConf::slotSynthFinished() +{ + // kdDebug() << "FestivalIntConf::slotSynthFinished: Running" << endl; + // If user canceled, progress dialog is gone, so exit. + if (!m_progressDlg) + { + m_festProc->ackFinished(); + return; + } + // Hide the Cancel button so user can't cancel in the middle of playback. + m_progressDlg->showCancelButton(false); + // Get new wavefile name. + m_waveFile = m_festProc->getFilename(); + // Tell synth we're done. + m_festProc->ackFinished(); + // Play the wave file (possibly adjusting its Speed). + // Player object deletes the wave file when done. + if (m_player) m_player->play(m_waveFile); + QFile::remove(m_waveFile); + m_waveFile = QString::null; + if (m_progressDlg) m_progressDlg->close(); +} + +void FestivalIntConf::slotSynthStopped() +{ + // Clean up after canceling test. + QString filename = m_festProc->getFilename(); + // kdDebug() << "FestivalIntConf::slotSynthStopped: filename = " << filename << endl; + if (!filename.isNull()) QFile::remove(filename); +} + +void FestivalIntConf::slotFestivalPath_textChanged() +{ + QString exePath = realFilePath(m_widget->festivalPath->url()); + m_widget->selectVoiceCombo->setEnabled(false); + if (!exePath.isEmpty() && !getLocation(exePath).isEmpty()) + { + m_widget->rescan->setEnabled(true); + } else m_widget->rescan->setEnabled(false); +} + +void FestivalIntConf::slotSelectVoiceCombo_activated() +{ + int index = m_widget->selectVoiceCombo->currentItem(); + QString codecName = m_voiceList[index].codecName; + int codecNdx = PlugInProc::codecNameToListIndex(codecName, m_codecList); + m_widget->characterCodingBox->setCurrentItem(codecNdx); + m_widget->preloadCheckBox->setChecked( + m_voiceList[index].preload); + if (m_voiceList[index].volumeAdjustable) + { + m_widget->volumeBox->setEnabled(true); + m_widget->volumeSlider->setEnabled(true); + } + else + { + m_widget->volumeBox->setValue(100); + volumeBox_valueChanged(100); + m_widget->volumeBox->setEnabled(false); + m_widget->volumeSlider->setEnabled(false); + } + if (m_voiceList[index].rateAdjustable) + { + m_widget->timeBox->setEnabled(true); + m_widget->timeSlider->setEnabled(true); + } + else + { + m_widget->timeBox->setValue(100); + timeBox_valueChanged(100); + m_widget->timeBox->setEnabled(false); + m_widget->timeSlider->setEnabled(false); + } + if (m_voiceList[index].pitchAdjustable) + { + m_widget->frequencyBox->setEnabled(true); + m_widget->frequencySlider->setEnabled(true); + } + else + { + m_widget->frequencyBox->setValue(100); + frequencyBox_valueChanged(100); + m_widget->frequencyBox->setEnabled(false); + m_widget->frequencySlider->setEnabled(false); + } +} + +// Basically the slider values are logarithmic (0,...,1000) whereas percent +// values are linear (50%,...,200%). +// +// slider = alpha * (log(percent)-log(50)) +// with alpha = 1000/(log(200)-log(50)) + +int FestivalIntConf::percentToSlider(int percentValue) { + double alpha = 1000 / (log(200) - log(50)); + return (int)floor (0.5 + alpha * (log(percentValue)-log(50))); +} + +int FestivalIntConf::sliderToPercent(int sliderValue) { + double alpha = 1000 / (log(200) - log(50)); + return (int)floor(0.5 + exp (sliderValue/alpha + log(50))); +} + +void FestivalIntConf::volumeBox_valueChanged(int percentValue) { + m_widget->volumeSlider->setValue(percentToSlider(percentValue)); +} + +void FestivalIntConf::timeBox_valueChanged(int percentValue) { + m_widget->timeSlider->setValue (percentToSlider (percentValue)); +} + +void FestivalIntConf::frequencyBox_valueChanged(int percentValue) { + m_widget->frequencySlider->setValue(percentToSlider(percentValue)); +} + +void FestivalIntConf::volumeSlider_valueChanged(int sliderValue) { + m_widget->volumeBox->setValue(sliderToPercent(sliderValue)); +} + +void FestivalIntConf::timeSlider_valueChanged(int sliderValue) { + m_widget->timeBox->setValue (sliderToPercent (sliderValue)); +} + +void FestivalIntConf::frequencySlider_valueChanged(int sliderValue) { + m_widget->frequencyBox->setValue(sliderToPercent(sliderValue)); +} diff --git a/kttsd/plugins/festivalint/festivalintconf.h b/kttsd/plugins/festivalint/festivalintconf.h new file mode 100644 index 0000000..a367682 --- /dev/null +++ b/kttsd/plugins/festivalint/festivalintconf.h @@ -0,0 +1,187 @@ +/***************************************************** vim:set ts=4 sw=4 sts=4: + Configuration widget and functions for Festival (Interactive) plug in + ------------------- + Copyright: + (C) 2004 by Gary Cramblitt <garycramblitt@comcast.net> + ------------------- + Original author: Gary Cramblitt <garycramblitt@comcast.net> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + ******************************************************************************/ + +#ifndef _FESTIVALINTCONF_H_ +#define _FESTIVALINTCONF_H_ + +// Qt includes. +#include <qstringlist.h> +#include <qvaluelist.h> + +// KDE includes. +#include <kconfig.h> +#include <kdebug.h> + +// KTTS includes. +#include "pluginconf.h" + +// FestivalInt includes. +#include "festivalintconfwidget.h" +#include "festivalintproc.h" + +class KProgressDialog; +class QDomNode; + +typedef struct voiceStruct{ + QString code; // Code as sent to Festival + QString name; // Name as displayed and returned in Talker Code. + QString languageCode; // Language code (en, es, etc) + QString codecName; // Character encoding codec name (eg. ISO 8859-1) + QString gender; // male, female, or neutral + bool preload; // Start Festival and load this language when KTTSD is started. + bool volumeAdjustable; // True if the voice supports volume adjustments. + bool rateAdjustable; // True if the voice supports rate adjustments. + bool pitchAdjustable; // True if the voice supports pitch adjustments. +} voice; + +class FestivalIntConf : public PlugInConf { + Q_OBJECT + + public: + /** Constructor */ + FestivalIntConf( QWidget* parent = 0, const char* name = 0, const QStringList &args = QStringList()); + + /** Destructor */ + ~FestivalIntConf(); + + /** This method is invoked whenever the module should read its + * configuration (most of the times from a config file) and update the + * user interface. This happens when the user clicks the "Reset" button in + * the control center, to undo all of his changes and restore the currently + * valid settings. NOTE that this is not called after the modules is loaded, + * so you probably want to call this method in the constructor. + */ + void load(KConfig *config, const QString &configGroup); + + /** This function gets called when the user wants to save the settings in + * the user interface, updating the config files or wherever the + * configuration is stored. The method is called when the user clicks "Apply" + * or "Ok". + */ + void save(KConfig *config, const QString &configGroup); + + /** This function is called to set the settings in the module to sensible + * default values. It gets called when hitting the "Default" button. The + * default values should probably be the same as the ones the application + * uses when started without a config file. */ + void defaults(); + + /** + * This function informs the plugin of the desired language to be spoken + * by the plugin. The plugin should attempt to adapt itself to the + * specified language code, choosing sensible defaults if necessary. + * If the passed-in code is QString::null, no specific language has + * been chosen. + * @param lang The desired language code or Null if none. + * + * If the plugin is unable to support the desired language, that is OK. + * Language codes are given by ISO 639-1 and are in lowercase. + * The code may also include an ISO 3166 country code in uppercase + * separated from the language code by underscore (_). For + * example, en_GB. If your plugin supports the given language, but + * not the given country, treat it as though the country + * code were not specified, i.e., adapt to the given language. + */ + void setDesiredLanguage(const QString &lang); + + /** + * Return fully-specified talker code for the configured plugin. This code + * uniquely identifies the configured instance of the plugin and distinquishes + * one instance from another. If the plugin has not been fully configured, + * i.e., cannot yet synthesize, return QString::null. + * @return Fully-specified talker code. + */ + QString getTalkerCode(); + + private slots: + /** Scan for the different voices in festivalPath/lib */ + void scanVoices(); + void configChanged(){ + // kdDebug() << "FestivalIntConf::configChanged: Running" << endl; + emit changed(true); + }; + void slotTest_clicked(); + void slotSynthFinished(); + void slotSynthStopped(); + void volumeBox_valueChanged(int percentValue); + void timeBox_valueChanged(int percentValue); + void frequencyBox_valueChanged(int percentValue); + void volumeSlider_valueChanged(int sliderValue); + void timeSlider_valueChanged(int sliderValue); + void frequencySlider_valueChanged(int sliderValue); + void slotFestivalPath_textChanged(); + void slotSelectVoiceCombo_activated(); + void slotQueryVoicesFinished(const QStringList &voiceCodes); + + private: + int percentToSlider(int percentValue); + int sliderToPercent(int sliderValue); + + /** + * Given an XML node and child element name, returns the string value from the child element. + * If no such child element, returns def. + */ + QString readXmlString(QDomNode &node, const QString &elementName, const QString &def); + + /** + * Given an XML node and child element name, returns the boolean value from the child element. + * If no such child element, returns def. + */ + bool readXmlBool(QDomNode &node, const QString &elementName, bool def); + + /** + * Given a voice code, returns index into m_voiceList array (and voiceCombo box). + * -1 if not found. + */ + int voiceCodeToListIndex(const QString& voiceCode) const; + + /** + * Chooses a default voice given scanned list of voices in m_voiceList and current + * language and country code, and updates controls. + * @param currentVoiceIndex This voice is preferred if it matches. + */ + void setDefaultVoice(int currentVoiceIndex); + + // Configuration Widget. + FestivalIntConfWidget* m_widget; + + // Language code. + QString m_languageCode; + // Language country code (if any). + QString m_countryCode; + // List of voices */ + QValueList<voice> m_voiceList; + // Festival synthesizer. + FestivalIntProc* m_festProc; + // Synthesized wave file name. + QString m_waveFile; + // Progress dialog. + KProgressDialog* m_progressDlg; + // List of voice codes supported by Festival. + QStringList m_supportedVoiceCodes; + // List of displayed codec names. + QStringList m_codecList; + // Whether Festival supports SSML or not. + FestivalIntProc::SupportsSSML m_supportsSSML; +}; +#endif // _FESTIVALINTCONF_H_ diff --git a/kttsd/plugins/festivalint/festivalintconfwidget.ui b/kttsd/plugins/festivalint/festivalintconfwidget.ui new file mode 100644 index 0000000..f8b33fb --- /dev/null +++ b/kttsd/plugins/festivalint/festivalintconfwidget.ui @@ -0,0 +1,598 @@ +<!DOCTYPE UI><UI version="3.2" stdsetdef="1"> +<class>FestivalIntConfWidget</class> +<author>Gary Cramblitt <garycramblitt@comcast.net></author> +<widget class="QWidget"> + <property name="name"> + <cstring>FestivalIntConfWidget</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>559</width> + <height>318</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>7</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="caption"> + <string>Festival Config UI</string> + </property> + <property name="whatsThis" stdset="0"> + <string>This is the dialog for configuring the Festival speech synthesizer in interactive mode.</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QGroupBox" row="0" column="0"> + <property name="name"> + <cstring>festivalConfigurationBox</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="frameShape"> + <enum>GroupBoxPanel</enum> + </property> + <property name="frameShadow"> + <enum>Sunken</enum> + </property> + <property name="title"> + <string>Festival &Interactive Configuration</string> + </property> + <property name="whatsThis" stdset="0"> + <string>This is the dialog for configuring the Festival speech synthesizer in interactive mode.</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>11</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="QLayoutWidget" row="0" column="0"> + <property name="name"> + <cstring>voicesPathBox</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>festivalPathLabel</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>1</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>&Festival executable:</string> + </property> + <property name="alignment"> + <set>AlignVCenter|AlignRight</set> + </property> + <property name="buddy" stdset="0"> + <cstring>festivalPath</cstring> + </property> + <property name="whatsThis" stdset="0"> + <string>If Festival is in your PATH environment variable, just enter "festival", otherwise specify the full path to the Festival executable program.</string> + </property> + </widget> + <widget class="KURLRequester"> + <property name="name"> + <cstring>festivalPath</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>1</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="whatsThis" stdset="0"> + <string>If Festival is in your PATH environment variable, just enter "festival", otherwise specify the full path to the Festival executable program.</string> + </property> + </widget> + </hbox> + </widget> + <widget class="QLayoutWidget" row="1" column="0"> + <property name="name"> + <cstring>selectVoiceBox</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>selectVoiceLabel</cstring> + </property> + <property name="text"> + <string>&Select voice:</string> + </property> + <property name="alignment"> + <set>AlignVCenter|AlignRight</set> + </property> + <property name="buddy" stdset="0"> + <cstring>selectVoiceCombo</cstring> + </property> + <property name="whatsThis" stdset="0"> + <string>Select a voice to speak text with. MultiSyn voices are high quality but are slow to load. If no voices are shown, check the Festival executable path. You must install at least one Festival voice. If you have installed a voice and still none are shown, check your Festival configuration. (See the README that comes with Festival.)</string> + </property> + </widget> + <widget class="KComboBox"> + <property name="name"> + <cstring>selectVoiceCombo</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="whatsThis" stdset="0"> + <string>Select a voice to speak text with. MultiSyn voices are high quality but are slow to load. If no voices are shown, check the Festival executable path. You must install at least one Festival voice. If you have installed a voice and still none are shown, check your Festival configuration. (See the README that comes with Festival.)</string> + </property> + </widget> + <widget class="KPushButton"> + <property name="name"> + <cstring>rescan</cstring> + </property> + <property name="text"> + <string>&Rescan</string> + <comment>Rescan for voices</comment> + </property> + </widget> + </hbox> + </widget> + <widget class="QLayoutWidget" row="2" column="0"> + <property name="name"> + <cstring>layout11</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout8</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>volumeLabel</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>&Volume:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>volumeBox</cstring> + </property> + <property name="whatsThis" stdset="0"> + <string>Sets the volume (loudness) of speech. Slide the slider to the left to lower the volume; to the right to increase volume. Anything less than 75 percent is considered "soft", and anything greater than 125 percent is considered "loud".</string> + </property> + </widget> + <widget class="QLabel"> + <property name="name"> + <cstring>timeLabel</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Sp&eed:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>timeBox</cstring> + </property> + <property name="whatsThis" stdset="0"> + <string>Sets the speed of speech. Slide the slider to the left to slow speech down; to the right to increase talking speed. Anything less than 75 percent is considered "slow", and anything greater than 125 percent is considered "fast". You cannot change the speed of MultiSyn voices.</string> + </property> + </widget> + <widget class="QLabel"> + <property name="name"> + <cstring>frequencyLabel</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>&Pitch:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>frequencyBox</cstring> + </property> + <property name="whatsThis" stdset="0"> + <string>Sets the tone (frequency) of speech. Slide the slider to the left to lower the voice tone; to the right to increase tone. Anything less than 75 percent is considered "low", and anything greater than 125 percent is considered "high". You cannot change the pitch of MultiSyn voices.</string> + </property> + </widget> + </vbox> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout9</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="KIntSpinBox"> + <property name="name"> + <cstring>volumeBox</cstring> + </property> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="suffix"> + <string> %</string> + </property> + <property name="maxValue"> + <number>200</number> + </property> + <property name="minValue"> + <number>50</number> + </property> + <property name="value"> + <number>100</number> + </property> + <property name="whatsThis" stdset="0"> + <string>Sets the volume (loudness) of speech. Slide the slider to the left to lower the volume; to the right to increase volume. Anything less than 75 percent is considered "soft", and anything greater than 125 percent is considered "loud".</string> + </property> + </widget> + <widget class="KIntSpinBox"> + <property name="name"> + <cstring>timeBox</cstring> + </property> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="suffix"> + <string> %</string> + </property> + <property name="maxValue"> + <number>200</number> + </property> + <property name="minValue"> + <number>50</number> + </property> + <property name="value"> + <number>100</number> + </property> + <property name="whatsThis" stdset="0"> + <string>Sets the speed of speech. Slide the slider to the left to slow speech down; to the right to increase talking speed. Anything less than 75 percent is considered "slow", and anything greater than 125 percent is considered "fast". You cannot change the speed of MultiSyn voices.</string> + </property> + </widget> + <widget class="KIntSpinBox"> + <property name="name"> + <cstring>frequencyBox</cstring> + </property> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="suffix"> + <string> %</string> + </property> + <property name="maxValue"> + <number>200</number> + </property> + <property name="minValue"> + <number>50</number> + </property> + <property name="value"> + <number>100</number> + </property> + <property name="whatsThis" stdset="0"> + <string>Sets the tone (frequency) of speech. Slide the slider to the left to lower the voice tone; to the right to increase tone. Anything less than 75 percent is considered "low", and anything greater than 125 percent is considered "high". You cannot change the pitch of MultiSyn voices.</string> + </property> + </widget> + </vbox> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout10</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QSlider"> + <property name="name"> + <cstring>volumeSlider</cstring> + </property> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="focusPolicy"> + <enum>NoFocus</enum> + </property> + <property name="minValue"> + <number>0</number> + </property> + <property name="maxValue"> + <number>1000</number> + </property> + <property name="lineStep"> + <number>10</number> + </property> + <property name="pageStep"> + <number>100</number> + </property> + <property name="value"> + <number>500</number> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="whatsThis" stdset="0"> + <string>Sets the volume (loudness) of speech. Slide the slider to the left to lower the volume; to the right to increase volume. Anything less than 75 percent is considered "soft", and anything greater than 125 percent is considered "loud".</string> + </property> + </widget> + <widget class="QSlider"> + <property name="name"> + <cstring>timeSlider</cstring> + </property> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="focusPolicy"> + <enum>NoFocus</enum> + </property> + <property name="maxValue"> + <number>1000</number> + </property> + <property name="lineStep"> + <number>10</number> + </property> + <property name="pageStep"> + <number>100</number> + </property> + <property name="value"> + <number>500</number> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="whatsThis" stdset="0"> + <string>Sets the speed of speech. Slide the slider to the left to slow speech down; to the right to increase talking speed. Anything less than 75 percent is considered "slow", and anything greater than 125 percent is considered "fast". You cannot change the speed of MultiSyn voices.</string> + </property> + </widget> + <widget class="QSlider"> + <property name="name"> + <cstring>frequencySlider</cstring> + </property> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="focusPolicy"> + <enum>NoFocus</enum> + </property> + <property name="maxValue"> + <number>1000</number> + </property> + <property name="lineStep"> + <number>10</number> + </property> + <property name="pageStep"> + <number>100</number> + </property> + <property name="value"> + <number>500</number> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="whatsThis" stdset="0"> + <string>Sets the tone (frequency) of speech. Slide the slider to the left to lower the voice tone; to the right to increase tone. Anything less than 75 percent is considered "low", and anything greater than 125 percent is considered "high". You cannot change the pitch of MultiSyn voices.</string> + </property> + </widget> + </vbox> + </widget> + </hbox> + </widget> + <widget class="QLayoutWidget" row="4" column="0"> + <property name="name"> + <cstring>layout6</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QCheckBox"> + <property name="name"> + <cstring>preloadCheckBox</cstring> + </property> + <property name="text"> + <string>&Load this voice when starting KTTSD</string> + </property> + <property name="whatsThis" stdset="0"> + <string>If checked, Festival will be started and this voice will be loaded when the Text-to-Speech Deamon (KTTSD) is started. Check when a voice requires a long time to load in Festival (for example, multisyn voices), otherwise, leave unchecked.</string> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>spacer3</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>101</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QPushButton"> + <property name="name"> + <cstring>testButton</cstring> + </property> + <property name="text"> + <string>&Test</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Click to test the configuration. Festival will be started and a test sentence will be spoken.</string> + </property> + </widget> + </hbox> + </widget> + <widget class="QLayoutWidget" row="3" column="0"> + <property name="name"> + <cstring>layout5</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>characterCodingLabel</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Character e&ncoding:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>characterCodingBox</cstring> + </property> + </widget> + <widget class="KComboBox"> + <property name="name"> + <cstring>characterCodingBox</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="whatsThis" stdset="0"> + <string>This combo box specifies which character encoding is used for passing the text.</string> + </property> + </widget> + </hbox> + </widget> + </grid> + </widget> + </grid> +</widget> +<customwidgets> +</customwidgets> +<tabstops> + <tabstop>festivalPath</tabstop> + <tabstop>selectVoiceCombo</tabstop> + <tabstop>rescan</tabstop> + <tabstop>volumeBox</tabstop> + <tabstop>timeBox</tabstop> + <tabstop>frequencyBox</tabstop> + <tabstop>preloadCheckBox</tabstop> + <tabstop>testButton</tabstop> +</tabstops> +<includes> + <include location="global" impldecl="in declaration">kurlrequester.h</include> + <include location="global" impldecl="in implementation">kurlrequester.h</include> +</includes> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>kurlrequester.h</includehint> + <includehint>klineedit.h</includehint> + <includehint>kpushbutton.h</includehint> + <includehint>kcombobox.h</includehint> + <includehint>kpushbutton.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>kcombobox.h</includehint> +</includehints> +</UI> diff --git a/kttsd/plugins/festivalint/festivalintplugin.cpp b/kttsd/plugins/festivalint/festivalintplugin.cpp new file mode 100644 index 0000000..d793b40 --- /dev/null +++ b/kttsd/plugins/festivalint/festivalintplugin.cpp @@ -0,0 +1,31 @@ +/***************************************************** vim:set ts=4 sw=4 sts=4: + Generating the factories so festival (interactive) can be used as plug in. + ------------------- + Copyright: + (C) 2004 by Gary Cramblitt <garycramblitt@comcast.net> + ------------------- + Original author: Gary Cramblitt <garycramblitt@comcast.net> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + ******************************************************************************/ + +#include <kgenericfactory.h> + +#include "festivalintconf.h" +#include "festivalintproc.h" + +typedef K_TYPELIST_2( FestivalIntProc, FestivalIntConf ) Festival; +K_EXPORT_COMPONENT_FACTORY( libkttsd_festivalintplugin, KGenericFactory<Festival>("kttsd_festivalint") ) + diff --git a/kttsd/plugins/festivalint/festivalintproc.cpp b/kttsd/plugins/festivalint/festivalintproc.cpp new file mode 100644 index 0000000..77822ea --- /dev/null +++ b/kttsd/plugins/festivalint/festivalintproc.cpp @@ -0,0 +1,662 @@ +/***************************************************** vim:set ts=4 sw=4 sts=4: + Main speaking functions for the Festival (Interactive) Plug in + ------------------- + Copyright: + (C) 2004 by Gary Cramblitt <garycramblitt@comcast.net> + ------------------- + Original author: Gary Cramblitt <garycramblitt@comcast.net> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + ******************************************************************************/ + +// C++ includes. +#include <math.h> + +// Qt includes. +#include <qstring.h> +#include <qstringlist.h> +#include <qthread.h> +#include <qtextcodec.h> + +// KDE includes. +#include <kdebug.h> +#include <kconfig.h> +#include <kstandarddirs.h> + +// KTTS includes. +#include "utils.h" + +// FestivalInt includes. +#include "festivalintproc.h" +#include "festivalintproc.moc" + +/** Constructor */ +FestivalIntProc::FestivalIntProc( QObject* parent, const char* name, const QStringList& ) : + PlugInProc( parent, name ){ + // kdDebug() << "FestivalIntProc::FestivalIntProc: Running" << endl; + m_ready = true; + m_writingStdin = false; + m_waitingQueryVoices = false; + m_waitingStop = false; + m_festProc = 0; + m_state = psIdle; + m_supportsSSML = ssUnknown; + m_languageCode = "en"; + m_codec = QTextCodec::codecForName("ISO8859-1"); +} + +/** Destructor */ +FestivalIntProc::~FestivalIntProc(){ + // kdDebug() << "FestivalIntProc::~FestivalIntProc: Running" << endl; + if (m_festProc) + { + if (m_festProc->isRunning()) + { + if (m_ready) + { + m_state = psIdle; + // kdDebug() << "FestivalIntProc::~FestivalIntProc: telling Festival to quit." << endl; + m_ready = false; + m_waitingStop = true; + m_festProc->writeStdin("(quit)", true); + } + else + { + // kdDebug() << "FestivalIntProc::~FestivalIntProc: killing Festival." << endl; + m_waitingStop = true; + m_festProc->kill(); + } + } + delete m_festProc; + } +} + +/** Initialize the speech */ +bool FestivalIntProc::init(KConfig *config, const QString &configGroup) +{ + // kdDebug() << "FestivalIntProc::init: Initializing plug in: Festival" << endl; + + config->setGroup(configGroup); + m_voiceCode = config->readEntry("Voice"); + m_festivalExePath = config->readEntry("FestivalExecutablePath", "festival"); + // kdDebug() << "---- The code for the selected voice " << config->readEntry("Voice") << " is " << voiceCode << endl; + m_time = config->readNumEntry("time", 100); + m_pitch = config->readNumEntry("pitch", 100); + m_volume = config->readNumEntry("volume", 100); + // If voice should be pre-loaded, start Festival and load the voice. + m_preload = config->readBoolEntry("Preload", false); + m_languageCode = config->readEntry("LanguageCode", "en"); + m_supportsSSML = static_cast<SupportsSSML>(config->readNumEntry("SupportsSSML", ssUnknown)); + QString codecName = config->readEntry("Codec", "Latin1"); + m_codec = codecNameToCodec(codecName); + if (m_preload) startEngine(m_festivalExePath, m_voiceCode, m_languageCode, m_codec); + return true; +} + +/** +* Say a text. Synthesize and audibilize it. +* @param text The text to be spoken. +* +* If the plugin supports asynchronous operation, it should return immediately. +*/ +void FestivalIntProc::sayText(const QString &text) +{ + synth(m_festivalExePath, text, QString::null, m_voiceCode, m_time, m_pitch, m_volume, + m_languageCode, m_codec); +} + +/** +* Synthesize text into an audio file, but do not send to the audio device. +* @param text The text to be synthesized. +* @param suggestedFilename Full pathname of file to create. The plugin +* may ignore this parameter and choose its own +* filename. KTTSD will query the generated +* filename using getFilename(). +* +* If the plugin supports asynchronous operation, it should return immediately. +*/ +void FestivalIntProc::synthText(const QString& text, const QString& suggestedFilename) +{ + synth(m_festivalExePath, text, suggestedFilename, m_voiceCode, m_time, m_pitch, m_volume, + m_languageCode, m_codec); +} + +/** +* Sends command to Festival to query for a list of supported voice codes. +* Fires queryVoicesFinished when completed. +* @return False if busy doing something else and therefore cannot +* do the query. +*/ +bool FestivalIntProc::queryVoices(const QString &festivalExePath) +{ + // kdDebug() << "FestivalIntProc::queryVoices: Running" << endl; + if (m_state != psIdle && m_waitingQueryVoices && m_waitingStop) return false; + // Start Festival if not already running. + startEngine(festivalExePath, QString::null, m_languageCode, m_codec); + // Set state, waiting for voice codes list from Festival. + m_waitingQueryVoices = true; + // Voice rab_diphone is needed in order to support SSML. + m_supportsSSML = ssUnknown; + // Send command to query the voice codes. + sendToFestival("(print (mapcar (lambda (pair) (car pair)) voice-locations))"); + return true; +} + +/** +* Start Festival engine. +* @param festivalExePath Path to the Festival executable, or just "festival". +* @param voiceCode Voice code in which to speak text. +* @param languageCode Language code, for example, "en". +*/ +void FestivalIntProc::startEngine(const QString &festivalExePath, const QString &voiceCode, + const QString &languageCode, QTextCodec* codec) +{ + // Initialize Festival only if it's not initialized. + if (m_festProc) + { + // Stop Festival if a different EXE is requested or different language code. + // If festProc exists but is not running, it is because it was stopped. + if ((festivalExePath != m_festivalExePath) || !m_festProc->isRunning() || + (m_languageCode != languageCode) || (codec->name() != m_codec->name())) + { + delete m_festProc; + m_festProc = 0; + } + } + if(!m_festProc) + { + // kdDebug()<< "FestivalIntProc::startEngine: Creating Festival object" << endl; + m_festProc = new KProcess; + *m_festProc << festivalExePath; + *m_festProc << "--interactive"; + m_festProc->setEnvironment("LANG", languageCode + "." + codec->mimeName()); + m_festProc->setEnvironment("LC_CTYPE", languageCode + "." + codec->mimeName()); + // kdDebug() << "FestivalIntProc::startEngine: setting LANG = LC_CTYPE = " << languageCode << "." << codec->mimeName() << endl; + connect(m_festProc, SIGNAL(processExited(KProcess*)), + this, SLOT(slotProcessExited(KProcess*))); + connect(m_festProc, SIGNAL(receivedStdout(KProcess*, char*, int)), + this, SLOT(slotReceivedStdout(KProcess*, char*, int))); + connect(m_festProc, SIGNAL(receivedStderr(KProcess*, char*, int)), + this, SLOT(slotReceivedStderr(KProcess*, char*, int))); + connect(m_festProc, SIGNAL(wroteStdin(KProcess*)), + this, SLOT(slotWroteStdin(KProcess*))); + } + if (!m_festProc->isRunning()) + { + // kdDebug() << "FestivalIntProc::startEngine: Starting Festival process" << endl; + m_runningVoiceCode = QString::null; + m_runningTime = 100; + m_runningPitch = 100; + m_ready = false; + m_outputQueue.clear(); + if (m_festProc->start(KProcess::NotifyOnExit, KProcess::All)) + { + // kdDebug()<< "FestivalIntProc:startEngine: Festival initialized" << endl; + m_festivalExePath = festivalExePath; + m_languageCode = languageCode; + m_codec = codec; + // Load the SABLE to Wave module. + sendToFestival("(load \"" + + KGlobal::dirs()->resourceDirs("data").last() + "kttsd/festivalint/sabletowave.scm\")"); + } + else + { + kdDebug() << "FestivalIntProc::startEngine: Error starting Festival process. Is festival in the PATH?" << endl; + m_ready = true; + m_state = psIdle; + return; + } + } + // If we just started Festival, or voiceCode has changed, send code to Festival. + if (m_runningVoiceCode != voiceCode && !voiceCode.isEmpty()) { + sendToFestival("(voice_" + voiceCode + ")"); + m_runningVoiceCode = voiceCode; + } +} + +/** +* Say or Synthesize text. +* @param festivalExePath Path to the Festival executable, or just "festival". +* @param text The text to be synthesized. +* @param suggestedFilename If not Null, synthesize only to this filename, otherwise +* synthesize and audibilize the text. +* @param voiceCode Voice code in which to speak text. +* @param time Speed percentage. 50 to 200. 200% = 2x normal. +* @param pitch Pitch persentage. 50 to 200. +* @param volume Volume percentage. 50 to 200. +* @param languageCode Language code, for example, "en". +*/ +void FestivalIntProc::synth( + const QString &festivalExePath, + const QString &text, + const QString &synthFilename, + const QString &voiceCode, + int time, + int pitch, + int volume, + const QString &languageCode, + QTextCodec* codec) +{ + // kdDebug() << "FestivalIntProc::synth: festivalExePath = " << festivalExePath + // << " voiceCode = " << voiceCode << endl; + + // Initialize Festival only if it's not initialized + startEngine(festivalExePath, voiceCode, languageCode, codec); + // If we just started Festival, or rate changed, tell festival. + if (m_runningTime != time) { + QString timeMsg; + if (voiceCode.contains("_hts") > 0) + { + // Map 50% to 200% onto 0 to 1000. + // slider = alpha * (log(percent)-log(50)) + // with alpha = 1000/(log(200)-log(50)) + double alpha = 1000 / (log(200) - log(50)); + int slider = (int)floor (0.5 + alpha * (log(time)-log(50))); + // Center at 0. + slider = slider - 500; + // Map -500 to 500 onto 0.15 to -0.15. + float stretchValue = -float(slider) * 0.15 / 500.0; + timeMsg = QString("(set! hts_duration_stretch %1)").arg( + stretchValue, 0, 'f', 3); + } + else + timeMsg = QString("(Parameter.set 'Duration_Stretch %1)").arg( + 1.0/(float(time)/100.0), 0, 'f', 2); + sendToFestival(timeMsg); + m_runningTime = time; + } + // If we just started Festival, or pitch changed, tell festival. + if (m_runningPitch != pitch) { + // Pitch values range from 50 to 200 %, with 100% as the midpoint, + // while frequency values range from 41 to 500 with 105 as the "midpoint". + int pitchValue; + if (pitch <= 100) + { + pitchValue = (((pitch - 50) * 64) / 50) + 41; + } + else + { + pitchValue = (((pitch - 100) * 395) / 100) + 105; + } + QString pitchMsg = QString( + "(set! int_lr_params '((target_f0_mean %1) (target_f0_std 14)" + "(model_f0_mean 170) (model_f0_std 34)))").arg(pitchValue, 0, 10); + sendToFestival(pitchMsg); + m_runningPitch = pitch; + } + + QString saidText = text; + + // Split really long sentences into shorter sentences, by looking for commas and converting + // to periods. + int len = saidText.length(); + while (len > c_tooLong) + { + len = saidText.findRev(", ", len - (c_tooLong * 2 / 3), true); + if (len != -1) + { + QString c = saidText.mid(len+2, 1); + if (c != c.upper()) + { + saidText.replace(len, 2, ". "); + saidText.replace(len+2, 1, c.upper()); + kdDebug() << "FestivalIntProc::synth: Splitting long sentence at " << len << endl; + // kdDebug() << saidText << endl; + } + } + } + + // Encode quotation characters. + saidText.replace("\\\"", "#!#!"); + saidText.replace("\"", "\\\""); + saidText.replace("#!#!", "\\\""); + // Remove certain comment characters. + saidText.replace("--", ""); + + // Ok, let's rock. + if (synthFilename.isNull()) + { + m_state = psSaying; + m_synthFilename = QString::null; + // kdDebug() << "FestivalIntProc::synth: Saying text: '" << saidText << "' using Festival plug in with voice " + // << voiceCode << endl; + saidText = "(SayText \"" + saidText + "\")"; + sendToFestival(saidText); + } else { + m_state = psSynthing; + m_synthFilename = synthFilename; + // Volume must be given for each utterance. + // Volume values range from 50 to 200%, with 100% = normal. + // Map onto rescale range of .5 to 2. + float volumeValue = float(volume) / 100; + // Expand to range .25 to 4. + // float volumeValue = exp(log(volumeValue) * 2); + // kdDebug() << "FestivalIntProc::synth: Synthing text: '" << saidText << "' using Festival plug in with voice " + // << voiceCode << endl; + if (isSable(saidText)) + { + // Synth the text and adjust volume. + saidText = + "(ktts_sabletowave \"" + saidText + "\" \"" + + synthFilename + "\" " + + QString::number(volumeValue) + ")"; + } + else + { + saidText = + // Suppress pause at the beginning of each utterance. + "(define (insert_initial_pause utt) " + "(item.set_feat (utt.relation.first utt 'Segment) 'end 0.0))" + // Synth the text and adjust volume. + "(set! utt1 (Utterance Text \"" + saidText + + "\"))(utt.synth utt1)" + + "(utt.wave.rescale utt1 " + QString::number(volumeValue) + " t)" + + "(utt.save.wave utt1 \"" + synthFilename + "\")"; + } + sendToFestival(saidText); + } +} + +/** +* If ready for more output, sends the given text to Festival process, otherwise, +* puts it in the queue. +* @param text Text to send or queue. +*/ +void FestivalIntProc::sendToFestival(const QString& text) +{ + if (text.isNull()) return; + m_outputQueue.append(text); + sendIfReady(); +} + +/** +* If Festival is ready for more input and there is more output to send, send it. +* To be ready for more input, the Stdin buffer must be empty and the "festival>" +* prompt must have been received (m_ready = true). +* @return False when Festival is ready for more input +* but there is nothing to be sent, or if Festival +* has exited. +*/ +bool FestivalIntProc::sendIfReady() +{ + if (!m_ready) return true; + if (m_writingStdin) return true; + if (m_outputQueue.isEmpty()) return false; + if (!m_festProc->isRunning()) return false; + QString text = m_outputQueue[0]; + text += "\n"; + QCString encodedText; + if (m_codec) + encodedText = m_codec->fromUnicode(text); + else + encodedText = text.latin1(); // Should not happen, but just in case. + m_outputQueue.pop_front(); + m_ready = false; + // kdDebug() << "FestivalIntProc::sendIfReady: sending to Festival: " << text << endl; + m_writingStdin = true; + m_festProc->writeStdin(encodedText, encodedText.length()); + return true; +} + +/** +* Determine if the text has SABLE tags. If so, we will have to use a different +* synthesis method. +*/ +bool FestivalIntProc::isSable(const QString &text) +{ + return KttsUtils::hasRootElement( text, "SABLE" ); +} + +/** +* Get the generated audio filename from synthText. +* @return Name of the audio file the plugin generated. +* Null if no such file. +* +* The plugin must not re-use the filename. +*/ +QString FestivalIntProc::getFilename() { return m_synthFilename; } + +/** + * Stop text + */ +void FestivalIntProc::stopText(){ + // kdDebug() << "FestivalIntProc::stopText: Running" << endl; + if (m_festProc) + { + if (m_festProc->isRunning()) + { + if (m_ready) + m_state = psIdle; + else + { + // If using a preloaded voice, killing Festival is a bad idea because of + // huge startup times. So if synthing (not saying), let Festival continue + // synthing. When it completes, we will emit the stopped signal. + if (m_preload && (m_state == psSynthing)) + { + m_waitingStop = true; + // kdDebug() << "FestivalIntProc::stopText: Optimizing stopText() for preloaded voice." << endl; + } + else + { + // kdDebug() << "FestivalIntProc::stopText: killing Festival." << endl; + m_waitingStop = true; + m_festProc->kill(); + } + } + } else m_state = psIdle; + } else m_state = psIdle; +} + +void FestivalIntProc::slotProcessExited(KProcess*) +{ + // kdDebug() << "FestivalIntProc:slotProcessExited: Festival process has exited." << endl; + m_ready = true; + pluginState prevState = m_state; + if (m_waitingStop || m_waitingQueryVoices) + { + if (m_waitingStop) + { + m_waitingStop = false; + m_state = psIdle; + // kdDebug() << "FestivalIntProc::slotProcessExited: emitting stopped signal" << endl; + emit stopped(); + } + if (m_waitingQueryVoices) + { + // kdDebug() << "FestivalIntProc::slotProcessExited: canceling queryVoices operation" << endl; + m_waitingQueryVoices = false; + m_state = psIdle; + } + } else { + if (m_state != psIdle) m_state = psFinished; + if (prevState == psSaying) + { + // kdDebug() << "FestivalIntProc::slotProcessExited: emitting sayFinished signal" << endl; + emit sayFinished(); + } else + if (prevState == psSynthing) + { + // kdDebug() << "FestivalIntProc::slotProcessExited: emitting synthFinished signal" << endl; + emit synthFinished(); + } + } + delete m_festProc; + m_festProc = 0; + m_outputQueue.clear(); +} + +void FestivalIntProc::slotReceivedStdout(KProcess*, char* buffer, int buflen) +{ + QString buf = QString::fromLatin1(buffer, buflen); + // kdDebug() << "FestivalIntProc::slotReceivedStdout: Received from Festival: " << buf << endl; + bool promptSeen = (buf.contains("festival>") > 0); + bool emitQueryVoicesFinished = false; + QStringList voiceCodesList; + if (m_waitingQueryVoices && m_outputQueue.isEmpty()) + { + // Look for opening ( and closing ). + buf.simplifyWhiteSpace(); + if (buf.left(3) == "nil") { + emitQueryVoicesFinished = true; + m_waitingQueryVoices = false; + } else { + if (buf.left(1) == "(") + { + int rightParen = buf.find(')'); + if (rightParen > 0) + { + m_waitingQueryVoices = false; + // Extract contents between parens. + buf = buf.mid(1, rightParen - 1); + // Space separated list. + voiceCodesList = QStringList::split(" ", buf, false); + emitQueryVoicesFinished = true; + } + } + } + } + if (promptSeen) + { + // kdDebug() << "FestivalIntProc::slotReceivedStdout: Prompt seen" << endl; + m_ready = true; + if (!sendIfReady()) + { + // kdDebug() << "FestivalIntProc::slotReceivedStdout: All output sent. " << endl; + pluginState prevState = m_state; + if (m_state != psIdle) m_state = psFinished; + if (prevState == psSaying) + { + // kdDebug() << "FestivalIntProc::slotReceivedStdout: emitting sayFinished signal" << endl; + emit sayFinished(); + } else + if (prevState == psSynthing) + { + if (m_waitingStop) + { + m_waitingStop = false; + m_state = psIdle; + // kdDebug() << "FestivalIntProc::slotReceivedStdout: emitting optimized stopped signal" << endl; + emit stopped(); + } + else + { + // kdDebug() << "FestivalIntProc::slotReceivedStdout: emitting synthFinished signal" << endl; + emit synthFinished(); + } + } + } + } + if (emitQueryVoicesFinished) + { + // kdDebug() << "FestivalIntProc::slotReceivedStdout: emitting queryVoicesFinished" << endl; + m_supportsSSML = (voiceCodesList.contains("rab_diphone")) ? ssYes : ssNo; + emit queryVoicesFinished(voiceCodesList); + } +} + +void FestivalIntProc::slotReceivedStderr(KProcess*, char* buffer, int buflen) +{ + QString buf = QString::fromLatin1(buffer, buflen); + kdDebug() << "FestivalIntProc::slotReceivedStderr: Received error from Festival: " << buf << endl; +} + +void FestivalIntProc::slotWroteStdin(KProcess* /*proc*/) +{ + // kdDebug() << "FestivalIntProc::slotWroteStdin: Running" << endl; + m_writingStdin = false; + if (!sendIfReady()) + { + // kdDebug() << "FestivalIntProc::slotWroteStdin: all output sent" << endl; + pluginState prevState = m_state; + if (m_state != psIdle) m_state = psFinished; + if (prevState == psSaying) + { + // kdDebug() << "FestivalIntProc::slotWroteStdin: emitting sayFinished signal" << endl; + emit sayFinished(); + } else + if (prevState == psSynthing) + { + // kdDebug() << "FestivalIntProc::slotWroteStdin: emitting synthFinished signal" << endl; + emit synthFinished(); + } + } +} + + +bool FestivalIntProc::isReady() { return m_ready; } + +/** +* Return the current state of the plugin. +* This function only makes sense in asynchronous mode. +* @return The pluginState of the plugin. +* +* @see pluginState +*/ +pluginState FestivalIntProc::getState() { return m_state; } + +/** +* Acknowledges a finished state and resets the plugin state to psIdle. +* +* If the plugin is not in state psFinished, nothing happens. +* The plugin may use this call to do any post-processing cleanup, +* for example, blanking the stored filename (but do not delete the file). +* Calling program should call getFilename prior to ackFinished. +*/ +void FestivalIntProc::ackFinished() +{ + if (m_state == psFinished) + { + m_state = psIdle; + m_synthFilename = QString::null; + } +} + +/** +* Returns True if the plugin supports asynchronous processing, +* i.e., returns immediately from sayText or synthText. +* @return True if this plugin supports asynchronous processing. +* +* If the plugin returns True, it must also implement @ref getState . +* It must also emit @ref sayFinished or @ref synthFinished signals when +* saying or synthesis is completed. +*/ +bool FestivalIntProc::supportsAsync() { return true; } + +/** +* Returns True if the plugin supports synthText method, +* i.e., is able to synthesize text to a sound file without +* audibilizing the text. +* @return True if this plugin supports synthText method. +*/ +bool FestivalIntProc::supportsSynth() { return true; } + +/** +* Returns the name of an XSLT stylesheet that will convert a valid SSML file +* into a format that can be processed by the synth. For example, +* The Festival plugin returns a stylesheet that will convert SSML into +* SABLE. Any tags the synth cannot handle should be stripped (leaving +* their text contents though). The default stylesheet strips all +* tags and converts the file to plain text. +* @return Name of the XSLT file. +*/ +QString FestivalIntProc::getSsmlXsltFilename() +{ + if (m_supportsSSML == ssYes) + return KGlobal::dirs()->resourceDirs("data").last() + "kttsd/festivalint/xslt/SSMLtoSable.xsl"; + else + return PlugInProc::getSsmlXsltFilename(); +} + diff --git a/kttsd/plugins/festivalint/festivalintproc.h b/kttsd/plugins/festivalint/festivalintproc.h new file mode 100644 index 0000000..a69642c --- /dev/null +++ b/kttsd/plugins/festivalint/festivalintproc.h @@ -0,0 +1,361 @@ +/***************************************************** vim:set ts=4 sw=4 sts=4: + Main speaking functions for the Festival (Interactive) Plug in + ------------------- + Copyright: + (C) 2004 by Gary Cramblitt <garycramblitt@comcast.net> + ------------------- + Original author: Gary Cramblitt <garycramblitt@comcast.net> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + ******************************************************************************/ + +#ifndef _FESTIVALINTPROC_H_ +#define _FESTIVALINTPROC_H_ + +#include <qstringlist.h> +#include <qmutex.h> + +#include <kprocess.h> + +#include <pluginproc.h> + +class QTextCodec; + +class FestivalIntProc : public PlugInProc{ + Q_OBJECT + + public: + enum SupportsSSML { + ssUnknown, + ssYes, + ssNo + }; + + /** + * Constructor + */ + FestivalIntProc( QObject* parent = 0, const char* name = 0, const QStringList &args = QStringList()); + + /** + * Destructor + */ + virtual ~FestivalIntProc(); + + /** + * Initializate the speech engine. + * @param config Settings object. + * @param configGroup Settings group. + */ + virtual bool init(KConfig *config, const QString &configGroup); + + /** + * Returns true when festival is ready to speak a sentence. + */ + bool isReady(); + + /** + * Say a text string. + * @param text The text to speak. + */ + virtual void sayText(const QString &text); + + /** + * Synthesize text into an audio file, but do not send to the audio device. + * @param text The text to be synthesized. + * @param suggestedFilename Full pathname of file to create. The plugin + * may ignore this parameter and choose its own + * filename. KTTSD will query the generated + * filename using getFilename(). + * + * If the plugin supports asynchronous operation, it should return immediately + * and emit @ref synthFinished signal when synthesis is completed. + * It must also implement the @ref getState method, which must return + * psFinished, when synthesis is completed. + */ + virtual void synthText(const QString &text, const QString &suggestedFilename); + + /** + * Get the generated audio filename from call to @ref synthText. + * @return Name of the audio file the plugin generated. + * Null if no such file. + * + * The plugin must not re-use or delete the filename. The file may not + * be locked when this method is called. The file will be deleted when + * KTTSD is finished using it. + */ + virtual QString getFilename(); + + /** + * Stop current operation (saying or synthesizing text). + * Important: This function may be called from a thread different from the + * one that called sayText or synthText. + * If the plugin cannot stop an in-progress @ref sayText or + * @ref synthText operation, it must not block waiting for it to complete. + * Instead, return immediately. + * + * If a plugin returns before the operation has actually been stopped, + * the plugin must emit the @ref stopped signal when the operation has + * actually stopped. + * + * The plugin should change to the psIdle state after stopping the + * operation. + */ + virtual void stopText(); + + /** + * Return the current state of the plugin. + * This function only makes sense in asynchronous mode. + * @return The pluginState of the plugin. + * + * @see pluginState + */ + virtual pluginState getState(); + + /** + * Acknowledges a finished state and resets the plugin state to psIdle. + * + * If the plugin is not in state psFinished, nothing happens. + * The plugin may use this call to do any post-processing cleanup, + * for example, blanking the stored filename (but do not delete the file). + * Calling program should call getFilename prior to ackFinished. + */ + virtual void ackFinished(); + + /** + * Returns True if the plugin supports asynchronous processing, + * i.e., returns immediately from sayText or synthText. + * @return True if this plugin supports asynchronous processing. + * + * If the plugin returns True, it must also implement @ref getState . + * It must also emit @ref sayFinished or @ref synthFinished signals when + * saying or synthesis is completed. + */ + virtual bool supportsAsync(); + + /** + * Returns True if the plugin supports synthText method, + * i.e., is able to synthesize text to a sound file without + * audibilizing the text. + * @return True if this plugin supports synthText method. + * + * If the plugin returns True, it must also implement the following methods: + * - @ref synthText + * - @ref getFilename + * - @ref ackFinished + * + * If the plugin returns True, it need not implement @ref sayText . + */ + virtual bool supportsSynth(); + + /** + * Say or Synthesize text with the given voice code. + * @param festivalExePath Path to the Festival executable, or just "festival". + * @param text The text to be synthesized. + * @param suggestedFilename If not Null, synthesize only to this filename, otherwise + * synthesize and audibilize the text. + * @param voiceCode Voice code. + * @param time Speed percentage. 50 to 200. 200% = 2x normal. + * @param pitch Pitch persentage. 50 to 200. + * @param volume Volume percentage. 50 to 200. + * @param languageCode Language code, for example, "en". + */ + void synth(const QString &festivalExePath, const QString &text, + const QString &synthFilename, const QString& voiceCode, + int time, int pitch, int volume, const QString &languageCode, + QTextCodec* codec); + + /** + * Sends commands to Festival to query for a list of supported voice codes. + * Fires queryVoicesFinished when completed. + * @return False if busy doing something else and therefore cannot + * do the query. + */ + bool queryVoices(const QString &festivalExePath); + + /** + * Returns the name of an XSLT stylesheet that will convert a valid SSML file + * into a format that can be processed by the synth. For example, + * The Festival plugin returns a stylesheet that will convert SSML into + * SABLE. Any tags the synth cannot handle should be stripped (leaving + * their text contents though). The default stylesheet strips all + * tags and converts the file to plain text. + * @return Name of the XSLT file. + */ + QString getSsmlXsltFilename(); + + /** + * Whether Festival supports SSML or not. + * 0 = Unknown + * 1 = Yes + * 2 = No + */ + SupportsSSML supportsSSML() { return m_supportsSSML; } + + signals: + /** + * This signal fires upon completion of a queryVoices operation. + * The list of voice codes do not have "voice_" prefix. + */ + void queryVoicesFinished(const QStringList &voiceCodes); + + private slots: + void slotProcessExited(KProcess* proc); + void slotReceivedStdout(KProcess* proc, char* buffer, int buflen); + void slotReceivedStderr(KProcess* proc, char* buffer, int buflen); + void slotWroteStdin(KProcess* proc); + + private: + /** + * Start Festival engine. + * @param festivalExePath Path to the Festival executable, or just "festival". + * @param voiceCode Voice code in which to speak text. + * @param languageCode Language code, for example, "en". + */ + void startEngine(const QString &festivalExePath, const QString &voiceCode, + const QString &languageCode, QTextCodec* codec); + + /** + * If ready for more output, sends the given text to Festival process, otherwise, + * puts it in the queue. + * @param text Text to send or queue. + */ + void sendToFestival(const QString& text); + + /** + * If Festival is ready for more input and there is more output to send, send it. + * To be ready for more input, the Stdin buffer must be empty and the "festival>" + * prompt must have been received (m_ready = true). + * @return False when Festival is ready for more input + * but there is nothing to be sent, or if Festival + * has exited. + */ + bool sendIfReady(); + + /** + * Determine if the text has SABLE tags. If so, we will have to use a different + * synthesis method. + */ + bool isSable(const QString &text); + + /** + * We attempt to shorten sentences longer than this by replacing commas with periods. + */ + static const int c_tooLong = 600; + + /** + * Path to the Festival executable. + */ + QString m_festivalExePath; + + /** + * Selected voice (from config). + */ + QString m_voiceCode; + + /** + * True if the voice is preloaded. Also used as a flag to supress killing + * Festival, since startup time will be excessive. + */ + bool m_preload; + + /** + * Selected speed (from config). + */ + int m_time; + + /** + * Selected pitch (frequency) (from config). + */ + int m_pitch; + + /** + * Selected volume (from config). + */ + int m_volume; + + /** + * Running voice. + */ + QString m_runningVoiceCode; + + /** + * Running time (speed). + */ + int m_runningTime; + + /** + * Running pitch (frequency). + */ + int m_runningPitch; + + /** + * Festival process + */ + KProcess* m_festProc; + + /** + * Synthesis filename. + */ + QString m_synthFilename; + + /** + * True when festival is ready for another input. + */ + volatile bool m_ready; + + /** + * Plugin state. + */ + pluginState m_state; + + /** + * True when stopText has been called. Used to force transition to psIdle when + * Festival exits. + */ + bool m_waitingStop; + + /** + * True when queryVoices has been called. + */ + bool m_waitingQueryVoices; + + /** + * A queue of outputs to be sent to the Festival process. + * Since Festival requires us to wait until the "festival>" prompt before + * sending the next command, this queue allows us to queue up multiple + * commands and send each one when the ReceivedStdOut signal fires. + */ + QStringList m_outputQueue; + + bool m_writingStdin; + + /** + * Language code. + */ + QString m_languageCode; + + /** + * Codec. + */ + QTextCodec* m_codec; + + /** + * Flag if SSML is supported. Festival cannot support SABLE (and therefore SSML) + * unless rab_diphone (British male) is installed. Gawd, I hope Festival folks fix this! + */ + SupportsSSML m_supportsSSML; +}; + +#endif // _FESTIVALINTPROC_H_ diff --git a/kttsd/plugins/festivalint/kttsd_festivalintplugin.desktop b/kttsd/plugins/festivalint/kttsd_festivalintplugin.desktop new file mode 100644 index 0000000..e8776da --- /dev/null +++ b/kttsd/plugins/festivalint/kttsd_festivalintplugin.desktop @@ -0,0 +1,72 @@ +[Desktop Entry] +Name=Festival Interactive +Name[da]=Festival Interaktiv +Name[el]=Διαδραστικό Festival +Name[eu]=Festival interaktiboa +Name[fa]=Festival تعاملی +Name[fi]=Interaktiivinen Festival +Name[ga]=Festival Idirghníomhach +Name[gl]=Festival Interactivo +Name[is]=Festival gagnvirkni +Name[it]=Festival Interattivo +Name[ja]=Festival インタラクティブ +Name[ka]=Festival ინტერაქტიული +Name[km]=អន្តរមុខងារ +Name[mk]=Интерактивен festival +Name[ms]=Interaktif Perayaan +Name[ne]=अन्तरक्रियात्मक फेस्टिभल +Name[pa]=ਫੈਸੀਟੇਵਲ ਇੰਟਰੇਕਟਵ +Name[pl]=Festival interaktywny +Name[pt_BR]=Festival Interativo +Name[sv]=Festival interaktiv +Name[ta]=பெஸ்டிவல் உள்செயல் +Name[tg]=Фестивали Интерактив +Name[tr]=Etkileşimli Festival +Name[vi]=Tương tác Festival +Comment=Festival speech synthetizer +Comment[bg]=Синтезатор на глас Festival +Comment[ca]=Sintetitzador de veu Festival +Comment[cs]=Hlasový syntetizér Festival +Comment[da]=Festival tale-synthetizer +Comment[de]=Festival Sprachsynthesizer +Comment[el]=Συνθέτης ομιλίας Festival +Comment[es]=Sintetizador de texto a voz Festival +Comment[et]=Kõnesüntesaator Festival +Comment[eu]=Festival hizketa-sintetizadorea +Comment[fa]=ترکیبدهندۀ گفتار Festival +Comment[fi]=Festival puhesyntetisaattori +Comment[fr]=Synthèse vocale Festival +Comment[ga]=Sintéiseoir cainte Festival +Comment[gl]=Sistetizador de voces Festival +Comment[hu]=Festival beszédszintetizátor +Comment[is]=Festival talgerfill +Comment[it]=Sintetizzatore vocale Festival +Comment[ja]=Festival スピーチシンセサイザ +Comment[ka]=Festival ხმის სინთეზატორი +Comment[km]= មុខងារកម្មវិធីសង្គ្រោះការនិយាយ +Comment[mk]=Синтетизатор за говор festival +Comment[ms]=Pensintesis tutur perayaan +Comment[nb]=Festival talesyntetisering +Comment[nds]=Blicksnuut Festival +Comment[ne]=संवाद सिन्थेसाइजर फेस्टिभल +Comment[nl]=Festival spraaksynthetizer +Comment[pa]=ਫੈਸੀਟੇਵਲ ਬੋਲੀ ਸੰਸਲੇਸ਼ਕ +Comment[pl]=Syntezator mowy Festival +Comment[pt]=O sintetizador de fala Festival +Comment[pt_BR]=Sistema de Sintetizador de Fala Festival +Comment[ru]=Синтезатор речи Festival +Comment[sk]=Syntetizátor reči Festival +Comment[sl]=Sintetizator govora Festival +Comment[sr]=Синтетизатор говора Festival +Comment[sr@Latn]=Sintetizator govora Festival +Comment[sv]=Festival talsyntes +Comment[ta]=பெஸ்டிவல் பேச்சு கூட்டிணைப்பான் +Comment[tg]=Таҳлилгари овози Festival +Comment[tr]=Festival konuşma bireştirici +Comment[uk]=Синтезатор мовлення Festival +Comment[vi]=Trình tổng hợp tiếng nói Festival +Comment[zh_TW]=Festival 語音合成器 +Type=Service +ServiceTypes=KTTSD/SynthPlugin +X-KDE-Library=libkttsd_festivalintplugin +X-KDE-Languages=en,en_US,en_GB,en_CA,es,es_mx,cy,de,fi,cs,pl,ru,it,sw,zu,fr_CA,vi diff --git a/kttsd/plugins/festivalint/sabletowave.scm b/kttsd/plugins/festivalint/sabletowave.scm new file mode 100644 index 0000000..71293b4 --- /dev/null +++ b/kttsd/plugins/festivalint/sabletowave.scm @@ -0,0 +1,92 @@ +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-*-mode:scheme-*- +;; ;; +;; Centre for Speech Technology Research ;; +;; University of Edinburgh, UK ;; +;; Copyright (c) 1996,1997 ;; +;; All Rights Reserved. ;; +;; ;; +;; Permission is hereby granted, free of charge, to use and distribute ;; +;; this software and its documentation without restriction, including ;; +;; without limitation the rights to use, copy, modify, merge, publish, ;; +;; distribute, sublicense, and/or sell copies of this work, and to ;; +;; permit persons to whom this work is furnished to do so, subject to ;; +;; the following conditions: ;; +;; 1. The code must retain the above copyright notice, this list of ;; +;; conditions and the following disclaimer. ;; +;; 2. Any modifications must be clearly marked as such. ;; +;; 3. Original authors' names are not deleted. ;; +;; 4. The authors' names are not used to endorse or promote products ;; +;; derived from this software without specific prior written ;; +;; permission. ;; +;; ;; +;; THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK ;; +;; DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ;; +;; ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT ;; +;; SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE ;; +;; FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ;; +;; WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ;; +;; AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ;; +;; ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF ;; +;; THIS SOFTWARE. ;; +;; ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Author: Alan W Black +;;; Date: November 1997 +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; Adapted from text2wave by Alan Black. Original copyright listed above. +;; +;; Copyright 2004 by Gary Cramblitt <garycramblitt@comcast.net> +;; +;; This scheme module is used by the Festival Interactive plugin, +;; which is part of KTTSD. To use, +;; (load sabletowave.scm) +;; after starting Festival interactively, then to synth text containing +;; SABLE tags to a single wave file. +;; (ktts_sabletowave "sable text" "filename" volume) +;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;;; List of generated intermediate wave files. +(defvar ktts_wavefiles nil) + +(define (ktts_save_record_wave utt) +"Saves the waveform and records its so it can be joined into a +a single waveform at the end." + (let ((fn (make_tmp_filename))) + (utt.save.wave utt fn) + (set! ktts_wavefiles (cons fn ktts_wavefiles)) + utt)) + +(define (ktts_combine_waves outfile volume) + "Join all the waves together into the desired output file +and delete the intermediate ones." + (let ((wholeutt (utt.synth (Utterance Text "")))) + (mapcar + (lambda (d) + (utt.import.wave wholeutt d t) + (delete-file d)) + (reverse ktts_wavefiles)) +;; (if ktts_frequency +;; (utt.wave.resample wholeutt (parse-number ktts_frequency))) + (if (not (equal? volume "1.0")) + (begin + (utt.wave.rescale wholeutt (parse-number volume)))) + (utt.save.wave wholeutt outfile 'riff) + )) + +;;; +;;; Redefine what happens to utterances during text to speech. +;;; Synthesize each utterance and save to a temporary wave file. +;;; +(set! tts_hooks (list utt.synth ktts_save_record_wave)) + +(define (ktts_sabletowave text filename volume) + (set! ktts_wavefiles nil) + ;; Do the synthesis, which creates multiple wave files. + (tts_text text 'sable) + ;; Now put the waveforms together and adjust volume. + (ktts_combine_waves filename volume) +) diff --git a/kttsd/plugins/festivalint/voices b/kttsd/plugins/festivalint/voices new file mode 100644 index 0000000..f6c0d58 --- /dev/null +++ b/kttsd/plugins/festivalint/voices @@ -0,0 +1,738 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<voices> + +<voice> + <code>kal_diphone</code> + <language>en_US</language> + <codec>ISO 8859-1</codec> + <gender>male</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>true</pitch-adjustable> + <name>American Male</name> +</voice> + +<voice> + <code>ked_diphone</code> + <language>en_US</language> + <codec>ISO 8859-1</codec> + <gender>male</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>true</pitch-adjustable> + <name>American Male</name> +</voice> + +<voice> + <code>us1_mbrola</code> + <language>en_US</language> + <codec>ISO 8859-1</codec> + <gender>female</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>true</pitch-adjustable> + <name>American Female, MBROLA</name> +</voice> + +<voice> + <code>us2_mbrola</code> + <language>en_US</language> + <codec>ISO 8859-1</codec> + <gender>male</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>true</pitch-adjustable> + <name>American Male, MBROLA</name> +</voice> + +<voice> + <code>us3_mbrola</code> + <language>en_US</language> + <codec>ISO 8859-1</codec> + <gender>male</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>true</pitch-adjustable> + <name>American Male, MBROLA</name> +</voice> + +<voice> + <code>don_diphone</code> + <language>en_GB</language> + <codec>ISO 8859-1</codec> + <gender>male</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>true</pitch-adjustable> + <name>British Male</name> +</voice> + +<voice> + <code>rab_diphone</code> + <language>en_GB</language> + <codec>ISO 8859-1</codec> + <gender>male</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>true</pitch-adjustable> + <name>British Male</name> +</voice> + +<voice> + <code>el_diphone</code> + <language>es</language> + <codec>ISO 8859-1</codec> + <gender>male</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>false</pitch-adjustable> + <name>Castilian Spanish Male</name> +</voice> + +<voice> + <code>cmu_us_bdl_arctic_hts</code> + <language>en_US</language> + <codec>ISO 8859-1</codec> + <gender>male</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>false</pitch-adjustable> + <name>American Male, HTS</name> +</voice> + +<voice> + <code>cmu_us_slt_arctic_hts</code> + <language>en_US</language> + <codec>ISO 8859-1</codec> + <gender>female</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>false</pitch-adjustable> + <name>American Female, HTS</name> +</voice> + +<voice> + <code>cmu_us_jmk_arctic_hts</code> + <language>en_CA</language> + <codec>ISO 8859-1</codec> + <gender>male</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>false</pitch-adjustable> + <name>Canadian English Male, HTS</name> +</voice> + +<voice> + <code>cmu_us_awb_arctic_hts</code> + <language>en_GB</language> + <codec>ISO 8859-1</codec> + <gender>male</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>false</pitch-adjustable> + <name>Scottish Male, HTS</name> +</voice> + +<voice> + <code>cmu_us_kal_com_hts</code> + <language>en_US</language> + <codec>ISO 8859-1</codec> + <gender>male</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>false</pitch-adjustable> + <name>American Male, HTS</name> +</voice> + +<voice> + <code>cstr_us_ked_timit_hts</code> + <language>en_US</language> + <codec>ISO 8859-1</codec> + <gender>male</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>false</pitch-adjustable> + <name>American Male, HTS</name> +</voice> + +<voice> + <code>cstr_us_jmk_arctic_multisyn</code> + <language>en_CA</language> + <codec>ISO 8859-1</codec> + <gender>male</gender> + <preload>true</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>false</rate-adjustable> + <pitch-adjustable>false</pitch-adjustable> + <name>Canadian English Male, MultiSyn</name> +</voice> + +<voice> + <code>cstr_us_awb_arctic_multisyn</code> + <language>en_GB</language> + <codec>ISO 8859-1</codec> + <gender>male</gender> + <preload>true</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>false</rate-adjustable> + <pitch-adjustable>false</pitch-adjustable> + <name>Scottish Male, MultiSyn</name> +</voice> + +<voice> + <code>german_de1_os</code> + <language>de</language> + <codec>ISO 8859-1</codec> + <gender>female</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>false</pitch-adjustable> + <name>German Female, Festival</name> +</voice> + +<voice> + <code>german_de2_os</code> + <language>de</language> + <codec>ISO 8859-1</codec> + <gender>male</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>false</pitch-adjustable> + <name>German Male, Festival</name> +</voice> + +<voice> + <code>german_de3_os</code> + <language>de</language> + <codec>ISO 8859-1</codec> + <gender>female</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>false</pitch-adjustable> + <name>German Female, Festival</name> +</voice> + +<voice> + <code>abc_diphone</code> + <language>es</language> + <codec>ISO 8859-1</codec> + <gender>male</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>true</pitch-adjustable> + <name>Mexican Spanish Male, OGC</name> +</voice> + +<voice> + <code>hvs_diphone</code> + <language>es</language> + <codec>ISO 8859-1</codec> + <gender>female</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>true</pitch-adjustable> + <name>Mexican Spanish Female, OGC</name> +</voice> + +<voice> + <code>mwm_diphone</code> + <language>en_US</language> + <codec>ISO 8859-1</codec> + <gender>male</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>true</pitch-adjustable> + <name>American Male, OGC</name> +</voice> + +<voice> + <code>aec_diphone</code> + <language>en_US</language> + <codec>ISO 8859-1</codec> + <gender>male</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>true</pitch-adjustable> + <name>American Male, OGC</name> +</voice> + +<voice> + <code>jph_diphone</code> + <language>en_US</language> + <codec>ISO 8859-1</codec> + <gender>male</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>true</pitch-adjustable> + <name>American Male, OGC</name> +</voice> + +<voice> + <code>tll_diphone</code> + <language>en_US</language> + <codec>ISO 8859-1</codec> + <gender>female</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>true</pitch-adjustable> + <name>American Female, OGC</name> +</voice> + +<voice> + <code>ogirab_diphone</code> + <language>en_UK</language> + <codec>ISO 8859-1</codec> + <gender>male</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>true</pitch-adjustable> + <name>British Male, OGC</name> +</voice> + +<voice> + <code>mwm2jph_diphone</code> + <language>en_US</language> + <codec>ISO 8859-1</codec> + <gender>male</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>true</pitch-adjustable> + <name>American Male, OGC</name> +</voice> + +<voice> + <code>mwm2tll_diphone</code> + <language>en_US</language> + <codec>ISO 8859-1</codec> + <gender>female</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>true</pitch-adjustable> + <name>American Female, OGC</name> +</voice> + +<voice> + <code>hy_fi_mv_diphone</code> + <language>fi</language> + <codec>ISO 8859-1</codec> + <gender>male</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>false</pitch-adjustable> + <name>Finnish Male</name> +</voice> + +<voice> + <code>czech_mbrola_cz2</code> + <language>cs_CZ</language> + <codec>ISO 8859-2</codec> + <gender>male</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>false</pitch-adjustable> + <name>Czech Male, MBROLA</name> +</voice> + +<voice> + <code>cstr_pl_em_diphone</code> + <language>pl</language> + <codec>ISO 8859-2</codec> + <gender>male</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>true</pitch-adjustable> + <name>Polish Male</name> +</voice> + +<voice> + <code>msu_ru_nsh_diphone</code> + <language>ru</language> + <codec>KOI8-R</codec> + <gender>male</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>false</pitch-adjustable> + <name>Russian Male</name> +</voice> + +<voice> + <code>pc_diphone</code> + <language>it</language> + <codec>ISO 8859-1</codec> + <gender>male</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>false</pitch-adjustable> + <name>Italian Male</name> +</voice> + +<voice> + <code>lp_diphone</code> + <language>it</language> + <codec>ISO 8859-1</codec> + <gender>female</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>false</pitch-adjustable> + <name>Italian Female</name> +</voice> + +<voice> + <code>lp_mbrola</code> + <language>it</language> + <codec>ISO 8859-1</codec> + <gender>female</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>false</pitch-adjustable> + <name>Italian Female</name> +</voice> + +<voice> + <code>pc_mbrola</code> + <language>it</language> + <codec>ISO 8859-1</codec> + <gender>female</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>false</pitch-adjustable> + <name>Italian Male</name> +</voice> + +<voice> + <code>pc_ogi_diphone</code> + <language>it</language> + <codec>ISO 8859-1</codec> + <gender>male</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>false</pitch-adjustable> + <name>Italian Male</name> +</voice> + +<voice> + <code>lp_ogi_diphone</code> + <language>it</language> + <codec>ISO 8859-1</codec> + <gender>female</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>false</pitch-adjustable> + <name>Italian Female</name> +</voice> + +<voice> + <code>UON_swahili_kw_multisyn</code> + <language>sw</language> + <codec>ISO 8859-1</codec> + <gender>male</gender> + <preload>true</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>false</rate-adjustable> + <pitch-adjustable>false</pitch-adjustable> + <name>Kiswahili Male</name> +</voice> + +<voice> + <code>uyo_ibibio_eno_multisyn</code> + <!-- There is no iso 639 (two-letter) code for ibibio. We use Zulu here. + The iso 639-2 (three-letter) code is nic (Niger-Kordofanian) --> + <language>zu</language> + <codec>ISO 8859-1</codec> + <gender>female</gender> + <preload>true</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>false</rate-adjustable> + <pitch-adjustable>false</pitch-adjustable> + <name>Ibibio Female</name> +</voice> + +<voice> + <code>csir_isizulu_buhle_multisyn</code> + <language>zu</language> + <codec>ISO 8859-1</codec> + <gender>male</gender> + <preload>true</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>false</rate-adjustable> + <pitch-adjustable>false</pitch-adjustable> + <name>Zulu Male</name> +</voice> + +<voice> + <code>cepstral_david</code> + <language>en_US</language> + <codec>ISO 8859-1</codec> + <gender>male</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>false/</pitch-adjustable> + <name>American Male</name> +</voice> + +<voice> + <code>cepstral_diane</code> + <language>en_US</language> + <codec>ISO 8859-1</codec> + <gender>female</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>false/</pitch-adjustable> + <name>American Female</name> +</voice> + +<voice> + <code>cepstral_william</code> + <language>en_US</language> + <codec>ISO 8859-1</codec> + <gender>male</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>false/</pitch-adjustable> + <name>American Male</name> +</voice> + +<voice> + <code>cepstral_amy</code> + <language>en_US</language> + <codec>ISO 8859-1</codec> + <gender>female</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>false/</pitch-adjustable> + <name>American Female</name> +</voice> + +<voice> + <code>cepstral_frank</code> + <language>en_US</language> + <codec>ISO 8859-1</codec> + <gender>male</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>false/</pitch-adjustable> + <name>American Male</name> +</voice> + +<voice> + <code>cepstral_emily</code> + <language>en_US</language> + <codec>ISO 8859-1</codec> + <gender>female</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>false/</pitch-adjustable> + <name>American Female</name> +</voice> + +<voice> + <code>cepstral_duncan</code> + <language>en_US</language> + <codec>ISO 8859-1</codec> + <gender>male</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>false/</pitch-adjustable> + <name>American Male</name> +</voice> + +<voice> + <code>cepstral_linda</code> + <language>en_US</language> + <codec>ISO 8859-1</codec> + <gender>female</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>false/</pitch-adjustable> + <name>American Female</name> +</voice> + +<voice> + <code>cepstral_robin</code> + <language>en_US</language> + <codec>ISO 8859-1</codec> + <gender>female</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>false/</pitch-adjustable> + <name>American Female</name> +</voice> + +<voice> + <code>cepstral_walter</code> + <language>en_US</language> + <codec>ISO 8859-1</codec> + <gender>male</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>false/</pitch-adjustable> + <name>American Male</name> +</voice> + +<voice> + <code>cepstral_lawrence</code> + <language>en_UK</language> + <codec>ISO 8859-1</codec> + <gender>male</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>false/</pitch-adjustable> + <name>British Male</name> +</voice> + +<voice> + <code>cepstral_millie</code> + <language>en_UK</language> + <codec>ISO 8859-1</codec> + <gender>female</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>false/</pitch-adjustable> + <name>British Female</name> +</voice> + +<voice> + <code>cepstral_jean-pierre</code> + <language>fr_CA</language> + <codec>ISO 8859-1</codec> + <gender>male</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>false/</pitch-adjustable> + <name>French Canadian Male</name> +</voice> + +<voice> + <code>cepstral_isabelle</code> + <language>fr_CA</language> + <codec>ISO 8859-1</codec> + <gender>female</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>false/</pitch-adjustable> + <name>French Canadian Female</name> +</voice> + +<voice> + <code>cepstral_matthias</code> + <language>de</language> + <codec>ISO 8859-1</codec> + <gender>male</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>false/</pitch-adjustable> + <name>German Male</name> +</voice> + +<voice> + <code>cepstral_katrin</code> + <language>de</language> + <codec>ISO 8859-1</codec> + <gender>female</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>false/</pitch-adjustable> + <name>German Female</name> +</voice> + +<voice> + <code>cepstral_miguel</code> + <language>es</language> + <codec>ISO 8859-1</codec> + <gender>male</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>false/</pitch-adjustable> + <name>Americas Spanish Male</name> +</voice> + +<voice> + <code>cepstral_marta</code> + <language>es</language> + <codec>ISO 8859-1</codec> + <gender>female</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <rate-adjustable>true</rate-adjustable> + <pitch-adjustable>false/</pitch-adjustable> + <name>Americas Spanish Female</name> +</voice> + +<voice> + <code>wow_vi_ptn_diphone</code> + <language>vi</language> + <codec>UTF-8</codec> + <gender>male</gender> + <preload>false</preload> + <volume-adjustable>true</volume-adjustable> + <speed-adjustable>true></speed-adjustable> + <pitch-adjustable>false</pitch-adjustable> + <name>Vietnamese Male</name> +</voice> + +<voice> + <code>wow_vi_liz_diphone</code> + <language>vi</language> + <codec>UTF-8</codec> + <gender>female</gender> + <volume-adjustable>true</volume-adjustable> + <speed-adjustable>true</speed-adjustable> + <pitch-adjustable>false</pitch-adjustable> + <name>Vietnamese Female</name> +</voice> + +</voices> |