1 | /*************************************************************************/ |
2 | /* */ |
3 | /* Language Technologies Institute */ |
4 | /* Carnegie Mellon University */ |
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 | /* CARNEGIE MELLON UNIVERSITY 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 CARNEGIE MELLON UNIVERSITY 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@cs.cmu.edu) */ |
34 | /* Date: December 1999 */ |
35 | /*************************************************************************/ |
36 | /* */ |
37 | /* Light weight run-time speech synthesis system, public API */ |
38 | /* */ |
39 | /*************************************************************************/ |
40 | #ifndef _FLITE_H__ |
41 | #define _FLITE_H__ |
42 | |
43 | #ifdef __cplusplus |
44 | extern "C" { |
45 | #endif /* __cplusplus */ |
46 | |
47 | #include "cst_string.h" |
48 | #include "cst_regex.h" |
49 | #include "cst_val.h" |
50 | #include "cst_features.h" |
51 | #include "cst_item.h" |
52 | #include "cst_relation.h" |
53 | #include "cst_utterance.h" |
54 | #include "cst_wave.h" |
55 | #include "cst_track.h" |
56 | |
57 | #include "cst_cart.h" |
58 | #include "cst_phoneset.h" |
59 | #include "cst_voice.h" |
60 | #include "cst_audio.h" |
61 | |
62 | #include "cst_utt_utils.h" |
63 | #include "cst_lexicon.h" |
64 | #include "cst_synth.h" |
65 | #include "cst_units.h" |
66 | #include "cst_tokenstream.h" |
67 | |
68 | #ifdef WIN32 |
69 | /* For Visual Studio 2012 global variable definitions */ |
70 | #define GLOBALVARDEF __declspec(dllexport) |
71 | #else |
72 | #define GLOBALVARDEF |
73 | #endif |
74 | extern GLOBALVARDEF cst_val *flite_voice_list; |
75 | extern GLOBALVARDEF cst_lang flite_lang_list[20]; |
76 | extern GLOBALVARDEF int flite_lang_list_length; |
77 | |
78 | /* Public functions */ |
79 | int flite_init(); |
80 | |
81 | /* General top level functions */ |
82 | cst_voice *flite_voice_select(const char *name); |
83 | cst_voice *flite_voice_load(const char *voice_filename); |
84 | int flite_voice_dump(cst_voice *voice, const char *voice_filename); |
85 | float flite_file_to_speech(const char *filename, |
86 | cst_voice *voice, |
87 | const char *outtype); |
88 | float flite_text_to_speech(const char *text, |
89 | cst_voice *voice, |
90 | const char *outtype); |
91 | float flite_phones_to_speech(const char *text, |
92 | cst_voice *voice, |
93 | const char *outtype); |
94 | float flite_ssml_file_to_speech(const char *filename, |
95 | cst_voice *voice, |
96 | const char *outtype); |
97 | float flite_ssml_text_to_speech(const char *text, |
98 | cst_voice *voice, |
99 | const char *outtype); |
100 | int flite_voice_add_lex_addenda(cst_voice *v, const cst_string *lexfile); |
101 | |
102 | /* Lower lever user functions */ |
103 | cst_wave *flite_text_to_wave(const char *text,cst_voice *voice); |
104 | cst_utterance *flite_synth_text(const char *text,cst_voice *voice); |
105 | cst_utterance *flite_synth_phones(const char *phones,cst_voice *voice); |
106 | |
107 | float flite_ts_to_speech(cst_tokenstream *ts, |
108 | cst_voice *voice, |
109 | const char *outtype); |
110 | cst_utterance *flite_do_synth(cst_utterance *u, |
111 | cst_voice *voice, |
112 | cst_uttfunc synth); |
113 | float flite_process_output(cst_utterance *u, |
114 | const char *outtype, |
115 | int append); |
116 | |
117 | /* for voices with external voxdata */ |
118 | int flite_mmap_clunit_voxdata(const char *voxdir, cst_voice *voice); |
119 | int flite_munmap_clunit_voxdata(cst_voice *voice); |
120 | |
121 | /* flite public export wrappers for features access */ |
122 | int flite_get_param_int(const cst_features *f, const char *name,int def); |
123 | float flite_get_param_float(const cst_features *f, const char *name, float def); |
124 | const char *flite_get_param_string(const cst_features *f, const char *name, const char *def); |
125 | const cst_val *flite_get_param_val(const cst_features *f, const char *name, cst_val *def); |
126 | void flite_feat_set_int(cst_features *f, const char *name, int v); |
127 | void flite_feat_set_float(cst_features *f, const char *name, float v); |
128 | void flite_feat_set_string(cst_features *f, const char *name, const char *v); |
129 | void flite_feat_set(cst_features *f, const char *name,const cst_val *v); |
130 | int flite_feat_remove(cst_features *f, const char *name); |
131 | |
132 | const char *flite_ffeature_string(const cst_item *item,const char *featpath); |
133 | int flite_ffeature_int(const cst_item *item,const char *featpath); |
134 | float flite_ffeature_float(const cst_item *item,const char *featpath); |
135 | const cst_val *flite_ffeature(const cst_item *item,const char *featpath); |
136 | cst_item* flite_path_to_item(const cst_item *item,const char *featpath); |
137 | |
138 | /* These functions are *not* thread-safe, they are designed to be called */ |
139 | /* before the initial synthesis occurs */ |
140 | int flite_add_voice(cst_voice *voice); |
141 | int flite_add_lang(const char *langname, |
142 | void (*lang_init)(cst_voice *vox), |
143 | cst_lexicon *(*lex_init)()); |
144 | /* These are init functions for generic grapheme based voices */ |
145 | void utf8_grapheme_lang_init(cst_voice *v); |
146 | cst_lexicon *utf8_grapheme_lex_init(void); |
147 | |
148 | #ifdef __cplusplus |
149 | } /* extern "C" */ |
150 | #endif /* __cplusplus */ |
151 | |
152 | #endif |
153 | |