Make LoadPhData return an espeak_ng_STATUS code.

This commit is contained in:
Reece H. Dunn
2016-01-01 13:17:11 +00:00
parent 2e88afeaa0
commit c2811d074e
19 changed files with 70 additions and 38 deletions
+2 -1
View File
@@ -1,6 +1,6 @@
/* eSpeak NG API. /* 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 * 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 * it under the terms of the GNU General Public License as published by
@@ -41,6 +41,7 @@ typedef enum {
ENE_WRITE_ERROR = -2, ENE_WRITE_ERROR = -2,
ENE_OUT_OF_MEMORY = -3, ENE_OUT_OF_MEMORY = -3,
ENE_COMPILE_ERRORS = -4, ENE_COMPILE_ERRORS = -4,
ENE_VERSION_MISMATCH = -5,
} espeak_ng_STATUS; } espeak_ng_STATUS;
#define espeakINITIALIZE_PATH_ONLY 0x4000 #define espeakINITIALIZE_PATH_ONLY 0x4000
+3 -1
View File
@@ -1,7 +1,7 @@
/* /*
* Copyright (C) 2005 to 2014 by Jonathan Duddington * Copyright (C) 2005 to 2014 by Jonathan Duddington
* email: jonsd@users.sourceforge.net * 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 * 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 * it under the terms of the GNU General Public License as published by
@@ -30,7 +30,9 @@
#include <wctype.h> #include <wctype.h>
#include <wchar.h> #include <wchar.h>
#include "espeak_ng.h"
#include "speak_lib.h" #include "speak_lib.h"
#include "speech.h" #include "speech.h"
#include "phoneme.h" #include "phoneme.h"
#include "synthesize.h" #include "synthesize.h"
+3 -1
View File
@@ -1,7 +1,7 @@
/* /*
* Copyright (C) 2005 to 2007 by Jonathan Duddington * Copyright (C) 2005 to 2007 by Jonathan Duddington
* email: jonsd@users.sourceforge.net * 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 * 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 * it under the terms of the GNU General Public License as published by
@@ -27,7 +27,9 @@
#include <stdint.h> #include <stdint.h>
#endif #endif
#include "espeak_ng.h"
#include "speak_lib.h" #include "speak_lib.h"
#include "speech.h" #include "speech.h"
#include "phoneme.h" #include "phoneme.h"
#include "synthesize.h" #include "synthesize.h"
+3 -1
View File
@@ -1,7 +1,7 @@
/* /*
* Copyright (C) 2008 by Jonathan Duddington * Copyright (C) 2008 by Jonathan Duddington
* email: jonsd@users.sourceforge.net * 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: * Based on a re-implementation by:
* (c) 1993,94 Jon Iles and Nick Ing-Simmons * (c) 1993,94 Jon Iles and Nick Ing-Simmons
@@ -33,7 +33,9 @@
#include <stdint.h> #include <stdint.h>
#endif #endif
#include "espeak_ng.h"
#include "speak_lib.h" #include "speak_lib.h"
#include "speech.h" #include "speech.h"
#include "klatt.h" #include "klatt.h"
#include "phoneme.h" #include "phoneme.h"
+3 -1
View File
@@ -1,7 +1,7 @@
/* /*
* Copyright (C) 2005 to 2015 by Jonathan Duddington * Copyright (C) 2005 to 2015 by Jonathan Duddington
* email: jonsd@users.sourceforge.net * 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 * 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 * it under the terms of the GNU General Public License as published by
@@ -31,7 +31,9 @@
#include <wctype.h> #include <wctype.h>
#include <wchar.h> #include <wchar.h>
#include "espeak_ng.h"
#include "speak_lib.h" #include "speak_lib.h"
#include "speech.h" #include "speech.h"
#include "phoneme.h" #include "phoneme.h"
#include "synthesize.h" #include "synthesize.h"
+3 -1
View File
@@ -1,7 +1,7 @@
/* /*
* Copyright (C) 2005 to 2014 by Jonathan Duddington * Copyright (C) 2005 to 2014 by Jonathan Duddington
* email: jonsd@users.sourceforge.net * 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 * 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 * it under the terms of the GNU General Public License as published by
@@ -26,7 +26,9 @@
#include <stdint.h> #include <stdint.h>
#endif #endif
#include "espeak_ng.h"
#include "speak_lib.h" #include "speak_lib.h"
#include "speech.h" #include "speech.h"
#include "phoneme.h" #include "phoneme.h"
#include "synthesize.h" #include "synthesize.h"
+3 -1
View File
@@ -1,7 +1,7 @@
/* /*
* Copyright (C) 2005 to 2015 by Jonathan Duddington * Copyright (C) 2005 to 2015 by Jonathan Duddington
* email: jonsd@users.sourceforge.net * 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 * 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 * it under the terms of the GNU General Public License as published by
@@ -30,7 +30,9 @@
#include <stdint.h> #include <stdint.h>
#endif #endif
#include "espeak_ng.h"
#include "speak_lib.h" #include "speak_lib.h"
#include "speech.h" #include "speech.h"
#include "phoneme.h" #include "phoneme.h"
#include "synthesize.h" #include "synthesize.h"
+3 -1
View File
@@ -1,7 +1,7 @@
/* /*
* Copyright (C) 2005 to 2011 by Jonathan Duddington * Copyright (C) 2005 to 2011 by Jonathan Duddington
* email: jonsd@users.sourceforge.net * 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 * 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 * it under the terms of the GNU General Public License as published by
@@ -26,7 +26,9 @@
#include <stdint.h> #include <stdint.h>
#endif #endif
#include "espeak_ng.h"
#include "speak_lib.h" #include "speak_lib.h"
#include "speech.h" #include "speech.h"
#include "phoneme.h" #include "phoneme.h"
#include "synthesize.h" #include "synthesize.h"
+7 -6
View File
@@ -1,7 +1,7 @@
/* /*
* Copyright (C) 2005 to 2013 by Jonathan Duddington * Copyright (C) 2005 to 2013 by Jonathan Duddington
* email: jonsd@users.sourceforge.net * 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 * 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 * it under the terms of the GNU General Public License as published by
@@ -40,8 +40,9 @@
#include <unistd.h> #include <unistd.h>
#endif #endif
#include "speak_lib.h"
#include "espeak_ng.h" #include "espeak_ng.h"
#include "speak_lib.h"
#include "phoneme.h" #include "phoneme.h"
#include "synthesize.h" #include "synthesize.h"
#include "voice.h" #include "voice.h"
@@ -308,19 +309,19 @@ static void init_path(const char *path)
static int initialise(int control) static int initialise(int control)
{ {
int param; int param;
int result;
int srate = 22050; // default sample rate 22050 Hz int srate = 22050; // default sample rate 22050 Hz
err = EE_OK; err = EE_OK;
LoadConfig(); LoadConfig();
if ((result = LoadPhData(&srate)) != 1) { // reads sample rate from espeak-data/phontab espeak_ng_STATUS result = LoadPhData(&srate);
if (result == -1) { if (result != ENS_OK) {
if (result == ENE_READ_ERROR) {
fprintf(stderr, "Failed to load espeak-data\n"); fprintf(stderr, "Failed to load espeak-data\n");
if ((control & espeakINITIALIZE_DONT_EXIT) == 0) if ((control & espeakINITIALIZE_DONT_EXIT) == 0)
exit(1); exit(1);
} else } 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); WavegenInit(srate, 0);
+4 -1
View File
@@ -1,7 +1,7 @@
/* /*
* Copyright (C) 2005 to 2007 by Jonathan Duddington * Copyright (C) 2005 to 2007 by Jonathan Duddington
* email: jonsd@users.sourceforge.net * 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 * 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 * it under the terms of the GNU General Public License as published by
@@ -19,11 +19,14 @@
#include "config.h" #include "config.h"
#include <stdio.h>
#if HAVE_STDINT_H #if HAVE_STDINT_H
#include <stdint.h> #include <stdint.h>
#endif #endif
#include "espeak_ng.h"
#include "speak_lib.h" #include "speak_lib.h"
#include "speech.h" #include "speech.h"
#include "phoneme.h" #include "phoneme.h"
#include "synthesize.h" #include "synthesize.h"
+3 -1
View File
@@ -1,7 +1,7 @@
/* /*
* Copyright (C) 2005 to 2013 by Jonathan Duddington * Copyright (C) 2005 to 2013 by Jonathan Duddington
* email: jonsd@users.sourceforge.net * 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 * 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 * it under the terms of the GNU General Public License as published by
@@ -29,7 +29,9 @@
#include <stdint.h> #include <stdint.h>
#endif #endif
#include "espeak_ng.h"
#include "speak_lib.h" #include "speak_lib.h"
#include "speech.h" #include "speech.h"
#include "phoneme.h" #include "phoneme.h"
#include "synthesize.h" #include "synthesize.h"
+10 -9
View File
@@ -1,7 +1,7 @@
/* /*
* Copyright (C) 2005 to 2014 by Jonathan Duddington * Copyright (C) 2005 to 2014 by Jonathan Duddington
* email: jonsd@users.sourceforge.net * 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 * 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 * it under the terms of the GNU General Public License as published by
@@ -29,7 +29,9 @@
#include <stdint.h> #include <stdint.h>
#endif #endif
#include "espeak_ng.h"
#include "speak_lib.h" #include "speak_lib.h"
#include "speech.h" #include "speech.h"
#include "phoneme.h" #include "phoneme.h"
#include "synthesize.h" #include "synthesize.h"
@@ -105,25 +107,24 @@ static char *ReadPhFile(void *ptr, const char *fname, int *size)
return p; return p;
} }
int LoadPhData(int *srate) espeak_ng_STATUS LoadPhData(int *srate)
{ {
int ix; int ix;
int n_phonemes; int n_phonemes;
int version; int version;
int result = 1;
int length; int length;
int rate; int rate;
unsigned char *p; unsigned char *p;
int *pw; int *pw;
if ((phoneme_tab_data = (unsigned char *)ReadPhFile((void *)(phoneme_tab_data), "phontab", NULL)) == NULL) 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) 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) 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) if ((tunes = (TUNE *)ReadPhFile((void *)(tunes), "intonations", &length)) == NULL)
return -1; return ENE_READ_ERROR;
wavefile_data = (unsigned char *)phondata_ptr; wavefile_data = (unsigned char *)phondata_ptr;
n_tunes = length / sizeof(TUNE); n_tunes = length / sizeof(TUNE);
@@ -136,7 +137,7 @@ int LoadPhData(int *srate)
} }
if (version != version_phdata) if (version != version_phdata)
result = version; return ENE_VERSION_MISMATCH;
// set up phoneme tables // set up phoneme tables
p = phoneme_tab_data; p = phoneme_tab_data;
@@ -161,7 +162,7 @@ int LoadPhData(int *srate)
if (srate != NULL) if (srate != NULL)
*srate = rate; *srate = rate;
return result; return ENS_OK;
} }
void FreePhData(void) void FreePhData(void)
+3 -1
View File
@@ -1,7 +1,7 @@
/* /*
* Copyright (C) 2005 to 2014 by Jonathan Duddington * Copyright (C) 2005 to 2014 by Jonathan Duddington
* email: jonsd@users.sourceforge.net * 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 * 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 * it under the terms of the GNU General Public License as published by
@@ -29,7 +29,9 @@
#include <stdint.h> #include <stdint.h>
#endif #endif
#include "espeak_ng.h"
#include "speak_lib.h" #include "speak_lib.h"
#include "speech.h" #include "speech.h"
#include "phoneme.h" #include "phoneme.h"
#include "synthesize.h" #include "synthesize.h"
+2 -2
View File
@@ -1,7 +1,7 @@
/* /*
* Copyright (C) 2005 to 2014 by Jonathan Duddington * Copyright (C) 2005 to 2014 by Jonathan Duddington
* email: jonsd@users.sourceforge.net * 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 * 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 * 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); frameref_t *LookupSpect(PHONEME_TAB *this_ph, int which, FMT_PARAMS *fmt_params, int *n_frames, PHONEME_LIST *plist);
unsigned char *LookupEnvelope(int ix); unsigned char *LookupEnvelope(int ix);
int LoadPhData(int *srate); espeak_ng_STATUS LoadPhData(int *srate);
void SynthesizeInit(void); void SynthesizeInit(void);
int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume); int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume);
+3 -1
View File
@@ -1,7 +1,7 @@
/* /*
* Copyright (C) 2005 to 2015 by Jonathan Duddington * Copyright (C) 2005 to 2015 by Jonathan Duddington
* email: jonsd@users.sourceforge.net * 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 * 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 * it under the terms of the GNU General Public License as published by
@@ -31,7 +31,9 @@
#include <wctype.h> #include <wctype.h>
#include "espeak_ng.h"
#include "speak_lib.h" #include "speak_lib.h"
#include "speech.h" #include "speech.h"
#include "phoneme.h" #include "phoneme.h"
#include "synthesize.h" #include "synthesize.h"
+3 -1
View File
@@ -1,7 +1,7 @@
/* /*
* Copyright (C) 2005 to 2014 by Jonathan Duddington * Copyright (C) 2005 to 2014 by Jonathan Duddington
* email: jonsd@users.sourceforge.net * 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 * 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 * it under the terms of the GNU General Public License as published by
@@ -30,7 +30,9 @@
#include <wctype.h> #include <wctype.h>
#include <wchar.h> #include <wchar.h>
#include "espeak_ng.h"
#include "speak_lib.h" #include "speak_lib.h"
#include "speech.h" #include "speech.h"
#include "phoneme.h" #include "phoneme.h"
#include "synthesize.h" #include "synthesize.h"
+3 -1
View File
@@ -1,7 +1,7 @@
/* /*
* Copyright (C) 2005 to 2015 by Jonathan Duddington * Copyright (C) 2005 to 2015 by Jonathan Duddington
* email: jonsd@users.sourceforge.net * 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 * 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 * it under the terms of the GNU General Public License as published by
@@ -36,7 +36,9 @@
#include "dirent.h" #include "dirent.h"
#endif #endif
#include "espeak_ng.h"
#include "speak_lib.h" #include "speak_lib.h"
#include "phoneme.h" #include "phoneme.h"
#include "synthesize.h" #include "synthesize.h"
#include "voice.h" #include "voice.h"
+3 -1
View File
@@ -1,7 +1,7 @@
/* /*
* Copyright (C) 2005 to 2013 by Jonathan Duddington * Copyright (C) 2005 to 2013 by Jonathan Duddington
* email: jonsd@users.sourceforge.net * 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 * 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 * it under the terms of the GNU General Public License as published by
@@ -30,7 +30,9 @@
#include <stdint.h> #include <stdint.h>
#endif #endif
#include "espeak_ng.h"
#include "speak_lib.h" #include "speak_lib.h"
#include "speech.h" #include "speech.h"
#include "phoneme.h" #include "phoneme.h"
#include "synthesize.h" #include "synthesize.h"
+6 -6
View File
@@ -1,7 +1,7 @@
/* /*
* Copyright (C) 2005 to 2013 by Jonathan Duddington * Copyright (C) 2005 to 2013 by Jonathan Duddington
* email: jonsd@users.sourceforge.net * 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 * 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 * it under the terms of the GNU General Public License as published by
@@ -46,8 +46,8 @@
#include <locale.h> #include <locale.h>
#include <sys/stat.h> #include <sys/stat.h>
#include "speak_lib.h"
#include "espeak_ng.h" #include "espeak_ng.h"
#include "speak_lib.h"
#include "phoneme.h" #include "phoneme.h"
#include "synthesize.h" #include "synthesize.h"
@@ -343,7 +343,6 @@ static void init_path(char *argv0, char *path_specified)
static int initialise(void) static int initialise(void)
{ {
int param; int param;
int result;
int srate = 22050; // default sample rate int srate = 22050; // default sample rate
// It seems that the wctype functions don't work until the locale has been set // 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, ""); setlocale(LC_CTYPE, "");
} }
if ((result = LoadPhData(&srate)) != 1) { espeak_ng_STATUS result = LoadPhData(&srate);
if (result == -1) { if (result != ENS_OK) {
if (result == ENE_READ_ERROR) {
fprintf(stderr, "Failed to load espeak-data\n"); fprintf(stderr, "Failed to load espeak-data\n");
exit(1); exit(1);
} else } 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); WavegenInit(srate, 0);
LoadConfig(); LoadConfig();