Filters (Advanced)

Filters are an advanced feature of Jovie. For the basic operation of Jovie, they are not needed.

Filters are used to pre-process text before it is sent to speech-dispatcher. 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.

Types of Jovie Messages

To understand how to use filters, it is helpful to first understand how text is processed by speech-dispatcher. Text spoken by Jovie is of four possible types.

  • Screen Reader Output.

  • Warnings.

  • Messages

  • Text Jobs

The type is determined by the application that sends the text to Jovie.

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 Jovie is speaking another Screen Reader Output, the speaking message is stopped and discarded.

Types of Filters

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).

Filters process the text and pass it on to the next filter. There are currently three kinds of filters.

  • String Replacers.

  • XML Transformers

  • Talker Choosers.

Note

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. Jovie 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. Jovie 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 Jovie. 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 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 Jovie, it passes through each of the enabled filters you have configured in the screen below. The order is from top to bottom.

Configuring Filters

To use filters, click the Filters tab in jovie.


The KDE Text-to-Speech Manager (Filters tab)

1

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.

2

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.

3

Click here to remove a filter.

4

Click here to change the configuration of a filter. See the configuration dialogs below.

5

Click these buttons to move a filter up or down in the list.

6

Be sure to click here, otherwise your settings will not take effect.

Configuring String Replacer Filters

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.


String Replacer

1

Enter a name for your filter. Use any name you like that distinguishes it from all other filters.

2

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.

3

Click here to add another word or regular expression to the list.

4

Click here to move the currently highlighted word or regular expression up or down in the list.

5

Click to change an existing word or regular expression in the list.

6

Click to remove the currently highlighted word or regular expression from the list.

7

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.

8

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.

9

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: konversation,kmail

Tip

You can discover the Application ID of running programs using the qdbus program. You should leave the D-Bus numbers out. For example, if qdbus shows an Application ID of kopete-3432, you would just enter kopete.

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.

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 Utils Git module in playground.

Jovie 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 Save button to save them to a file and send them to the Jovie team for inclusion in the next version.

Configuring XML Transformer Filters

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.


XML Transformer

1

Enter a name for your filter. Use any name you like that distinguishes it from all other filters.

2

Enter the full path to an existing XSLT file, which will perform the transformation.

3

Specify the path to the xsltproc utility. If xsltproc is in your environment PATH, simply enter xsltproc.

4

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 distinguishes one form of XML from another. For example, html in the DOCTYPE box will match <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">.

5

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: konversation,kmail

Tip

You can discover the Application ID of running programs using the qdbus program. You should leave the D-Bus numbers out. For example, if qdbus shows an Application ID of kopete-3432, you would just enter kopete.

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.

Configuring Talker Chooser Filters

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 Talkers”.

Just before Jovie 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 Jovie 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.


Talker Chooser

1

Enter a name for your filter. Use any name you like that distinguishes it from all other filters.

2

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.

Tip

For better performance, try to "anchor" the regular expression to the start of the string. In other words, start your regular expression with ^.

3

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: konversation,kmail

Tip

You can discover the Application ID of running programs using the qdbus program. You should leave the D-Bus numbers out. For example, if qdbus shows an Application ID of kopete-3432, you would just enter kopete.

4

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.

5

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.