Initial import to Gerrit.
[profile/ivi/festival.git] / examples / festival_client.h
1 /*************************************************************************/
2 /*                                                                       */
3 /*                Centre for Speech Technology Research                  */
4 /*                     University of Edinburgh, UK                       */
5 /*                        Copyright (c) 1999                             */
6 /*                        All Rights Reserved.                           */
7 /*                                                                       */
8 /*  Permission is hereby granted, free of charge, to use and distribute  */
9 /*  this software and its documentation without restriction, including   */
10 /*  without limitation the rights to use, copy, modify, merge, publish,  */
11 /*  distribute, sublicense, and/or sell copies of this work, and to      */
12 /*  permit persons to whom this work is furnished to do so, subject to   */
13 /*  the following conditions:                                            */
14 /*   1. The code must retain the above copyright notice, this list of    */
15 /*      conditions and the following disclaimer.                         */
16 /*   2. Any modifications must be clearly marked as such.                */
17 /*   3. Original authors' names are not deleted.                         */
18 /*   4. The authors' names are not used to endorse or promote products   */
19 /*      derived from this software without specific prior written        */
20 /*      permission.                                                      */
21 /*                                                                       */
22 /*  THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK        */
23 /*  DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING      */
24 /*  ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT   */
25 /*  SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE     */
26 /*  FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES    */
27 /*  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN   */
28 /*  AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,          */
29 /*  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF       */
30 /*  THIS SOFTWARE.                                                       */
31 /*                                                                       */
32 /*************************************************************************/
33 /*             Author :  Alan W Black (awb@cstr.ed.ac.uk)                */
34 /*             Date   :  March 1999                                      */
35 /*-----------------------------------------------------------------------*/
36 /*                                                                       */
37 /* Client end of Festival server API (in C) designed specifically for    */
38 /* Galaxy Communicator use, though might be of use for other things      */
39 /*                                                                       */
40 /*=======================================================================*/
41 #ifndef _FESTIVAL_CLIENT_H_
42 #define _FESTIVAL_CLIENT_H_
43
44 #define FESTIVAL_DEFAULT_SERVER_HOST "localhost"
45 #define FESTIVAL_DEFAULT_SERVER_PORT 1314
46 #define FESTIVAL_DEFAULT_TEXT_MODE "fundamental"
47
48 typedef struct FT_Info
49 {
50     int encoding;
51     char *server_host;
52     int server_port;
53     char *text_mode;
54     
55     int server_fd;
56 } FT_Info;
57
58 typedef struct FT_Wave
59 {
60     int num_samples;
61     int sample_rate;
62     short *samples;
63 } FT_Wave;
64
65 void delete_FT_Wave(FT_Wave *wave);
66 void delete_FT_Info(FT_Info *info);
67
68 #define SWAPSHORT(x) ((((unsigned)x) & 0xff) << 8 | \
69                       (((unsigned)x) & 0xff00) >> 8)
70 #define SWAPINT(x) ((((unsigned)x) & 0xff) << 24 | \
71                     (((unsigned)x) & 0xff00) << 8 | \
72                     (((unsigned)x) & 0xff0000) >> 8 | \
73                     (((unsigned)x) & 0xff000000) >> 24)
74
75 /* Sun, HP, SGI Mips, M68000 */
76 #define FAPI_BIG_ENDIAN (((char *)&fapi_endian_loc)[0] == 0)
77 /* Intel, Alpha, DEC Mips, Vax */
78 #define FAPI_LITTLE_ENDIAN (((char *)&fapi_endian_loc)[0] != 0)
79
80
81 /*****************************************************************/
82 /*  Public functions to interface                                */
83 /*****************************************************************/
84
85 /* If called with NULL will attempt to access using defaults */
86 FT_Info *festivalOpen(FT_Info *info);
87 FT_Wave *festivalStringToWave(FT_Info *info,char *text);
88 int festivalClose(FT_Info *info);
89
90 #endif