# The &kmyapplication; Handbook

Gary
R.
Cramblitt
garycramblitt@comcast.net
2004-2005
Gary R. Cramblitt
&FDLNotice;
2005-02-01
1.03.00

&kmyapplication; - the KDE Text-to-Speech system - is a plugin based service that allows any KDE (or non-KDE) application to speak using the DCOP interface.

&kmyapplication; intends to be the implementation for the KDE Text-to-Speech API.

KDE
accessibility
kdeaccessibility
TTS
Text-to-Speech
KTTSD
kttsmgr
festival
flite
hadifix
MBROLA
freetts
epos
SSML

## Introduction

&kmyapplication; is a subsysem within KDE for producing Text-to-Speech (TTS). It provides a common API for KDE programmers to give TTS capabilities to their applications. It provides some nice capabilities for end users as well.

User features:

- Speak contents of a text file.

- Speak KDE notification events (KNotify).

- Speak all or part of the text of a web page in Konqueror.

- Speak all or part of the text in Kate text editor, including instances where Kate is embedded in another KDE application.

- Long text is parsed into sentences. User may backup by sentence or paragraph, replay, pause, and stop playing.

- Audio output via aRts or GStreamer (version 0.8.7 or later)

- User-configurable filters for substituting mispoken words, choosing speech synthesizers, and transforming XML documents.

Programmer features:

- Priority system for screen reader outputs, warnings and messages, while still playing regular texts.

- Plugin-based architecture for support of a wide variety of speech synthesis engines and drivers.

- Permit generation of speech from the command line (or via shell scripts) using the KDE DCOP utilities.

- Provide a lightweight and easily usable interface for applications to generate speech output.

- Applications need not be concerned about contention over the speech device.

- FUTURE: Provide support for speech markup languages, such as VoiceXML, Sable, Java Speech Markup Language (JSML), and Speech Markup Meta-language (SMML).

- FUTURE: Provide limited support for embedded speech markers.

- Asynchronous to prevent system blocking.

&kmyapplication; actually consists of several programs:

`kttsd`

  the KDE Text-to-Speech Deamon, which is a non-GUI application that provides TTS services to applications via DCOP.

`kttsmgr`

  a GUI application for configuring and controlling kttsd. kttsmgr sits in the system tray.

`libkhtmlkttsdplugin`

  A plugin for the Konqueror web browser that permits you to speak all or a portion of the text on a web page.

`ktexteditor_kttsd`

  A plugin for the Kate text editor that permits you to speak all or a portion of a text file.

### Support

