Filters are an advanced feature of KTTS. For the basic operation of KTTS, they are not needed.
Filters are used to pre-process text before it is sent to the speech synthesis engine. They are useful for enhancing speech, substituting for misspoken words or abbreviations, choosing the appropriate language and talker to do the speaking, or working around certain limitations of speech synthesizers and their voices.
To understand how to use filters, it is helpful to first understand how text is processed by KTTS. Text spoken by KTTS is of four possible types.
Screen Reader Output.
Warnings.
Messages
Text Jobs
The type is determined by the application that sends the text to KTTS.
Screen Reader Output has the highest priority. It is reserved for use by Screen Reader applications. Screen Reader Output preempts all other messages, causing those jobs to pause. Once the Screen Reader Output has been spoken, the preempted messages will automatically resume.
Warnings are the next highest priority. It is reserved for high-priority messages, such as "CPU is over-heating." A Warning will preempt Messages and regular text, causing those jobs to pause. Once the Warning has been spoken, the preempted messages will automatically resume.
Messages are the next highest priority. A Message will preempt regular text jobs. KMouth is an example of an application that uses Messages. For example, while reading out long text from a web page, KMouth can be used to greet someone who walks into the room. KDE Notifications are also Messages (see the section called “Speaking Notifications (KNotify)”).
The rest are ordinary Text Jobs. Any job you initiate from the Jobs tab is a Text Job. KSayit is an example of an application that uses Text Jobs. Text Jobs are intended for longer speech output that is not urgent.
All four kinds of jobs are queues, except for Screen Reader Output. If a Screen Reader Output is sent from an application while KTTS is speaking another Screen Reader Output, the speaking message is stopped and discarded.
The first thing you must know about filters is that they are never applied to Screen Reader Output. They are applied to Warnings, Messages, and Text jobs, and also KDE notifications (KNotify).
There are two kinds of filters -- ordinary filters and Sentence Boundary Detector (SBD) filters. SBDs break text up into individual sentences. This allows KTTS to begin speaking faster because it need only synthesize the first sentence; not the entire Text Job. It also permits you to advance or rewind by sentence in the Jobs tab, or to stop or pause Text Jobs when the speech synthesizer does not directly support stopping of speech.
Ordinary filters process the text and pass it on to the next filter. There are currently three kinds of ordinary filters.
String Replacers.
XML Transformers
Talker Choosers.
Filters are implemented using a plugin architecture. In the future, there may be additional kinds of filters.
String Replacer filters substitute pieces of text with other text. The replaced pieces are matched either as words or as regular expressions. KTTS comes with pre-defined String Replacer filters for speaking abbreviations, speaking chat emoticons, such as ":-)", or reformatting notification messages from Konversation or KMail into a more understandable form.
XML Transformers use an XML Style Language - Transforms (XSLT) file to convert XML of one format to another format. KTTS comes with a couple of XSLT files for converting XHTML into SSML.
Talker Choosers permit you redirect jobs to a talker based on the contents of the text, or upon the application that sent it to KTTS. For example, if you have configured a female talker in the Talkers tab, you can direct text coming from KSayIt to that talker. See the section called “Configuring Synthesis Plugins (Talkers)”.
Each of these kinds of filters has configurable rules for when the filter should apply itself to the text to be spoken. If the filter determines that it should not apply itself, the text is passed on to the next filter unaltered.
When a Text Job, Message, Warning, or KDE Notification message is sent to KTTS, it passes through each of the enabled filters you have configured in the screen below. The order is from top to bottom. After passing through each of the ordinary filters listed in the top portion of the screen, Text Jobs are passed to the Sentence Boundary Detector (SBD) filters. (KDE Notifications, Warnings, and Messages never pass through SBD filters.) Unlike ordinary filters, the first SBD filter that makes changes to the text stops any further filtering.
To use filters, click the Filters tab in kttsmgr.
![]() | This is the list of configured ordinary filters. If unchecked, the filter is inactive and will be bypassed. Filters are applied in the order specified here, top to bottom. |
![]() | Click here to add a new filter. You will be prompted for the kind of filter to add. After choosing the kind, see the configuration dialogs below. |
![]() | Click here to remove a filter. |
![]() | Click here to change the configuration of a filter. See the configuration dialogs below. |
![]() | Click these buttons to move a filter up or down in the list. |
![]() | These are the Sentence Boundary Detector filters. When you first start KTTS, the Standard Sentence Boundary Detector is automatically configured for you. You can change this filter's configuration, or add additional Sentence Boundary Detectors, but we advise beginners not to change them. |
![]() | This drop-down button permits you to add, remove, edit, or change the order of Sentence Boundary Detector filters. |
![]() | Be sure to click here, otherwise your settings will not take effect. |
You configure String Replacer filters by supplying a list of words or regular expressions to be matched. When the matched words or regular expressions are found in the text, each is replaced by a substitute string you supply. Matching is case insensitive.
![]() | Enter a name for your filter. Use any name you like that distinquishes it from all other filters. |
![]() | This is the list of words and regular expressions. The filter searches for matches on each string in the Match column, replacing the matched string with the string in the Replace With column. The list is processed in the order displayed, top to bottom. |
![]() | Click here to add another word or regular expression to the list. |
![]() | Click here to move the currently highlighted word or regular expression up or down in the list. |
![]() | Click to change an existing word or regular expression in the list. |
![]() | Click to remove the currently highlighted word or regular expression from the list. |
![]() | Use these buttons to load a list of words or regular expression from a file, save the current list to a file, or clear the entire list. When loading from a file, the items in the file are appended to the existing list. |
![]() | If not blank, the filter will apply itself only if the job's talker language matches the language you enter here. Click the button to display a list of languages. You may select more than one language by pressing Ctrl while clicking. |
![]() | If not blank, the filter will
apply itself only if the text came from one of the applications listed.
You may enter more than one application separated by commas.
Example: TipYou can discover the Application ID
of running programs using the kdcop program.
You should leave the DCOP numbers out. For example, if kdcop shows
an Application ID of kopete-3432, you would just
enter |
The String Replacer filter will only apply itself to the text if all non-blank conditions are met in the Apply This Filter When box. if all the boxes are blank, the filter will apply to all text.
All matching is case insensitive.
When matching words, the String Replacer filter internally uses a
regular expression of the form \sword
\s.
In other words, the word must have word boundaries (spaces) on either side of it.
A discussion on how to write regular expressions is outside the scope of this handbook. If you have the KDE Regular Expression editor installed, there is a button available on the Add or Edit screens that will assist you at constructing regular expressions. The KDE Regular Expression Editor is part of the tdeutils package.
KTTS comes with a few word list files, including a list of emoticons, such as ":-)", some abbreviations typically used in IRC or instant messaging applications, and a list of other abbreviations. There is also a list of special characters which the current version of the Polish Festival voice cannot handle. If you develop useful word lists of your own, use the button to save them to a file and send them to the KTTS team for inclusion in the next version.
The XML Transformer filter uses XSLT files to transform XML from one format to another. XSLT, the XML Style Language - Transforms, is a W3C standard language for performing such transformations. It can only be used on well-formed XML. You must have the xsltproc utility installed.
![]() | Enter a name for your filter. Use any name you like that distinquishes it from all other filters. |
![]() | Enter the full path to an existing XSLT file, which will perform the transformation. |
![]() | Specify the path to the
xsltproc utility. If xsltproc is in your environment
PATH, simply enter |
![]() | If not blank, the filter
will apply itself only if the XML has the specified root element
or a <!DOCTYPE specification
beginning with the entered string. This distinquishes one
form of XML from another. For example,
|
![]() | If not blank, the filter will
apply itself only if the text came from one of the applications listed.
You may enter more than one application separated by commas.
Example: TipYou can discover the Application ID
of running programs using the kdcop program.
You should leave the DCOP numbers out. For example, if kdcop shows
an Application ID of kopete-3432, you would just
enter |
The XML Transformer filter will only apply itself to the text if the specified root element or DOCTYPE are met and if the application ID is met in the Apply This Filter When box. If an item in this box is blank, the test is not performed, so if all the boxes are blank, the filter will apply itself to all text. However, you should fill in at least one box, since many text jobs will not be in XML format.
Talker Chooser filters are used to direct the text to a desired talker configured in the Talker tab, or to any talker having specified attributes. For example, you can specify that text coming from kmail should be spoken using a talker configured with a female voice. See the section called “Configuring Synthesis Plugins (Talkers)”.
Just before KTTS begins sending text to each of the filters, it picks a talker to speak the text. The talker chosen is based on the talker attributes specified by the application that sent the text to KTTS and the attributes of the talkers that you have configured on the Talkers tab. The Talker Chooser filter permits you to override the chosen talker.
![]() | Enter a name for your filter. Use any name you like that distinquishes it from all other filters. |
![]() | If not blank, the filter will apply itself only if the text contains the entered regular expression. If it is installed, click the browse button to launch the KDE Regular Expression Editor to assist you at entering the regular expression. TipFor better performance, try to "anchor" the regular expression to the
start of the string. In other words, start your regular expression with
|
![]() | If not blank, the filter will
apply itself only if the text came from one of the applications listed.
You may enter more than one application separated by commas.
Example: TipYou can discover the Application ID
of running programs using the kdcop program.
You should leave the DCOP numbers out. For example, if kdcop shows
an Application ID of kopete-3432, you would just
enter |
![]() | Specify the attributes of the talker you prefer to speak the text here. If the text meets the filter conditions above, a talker will be chosen that most closely matches the attributes you specify here. Click the button at the right to display the Select Talker screen. See the section called “Selecting Talkers (Advanced)”. |
![]() | Use these buttons to save your Talker Chooser settings, load settings from a saved file, or clear all the settings. |
The Talker Chooser filter will only apply itself to the text if all non-blank conditions are met in the Apply This Filter When box. You must fill in at least one of the boxes.
The easiest way to learn how to configure Talker Choosers is to experiment. Disable the Talker Chooser and submit some text. In the Jobs tab, note the talker that KTTS chooses. Click the button, enter some attributes, and try again to see how the choice is affected. Of course, you must have more than one talker configured for the Talker Chooser to do anything.
Sentence Boundary Detector (SBD) filters break text up into individual sentences. This is important because it
allows KTTS to begin speaking faster because it need only synthesize the first sentence, rather than the entire block of text, which might be very long, and
allows you to rewind and advance by sentences in the Jobs tab, and
allows you to pause or stop Text Jobs in the Jobs tab even if the speech synthesizer is not capable of being stopped.
For these reasons, the Standard Sentence Boundary Detector filter is automatically configured the first time you run kttsmgr and cannot be disabled (although you can remove it). We advise you not to modify this filter unless you know what you are doing.
You can, however, add additional SBD filters to solve certain
problems. For example, as of February 2005, the Polish Festival voice
has the annoying attribute of speaking sentence punctuation. It will
speak the periods at the end of each sentence, for instance. You cannot solve this problem
by creating a String Replacer filter to remove the sentence punctuation,
because doing so will prevent the Standard SBD from recognizing any
sentences. Instead, you can create a modified version of the
Standard SBD that recognizes sentences while simultaneously removing
the sentence punctuation. To do this, add an SBD filter and use the
button to load the polish_festival_sbdrc
file that comes with KTTS.
SBD filters work by matching an end-of-sentence regular expression and inserting Tab (decimal 8) characters at the sentence boundaries. (All Tab characters are automatically stripped from text before filtering begins.) Note that the Standard SBD preserves the sentence punctuation.
SBD filters are never applied to KDE Notification messages (knotify), Warnings, Messages, or Screen Reader Outputs.
If you accidentally remove the Standard Sentence Boundary Detectory filter,
you can get it back by loading the standard_sbdrc
file,
which comes with KTTS.
Would you like to comment or contribute an update to this page?
Send feedback to the TDE Development Team