1/*
2 * libspeechd.h - Shared library for easy acces 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 FILE *stream;
90 SPDConnectionMode mode;
91
92 pthread_mutex_t ssip_mutex;
93
94 struct SPDConnection_threaddata *td;
95
96 char *reply;
97
98} SPDConnection;
99
100/* -------------- Public functions --------------------------*/
101
102/* Opening and closing Speech Dispatcher connection */
103SPDConnectionAddress *spd_get_default_address(char **error);
104SPDConnection *spd_open(const char *client_name, const char *connection_name,
105 const char *user_name, SPDConnectionMode mode);
106SPDConnection *spd_open2(const char *client_name, const char *connection_name,
107 const char *user_name, SPDConnectionMode mode,
108 const SPDConnectionAddress * address, int autospawn,
109 char **error_result);
110
111int spd_get_client_id(SPDConnection * connection);
112
113void spd_close(SPDConnection * connection);
114
115/* Speaking */
116int spd_say(SPDConnection * connection, SPDPriority priority, const char *text);
117int spd_sayf(SPDConnection * connection, SPDPriority priority,
118 const char *format, ...)
119 SPD_ATTRIBUTE_FORMAT(printf, 3, 4);
120
121/* Speech flow */
122int spd_stop(SPDConnection * connection);
123int spd_stop_all(SPDConnection * connection);
124int spd_stop_uid(SPDConnection * connection, int target_uid);
125
126int spd_cancel(SPDConnection * connection);
127int spd_cancel_all(SPDConnection * connection);
128int spd_cancel_uid(SPDConnection * connection, int target_uid);
129
130int spd_pause(SPDConnection * connection);
131int spd_pause_all(SPDConnection * connection);
132int spd_pause_uid(SPDConnection * connection, int target_uid);
133
134int spd_resume(SPDConnection * connection);
135int spd_resume_all(SPDConnection * connection);
136int spd_resume_uid(SPDConnection * connection, int target_uid);
137
138/* Characters and keys */
139int spd_key(SPDConnection * connection, SPDPriority priority,
140 const char *key_name);
141int spd_char(SPDConnection * connection, SPDPriority priority,
142 const char *character);
143int spd_wchar(SPDConnection * connection, SPDPriority priority,
144 wchar_t wcharacter);
145
146/* Sound icons */
147int spd_sound_icon(SPDConnection * connection, SPDPriority priority,
148 const char *icon_name);
149
150/* Setting parameters */
151int spd_set_voice_type(SPDConnection *, SPDVoiceType type);
152int spd_set_voice_type_all(SPDConnection *, SPDVoiceType type);
153int spd_set_voice_type_uid(SPDConnection *, SPDVoiceType type,
154 unsigned int uid);
155SPDVoiceType spd_get_voice_type(SPDConnection *);
156
157int spd_set_synthesis_voice(SPDConnection *, const char *voice_name);
158int spd_set_synthesis_voice_all(SPDConnection *, const char *voice_name);
159int spd_set_synthesis_voice_uid(SPDConnection *, const char *voice_name,
160 unsigned int uid);
161
162int spd_set_data_mode(SPDConnection * connection, SPDDataMode mode);
163
164int spd_set_notification_on(SPDConnection * connection,
165 SPDNotification notification);
166int spd_set_notification_off(SPDConnection * connection,
167 SPDNotification notification);
168int spd_set_notification(SPDConnection * connection,
169 SPDNotification notification, const char *state);
170
171int spd_set_voice_rate(SPDConnection * connection, signed int rate);
172int spd_set_voice_rate_all(SPDConnection * connection, signed int rate);
173int spd_set_voice_rate_uid(SPDConnection * connection, signed int rate,
174 unsigned int uid);
175int spd_get_voice_rate(SPDConnection * connection);
176
177int spd_set_voice_pitch(SPDConnection * connection, signed int pitch);
178int spd_set_voice_pitch_all(SPDConnection * connection, signed int pitch);
179int spd_set_voice_pitch_uid(SPDConnection * connection, signed int pitch,
180 unsigned int uid);
181int spd_get_voice_pitch(SPDConnection * connection);
182
183int spd_set_voice_pitch_range(SPDConnection * connection,
184 signed int pitch_range);
185int spd_set_voice_pitch_range_all(SPDConnection * connection,
186 signed int pitch_range);
187int spd_set_voice_pitch_range_uid(SPDConnection * connection,
188 signed int pitch_range, unsigned int uid);
189
190int spd_set_volume(SPDConnection * connection, signed int volume);
191int spd_set_volume_all(SPDConnection * connection, signed int volume);
192int spd_set_volume_uid(SPDConnection * connection, signed int volume,
193 unsigned int uid);
194int spd_get_volume(SPDConnection * connection);
195
196int spd_set_punctuation(SPDConnection * connection, SPDPunctuation type);
197int spd_set_punctuation_all(SPDConnection * connection, SPDPunctuation type);
198int spd_set_punctuation_uid(SPDConnection * connection, SPDPunctuation type,
199 unsigned int uid);
200
201int spd_set_capital_letters(SPDConnection * connection, SPDCapitalLetters type);
202int spd_set_capital_letters_all(SPDConnection * connection,
203 SPDCapitalLetters type);
204int spd_set_capital_letters_uid(SPDConnection * connection,
205 SPDCapitalLetters type, unsigned int uid);
206
207int spd_set_spelling(SPDConnection * connection, SPDSpelling type);
208int spd_set_spelling_all(SPDConnection * connection, SPDSpelling type);
209int spd_set_spelling_uid(SPDConnection * connection, SPDSpelling type,
210 unsigned int uid);
211
212int spd_set_language(SPDConnection * connection, const char *language);
213int spd_set_language_all(SPDConnection * connection, const char *language);
214int spd_set_language_uid(SPDConnection * connection, const char *language,
215 unsigned int uid);
216char *spd_get_language(SPDConnection * connection);
217
218int spd_set_output_module(SPDConnection * connection,
219 const char *output_module);
220int spd_set_output_module_all(SPDConnection * connection,
221 const char *output_module);
222int spd_set_output_module_uid(SPDConnection * connection,
223 const char *output_module, unsigned int uid);
224
225int spd_get_client_list(SPDConnection * connection, char **client_names,
226 int *client_ids, int *active);
227int spd_get_message_list_fd(SPDConnection * connection, int target,
228 int *msg_ids, char **client_names);
229
230char **spd_list_modules(SPDConnection * connection);
231void free_spd_modules(char **);
232char *spd_get_output_module(SPDConnection * connection);
233
234char **spd_list_voices(SPDConnection * connection);
235SPDVoice **spd_list_synthesis_voices(SPDConnection * connection);
236void free_spd_voices(SPDVoice ** voices);
237char **spd_execute_command_with_list_reply(SPDConnection * connection,
238 const char *command);
239
240/* Direct SSIP communication */
241int spd_execute_command(SPDConnection * connection, const char *command);
242int spd_execute_command_with_reply(SPDConnection * connection, const char *command,
243 char **reply);
244int spd_execute_command_wo_mutex(SPDConnection * connection, const char *command);
245char *spd_send_data(SPDConnection * connection, const char *message, int wfr);
246char *spd_send_data_wo_mutex(SPDConnection * connection, const char *message,
247 int wfr);
248
249
250
251/* *INDENT-OFF* */
252#ifdef __cplusplus
253}
254#endif /* __cplusplus */
255/* *INDENT-ON* */
256
257#endif /* ifndef _LIBSPEECHD_H */
258

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