1 /*
2 * Copyright (c) 2012 Stefano Sabatini
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg 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
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 /**
22 * @file
23 * flite voice synth source
24 */
25
26 #include <flite/flite.h>
34
49
50 #define OFFSET(x) offsetof(FliteContext, x)
51 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
52
61 { NULL }
62 };
63
65
67
68 /* declare functions for all the supported voices */
69 #define DECLARE_REGISTER_VOICE_FN(name) \
70 cst_voice *register_cmu_us_## name(const char *); \
71 void unregister_cmu_us_## name(cst_voice *);
77
80 cst_voice * (*register_fn)(
const char *);
85
86 #define MAKE_VOICE_STRUCTURE(voice_name) { \
87 .name = #voice_name, \
88 .register_fn = register_cmu_us_ ## voice_name, \
89 .unregister_fn = unregister_cmu_us_ ## voice_name, \
90 }
97 };
98
100 {
102 for (i = 0; i <
n; i++)
104 voice_entries[i].
name, i < (n-1) ? sep :
"\n");
105 }
106
108 {
109 int i;
110
113 if (!strcmp(entry->
name, voice_name)) {
118 "Could not register voice '%s'\n", voice_name);
120 }
122 *entry_ret = entry;
123 return 0;
124 }
125 }
126
130
132 }
133
135 {
138
142 }
143
145 if (flite_init() < 0) {
148 }
150 }
151
155
158 "Both text and textfile options set: only one must be specified\n");
160 }
161
164 size_t textbuf_size;
165
168 "The text file '%s' could not be read: %s\n",
171 }
172
175 memcpy(flite->
text, textbuf, textbuf_size);
176 flite->
text[textbuf_size] = 0;
178 }
179
182 "No speech text specified, specify the 'text' or 'textfile' option\n");
184 }
185
186 /* synth all the file data in block */
190 return 0;
191 }
192
194 {
196
201 delete_wave(flite->
wave);
203 }
204
206 {
208
213
220
221 return 0;
222 }
223
225 {
228
231
235 return 0;
236 }
237
239 {
243
244 if (!nb_samples)
246
248 if (!samplesref)
250
252 nb_samples * flite->
wave->num_channels * 2);
253 samplesref->
pts = flite->
pts;
256 flite->
pts += nb_samples;
259
261 }
262
264 {
269 },
270 { NULL }
271 };
272
282 .priv_class = &flite_class,
283 };