speech-dispatcher: Speech Synthesis Commands in C
4.1.2 Speech Synthesis Commands
-------------------------------
-- Variable: C API type SPDPriority
'SPDPriority' is an enum type that represents the possible
priorities that can be assigned to a message.
typedef enum{
SPD_IMPORTANT = 1,
SPD_MESSAGE = 2,
SPD_TEXT = 3,
SPD_NOTIFICATION = 4,
SPD_PROGRESS = 5
}SPDPriority;
Message Priority Model (ssip)Top.
-- C API function: int spd_say(SPDConnection* connection, SPDPriority
priority, char* text);
Sends a message to Speech Dispatcher. If this message isn't
blocked by some message of higher priority and this CONNECTION
isn't paused, it will be synthesized directly on one of the output
devices. Otherwise, the message will be discarded or delayed
according to its priority.
'connection' is the SPDConnection* connection created by
spd_open().
'priority' is the desired priority for this message. Message
Priority Model (ssip)Top.
'text' is a null terminated string containing text you want sent to
synthesis. It must be encoded in UTF-8. Note that this doesn't
have to be what you will finally hear. It can be affected by
different settings, such as spelling, punctuation, text
substitution etc.
It returns a positive unique message identification number on
success, -1 otherwise. This message identification number can be
saved and used for the purpose of event notification callbacks or
history handling.
-- C API function: int spd_sayf(SPDConnection* connection, SPDPriority
priority, char* format, ...);
Similar to 'spd_say()', simulates the behavior of printf().
'format' is a string containing text and formatting of the
parameters, such as "%d", "%s" etc. It must be encoded in UTF-8.
'...' is an arbitrary number of arguments.
All other parameters are the same as for spd_say().
For example:
spd_sayf(conn, SPD_TEXT, "Hello %s, how are you?", username);
spd_sayf(conn, SPD_IMPORTANT, "Fatal error on [%s:%d]", filename, line);
But be careful with unicode! For example this doesn't work:
spd_sayf(conn, SPD_NOTIFY, ``Pressed key is %c.'', key);
Why? Because you are supposing that key is a char, but that will
fail with languages using multibyte charsets. The proper solution
is:
spd_sayf(conn, SPD_NOTIFY, ``Pressed key is %s'', key);
where key is an encoded string.
It returns a positive unique message identification number on
success, -1 otherwise. This message identification number can be
saved and used for the purpose of event notification callbacks or
history handling.