[Kde-accessibility] Proposol (with implementation) for synthesizer interface

Roger Butenuth butenuth at online.de
Mon Mar 29 22:11:41 CEST 2004


Hello!

Before I make my proposol, I want to introduce myself: I am one of the two
developers of "brass" (Braille and Speech Server). brass is NOT a kde
application, just a screenreader for the Linux console. The homepage of
brass is: http://butenuth.onlinehome.de/blinux/index-en.html. You can find
the latest source in the CVS on sourceforge (project name is brass).

Some parts of brass may be usefull for the kde accesibility project: The
low level interface for speech synthesizers including code to interface
with hadifix/mbrola (for German speech) and freephone/mbrola (for English
speech).

The interface consists of two layers:

1. synthesizer.h: The lower layer with direct access to the synthesizer

2. language.h: The upper layer, doing some buffering and language
dependent conversione (e.g. convert "123" to "one hundred twentythree").

I will start in this mail with the lower layer. It is implemented as a
shared libary, after loading the libary you call

synth_t *open_synthesizer(void *context, lookup_string_t lookup);

to open a synthesier. The call

int     close_synthesizer(synth_t *synth);

closes the synthesizer and frees all resources.

The open call gets two pointers as parameters. The first is used as a
parameter to a callback function, the second is the callback function:

typedef char *(*lookup_string_t)(void *context, const char *name);

The callback mechanism is used to pass arbritrary string parameters to the
synthesizer. This can be mapped to getenv() (in this case you don't need
the config pointer) or a config file reader (as in brass).

The synthesizer library needs no other references back in your code.

All functions of the library are accessed through pointer in the synth_t
structure:

typedef struct synth_struct {
    synth_state_p state;
    lang_descr_t  *lang;
    char          *name;
    void          *lib_handle;
    int (*close)(struct synth_struct *s);
    int (*synth)(struct synth_struct *s, unsigned char *buffer);
    int (*flush)(struct synth_struct *s);
    int (*clear)(struct synth_struct *s);
    int (*index_set)(struct synth_struct *s);
    int (*index_wait)(struct synth_struct *s, int id, int timeout);
    int (*get_param)(struct synth_struct *s, synth_par_t par, int *value);
    int (*set_param)(struct synth_struct *s, synth_par_t par, int value);
} synth_t;

I tried to make an object oriented interface in C...

The functions/methods do:

close: Close synthesizer

synth: Send a string to the synthesizer. Speaking can start, but it can be
delayed to flush.

flush: Start synthesizing.

clear: Stop synthesizing as fast as possible, delete any buffered speech.

index_set: Set an index, returns the id of the index.

index_wait: Wait until the index is reached. Return codes:
 0 sync point not reached
 1 sync point reached
 2 timeout

Indexing does not work with most of the synthesizers, currently it is not
used in brass.

get_/set_param: Get or set one of the parameters (speed, pitch, volume).

The whole interface is not very elegant and uses hardcoded integers to
interface languages, so there is room for improvement. As long as I have
to maintain it, I would like to keep it really small.

	Roger Butenuth





More information about the kde-accessibility mailing list