1/*
2 * libspeechd.h - Shared library for easy access to Speech Dispatcher functions (header)
3 *
4 * Copyright (C) 2001, 2002, 2003, 2004 Brailcom, o.p.s.
5 *
6 * This is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1, or (at your option)
9 * any later version.
10 *
11 * This software is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 *
19 * $Id: libspeechd.h,v 1.29 2008-07-30 09:47:00 hanke Exp $
20 */
21
22#ifndef _LIBSPEECHD_H
23#define _LIBSPEECHD_H
24
25#include <stdio.h>
26#include <stddef.h>
27#include <pthread.h>
28
29#include "libspeechd_version.h"
30#include "speechd_types.h"
31
32/* *INDENT-OFF* */
33#ifdef __cplusplus
34extern "C" {
35#endif
36/* *INDENT-ON* */
37 /* Speech Dispatcher's default port for inet communication */
38#define SPEECHD_DEFAULT_PORT 6560
39
40 /* Arguments for spd_send_data() */
41#define SPD_WAIT_REPLY 1 /* Wait for reply */
42#define SPD_NO_REPLY 0 /* No reply requested */
43
44 /* --------------------- Public data types ------------------------ */
45
46#ifdef __GNUC__
47# define SPD_ATTRIBUTE_FORMAT(type, string, first) __attribute__((format(type, string, first)))
48#else
49# define SPD_ATTRIBUTE_FORMAT(type, string, first)
50#endif
51
52typedef enum {
53 SPD_MODE_SINGLE = 0,
54 SPD_MODE_THREADED = 1
55} SPDConnectionMode;
56
57typedef enum {
58 SPD_METHOD_UNIX_SOCKET = 0,
59 SPD_METHOD_INET_SOCKET = 1,
60} SPDConnectionMethod;
61
62typedef struct {
63 SPDConnectionMethod method;
64 char *unix_socket_name;
65 char *inet_socket_host;
66 int inet_socket_port;
67 char *dbus_bus;
68} SPDConnectionAddress;
69
70void SPDConnectionAddress__free(SPDConnectionAddress * address);
71
72typedef void (*SPDCallback) (size_t msg_id, size_t client_id,
73 SPDNotificationType state);
74typedef void (*SPDCallbackIM) (size_t msg_id, size_t client_id,
75 SPDNotificationType state, char *index_mark);
76
77typedef struct {
78
79 /* PUBLIC */
80 SPDCallback callback_begin;
81 SPDCallback callback_end;
82 SPDCallback callback_cancel;
83 SPDCallback callback_pause;
84 SPDCallback callback_resume;
85 SPDCallbackIM callback_im;
86
87 /* PRIVATE */
88 int socket;
89 void *stream;
90 SPDConnectionMode mode;
91 char *buf;
92 size_t buf_start;
93 size_t buf_used;
94
95 pthread_mutex_t ssip_mutex;
96
97 struct SPDConnection_threaddata *td;
98
99 char *reply;
100
101} SPDConnection;
102
103/* -------------- Public functions --------------------------*/
104
105/* Opening and closing Speech Dispatcher connection */
106SPDConnectionAddress *spd_get_default_address(char **error);
107SPDConnection *spd_open(const char *client_name, const char *connection_name,
108 const char *user_name, SPDConnectionMode mode);
109SPDConnection *spd_open2(const char *client_name, const char *connection_name,
110 const char *user_name, SPDConnectionMode mode,
111 const SPDConnectionAddress * address, int autospawn,
112 char **error_result);
113
114int spd_fd(SPDConnection * connection);
115
116int spd_get_client_id(SPDConnection * connection);
117
118void spd_close(SPDConnection * connection);
119
120/* Speaking */
121int spd_say(SPDConnection * connection, SPDPriority priority, const char *text);
122int spd_sayf(SPDConnection * connection, SPDPriority priority,
123 const char *format, ...)
124 SPD_ATTRIBUTE_FORMAT(printf, 3, 4);
125
126/* Speech flow */
127int spd_stop(SPDConnection * connection);
128int spd_stop_all(SPDConnection * connection);
129int spd_stop_uid(SPDConnection * connection, int target_uid);
130
131int spd_cancel(SPDConnection * connection);
132int spd_cancel_all(SPDConnection * connection);
133int spd_cancel_uid(SPDConnection * connection, int target_uid);
134
135int spd_pause(SPDConnection * connection);
136int spd_pause_all(SPDConnection * connection);
137int spd_pause_uid(SPDConnection * connection, int target_uid);
138
139int spd_resume(SPDConnection * connection);
140int spd_resume_all(SPDConnection * connection);
141int spd_resume_uid(SPDConnection * connection, int target_uid);
142
143/* Characters and keys */
144int spd_key(SPDConnection * connection, SPDPriority priority,
145 const char *key_name);
146int spd_char(SPDConnection * connection, SPDPriority priority,
147 const char *character);
148int spd_wchar(SPDConnection * connection, SPDPriority priority,
149 wchar_t wcharacter);
150
151/* Sound icons */
152int spd_sound_icon(SPDConnection * connection, SPDPriority priority,
153 const char *icon_name);
154
155/* Setting parameters */
156int spd_set_voice_type(SPDConnection *, SPDVoiceType type);
157int spd_set_voice_type_all(SPDConnection *, SPDVoiceType type);
158int spd_set_voice_type_uid(SPDConnection *, SPDVoiceType type,
159 unsigned int uid);
160SPDVoiceType spd_get_voice_type(SPDConnection *);
161
162int spd_set_synthesis_voice(SPDConnection *, const char *voice_name);
163int spd_set_synthesis_voice_all(SPDConnection *, const char *voice_name);
164int spd_set_synthesis_voice_uid(SPDConnection *, const char *voice_name,
165 unsigned int uid);
166
167int spd_set_data_mode(SPDConnection * connection, SPDDataMode mode);
168
169int spd_set_notification_on(SPDConnection * connection,
170 SPDNotification notification);
171int spd_set_notification_off(SPDConnection * connection,
172 SPDNotification notification);
173int spd_set_notification(SPDConnection * connection,
174 SPDNotification notification, const char *state);
175
176int spd_set_voice_rate(SPDConnection * connection, signed int rate);
177int spd_set_voice_rate_all(SPDConnection * connection, signed int rate);
178int spd_set_voice_rate_uid(SPDConnection * connection, signed int rate,
179 unsigned int uid);
180int spd_get_voice_rate(SPDConnection * connection);
181
182int spd_set_voice_pitch(SPDConnection * connection, signed int pitch);
183int spd_set_voice_pitch_all(SPDConnection * connection, signed int pitch);
184int spd_set_voice_pitch_uid(SPDConnection * connection, signed int pitch,
185 unsigned int uid);
186int spd_get_voice_pitch(SPDConnection * connection);
187
188int spd_set_voice_pitch_range(SPDConnection * connection,
189 signed int pitch_range);
190int spd_set_voice_pitch_range_all(SPDConnection * connection,
191 signed int pitch_range);
192int spd_set_voice_pitch_range_uid(SPDConnection * connection,
193 signed int pitch_range, unsigned int uid);
194
195int spd_set_volume(SPDConnection * connection, signed int volume);
196int spd_set_volume_all(SPDConnection * connection, signed int volume);
197int spd_set_volume_uid(SPDConnection * connection, signed int volume,
198 unsigned int uid);
199int spd_get_volume(SPDConnection * connection);
200
201int spd_set_punctuation(SPDConnection * connection, SPDPunctuation type);
202int spd_set_punctuation_all(SPDConnection * connection, SPDPunctuation type);
203int spd_set_punctuation_uid(SPDConnection * connection, SPDPunctuation type,
204 unsigned int uid);
205
206int spd_set_capital_letters(SPDConnection * connection, SPDCapitalLetters type);
207int spd_set_capital_letters_all(SPDConnection * connection,
208 SPDCapitalLetters type);
209int spd_set_capital_letters_uid(SPDConnection * connection,
210 SPDCapitalLetters type, unsigned int uid);
211
212int spd_set_spelling(SPDConnection * connection, SPDSpelling type);
213int spd_set_spelling_all(SPDConnection * connection, SPDSpelling type);
214int spd_set_spelling_uid(SPDConnection * connection, SPDSpelling type,
215 unsigned int uid);
216
217int spd_set_language(SPDConnection * connection, const char *language);
218int spd_set_language_all(SPDConnection * connection, const char *language);
219int spd_set_language_uid(SPDConnection * connection, const char *language,
220 unsigned int uid);
221char *spd_get_language(SPDConnection * connection);
222
223int spd_set_output_module(SPDConnection * connection,
224 const char *output_module);
225int spd_set_output_module_all(SPDConnection * connection,
226 const char *output_module);
227int spd_set_output_module_uid(SPDConnection * connection,
228 const char *output_module, unsigned int uid);
229
230int spd_get_client_list(SPDConnection * connection, char **client_names,
231 int *client_ids, int *active);
232int spd_get_message_list_fd(SPDConnection * connection, int target,
233 int *msg_ids, char **client_names);
234
235char **spd_list_modules(SPDConnection * connection);
236void free_spd_modules(char **);
237char *spd_get_output_module(SPDConnection * connection);
238
239char **spd_list_voices(SPDConnection * connection);
240void free_spd_symbolic_voices(char **voices);
241SPDVoice **spd_list_synthesis_voices(SPDConnection * connection);
242SPDVoice **spd_list_synthesis_voices2(SPDConnection * connection, const char *language, const char *variant);
243void free_spd_voices(SPDVoice ** voices);
244char **spd_execute_command_with_list_reply(SPDConnection * connection,
245 const char *command);
246
247/* Direct SSIP communication */
248int spd_execute_command(SPDConnection * connection, const char *command);
249int spd_execute_command_with_reply(SPDConnection * connection, const char *command,
250 char **reply);
251int spd_execute_command_wo_mutex(SPDConnection * connection, const char *command);
252char *spd_send_data(SPDConnection * connection, const char *message, int wfr);
253char *spd_send_data_wo_mutex(SPDConnection * connection, const char *message,
254 int wfr);
255
256
257
258/* *INDENT-OFF* */
259#ifdef __cplusplus
260}
261#endif /* __cplusplus */
262/* *INDENT-ON* */
263
264#endif /* ifndef _LIBSPEECHD_H */
265

source code of include/speech-dispatcher/libspeechd.h