libspeechd.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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 package; see the file COPYING. If not, write to
  18. * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  19. * Boston, MA 02110-1301, USA.
  20. *
  21. * $Id: libspeechd.h,v 1.29 2008-07-30 09:47:00 hanke Exp $
  22. */
  23. #ifndef _LIBSPEECHD_H
  24. #define _LIBSPEECHD_H
  25. #include <stdio.h>
  26. #include <stddef.h>
  27. #include <pthread.h>
  28. #include "libspeechd_version.h"
  29. #include "speechd_types.h"
  30. /* *INDENT-OFF* */
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34. /* *INDENT-ON* */
  35. /* Speech Dispatcher's default port for inet communication */
  36. #define SPEECHD_DEFAULT_PORT 6560
  37. /* Arguments for spd_send_data() */
  38. #define SPD_WAIT_REPLY 1 /* Wait for reply */
  39. #define SPD_NO_REPLY 0 /* No reply requested */
  40. /* --------------------- Public data types ------------------------ */
  41. typedef enum {
  42. SPD_MODE_SINGLE = 0,
  43. SPD_MODE_THREADED = 1
  44. } SPDConnectionMode;
  45. typedef enum {
  46. SPD_METHOD_UNIX_SOCKET = 0,
  47. SPD_METHOD_INET_SOCKET = 1,
  48. } SPDConnectionMethod;
  49. typedef struct {
  50. SPDConnectionMethod method;
  51. char *unix_socket_name;
  52. char *inet_socket_host;
  53. int inet_socket_port;
  54. char *dbus_bus;
  55. } SPDConnectionAddress;
  56. void SPDConnectionAddress__free(SPDConnectionAddress * address);
  57. typedef void (*SPDCallback) (size_t msg_id, size_t client_id,
  58. SPDNotificationType state);
  59. typedef void (*SPDCallbackIM) (size_t msg_id, size_t client_id,
  60. SPDNotificationType state, char *index_mark);
  61. typedef struct {
  62. /* PUBLIC */
  63. SPDCallback callback_begin;
  64. SPDCallback callback_end;
  65. SPDCallback callback_cancel;
  66. SPDCallback callback_pause;
  67. SPDCallback callback_resume;
  68. SPDCallbackIM callback_im;
  69. /* PRIVATE */
  70. int socket;
  71. FILE *stream;
  72. SPDConnectionMode mode;
  73. pthread_mutex_t *ssip_mutex;
  74. pthread_t *events_thread;
  75. pthread_mutex_t *comm_mutex;
  76. pthread_cond_t *cond_reply_ready;
  77. pthread_mutex_t *mutex_reply_ready;
  78. pthread_cond_t *cond_reply_ack;
  79. pthread_mutex_t *mutex_reply_ack;
  80. char *reply;
  81. } SPDConnection;
  82. /* -------------- Public functions --------------------------*/
  83. /* Opening and closing Speech Dispatcher connection */
  84. SPDConnectionAddress *spd_get_default_address(char **error);
  85. SPDConnection *spd_open(const char *client_name, const char *connection_name,
  86. const char *user_name, SPDConnectionMode mode);
  87. SPDConnection *spd_open2(const char *client_name, const char *connection_name,
  88. const char *user_name, SPDConnectionMode mode,
  89. SPDConnectionAddress * address, int autospawn,
  90. char **error_result);
  91. void spd_close(SPDConnection * connection);
  92. /* Speaking */
  93. int spd_say(SPDConnection * connection, SPDPriority priority, const char *text);
  94. int spd_sayf(SPDConnection * connection, SPDPriority priority,
  95. const char *format, ...);
  96. /* Speech flow */
  97. int spd_stop(SPDConnection * connection);
  98. int spd_stop_all(SPDConnection * connection);
  99. int spd_stop_uid(SPDConnection * connection, int target_uid);
  100. int spd_cancel(SPDConnection * connection);
  101. int spd_cancel_all(SPDConnection * connection);
  102. int spd_cancel_uid(SPDConnection * connection, int target_uid);
  103. int spd_pause(SPDConnection * connection);
  104. int spd_pause_all(SPDConnection * connection);
  105. int spd_pause_uid(SPDConnection * connection, int target_uid);
  106. int spd_resume(SPDConnection * connection);
  107. int spd_resume_all(SPDConnection * connection);
  108. int spd_resume_uid(SPDConnection * connection, int target_uid);
  109. /* Characters and keys */
  110. int spd_key(SPDConnection * connection, SPDPriority priority,
  111. const char *key_name);
  112. int spd_char(SPDConnection * connection, SPDPriority priority,
  113. const char *character);
  114. int spd_wchar(SPDConnection * connection, SPDPriority priority,
  115. wchar_t wcharacter);
  116. /* Sound icons */
  117. int spd_sound_icon(SPDConnection * connection, SPDPriority priority,
  118. const char *icon_name);
  119. /* Setting parameters */
  120. int spd_set_voice_type(SPDConnection *, SPDVoiceType type);
  121. int spd_set_voice_type_all(SPDConnection *, SPDVoiceType type);
  122. int spd_set_voice_type_uid(SPDConnection *, SPDVoiceType type,
  123. unsigned int uid);
  124. SPDVoiceType spd_get_voice_type(SPDConnection *);
  125. int spd_set_synthesis_voice(SPDConnection *, const char *voice_name);
  126. int spd_set_synthesis_voice_all(SPDConnection *, const char *voice_name);
  127. int spd_set_synthesis_voice_uid(SPDConnection *, const char *voice_name,
  128. unsigned int uid);
  129. int spd_set_data_mode(SPDConnection * connection, SPDDataMode mode);
  130. int spd_set_notification_on(SPDConnection * connection,
  131. SPDNotification notification);
  132. int spd_set_notification_off(SPDConnection * connection,
  133. SPDNotification notification);
  134. int spd_set_notification(SPDConnection * connection,
  135. SPDNotification notification, const char *state);
  136. int spd_set_voice_rate(SPDConnection * connection, signed int rate);
  137. int spd_set_voice_rate_all(SPDConnection * connection, signed int rate);
  138. int spd_set_voice_rate_uid(SPDConnection * connection, signed int rate,
  139. unsigned int uid);
  140. int spd_get_voice_rate(SPDConnection * connection);
  141. int spd_set_voice_pitch(SPDConnection * connection, signed int pitch);
  142. int spd_set_voice_pitch_all(SPDConnection * connection, signed int pitch);
  143. int spd_set_voice_pitch_uid(SPDConnection * connection, signed int pitch,
  144. unsigned int uid);
  145. int spd_get_voice_pitch(SPDConnection * connection);
  146. int spd_set_volume(SPDConnection * connection, signed int volume);
  147. int spd_set_volume_all(SPDConnection * connection, signed int volume);
  148. int spd_set_volume_uid(SPDConnection * connection, signed int volume,
  149. unsigned int uid);
  150. int spd_get_volume(SPDConnection * connection);
  151. int spd_set_punctuation(SPDConnection * connection, SPDPunctuation type);
  152. int spd_set_punctuation_all(SPDConnection * connection, SPDPunctuation type);
  153. int spd_set_punctuation_uid(SPDConnection * connection, SPDPunctuation type,
  154. unsigned int uid);
  155. int spd_set_capital_letters(SPDConnection * connection, SPDCapitalLetters type);
  156. int spd_set_capital_letters_all(SPDConnection * connection,
  157. SPDCapitalLetters type);
  158. int spd_set_capital_letters_uid(SPDConnection * connection,
  159. SPDCapitalLetters type, unsigned int uid);
  160. int spd_set_spelling(SPDConnection * connection, SPDSpelling type);
  161. int spd_set_spelling_all(SPDConnection * connection, SPDSpelling type);
  162. int spd_set_spelling_uid(SPDConnection * connection, SPDSpelling type,
  163. unsigned int uid);
  164. int spd_set_language(SPDConnection * connection, const char *language);
  165. int spd_set_language_all(SPDConnection * connection, const char *language);
  166. int spd_set_language_uid(SPDConnection * connection, const char *language,
  167. unsigned int uid);
  168. char *spd_get_language(SPDConnection * connection);
  169. int spd_set_output_module(SPDConnection * connection,
  170. const char *output_module);
  171. int spd_set_output_module_all(SPDConnection * connection,
  172. const char *output_module);
  173. int spd_set_output_module_uid(SPDConnection * connection,
  174. const char *output_module, unsigned int uid);
  175. int spd_get_client_list(SPDConnection * connection, char **client_names,
  176. int *client_ids, int *active);
  177. int spd_get_message_list_fd(SPDConnection * connection, int target,
  178. int *msg_ids, char **client_names);
  179. char **spd_list_modules(SPDConnection * connection);
  180. void free_spd_modules(char **);
  181. char *spd_get_output_module(SPDConnection * connection);
  182. char **spd_list_voices(SPDConnection * connection);
  183. SPDVoice **spd_list_synthesis_voices(SPDConnection * connection);
  184. void free_spd_voices(SPDVoice ** voices);
  185. char **spd_execute_command_with_list_reply(SPDConnection * connection,
  186. char *command);
  187. /* Direct SSIP communication */
  188. int spd_execute_command(SPDConnection * connection, char *command);
  189. int spd_execute_command_with_reply(SPDConnection * connection, char *command,
  190. char **reply);
  191. int spd_execute_command_wo_mutex(SPDConnection * connection, char *command);
  192. char *spd_send_data(SPDConnection * connection, const char *message, int wfr);
  193. char *spd_send_data_wo_mutex(SPDConnection * connection, const char *message,
  194. int wfr);
  195. /* *INDENT-OFF* */
  196. #ifdef __cplusplus
  197. }
  198. #endif /* __cplusplus */
  199. /* *INDENT-ON* */
  200. #endif /* ifndef _LIBSPEECHD_H */