From c2811d074e77d2751f6d2329280584a5cbcbd75e Mon Sep 17 00:00:00 2001 From: "Reece H. Dunn" Date: Fri, 1 Jan 2016 13:17:11 +0000 Subject: [PATCH] Make LoadPhData return an espeak_ng_STATUS code. --- src/include/espeak-ng/espeak_ng.h | 3 ++- src/libespeak-ng/dictionary.c | 4 +++- src/libespeak-ng/intonation.c | 4 +++- src/libespeak-ng/klatt.c | 4 +++- src/libespeak-ng/numbers.c | 4 +++- src/libespeak-ng/phonemelist.c | 4 +++- src/libespeak-ng/readclause.c | 4 +++- src/libespeak-ng/setlengths.c | 4 +++- src/libespeak-ng/speak_lib.c | 13 +++++++------ src/libespeak-ng/spect.c | 5 ++++- src/libespeak-ng/synth_mbrola.c | 4 +++- src/libespeak-ng/synthdata.c | 19 ++++++++++--------- src/libespeak-ng/synthesize.c | 4 +++- src/libespeak-ng/synthesize.h | 4 ++-- src/libespeak-ng/tr_languages.c | 4 +++- src/libespeak-ng/translate.c | 4 +++- src/libespeak-ng/voices.c | 4 +++- src/libespeak-ng/wavegen.c | 4 +++- src/speak-ng.c | 12 ++++++------ 19 files changed, 70 insertions(+), 38 deletions(-) diff --git a/src/include/espeak-ng/espeak_ng.h b/src/include/espeak-ng/espeak_ng.h index 5acd215d..f6830eb8 100644 --- a/src/include/espeak-ng/espeak_ng.h +++ b/src/include/espeak-ng/espeak_ng.h @@ -1,6 +1,6 @@ /* eSpeak NG API. * - * Copyright (C) 2015 Reece H. Dunn + * Copyright (C) 2015-2016 Reece H. Dunn * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -41,6 +41,7 @@ typedef enum { ENE_WRITE_ERROR = -2, ENE_OUT_OF_MEMORY = -3, ENE_COMPILE_ERRORS = -4, + ENE_VERSION_MISMATCH = -5, } espeak_ng_STATUS; #define espeakINITIALIZE_PATH_ONLY 0x4000 diff --git a/src/libespeak-ng/dictionary.c b/src/libespeak-ng/dictionary.c index f3923d92..5477f222 100644 --- a/src/libespeak-ng/dictionary.c +++ b/src/libespeak-ng/dictionary.c @@ -1,7 +1,7 @@ /* * Copyright (C) 2005 to 2014 by Jonathan Duddington * email: jonsd@users.sourceforge.net - * Copyright (C) 2013-2015 Reece H. Dunn + * Copyright (C) 2013-2016 Reece H. Dunn * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,7 +30,9 @@ #include #include +#include "espeak_ng.h" #include "speak_lib.h" + #include "speech.h" #include "phoneme.h" #include "synthesize.h" diff --git a/src/libespeak-ng/intonation.c b/src/libespeak-ng/intonation.c index 7290df0d..8b4d99ec 100644 --- a/src/libespeak-ng/intonation.c +++ b/src/libespeak-ng/intonation.c @@ -1,7 +1,7 @@ /* * Copyright (C) 2005 to 2007 by Jonathan Duddington * email: jonsd@users.sourceforge.net - * Copyright (C) 2015 Reece H. Dunn + * Copyright (C) 2015-2016 Reece H. Dunn * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,7 +27,9 @@ #include #endif +#include "espeak_ng.h" #include "speak_lib.h" + #include "speech.h" #include "phoneme.h" #include "synthesize.h" diff --git a/src/libespeak-ng/klatt.c b/src/libespeak-ng/klatt.c index 78856f3a..87656923 100644 --- a/src/libespeak-ng/klatt.c +++ b/src/libespeak-ng/klatt.c @@ -1,7 +1,7 @@ /* * Copyright (C) 2008 by Jonathan Duddington * email: jonsd@users.sourceforge.net - * Copyright (C) 2013-2015 Reece H. Dunn + * Copyright (C) 2013-2016 Reece H. Dunn * * Based on a re-implementation by: * (c) 1993,94 Jon Iles and Nick Ing-Simmons @@ -33,7 +33,9 @@ #include #endif +#include "espeak_ng.h" #include "speak_lib.h" + #include "speech.h" #include "klatt.h" #include "phoneme.h" diff --git a/src/libespeak-ng/numbers.c b/src/libespeak-ng/numbers.c index 133d8bf0..dfa0447a 100644 --- a/src/libespeak-ng/numbers.c +++ b/src/libespeak-ng/numbers.c @@ -1,7 +1,7 @@ /* * Copyright (C) 2005 to 2015 by Jonathan Duddington * email: jonsd@users.sourceforge.net - * Copyright (C) 2015 Reece H. Dunn + * Copyright (C) 2015-2016 Reece H. Dunn * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,7 +31,9 @@ #include #include +#include "espeak_ng.h" #include "speak_lib.h" + #include "speech.h" #include "phoneme.h" #include "synthesize.h" diff --git a/src/libespeak-ng/phonemelist.c b/src/libespeak-ng/phonemelist.c index c9fc3f38..f163fd91 100644 --- a/src/libespeak-ng/phonemelist.c +++ b/src/libespeak-ng/phonemelist.c @@ -1,7 +1,7 @@ /* * Copyright (C) 2005 to 2014 by Jonathan Duddington * email: jonsd@users.sourceforge.net - * Copyright (C) 2015 Reece H. Dunn + * Copyright (C) 2015-2016 Reece H. Dunn * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,7 +26,9 @@ #include #endif +#include "espeak_ng.h" #include "speak_lib.h" + #include "speech.h" #include "phoneme.h" #include "synthesize.h" diff --git a/src/libespeak-ng/readclause.c b/src/libespeak-ng/readclause.c index 2aa58cb8..8e3288a3 100644 --- a/src/libespeak-ng/readclause.c +++ b/src/libespeak-ng/readclause.c @@ -1,7 +1,7 @@ /* * Copyright (C) 2005 to 2015 by Jonathan Duddington * email: jonsd@users.sourceforge.net - * Copyright (C) 2015 Reece H. Dunn + * Copyright (C) 2015-2016 Reece H. Dunn * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,7 +30,9 @@ #include #endif +#include "espeak_ng.h" #include "speak_lib.h" + #include "speech.h" #include "phoneme.h" #include "synthesize.h" diff --git a/src/libespeak-ng/setlengths.c b/src/libespeak-ng/setlengths.c index 66708427..2222c089 100644 --- a/src/libespeak-ng/setlengths.c +++ b/src/libespeak-ng/setlengths.c @@ -1,7 +1,7 @@ /* * Copyright (C) 2005 to 2011 by Jonathan Duddington * email: jonsd@users.sourceforge.net - * Copyright (C) 2015 Reece H. Dunn + * Copyright (C) 2015-2016 Reece H. Dunn * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,7 +26,9 @@ #include #endif +#include "espeak_ng.h" #include "speak_lib.h" + #include "speech.h" #include "phoneme.h" #include "synthesize.h" diff --git a/src/libespeak-ng/speak_lib.c b/src/libespeak-ng/speak_lib.c index b84fd27f..1103a93a 100644 --- a/src/libespeak-ng/speak_lib.c +++ b/src/libespeak-ng/speak_lib.c @@ -1,7 +1,7 @@ /* * Copyright (C) 2005 to 2013 by Jonathan Duddington * email: jonsd@users.sourceforge.net - * Copyright (C) 2013-2015 Reece H. Dunn + * Copyright (C) 2013-2016 Reece H. Dunn * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -40,8 +40,9 @@ #include #endif -#include "speak_lib.h" #include "espeak_ng.h" +#include "speak_lib.h" + #include "phoneme.h" #include "synthesize.h" #include "voice.h" @@ -308,19 +309,19 @@ static void init_path(const char *path) static int initialise(int control) { int param; - int result; int srate = 22050; // default sample rate 22050 Hz err = EE_OK; LoadConfig(); - if ((result = LoadPhData(&srate)) != 1) { // reads sample rate from espeak-data/phontab - if (result == -1) { + espeak_ng_STATUS result = LoadPhData(&srate); + if (result != ENS_OK) { + if (result == ENE_READ_ERROR) { fprintf(stderr, "Failed to load espeak-data\n"); if ((control & espeakINITIALIZE_DONT_EXIT) == 0) exit(1); } else - fprintf(stderr, "Wrong version of espeak-data 0x%x (expects 0x%x) at %s\n", result, version_phdata, path_home); + fprintf(stderr, "Wrong version of espeak-data (expected 0x%x) at %s\n", version_phdata, path_home); } WavegenInit(srate, 0); diff --git a/src/libespeak-ng/spect.c b/src/libespeak-ng/spect.c index 24497043..7d64e800 100644 --- a/src/libespeak-ng/spect.c +++ b/src/libespeak-ng/spect.c @@ -1,7 +1,7 @@ /* * Copyright (C) 2005 to 2007 by Jonathan Duddington * email: jonsd@users.sourceforge.net - * Copyright (C) 2013-2015 Reece H. Dunn + * Copyright (C) 2013-2016 Reece H. Dunn * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,11 +19,14 @@ #include "config.h" +#include #if HAVE_STDINT_H #include #endif +#include "espeak_ng.h" #include "speak_lib.h" + #include "speech.h" #include "phoneme.h" #include "synthesize.h" diff --git a/src/libespeak-ng/synth_mbrola.c b/src/libespeak-ng/synth_mbrola.c index 79d643fe..a867a092 100644 --- a/src/libespeak-ng/synth_mbrola.c +++ b/src/libespeak-ng/synth_mbrola.c @@ -1,7 +1,7 @@ /* * Copyright (C) 2005 to 2013 by Jonathan Duddington * email: jonsd@users.sourceforge.net - * Copyright (C) 2015 Reece H. Dunn + * Copyright (C) 2015-2016 Reece H. Dunn * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,7 +29,9 @@ #include #endif +#include "espeak_ng.h" #include "speak_lib.h" + #include "speech.h" #include "phoneme.h" #include "synthesize.h" diff --git a/src/libespeak-ng/synthdata.c b/src/libespeak-ng/synthdata.c index dfd75704..cab5fd2e 100644 --- a/src/libespeak-ng/synthdata.c +++ b/src/libespeak-ng/synthdata.c @@ -1,7 +1,7 @@ /* * Copyright (C) 2005 to 2014 by Jonathan Duddington * email: jonsd@users.sourceforge.net - * Copyright (C) 2015 Reece H. Dunn + * Copyright (C) 2015-2016 Reece H. Dunn * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,7 +29,9 @@ #include #endif +#include "espeak_ng.h" #include "speak_lib.h" + #include "speech.h" #include "phoneme.h" #include "synthesize.h" @@ -105,25 +107,24 @@ static char *ReadPhFile(void *ptr, const char *fname, int *size) return p; } -int LoadPhData(int *srate) +espeak_ng_STATUS LoadPhData(int *srate) { int ix; int n_phonemes; int version; - int result = 1; int length; int rate; unsigned char *p; int *pw; if ((phoneme_tab_data = (unsigned char *)ReadPhFile((void *)(phoneme_tab_data), "phontab", NULL)) == NULL) - return -1; + return ENE_READ_ERROR; if ((phoneme_index = (USHORT *)ReadPhFile((void *)(phoneme_index), "phonindex", NULL)) == NULL) - return -1; + return ENE_READ_ERROR; if ((phondata_ptr = ReadPhFile((void *)(phondata_ptr), "phondata", NULL)) == NULL) - return -1; + return ENE_READ_ERROR; if ((tunes = (TUNE *)ReadPhFile((void *)(tunes), "intonations", &length)) == NULL) - return -1; + return ENE_READ_ERROR; wavefile_data = (unsigned char *)phondata_ptr; n_tunes = length / sizeof(TUNE); @@ -136,7 +137,7 @@ int LoadPhData(int *srate) } if (version != version_phdata) - result = version; + return ENE_VERSION_MISMATCH; // set up phoneme tables p = phoneme_tab_data; @@ -161,7 +162,7 @@ int LoadPhData(int *srate) if (srate != NULL) *srate = rate; - return result; + return ENS_OK; } void FreePhData(void) diff --git a/src/libespeak-ng/synthesize.c b/src/libespeak-ng/synthesize.c index 62c42bb6..0692cca3 100644 --- a/src/libespeak-ng/synthesize.c +++ b/src/libespeak-ng/synthesize.c @@ -1,7 +1,7 @@ /* * Copyright (C) 2005 to 2014 by Jonathan Duddington * email: jonsd@users.sourceforge.net - * Copyright (C) 2015 Reece H. Dunn + * Copyright (C) 2015-2016 Reece H. Dunn * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,7 +29,9 @@ #include #endif +#include "espeak_ng.h" #include "speak_lib.h" + #include "speech.h" #include "phoneme.h" #include "synthesize.h" diff --git a/src/libespeak-ng/synthesize.h b/src/libespeak-ng/synthesize.h index 32d06f8c..13f3f057 100644 --- a/src/libespeak-ng/synthesize.h +++ b/src/libespeak-ng/synthesize.h @@ -1,7 +1,7 @@ /* * Copyright (C) 2005 to 2014 by Jonathan Duddington * email: jonsd@users.sourceforge.net - * Copyright (C) 2015 Reece H. Dunn + * Copyright (C) 2015-2016 Reece H. Dunn * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -499,7 +499,7 @@ unsigned int LookupSound(PHONEME_TAB *ph1, PHONEME_TAB *ph2, int which, int *mat frameref_t *LookupSpect(PHONEME_TAB *this_ph, int which, FMT_PARAMS *fmt_params, int *n_frames, PHONEME_LIST *plist); unsigned char *LookupEnvelope(int ix); -int LoadPhData(int *srate); +espeak_ng_STATUS LoadPhData(int *srate); void SynthesizeInit(void); int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume); diff --git a/src/libespeak-ng/tr_languages.c b/src/libespeak-ng/tr_languages.c index 8fe0ce37..59169c4c 100644 --- a/src/libespeak-ng/tr_languages.c +++ b/src/libespeak-ng/tr_languages.c @@ -1,7 +1,7 @@ /* * Copyright (C) 2005 to 2015 by Jonathan Duddington * email: jonsd@users.sourceforge.net - * Copyright (C) 2015 Reece H. Dunn + * Copyright (C) 2015-2016 Reece H. Dunn * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,7 +31,9 @@ #include +#include "espeak_ng.h" #include "speak_lib.h" + #include "speech.h" #include "phoneme.h" #include "synthesize.h" diff --git a/src/libespeak-ng/translate.c b/src/libespeak-ng/translate.c index eca9f7dd..a07e6124 100644 --- a/src/libespeak-ng/translate.c +++ b/src/libespeak-ng/translate.c @@ -1,7 +1,7 @@ /* * Copyright (C) 2005 to 2014 by Jonathan Duddington * email: jonsd@users.sourceforge.net - * Copyright (C) 2015 Reece H. Dunn + * Copyright (C) 2015-2016 Reece H. Dunn * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,7 +30,9 @@ #include #include +#include "espeak_ng.h" #include "speak_lib.h" + #include "speech.h" #include "phoneme.h" #include "synthesize.h" diff --git a/src/libespeak-ng/voices.c b/src/libespeak-ng/voices.c index 39ad360b..a168b73f 100644 --- a/src/libespeak-ng/voices.c +++ b/src/libespeak-ng/voices.c @@ -1,7 +1,7 @@ /* * Copyright (C) 2005 to 2015 by Jonathan Duddington * email: jonsd@users.sourceforge.net - * Copyright (C) 2015 Reece H. Dunn + * Copyright (C) 2015-2016 Reece H. Dunn * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -36,7 +36,9 @@ #include "dirent.h" #endif +#include "espeak_ng.h" #include "speak_lib.h" + #include "phoneme.h" #include "synthesize.h" #include "voice.h" diff --git a/src/libespeak-ng/wavegen.c b/src/libespeak-ng/wavegen.c index 149d76d4..6809f28e 100644 --- a/src/libespeak-ng/wavegen.c +++ b/src/libespeak-ng/wavegen.c @@ -1,7 +1,7 @@ /* * Copyright (C) 2005 to 2013 by Jonathan Duddington * email: jonsd@users.sourceforge.net - * Copyright (C) 2015 Reece H. Dunn + * Copyright (C) 2015-2016 Reece H. Dunn * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,7 +30,9 @@ #include #endif +#include "espeak_ng.h" #include "speak_lib.h" + #include "speech.h" #include "phoneme.h" #include "synthesize.h" diff --git a/src/speak-ng.c b/src/speak-ng.c index 42f3610c..314d57e0 100644 --- a/src/speak-ng.c +++ b/src/speak-ng.c @@ -1,7 +1,7 @@ /* * Copyright (C) 2005 to 2013 by Jonathan Duddington * email: jonsd@users.sourceforge.net - * Copyright (C) 2015 Reece H. Dunn + * Copyright (C) 2015-2016 Reece H. Dunn * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -46,8 +46,8 @@ #include #include -#include "speak_lib.h" #include "espeak_ng.h" +#include "speak_lib.h" #include "phoneme.h" #include "synthesize.h" @@ -343,7 +343,6 @@ static void init_path(char *argv0, char *path_specified) static int initialise(void) { int param; - int result; int srate = 22050; // default sample rate // It seems that the wctype functions don't work until the locale has been set @@ -354,12 +353,13 @@ static int initialise(void) setlocale(LC_CTYPE, ""); } - if ((result = LoadPhData(&srate)) != 1) { - if (result == -1) { + espeak_ng_STATUS result = LoadPhData(&srate); + if (result != ENS_OK) { + if (result == ENE_READ_ERROR) { fprintf(stderr, "Failed to load espeak-data\n"); exit(1); } else - fprintf(stderr, "Wrong version of espeak-data 0x%x (expects 0x%x) at %s\n", result, version_phdata, path_home); + fprintf(stderr, "Wrong version of espeak-data (expected 0x%x) at %s\n", version_phdata, path_home); } WavegenInit(srate, 0); LoadConfig();