diff options
| author | XANTRONIX Development | 2022-03-07 20:26:07 -0500 | 
|---|---|---|
| committer | XANTRONIX Development | 2022-03-07 20:26:07 -0500 | 
| commit | 93d36f1dd495078ee7d7ba95c4c5ddbb5baaeaa8 (patch) | |
| tree | 1799496f56be7cd6af682c8f0736947f990fe515 /examples | |
| parent | db032424069c9676659671f8af69b6b182765643 (diff) | |
| download | xas-93d36f1dd495078ee7d7ba95c4c5ddbb5baaeaa8.tar.gz xas-93d36f1dd495078ee7d7ba95c4c5ddbb5baaeaa8.tar.bz2 xas-93d36f1dd495078ee7d7ba95c4c5ddbb5baaeaa8.zip | |
Add record_speech_sample() in examples/seq.c
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; | 
 
    