OLD | NEW |
(Empty) | |
| 1 |
| 2 /* |
| 3 * libspeechd.h - Shared library for easy acces to Speech Dispatcher functions (
header) |
| 4 * |
| 5 * Copyright (C) 2001, 2002, 2003, 2004 Brailcom, o.p.s. |
| 6 * |
| 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) |
| 10 * any later version. |
| 11 * |
| 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. |
| 16 * |
| 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. |
| 21 * |
| 22 * $Id: libspeechd.h,v 1.29 2008-07-30 09:47:00 hanke Exp $ |
| 23 */ |
| 24 |
| 25 #ifndef _LIBSPEECHD_H |
| 26 #define _LIBSPEECHD_H |
| 27 |
| 28 #include <stdio.h> |
| 29 #include <stddef.h> |
| 30 #include <pthread.h> |
| 31 |
| 32 #ifdef __cplusplus |
| 33 extern "C" { |
| 34 #endif |
| 35 |
| 36 #ifdef LIBSPEECHD_DEBUG |
| 37 /* Debugging */ |
| 38 FILE* spd_debug; |
| 39 #endif |
| 40 |
| 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); } |
| 43 |
| 44 /* Arguments for spd_send_data() */ |
| 45 #define SPD_WAIT_REPLY 1 /* Wait for reply */ |
| 46 #define SPD_NO_REPLY 0 /* No reply requested */ |
| 47 |
| 48 |
| 49 /* --------------------- Public data types ------------------------ */ |
| 50 |
| 51 typedef enum{ |
| 52 SPD_PUNCT_ALL = 0, |
| 53 SPD_PUNCT_NONE = 1, |
| 54 SPD_PUNCT_SOME = 2 |
| 55 }SPDPunctuation; |
| 56 |
| 57 typedef enum{ |
| 58 SPD_CAP_NONE = 0, |
| 59 SPD_CAP_SPELL = 1, |
| 60 SPD_CAP_ICON = 2 |
| 61 }SPDCapitalLetters; |
| 62 |
| 63 typedef enum{ |
| 64 SPD_SPELL_OFF = 0, |
| 65 SPD_SPELL_ON = 1 |
| 66 }SPDSpelling; |
| 67 |
| 68 typedef enum{ |
| 69 SPD_DATA_TEXT = 0, |
| 70 SPD_DATA_SSML = 1 |
| 71 }SPDDataMode; |
| 72 |
| 73 typedef enum{ |
| 74 SPD_MALE1 = 1, |
| 75 SPD_MALE2 = 2, |
| 76 SPD_MALE3 = 3, |
| 77 SPD_FEMALE1 = 4, |
| 78 SPD_FEMALE2 = 5, |
| 79 SPD_FEMALE3 = 6, |
| 80 SPD_CHILD_MALE = 7, |
| 81 SPD_CHILD_FEMALE = 8 |
| 82 }SPDVoiceType; |
| 83 |
| 84 |
| 85 typedef struct{ |
| 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. */ |
| 89 }SPDVoice; |
| 90 |
| 91 typedef enum{ |
| 92 SPD_BEGIN = 1, |
| 93 SPD_END = 2, |
| 94 SPD_INDEX_MARKS = 4, |
| 95 SPD_CANCEL = 8, |
| 96 SPD_PAUSE = 16, |
| 97 SPD_RESUME = 32 |
| 98 }SPDNotification; |
| 99 |
| 100 typedef enum{ |
| 101 SPD_IMPORTANT = 1, |
| 102 SPD_MESSAGE = 2, |
| 103 SPD_TEXT = 3, |
| 104 SPD_NOTIFICATION = 4, |
| 105 SPD_PROGRESS = 5 |
| 106 }SPDPriority; |
| 107 |
| 108 typedef enum{ |
| 109 SPD_EVENT_BEGIN, |
| 110 SPD_EVENT_END, |
| 111 SPD_EVENT_CANCEL, |
| 112 SPD_EVENT_PAUSE, |
| 113 SPD_EVENT_RESUME, |
| 114 SPD_EVENT_INDEX_MARK |
| 115 }SPDNotificationType; |
| 116 |
| 117 typedef enum{ |
| 118 SPD_MODE_SINGLE = 0, |
| 119 SPD_MODE_THREADED = 1 |
| 120 }SPDConnectionMode; |
| 121 |
| 122 typedef enum{ |
| 123 SPD_METHOD_UNIX_SOCKET = 0, |
| 124 SPD_METHOD_INET_SOCKET = 1, |
| 125 }SPDConnectionMethod; |
| 126 |
| 127 typedef struct{ |
| 128 SPDConnectionMethod method; |
| 129 char *unix_socket_name; |
| 130 char *inet_socket_host; |
| 131 int inet_socket_port; |
| 132 char *dbus_bus; |
| 133 }SPDConnectionAddress; |
| 134 |
| 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, SPDNotificationTy
pe state, char *index_mark); |
| 137 |
| 138 typedef struct{ |
| 139 |
| 140 /* PUBLIC */ |
| 141 SPDCallback callback_begin; |
| 142 SPDCallback callback_end; |
| 143 SPDCallback callback_cancel; |
| 144 SPDCallback callback_pause; |
| 145 SPDCallback callback_resume; |
| 146 SPDCallbackIM callback_im; |
| 147 |
| 148 /* PRIVATE */ |
| 149 int socket; |
| 150 FILE *stream; |
| 151 SPDConnectionMode mode; |
| 152 |
| 153 pthread_mutex_t *ssip_mutex; |
| 154 |
| 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; |
| 161 |
| 162 char *reply; |
| 163 |
| 164 }SPDConnection; |
| 165 |
| 166 /* -------------- Public functions --------------------------*/ |
| 167 |
| 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, co
nst char* user_name, |
| 171 SPDConnectionMode mode); |
| 172 SPDConnection* spd_open2(const char* client_name, const char* connection_name, c
onst char* user_name, |
| 173 SPDConnectionMode mode, SPDConnectionAddress *address,
int autospawn, |
| 174 char **error_result); |
| 175 |
| 176 void spd_close(SPDConnection* connection); |
| 177 |
| 178 /* Speaking */ |
| 179 int spd_say(SPDConnection* connection, SPDPriority priority, const char* text); |
| 180 int spd_sayf(SPDConnection* connection, SPDPriority priority, const char *format
, ...); |
| 181 |
| 182 /* Speech flow */ |
| 183 int spd_stop(SPDConnection* connection); |
| 184 int spd_stop_all(SPDConnection* connection); |
| 185 int spd_stop_uid(SPDConnection* connection, int target_uid); |
| 186 |
| 187 int spd_cancel(SPDConnection* connection); |
| 188 int spd_cancel_all(SPDConnection* connection); |
| 189 int spd_cancel_uid(SPDConnection* connection, int target_uid); |
| 190 |
| 191 int spd_pause(SPDConnection* connection); |
| 192 int spd_pause_all(SPDConnection* connection); |
| 193 int spd_pause_uid(SPDConnection* connection, int target_uid); |
| 194 |
| 195 int spd_resume(SPDConnection* connection); |
| 196 int spd_resume_all(SPDConnection* connection); |
| 197 int spd_resume_uid(SPDConnection* connection, int target_uid); |
| 198 |
| 199 /* Characters and keys */ |
| 200 int spd_key(SPDConnection* connection, SPDPriority priority, const char *key_nam
e); |
| 201 int spd_char(SPDConnection* connection, SPDPriority priority, const char *charac
ter); |
| 202 int spd_wchar(SPDConnection* connection, SPDPriority priority, wchar_t wcharacte
r); |
| 203 |
| 204 /* Sound icons */ |
| 205 int spd_sound_icon(SPDConnection* connection, SPDPriority priority, const char *
icon_name); |
| 206 |
| 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); |
| 211 |
| 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); |
| 215 |
| 216 int spd_set_data_mode(SPDConnection *connection, SPDDataMode mode); |
| 217 |
| 218 int spd_set_notification_on(SPDConnection* connection, SPDNotification notificat
ion); |
| 219 int spd_set_notification_off(SPDConnection* connection, SPDNotification notifica
tion); |
| 220 int spd_set_notification(SPDConnection* connection, SPDNotification notification
, const char* state); |
| 221 |
| 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); |
| 225 |
| 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, unsigne
d int uid); |
| 229 |
| 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 in
t uid); |
| 233 |
| 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, unsi
gned int uid); |
| 237 |
| 238 int spd_set_capital_letters(SPDConnection* connection, SPDCapitalLetters type); |
| 239 int spd_set_capital_letters_all(SPDConnection* connection, SPDCapitalLetters typ
e); |
| 240 int spd_set_capital_letters_uid(SPDConnection* connection, SPDCapitalLetters typ
e, unsigned int uid); |
| 241 |
| 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 i
nt uid); |
| 245 |
| 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, unsign
ed int uid); |
| 249 |
| 250 int spd_set_output_module(SPDConnection* connection, const char* output_module); |
| 251 int spd_set_output_module_all(SPDConnection* connection, const char* output_modu
le); |
| 252 int spd_set_output_module_uid(SPDConnection* connection, const char* output_modu
le, unsigned int uid); |
| 253 |
| 254 int spd_get_client_list(SPDConnection *connection, char **client_names, int *cli
ent_ids, int* active); |
| 255 int spd_get_message_list_fd(SPDConnection *connection, int target, int *msg_ids,
char **client_names); |
| 256 |
| 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* comm
and); |
| 261 |
| 262 |
| 263 /* Direct SSIP communication */ |
| 264 int spd_execute_command(SPDConnection* connection, char* command); |
| 265 int spd_execute_command_with_reply(SPDConnection *connection, char* command, cha
r **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); |
| 269 |
| 270 |
| 271 |
| 272 #ifdef __cplusplus |
| 273 } |
| 274 #endif /* __cplusplus */ |
| 275 |
| 276 #endif /* ifndef _LIBSPEECHD_H */ |
OLD | NEW |