diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/seq.c | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/examples/seq.c b/examples/seq.c index 3dc94e4..892f3b8 100644 --- a/examples/seq.c +++ b/examples/seq.c @@ -6,8 +6,9 @@ #include <fcntl.h> #include <math.h> -#include <xas/vox.h> #include <xas/audio.h> +#include <xas/vox.h> +#include <xas/bank.h> #include <xas/riff.h> #include <xas/spatial.h> #include <xas/seq.h> @@ -29,6 +30,48 @@ static void usage(int argc, char **argv, const char *message, ...) { exit(EX_USAGE); } +static int record_speech_sample(xas_bank *bank, + size_t buffer_size, + size_t entry_index, + float speed, + const char *text) { + xas_vox *vox; + xas_audio_stream *source; + + if ((vox = xas_vox_new(bank->format, + buffer_size, + "/usr/bin/text2wave")) == NULL) { + goto error_vox_new; + } + + if ((source = xas_vox_stream_new(vox)) == NULL) { + goto error_vox_stream_new; + } + + xas_vox_set_voice(vox, "voice_cmu_us_slt_cg"); + xas_vox_set_parameter_float(vox, "Duration_Stretch", speed); + xas_vox_say(vox, text); + xas_vox_generate(vox); + + if (xas_bank_record(bank, source, entry_index, bank->entry_size) < 0) { + goto error_bank_record; + } + + xas_audio_stream_destroy(source); + xas_vox_destroy(vox); + + return 0; + +error_bank_record: + xas_audio_stream_destroy(source); + +error_vox_stream_new: + xas_vox_destroy(vox); + +error_vox_new: + return -1; +} + int main(int argc, char **argv) { xas_spatial_scene *scene; xas_seq *seq; |