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 #ifdef LIBSPEECHD_DEBUG
41 /* Unless there is an fatal error, it doesn't print anything */
42 #define SPD_FATAL(msg) { printf("Fatal error (libspeechd) [%s:%d]:"msg, __FILE__, __LINE__); fflush(stdout); exit(EXIT_FAILURE); }
44 /* Arguments for spd_send_data() */
45 #define SPD_WAIT_REPLY 1 /* Wait for reply */
46 #define SPD_NO_REPLY 0 /* No reply requested */
49 /* --------------------- Public data types ------------------------ */
86 char *name
; /* Name of the voice (id) */
87 char *language
; /* 2-letter ISO language code */
88 char *variant
; /* a not-well defined string describing dialect etc. */
104 SPD_NOTIFICATION
= 4,
115 }SPDNotificationType
;
119 SPD_MODE_THREADED
= 1
123 SPD_METHOD_UNIX_SOCKET
= 0,
124 SPD_METHOD_INET_SOCKET
= 1,
125 }SPDConnectionMethod
;
128 SPDConnectionMethod method
;
129 char *unix_socket_name
;
130 char *inet_socket_host
;
131 int inet_socket_port
;
133 }SPDConnectionAddress
;
135 typedef void (*SPDCallback
)(size_t msg_id
, size_t client_id
, SPDNotificationType state
);
136 typedef void (*SPDCallbackIM
)(size_t msg_id
, size_t client_id
, SPDNotificationType state
, char *index_mark
);
141 SPDCallback callback_begin
;
142 SPDCallback callback_end
;
143 SPDCallback callback_cancel
;
144 SPDCallback callback_pause
;
145 SPDCallback callback_resume
;
146 SPDCallbackIM callback_im
;
151 SPDConnectionMode mode
;
153 pthread_mutex_t
*ssip_mutex
;
155 pthread_t
*events_thread
;
156 pthread_mutex_t
*comm_mutex
;
157 pthread_cond_t
*cond_reply_ready
;
158 pthread_mutex_t
*mutex_reply_ready
;
159 pthread_cond_t
*cond_reply_ack
;
160 pthread_mutex_t
*mutex_reply_ack
;
166 /* -------------- Public functions --------------------------*/
168 /* Openning and closing Speech Dispatcher connection */
169 SPDConnectionAddress
* spd_get_default_address(char** error
);
170 SPDConnection
* spd_open(const char* client_name
, const char* connection_name
, const char* user_name
,
171 SPDConnectionMode mode
);
172 SPDConnection
* spd_open2(const char* client_name
, const char* connection_name
, const char* user_name
,
173 SPDConnectionMode mode
, SPDConnectionAddress
*address
, int autospawn
,
174 char **error_result
);
176 void spd_close(SPDConnection
* connection
);
179 int spd_say(SPDConnection
* connection
, SPDPriority priority
, const char* text
);
180 int spd_sayf(SPDConnection
* connection
, SPDPriority priority
, const char *format
, ...);
183 int spd_stop(SPDConnection
* connection
);
184 int spd_stop_all(SPDConnection
* connection
);
185 int spd_stop_uid(SPDConnection
* connection
, int target_uid
);
187 int spd_cancel(SPDConnection
* connection
);
188 int spd_cancel_all(SPDConnection
* connection
);
189 int spd_cancel_uid(SPDConnection
* connection
, int target_uid
);
191 int spd_pause(SPDConnection
* connection
);
192 int spd_pause_all(SPDConnection
* connection
);
193 int spd_pause_uid(SPDConnection
* connection
, int target_uid
);
195 int spd_resume(SPDConnection
* connection
);
196 int spd_resume_all(SPDConnection
* connection
);
197 int spd_resume_uid(SPDConnection
* connection
, int target_uid
);
199 /* Characters and keys */
200 int spd_key(SPDConnection
* connection
, SPDPriority priority
, const char *key_name
);
201 int spd_char(SPDConnection
* connection
, SPDPriority priority
, const char *character
);
202 int spd_wchar(SPDConnection
* connection
, SPDPriority priority
, wchar_t wcharacter
);
205 int spd_sound_icon(SPDConnection
* connection
, SPDPriority priority
, const char *icon_name
);
207 /* Setting parameters */
208 int spd_set_voice_type(SPDConnection
*, SPDVoiceType type
);
209 int spd_set_voice_type_all(SPDConnection
*, SPDVoiceType type
);
210 int spd_set_voice_type_uid(SPDConnection
*, SPDVoiceType type
, unsigned int uid
);
212 int spd_set_synthesis_voice(SPDConnection
*, const char *voice_name
);
213 int spd_set_synthesis_voice_all(SPDConnection
*, const char *voice_name
);
214 int spd_set_synthesis_voice_uid(SPDConnection
*, const char *voice_name
, unsigned int uid
);
216 int spd_set_data_mode(SPDConnection
*connection
, SPDDataMode mode
);
218 int spd_set_notification_on(SPDConnection
* connection
, SPDNotification notification
);
219 int spd_set_notification_off(SPDConnection
* connection
, SPDNotification notification
);
220 int spd_set_notification(SPDConnection
* connection
, SPDNotification notification
, const char* state
);
222 int spd_set_voice_rate(SPDConnection
* connection
, signed int rate
);
223 int spd_set_voice_rate_all(SPDConnection
* connection
, signed int rate
);
224 int spd_set_voice_rate_uid(SPDConnection
* connection
, signed int rate
, unsigned int uid
);
226 int spd_set_voice_pitch(SPDConnection
* connection
, signed int pitch
);
227 int spd_set_voice_pitch_all(SPDConnection
* connection
, signed int pitch
);
228 int spd_set_voice_pitch_uid(SPDConnection
* connection
, signed int pitch
, unsigned int uid
);
230 int spd_set_volume(SPDConnection
* connection
, signed int volume
);
231 int spd_set_volume_all(SPDConnection
* connection
, signed int volume
);
232 int spd_set_volume_uid(SPDConnection
* connection
, signed int volume
, unsigned int uid
);
234 int spd_set_punctuation(SPDConnection
* connection
, SPDPunctuation type
);
235 int spd_set_punctuation_all(SPDConnection
* connection
, SPDPunctuation type
);
236 int spd_set_punctuation_uid(SPDConnection
* connection
, SPDPunctuation type
, unsigned int uid
);
238 int spd_set_capital_letters(SPDConnection
* connection
, SPDCapitalLetters type
);
239 int spd_set_capital_letters_all(SPDConnection
* connection
, SPDCapitalLetters type
);
240 int spd_set_capital_letters_uid(SPDConnection
* connection
, SPDCapitalLetters type
, unsigned int uid
);
242 int spd_set_spelling(SPDConnection
* connection
, SPDSpelling type
);
243 int spd_set_spelling_all(SPDConnection
* connection
, SPDSpelling type
);
244 int spd_set_spelling_uid(SPDConnection
* connection
, SPDSpelling type
, unsigned int uid
);
246 int spd_set_language(SPDConnection
* connection
, const char* language
);
247 int spd_set_language_all(SPDConnection
* connection
, const char* language
);
248 int spd_set_language_uid(SPDConnection
* connection
, const char* language
, unsigned int uid
);
250 int spd_set_output_module(SPDConnection
* connection
, const char* output_module
);
251 int spd_set_output_module_all(SPDConnection
* connection
, const char* output_module
);
252 int spd_set_output_module_uid(SPDConnection
* connection
, const char* output_module
, unsigned int uid
);
254 int spd_get_client_list(SPDConnection
*connection
, char **client_names
, int *client_ids
, int* active
);
255 int spd_get_message_list_fd(SPDConnection
*connection
, int target
, int *msg_ids
, char **client_names
);
257 char** spd_list_modules(SPDConnection
*connection
);
258 char** spd_list_voices(SPDConnection
*connection
);
259 SPDVoice
** spd_list_synthesis_voices(SPDConnection
*connection
);
260 char** spd_execute_command_with_list_reply(SPDConnection
*connection
, char* command
);
263 /* Direct SSIP communication */
264 int spd_execute_command(SPDConnection
* connection
, char* command
);
265 int spd_execute_command_with_reply(SPDConnection
*connection
, char* command
, char **reply
);
266 int spd_execute_command_wo_mutex(SPDConnection
*connection
, char* command
);
267 char* spd_send_data(SPDConnection
* connection
, const char *message
, int wfr
);
268 char* spd_send_data_wo_mutex(SPDConnection
*connection
, const char *message
, int wfr
);
274 #endif /* __cplusplus */
276 #endif /* ifndef _LIBSPEECHD_H */