From 93d36f1dd495078ee7d7ba95c4c5ddbb5baaeaa8 Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Mon, 7 Mar 2022 20:26:07 -0500 Subject: Add record_speech_sample() in examples/seq.c --- examples/seq.c | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) 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 #include -#include #include +#include +#include #include #include #include @@ -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; -- cgit v1.2.3