In addition to the KDE Bugzilla database ( http://bugs.kde.org/ ), discussions for &kmyapplication; currently take place in the kde-accessibility mailing list. Subscribe at https://mail.kde.org/mailman/listinfo/kde-accessibility. Developers also hang out in IRC (irc.kde.org, channel #kde-accessibility).

## Using &kmyapplication;

Before you can use &kmyapplication;, you must install at least one speech synthesis engine and make sure it is working. See .

### Starting `kttsmgr`

To start the &kmyapplication; system, type the following command in a Konsole

`kttsmgr`

or click on &kmyapplication; in the KDE Menu.

If this is the first time running `kttsmgr`, or if you have not yet configured any Talkers, the Talkers screen appears. See . If you have already configured at least one Talker, the General screen appears. See .

### Selecting Synthesis Plugins (Talkers)

When you click the Talkers tab in `kttsmgr`, the Talkers screen appears.

The KDE Text-to-Speech Manager (Talkers tab). The KDE Text-to-Speech Manager (Talkers tab)

Click to add a new talker, which is a speech synthesis plugin.

All the configured Talkers are listed here. Highest priority Talkers are listed at the top. The top-most talker will be used to do the speaking when an application does not specify a talker.

Click on a talker in the list to highlight it and click this button to remove it.

Click on a talker in the list to highlight it and click this button to display the synthesis plugin's configuration dialog.

Click on a talker in the list to highlight it and click this button to move it down one row in the list. The lower a talker appears in the list, the lower its priority.

Click one of these buttons to apply the changes you have made to the running &kmyapplication; system.

When you click the Add button, the Add Talker screen appears.

Add Talker screen. Add Talker screen

You can select a speech synthesis plugin by either Synthesizer name, or by the Language the synthesizer can speak. Check the radio button next to the corresponding box. When the Language radio button is checked, the Language box displays all the languages supported by all available synthesizers, and the Synthesizer box displays only those synthesizers that support the chosen language. When the Synthesizer radio button is checked, the Synthesizer box displays all available synthesizers, and the Language box displays only the languages supported by the chosen synthesizer.

Choose the language and synthesizer plugin here.

When you click here, most synthesizer plugins will automatically configure themselves, choosing a default setup. A new talker will appear in the list on the Talkers tab. Click the Edit button to display or edit the talker's configuration. See .

You must configure at least one talker and click the Apply or OK buttons before you can start the &kmyapplication; system and begin speaking text. To start the &kmyapplication; system, click the General tab and check the Enable Text-to-Speech System (KTTSD) box. see .

### Configuring Synthesis Plugins (Talkers)

When you click the Add button on the Talkers tab and add a Talker, or click the Edit button, the Talker Configuration screen appears. Each speech synthesis plugin has a different Talker Configuration screen. The following is an example for configuring the Festival Interactive plugin. For specifics for each kind of plugin, see .

Talker Configuration Talker Configuration

Specify the path to the Festival executable program. If Festival is in your PATH environment variable, just enter `festival`.

Click to scan for available voices.

Select a voice.

Click to test. You should hear a test sentence spoken.

Use these controls to set the volume, talking speed, and pitch (tone) of the synthesized speech. If any of these are disabled (grayed), the chosen voice does not support changing them.

Some voices, such as the MultiSyn voices, are so large that they require several seconds to load. Checking this box will cause them to be loaded when KTTSD is started, thereby saving time (at the expense of using more memory) before the first sentence is synthesized.

Click the OK button to save the Talker configuration settings.

Be sure to click the Apply button, otherwise your changes will not take effect in the running &kmyapplication; system.

Assuming the test worked, you are almost ready to begin using &kmyapplication;. Now go back to the General tab and check the Enable Text-to-Speech System (KTTSD) box. This will start the KDE TTS Deamon. See . You may now begin using &kmyapplication; to speak text. Click the Jobs tab to create and manage text jobs. See .

### Starting KTTSD and Setting General Options

Once you have configured at least one Talker, you can start the KDE Text-to-Speech System. Click on the General tab. The General screen appears. You can also set some general options on this screen.

The KDE Text-to-Speech Manager (General tab). The KDE Text-to-Speech Manager (General tab)

Check this box to activate the &kmyapplication; system. This starts the KDE TTS Deamon (KTTSD). If KTTSD starts successfully, the Jobs tab will appear. Once KTTSD has been started, you can begin creating and speaking text jobs. See . Unchecking will stop KTTSD and deactivate the KDE TTS system.

If this box is disabled, you have not yet configured any Talkers (or you forgot to click the Apply button). See .

Check this box to speak KDE notifications. See for more information.

Check this box to speak only those KDE notifications that are displayed in a popup window.

Check this box to speak only those KDE notifications that are displayed in a passive popup window.

When this box is checked, an icon appears in the system tray whenever `kttsmgr` is running. In this mode, clicking OK or Cancel does not cause `kttsmgr` to exit. Instead, the screen disappears but `kttsmgr` continues running in the system tray. Click the icon to restore the screen. To quit `kttsmgr`, right-click on the icon in the system tray and choose Quit. When unchecked, an icon does not appear in the system tray. Clicking OK or Cancel quits `kttsmgr`.

When `kttsmgr` exits, &kmyapplication; keeps running if the Enable Text-to-Speech System (KTTSD) box is checked.

This option does not take effect until the next time `kttsmgr` is started.

This option has no effect when `kttsmgr` is running in the KDE Control Center.

When this box is checked, the `kttsmgr` screen appears when you start `kttsmgr`. If unchecked, the `kttsmgr` icon appears in the system tray when `kttsmgr` is started, but the screen does not appear. Click the icon in the system tray to make the screen appear.

Be sure to click here to save your settings.

### Managing Text Jobs

When you click the Jobs tab in `kttsmgr`, the Jobs screen appears.

The KDE Text-to-Speech Manager (Jobs tab). The KDE Text-to-Speech Manager (Jobs tab)

The buttons on this toolbar permit you to start, delete, and pause text jobs. Select a job in the list below, then click one of these buttons.

The buttons on this toolbar permit you to advance or rewind by sentence within the job selected in the list below. (Not all jobs have multiple parts.)

The buttons on this toolbar permit you to speak the text currently in the KDE clipboard, or open a text file for speaking. You can also refresh the list of text jobs.

The currently-speaking sentence appears here. If you need to, you can resize this panel by dragging the divider up or down.

When you click OK, all changes to settings on other screens are applied (if any) and `kttsmgr` minimizes to the system tray. Click on the icon in the system tray to restore the screen.

The Jobs tab only appears when KTTSD is running. If you do not see the Jobs tab, click on the General tab and check the Enable Text-to-Speech (KTTSD) box.

### Audio Settings

When you click the Audio tab in `kttsmgr`, the Audio screen appears.

The KDE Text-to-Speech Manager (Audio tab). The KDE Text-to-Speech Manager (Audio tab)

Select the method of audio output here. If GStreamer is grayed, either &kmyapplication; was compiled without GStreamer support, or &kmyapplication; was unable to load the necessary GStreamer libraries.

If GStreamer is selected for audio output, choose the GStreamer audio sink method here. If no sinks are listed, you need to install at least one. See .

Adjust the speed of talking here. 50% is approximately twice as slow as normal while 200% is approximately twice as fast. You must have the `sox` utility installed for this setting to work.

When this box is checked, &kmyapplication; will copy temporary audio files (.wav files) into the indicated directory. Choose any directory on your hard drive you like, but you must have write access to it. This can be useful for creating audio files of speech for other purposes. The files will have names of the form `kttsd-J-SS` where `J` is the job number and `SS` is the sentence number. Existing files with the same name will be deleted. Do not forget to uncheck this box, otherwise your hard drive will fill up!

Be sure to click Apply to apply the new settings to the running &kmyapplication; system.

There are two ways to adjust the speed of speech in &kmyapplication;. Many of the Talkers have a Speed setting in their configuration dialogs, which you can display by clicking Edit on the Talkers screen. This Speed setting on the Audio screen is in addition to the Talker speed setting and generally can be used even if the Talker does not support a speed setting. For this speed setting to work, you must have the `sox` utility installed on your system (Debian users: `apt-get install sox`). Also, this speed setting is ignored when speaking text containing SSML. (See )

### Filters

Filters are an advanced feature of &kmyapplication;. For the basic operation of &kmyapplication; 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 mispoken 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 &kmyapplication;. Text spoken by &kmyapplication; is of four possible types.

- Screen Reader Output.

- Warnings.

- Messages

- Text Jobs

The type is determined by the application that sends the text to &kmyapplication;. Screen Reader Output is used by applications designed for the blind or low-sighted. Screen Reader Outputs are always spoken before any other type and will interrupt any type of speech. Warnings and Messages are short messages that alert you to urgent information. They interrupt Text Jobs. Warnings are higher priority than Messages. KMouth is an example of an application that uses Messages for its speech. KDE Notifications are also Messages. 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.

The first thing you must know about filters is that they are applied only to ordinary Text Jobs and to KDE Notification messages. All other Screen Reader Ouput, Warnings, and Messages are not affected by filters.

There are two kinds of filters -- ordinary filters and Sentence Boundary Detector (SBD) filters. SBDs break text up into individual sentences. This allows &kmyapplication; 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. &kmyapplication; 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. &kmyapplication; comes with an XSLT file for converting XHTML into SSML, but this should be considered highly experimental.

Talker Choosers permit you redirect jobs to a talker based on the contents of the text, or upon the application that sent it to &kmyapplication;. For example, if you have configured a female talker in the Talkers tab, you can direct text coming from KDE Notifications to that talker. See .

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 or KDE Notification message is sent to &kmyapplication;, 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 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`.

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

This is the list of configured ordinary filters. If unchecked, the filter is inactive and will be bypassed. When you run &kmyapplication; for the first time, this is automatically filled with one instance of each kind of filter, but they are all inactive. 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. If the filter is the last of its kind, it is not removed; instead it is inactivated.

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 &kmyapplication;, 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.

#### 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. Matching is case insensitive.

String Replacer String Replacer

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.

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. The list is processed in the order displayed, top to bottom.

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 Text 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: ``knotify,konversation``

You 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 ``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.

All matching is case insensitive.

When matching words, the String Replacer filter internally uses a regular expression of the form `\s`word`\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 `kdeutils` package.

&kmyapplication; 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, user the Save button to save them to a file and send them to the &kmyapplication; 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.

XML Transformer XML Transformer

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 ``xsltproc``.

If not blank, the filter will apply itself only if the XML has the specified root element. This distinquishes one form of XML from another.

If not blank, the filter will apply itself only if the XML has a `<!DOCTYPE` specification beginning with the entered string. For example, ``html`` will match `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">`.

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: ``knotify,konversation``

You 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 ``kopete``.

The XML Transformer filter will only apply itself to the text if all non-blank conditions are met in the Apply This Filter When box.

#### 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 `knotify` should be spoken using a talker configured with a female voice. See .

Just before &kmyapplication; begins sending text to each of the filters, it picks a talker to to speak the text. The talker chosen is based on the talker attributes specified by the application that sent the text to &kmyapplication; 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 Talker Chooser

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.

For 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: ``knotify,konversation``

You 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 ``kopete``.

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. You can specify a language by clicking this button.

Similarly, the entries you make here also specify the attributes of the talker you prefer to speak the text. You do not have to specify all attributes.

You can specify that an attribute is more important than other attributes by checking these boxes.

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.

The Language attribute is special because text will probably be unintelligible if spoken by a talker that speaks a language different from the text. Therefore, language is automatically a preferred attribute. If you specify a language, it will override the chosen language, but if you leave it blank, the existing language already chosen by &kmyapplication; will be used. If the application that sent the text to &kmyapplication; did not specify a language, &kmyapplication; assigns the language of the topmost talker you have configured in the Talkers tab. The other attributes always override. In other words, if you leave the Rate attribute blank, the Talker Chooser will find the closest matching talker independently of rate of speech.

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 &kmyapplication; chooses. Enable the Talker Chooser, 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.

#### Configuring Sentence Boundary Detector Filters.

Sentence Boundary Detector (SBD) filters break text up into individual sentences. This is important because it

- allows &kmyapplication; 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 Load button to load the `polish_festival_sbdrc` file that comes with &kmyapplication;.

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

If you accidentally remove the Standard Sentence Boundary Detectory filter, you can get it back by loading the `standard_sbdrc` file, which comes with &kmyapplication;.

### Text Interruption Settings

When you click the Interruption tab in `kttsmgr`, the Interruption screen appears.

The KDE Text-to-Speech Manager (Interruption tab). The KDE Text-to-Speech Manager (Interruption tab)

This screen permits you to specify special actions to be taken whenever a text job is interrupted by another, higher priority, message. There are four kinds of speech jobs that &kmyapplication; handles:

- Regular text.

- Messages.

- Warnings.

- Screen Reader Output.

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

All four kinds of jobs are queues, except for Screen Reader Output. If a Screen Reader Output is sent from an application while &kmyapplication; is speaking another Screen Reader Output, the speaking message is stopped and discarded.

When a text job is interrupted by a Message, Warning, or Screen Reader Output, &kmyapplication; will add the audio outputs on this screen to the stream.

This message is spoken whenever a regular text job is interrupted.

This audio file is sounded whenever a regular text job is interrupted. If both a Pre-sound and a Pre-message are specified, the Pre-sound is sounded before the Pre-message.

This message is spoken whenever an interrupted text job resumes.

This audio file is sounded whenever an interrupted text job resumes. It is sounded last.

The settings on this screen apply only to regular text jobs. Messages, Warnings, and Screen Reader Outputs have no special actions when they are preempted by a higher-priority message.

### Speaking Text from Web Pages

While running the KDE Konqueror web browser, you can speak the text of the web page displayed. First ensure that &kmyapplication; is running. Highlight the text you want spoken and choose Tools Speak Text on the main menu. After a moment, the highlighted text should begin speaking.

It is almost always a good idea to highlight the text on the web page you want spoken. You can skip this step, but you will hear a lot of HTML headers and other invisible tags spoken.

### Speaking Text from Kate Text Editor

While running the KDE Advanced Text Editor (Kate), you can speak the text displayed. First ensure that &kmyapplication; is running. Highlight the text you want spoken and choose Tools Speak Text on the main menu. After a moment, the highlighted text should begin speaking.

You do not have to first highlight text. In this case, the entire file will be spoken.

This also works when Kate is running embedded in another application, such as Konqueror or Quanta.

### Speaking Notifications (KNotify)

KNotify is the notification subsystem within KDE, which alerts you to events you configure within the KDE system. You can configure &kmyapplication; to speak text notifications.

For example, Konversation, a KDE IRC application, permits you to configure a wide variety of notifications. For instance, you can tell Konversation to notify you whenever a message appears in an IRC channel with your nickname in it. Together with &kmyapplication; you can have KDE speak the text of the IRC message to you.

In general, if a KDE application supports KNotify, a Notifications menu item will appear under the Settings menu. The specifics for configuring each application with KNotify vary from application to application.

To enable &kmyapplication; to speak KNotify text notifications, start `kttsmgr`, click the General tab, and check the Speak notifications (KNotify) box. Then click the Apply button.

### SSML

The Speech Synthesis Markup Language (SSML) is a W3C standard for marking up text for speech output. It provides tags for controlling voices, rate of speech, volume, gender, and pitch (tone). It also provides tags for controlling how words are spoken, for instance spelling out abbreviations. SSML is part of the VoiceXML specification, which is also a W3C standard.

At this time, &kmyapplication; provides limited and very basic support for SSML. It currently has the following restrictions.

- Works only with the Festival Interactive and Hadifix Talkers.

- You must install the `rab_diphone` (British male) voice, as this is the default voice Festival uses when speaking SSML.

- The Speed setting on the Audio screen is ignored when speaking text containing SSML.

- If the Speed or Pitch settings in the Festival configuration dialog are not set to 100%, it will usually cause the SSML text to be spoken in a monotone.

The following sample text can be used to experiment with SSML.

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE speak PUBLIC "-//W3C//DTD SYNTHESIS 1.0//EN"
        "http://www.w3.org/TR/speech-synthesis/synthesis.dtd">

    <speak version="1.0" xml:lang="en-US">
        <prosody pitch="low">
            Who's been sleeping in my bed?
        </prosody>
        said papa bear.
        <prosody pitch="medium">
            Who's been sleeping in my bed?
        </prosody>
        said momma bear.
        <prosody pitch="high">
            Who's been sleeping in my bed?
        </prosody>
        said baby bear.
    </speak>

More robust support for SSML is planned for the next version of &kmyapplication;.

## Command Reference

TODO

## Developer's Guide to &kmyapplication;

&kmyapplication; has two Application Programmer Interfaces (APIs):

- The KDE Text-to-Speech API, which is used by application programmers to give their applications TTS capabilities. Applications communicate with KTTSD via DCOP.

- The KTTSD Plugin API, which is used to add speech synthesis plugins to KTTSD so that &kmyapplication; will work with a new speech synthesis engine.

The following section gives a short description of the KDE Text-to-Speech API DCOP Interface. Full documentation for both APIs is available online at the KDE Accessibility web site (http://accessibility.kde.org).

### The &kmyapplication; DCOP Interface

Applications communicate requests for Text-to-Speech services via the KDE DCOP interface to program `kttsd` object `KSpeech`.

Enter the following commands in a Konsole.

If KTTSD is not already running

`kttsd`

To queue a text job to be spoken

`dcop kttsd KSpeech setText "text" "talker"`

where `text` is the text to be spoken, and `talker` is a language code such as `en`, `cy`, etc. This command does not speak the text; instead it queues a text job for speaking.

Example.

`dcop kttsd KSpeech setText "This is a test." "en"`

To speak the last queued text job

`dcop kttsd KSpeech startText 0`

In this case, `0` refers to the last text job queued. You may also specify a specific job number. (If no job number is given, a `0` is required.)

To stop the currently speaking text job

`dcop kttsd KSpeech stopText 0`

Depending upon the speech plugin used, speaking may not immediately stop.

There are many more commands that can be sent. To see a list of possible commands,

`dcop kttsd KSpeech`

or read the KDE Text-to-Speech API online.

## Questions and Answers

&reporting.bugs; &updating.documentation;

I need to start over. How do I get &kmyapplication; completely terminated?

Enter the following commands in a Konsole:

    killall kttsd
    killall kttsmgr

How can I see debugging output from `kttsd`?

Open two Konsole windows. First start `kttsd` in one window, then start `kttsmgr` in the second.

I have an additional Festival voice I downloaded from the Internet. I installed it, and I can use it in Festival, but it does not show up in `kttsmgr`.

Edit file `$KDEHOME/share/apps/kttsd/festivalint/voices` to add the new voice. The other entries can be used as a guide. If you successfully add a voice, please send a patch to the developers along with the URL from which you obtained the voice file.

None of the supported speech synthesizers support the language I need. Where can I get a synth for my language?

Google(tm) is your friend. This link might also help. If you find a free synthesis engine that supports your desired language, and want to add support for it to &kmyapplication;, please contact the development team. Open source engines are especially welcome. If you know of a commercial synth, perhaps you can pursuade the vendor to donate a free copy to the &kmyapplication; development team. In the meantime, you may be able to get the synth working using the Command plugin. See .

## Credits and License

&kmyapplication;

Program Copyright © 2002 José Pablo Ezequiel "Pupeno" Fernández pupeno@kde.org

Current Maintainer: Gary Cramblitt garycramblitt@comcast.net

Contributors:

- Olaf Schmidt ojschmidt@kde.org

- Gunnar Schmi Dt gunnar@schmi-dt.de

- Paul Giannaros ceruleanblaze@gmail.com

Documentation Copyright © 2004 Gary R. Cramblitt garycramblitt@comcast.net

&underFDL;

&underGPL;

Speech synthesis engines used by &kmyapplication; have their own licenses. See each engine's documentation or website for details.

## Installation

### How to obtain &kmyapplication;

&install.intro.documentation;

(FUTURE) Debian Install Command: `apt-get install kdeaccessibility`

You will find links to source and binary packages on the KDE Accessibility web site (http://accessibility.kde.org).

If you have access to KDE CVS, you can download &kmyapplication; by checking out the `kdeaccessibility` module. &kmyapplication; will be found in the `kttsd` directory. You can also download a nightly tarball of all kdeaccessibility from ftp://ftp.kde.org/pub/kde/unstable/latest/kdeaccessibility.tar.bz2

### Requirements

Mandatory requirements:

- KDE version 3.2 or later.

- A speech synthesis engine. The following engines and spoken languages are currently supported.

  Festival | American English, British, Spanish, German, Finnish, Czech, Polish, Russian
  Festival Lite (flite) | English
  Hadifix (MBROLA and txt2pho) | German
  Epos | Czech, Slovak
  FreeTTS | English

  It also works with any synthesis engine that can be run from a command in a Konsole.

  The languages listed above may not be comprehensive or up-to-date. Check the specifications for each engine for a complete list of supported languages.

  &kmyapplication; uses a flexible plugin architecture for speech synthesis engines. If you want to enhance &kmyapplication; to support another engine, contact the development team.

  See for specific instructions for each of these engines.

Optional components:

- The `sox` audio utility is needed for adjusting overall speech speed, but not required. Debian users can install sox with the command `apt-get install sox`. Sox is included on most &Linux; distribution CDs.

- The `xsltproc` utility is needed for SSML support and for the XML Transformer filter, but not required. Debian users can install xsltproc with the command `apt-get install xsltproc`.

- GStreamer version 0.8.7 or later. By default, &kmyapplication; uses aRts for audio output, but if you install GStreamer, you can use it instead. You can obtain GStreamer from

  http://gstreamer.freedesktop.org/

### Compilation and Installation

In order to compile &kmyapplication;, you must have a recent (KDE 3.4 or greater) copy of the KDE development files, including kdelibs and arts.

If you downloaded &kmyapplication; as a tarball, log in as a normal user and untar the tarball to a suitable directory, change to that directory, and enter the following commands.

    ./configure
    make

If you have the GStreamer 0.8.7 or greater development files installed, and wish to build &kmyapplication; with support for GStreamer, enter the following commands instead.

    ./configure --enable-kttsd-gstreamer
    make

By default, the commands above will install &kmyapplication; to `/opt/kde3`. If this directory is not in your $`KDEDIRS` path, you may need to add a `--prefix=target` option. For example,

    ./configure --prefix=/usr/local
    make

On Debian systems, `/usr/local` is the usual place to install applications compiled from source code.

Login as root and install the compiled &kmyapplication; using the following commands.

    su
    make install

If you downloaded the &kmyapplication; source from the `kdeaccessibility` CVS module, or downloaded the nightly CVS tarball, use the following commands to compile and install.

    cd kdeaccessibility
    echo kttsd>inst-apps
    make -f Makefile.cvs
    ./configure
    cd kttsd
    make
    su
    make install

### Configuration

Make sure your speech synthesis engine is working before using &kmyapplication;. Follow the instructions that came with the engine.

In some cases, you may need to grant write access to the audio device.

`chmod a+rw /dev/dsp*`

#### Using with Festival (Interactive)

Festival is one of the best free and open source TTS engines available. Voice quality is generally good and there are quite a few languages and voices supported. For many voices, you can control the volume, speed of the generated speech, and pitch (tone) from &kmyapplication;.

Synthesizer Name: Festival Interactive

URL: http://www.cstr.ed.ac.uk/projects/festival/

Debian Install Command: `apt-get install festival`

You will need to install at least one language. Follow the instructions that come with Festival.

Additional English festival voices are available from

http://hts.ics.nitech.ac.jp/.

Additional Spanish, English, and German voices are available from

http://cslu.cse.ogi.edu/tts/download/

You must compile an additional module for these voices, therefore, you must have the Festival source code. The German voices have limited distribution.

A Finnish male voice is available from

http://www.ling.helsinki.fi/suopuhe/download/.

A Polish male voice is available from

http://www.artegence.com/download/voicexml/speech/festival_polish_voice.tgz.

A Russian male voice is available from

http://nshmyrev.narod.ru/festival/festival.html

You must have Festival 1.95 beta or later to use this voice. The voice is still in early development. Untar to `festival/lib/voices/russian/`. When you configure the Russian talker, the voice code is `msu_ru_nsh_diphone`. Be sure to select a single-byte cryllic encoding, such as `KOI8-R`.

Festival is typically included with &Linux; distributions. Check your distro CDs to see if it is included.

Start `kttsmgr`. On the Talkers screen, click the Add button. Choose Festival Interactive and a Language. If the Configure Talker screen does not appear, click the Edit button. If the Festival executable program is not in your `PATH`, enter the full path to the executable. Click the Rescan button, pick a voice, and click the Test button. You should hear a test sentence spoken.

When using the Polish or Czech languages, be sure the Encoding option is set to `ISO 8859-2`.

When using the Russian voice, be sure the Encoding option is set to a single-byte cryllic encoding, such as `KOI8-R`.

##### Using Festival with &mbrola;

Festival can be used in combination with the &mbrola; synthesizer. In this mode, Festival does the lexical analysis and &mbrola; produces the audio. The &mbrola; binary and &mbrola; voice files can be downloaded from

http://festvox.org/mbrola/.

Follow the instructions in the `readme.txt` that comes with the download.

Note that &mbrola; is not a complete Text-to-Speech system. &mbrola; synthesizes speech from diphone files. You must have additional software that can produce the diphones. When combined with Festival, Festival produces the diphones needed by &mbrola;. `txt2pho` can also be used to produce diphones from German text. See for more information.

There are three methods of combining Festival with &mbrola;.

- &mbrola; Wrappers. At the time of writing this Handbook, this method is limited to English voices.

- IMS German Festival.

- Festival-Czech.

###### Using Festival with &mbrola; Wrappers

In this method, additional wrapper code is added to Festival to enable speech synthesis using &mbrola; voice files. Note that the &mbrola; voice files are not installed in the &mbrola; directory tree. Instead, they are installed in the `festival/lib/` directory tree. For instructions, see

http://www.cstr.ed.ac.uk/projects/festival/mbrola.html

###### Using IMS German Festival

IMS German Festival is a modified version of Festival that uses German &mbrola; voices. It works with either Festival version 1.4.1 or Festival 2.0 (1.95beta). First install Festival and &mbrola;, if you have not already done so. Next, download IMS German Festival, from

http://www.ims.uni-stuttgart.de/phonetik/synthesis/festival_opensource.html.

Follow the instructions in the `README` that comes with the download. (Note, if using in combination with Festival 2.0, it is not necessary to apply the `fixes` tarball, but you must still rebuild festival.) Finally, add the following lines to the `festival/lib/siteinit.scm` file.

    (voice-location "german_de1_os" "/usr/local/mbrola/de1"
      "German Female, IMS Festival de1")
    (voice-location "german_de2_os" "/usr/local/mbrola/de2"
      "German Male, IMS Festival de2")
    (voice-location "german_de3_os" "/usr/local/mbrola/de3"
      "German Female, IMS Festival de3")

just above the line that reads

    (provide 'siteinit)

On some systems, the file you edit is `/etc/festival.scm`. Only add the lines that correspond to the German voices you have installed. Substitute the correct path for `/usr/local/mbrola/`. Also note that (at the time of this writing) IMS German Festival does not work with the de4, de5, or de6 German voices.

###### Using Festival-Czech

This method uses some special code to enable speech synthesis using Festival with an &mbrola; Czech voice. To install, first download, install Festival and &mbrola;, and make sure both are working. Next, download Festival-Czech from

http://www.freebsoft.org/festival-czech

In the following procedures substitute the correct directory paths as needed.

Untar the download to a suitable directory and make the lexicon. The Festival executable must be in your `PATH`.

    cd /usr/local
    tar xvfz festival-czech.tar.gz
    cd festival-czech
    make

Download the `cz2` voice file from the &mbrola; website, and unzip it in the &mbrola; directory.

    cd /usr/local/mbrola
    mkdir cz2
    cd cz2
    unzip cz2-001009.zip

Add the following lines to the `festival/lib/siteinit.scm` file.

    (set! czech-lexicon-file "/usr/local/festival-czech/czech-lexicon.out")
    (set! load-path (cons "/usr/local/festival-czech" load-path))
    (require 'czech)
    (set! czech-mbrola_database "/usr/local/mbrola/cz2/cz2")
    (set! mbrola_progname "/usr/local/mbrola/mbrola")
    (voice-location "czech_mbrola_cz2" "/usr/local/mbrola/cz2"
        "Czech Male, MBROLA")
    (require 'czech-mbrola)

just above the line that reads

    (provide 'siteinit)

On some systems, the file you edit is `/etc/festival.scm`.

#### Using with Festival Lite (flite)

Festival Lite is a free open source engine that currently supports a limited number of voices and languages. It is light weight, but sacrifices voice quality somewhat. You cannot control the pitch, volume, or speed of this engine from &kmyapplication;.

Synthesizer Name: Festival Lite (flite)

URL: http://www.speech.cs.cmu.edu/flite/index.html

Debian Install Command: `apt-get install flite`

flite is typically included with &Linux; distributions. Check your distro CDs to see if it is included.

Build and install flite following the instructions in the `README` that comes with it.

#### Using with Hadifix (&mbrola; and txt2pho)

Hadifix is a two-stage synthesis engine based on diphones. The `txt2pho` utility converts text into diphones and the &mbrola; engine synthesizes the diphones to sound. Voice quality is good, but language support is currently somewhat limited. You can control the voice, pitch, speed, and volume from kttsmgr.

Synthesizer Name: Hadifix

URL: see below

Debian Install Command: none

If you do not already have Hadifix installed, do this:

1. Download MBROLA binary from http://festvox.org/mbrola/.

2. Install &mbrola; to `/usr/local/mbrola` directory.

3. Download at least one german language file from the &mbrola; site. Unzip to the `/usr/local/mbrola` directory.

4. Download txt2pho from

   http://www.ikp.uni-bonn.de/dt/forsch/phonetik/hadifix/HADIFIXforMBROLA.html.

5. Unzip txt2pho to `/usr/local/txt2pho`.

6. Edit `txt2phorc` file, putting correct data paths in.

7. Either copy `txt2phorc` to `~/.txt2phorc` or to `/etc/txt2pho`. Note that you drop the "rc" in file name.

8. In kttsmgr, choose the German language (de), and add Hadifix.

9. On the Configure Talker screen, configure a voice and the paths to &mbrola; and txt2pho.

10. Click the Test button to test.

#### Using with Epos

Epos is a free Czeck and Slovak open source engine. It is light weight, but sacrifices voice quality somewhat. You cannot control the volume of this engine from &kmyapplication;.

Synthesizer Name: Epos TTS Synthesis System

URL: http://epos.ure.cas.cz/

Debian Install Command: `apt-get install epos`

Start kttsmgr. On the Talkers tab, click the Add button. Choose Czeck or Slovak language and Epos TTS Synthesis System. If the epos server executable and client are not in your `PATH`, specify the paths to these executables in the Configure Talker screen. The options boxes permit you to pass additional options to the server and client. In a Konsole, type `epos -h` or `say -h` for information.

#### Using with FreeTTS

FreeTTS is a free open source speech engine written in Java(tm), which means that you must have the Java Virtual Machine software installed on your system to use it. It currently has limited voice and language support. You cannot control the pitch, volume, or speed of this engine from &kmyapplication;.

Synthesizer Name: FreeTTS

URL: http://sourceforge.net/projects/freetts/

Debian Install Command: none

#### Using the Command Plugin

The command plugin permits you to use &kmyapplication; with any speech synthesis engine that can be run as a command in a Konsole.

Synthesizer Name: Command

URL: none

Debian Install Command: none

Ideally, you should use a command that synthesizes to a temporary audio (wav) file, rather than send the speech directly to the audio device.

If the speech synthesis engine requires text to be encoded differently from your desktop encoding setting, you must use the `%f` parameter to pass the text to the engine. &kmyapplication; will encode the text in the setting you specify when it writes the text to the temporary file. If you attempt to pass text on the command line using the `%t` parameter, it will be encoded using your desktop locale setting. You can also use the Send the data as standard input option to solve this problem, if the engine accepts input from StdIn. For example, here is a sample command to send polish text to Festival using ISO 8859-2 encoding and removing unspeakable punctuation characters.

`cat %f | tr '(){}[]"' ' ' | festival --tts --language polish`

&documentation.index;