3 * libspeechd.h - Shared library for easy acces to Speech Dispatcher functions (header)
5 * Copyright (C) 2001, 2002, 2003, 2004 Brailcom, o.p.s.
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this package; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
22 * $Id: libspeechd.h,v 1.29 2008-07-30 09:47:00 hanke Exp $
36 /* Arguments for spd_send_data() */
37 #define SPD_WAIT_REPLY 1 /* Wait for reply */
38 #define SPD_NO_REPLY 0 /* No reply requested */
41 /* --------------------- Public data types ------------------------ */
78 char *name
; /* Name of the voice (id) */
79 char *language
; /* 2-letter ISO language code */
80 char *variant
; /* a not-well defined string describing dialect etc. */
107 }SPDNotificationType
;
111 SPD_MODE_THREADED
= 1
115 SPD_METHOD_UNIX_SOCKET
= 0,
116 SPD_METHOD_INET_SOCKET
= 1,
117 }SPDConnectionMethod
;
120 SPDConnectionMethod method
;
121 char *unix_socket_name
;
122 char *inet_socket_host
;
123 int inet_socket_port
;
125 }SPDConnectionAddress
;
127 typedef void (*SPDCallback
)(size_t msg_id
, size_t client_id
, SPDNotificationType state
);
128 typedef void (*SPDCallbackIM
)(size_t msg_id
, size_t client_id
, SPDNotificationType state
, char *index_mark
);
133 SPDCallback callback_begin
;
134 SPDCallback callback_end
;
135 SPDCallback callback_cancel
;
136 SPDCallback callback_pause
;
137 SPDCallback callback_resume
;
138 SPDCallbackIM callback_im
;
143 SPDConnectionMode mode
;
145 pthread_mutex_t
*ssip_mutex
;
147 pthread_t
*events_thread
;
148 pthread_mutex_t
*comm_mutex
;
149 pthread_cond_t
*cond_reply_ready
;
150 pthread_mutex_t
*mutex_reply_ready
;
151 pthread_cond_t
*cond_reply_ack
;
152 pthread_mutex_t
*mutex_reply_ack
;
158 /* -------------- Public functions --------------------------*/
160 /* Openning and closing Speech Dispatcher connection */
161 SPDConnectionAddress
* spd_get_default_address(char** error
);
162 SPDConnection
* spd_open(const char* client_name
, const char* connection_name
, const char* user_name
,
163 SPDConnectionMode mode
);
164 SPDConnection
* spd_open2(const char* client_name
, const char* connection_name
, const char* user_name
,
165 SPDConnectionMode mode
, SPDConnectionAddress
*address
, int autospawn
,
166 char **error_result
);
168 void spd_close(SPDConnection
* connection
);
171 int spd_say(SPDConnection
* connection
, SPDPriority priority
, const char* text
);
172 int spd_sayf(SPDConnection
* connection
, SPDPriority priority
, const char *format
, ...);
175 int spd_stop(SPDConnection
* connection
);
176 int spd_stop_all(SPDConnection
* connection
);
177 int spd_stop_uid(SPDConnection
* connection
, int target_uid
);
179 int spd_cancel(SPDConnection
* connection
);
180 int spd_cancel_all(SPDConnection
* connection
);
181 int spd_cancel_uid(SPDConnection
* connection
, int target_uid
);
183 int spd_pause(SPDConnection
* connection
);
184 int spd_pause_all(SPDConnection
* connection
);
185 int spd_pause_uid(SPDConnection
* connection
, int target_uid
);
187 int spd_resume(SPDConnection
* connection
);
188 int spd_resume_all(SPDConnection
* connection
);
189 int spd_resume_uid(SPDConnection
* connection
, int target_uid
);
191 /* Characters and keys */
192 int spd_key(SPDConnection
* connection
, SPDPriority priority
, const char *key_name
);
193 int spd_char(SPDConnection
* connection
, SPDPriority priority
, const char *character
);
194 int spd_wchar(SPDConnection
* connection
, SPDPriority priority
, wchar_t wcharacter
);
197 int spd_sound_icon(SPDConnection
* connection
, SPDPriority priority
, const char *icon_name
);
199 /* Setting parameters */
200 int spd_set_voice_type(SPDConnection
*, SPDVoiceType type
);
201 int spd_set_voice_type_all(SPDConnection
*, SPDVoiceType type
);
202 int spd_set_voice_type_uid(SPDConnection
*, SPDVoiceType type
, unsigned int uid
);
204 int spd_set_synthesis_voice(SPDConnection
*, const char *voice_name
);
205 int spd_set_synthesis_voice_all(SPDConnection
*, const char *voice_name
);
206 int spd_set_synthesis_voice_uid(SPDConnection
*, const char *voice_name
, unsigned int uid
);
208 int spd_set_data_mode(SPDConnection
*connection
, SPDDataMode mode
);
210 int spd_set_notification_on(SPDConnection
* connection
, SPDNotification notification
);
211 int spd_set_notification_off(SPDConnection
* connection
, SPDNotification notification
);
212 int spd_set_notification(SPDConnection
* connection
, SPDNotification notification
, const char* state
);
214 int spd_set_voice_rate(SPDConnection
* connection
, signed int rate
);
215 int spd_set_voice_rate_all(SPDConnection
* connection
, signed int rate
);
216 int spd_set_voice_rate_uid(SPDConnection
* connection
, signed int rate
, unsigned int uid
);
218 int spd_set_voice_pitch(SPDConnection
* connection
, signed int pitch
);
219 int spd_set_voice_pitch_all(SPDConnection
* connection
, signed int pitch
);
220 int spd_set_voice_pitch_uid(SPDConnection
* connection
, signed int pitch
, unsigned int uid
);
222 int spd_set_volume(SPDConnection
* connection
, signed int volume
);
223 int spd_set_volume_all(SPDConnection
* connection
, signed int volume
);
224 int spd_set_volume_uid(SPDConnection
* connection
, signed int volume
, unsigned int uid
);
226 int spd_set_punctuation(SPDConnection
* connection
, SPDPunctuation type
);
227 int spd_set_punctuation_all(SPDConnection
* connection
, SPDPunctuation type
);
228 int spd_set_punctuation_uid(SPDConnection
* connection
, SPDPunctuation type
, unsigned int uid
);
230 int spd_set_capital_letters(SPDConnection
* connection
, SPDCapitalLetters type
);
231 int spd_set_capital_letters_all(SPDConnection
* connection
, SPDCapitalLetters type
);
232 int spd_set_capital_letters_uid(SPDConnection
* connection
, SPDCapitalLetters type
, unsigned int uid
);
234 int spd_set_spelling(SPDConnection
* connection
, SPDSpelling type
);
235 int spd_set_spelling_all(SPDConnection
* connection
, SPDSpelling type
);
236 int spd_set_spelling_uid(SPDConnection
* connection
, SPDSpelling type
, unsigned int uid
);
238 int spd_set_language(SPDConnection
* connection
, const char* language
);
239 int spd_set_language_all(SPDConnection
* connection
, const char* language
);
240 int spd_set_language_uid(SPDConnection
* connection
, const char* language
, unsigned int uid
);
242 int spd_set_output_module(SPDConnection
* connection
, const char* output_module
);
243 int spd_set_output_module_all(SPDConnection
* connection
, const char* output_module
);
244 int spd_set_output_module_uid(SPDConnection
* connection
, const char* output_module
, unsigned int uid
);
246 int spd_get_client_list(SPDConnection
*connection
, char **client_names
, int *client_ids
, int* active
);
247 int spd_get_message_list_fd(SPDConnection
*connection
, int target
, int *msg_ids
, char **client_names
);
249 char** spd_list_modules(SPDConnection
*connection
);
250 char** spd_list_voices(SPDConnection
*connection
);
251 SPDVoice
** spd_list_synthesis_voices(SPDConnection
*connection
);
252 char** spd_execute_command_with_list_reply(SPDConnection
*connection
, char* command
);
255 /* Direct SSIP communication */
256 int spd_execute_command(SPDConnection
* connection
, char* command
);
257 int spd_execute_command_with_reply(SPDConnection
*connection
, char* command
, char **reply
);
258 int spd_execute_command_wo_mutex(SPDConnection
*connection
, char* command
);
259 char* spd_send_data(SPDConnection
* connection
, const char *message
, int wfr
);
260 char* spd_send_data_wo_mutex(SPDConnection
*connection
, const char *message
, int wfr
);
266 #endif /* __cplusplus */
268 #endif /* ifndef _LIBSPEECHD_H */