Browse Source

Make LoadPhData return an espeak_ng_STATUS code.

master
Reece H. Dunn 9 years ago
parent
commit
c2811d074e

+ 2
- 1
src/include/espeak-ng/espeak_ng.h View File

/* 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
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
src/libespeak-ng/dictionary.c View File

/* /*
* Copyright (C) 2005 to 2014 by Jonathan Duddington * Copyright (C) 2005 to 2014 by Jonathan Duddington
* email: [email protected] * email: [email protected]
* 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
#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
src/libespeak-ng/intonation.c View File

/* /*
* Copyright (C) 2005 to 2007 by Jonathan Duddington * Copyright (C) 2005 to 2007 by Jonathan Duddington
* email: [email protected] * email: [email protected]
* 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
#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
src/libespeak-ng/klatt.c View File

/* /*
* Copyright (C) 2008 by Jonathan Duddington * Copyright (C) 2008 by Jonathan Duddington
* email: [email protected] * email: [email protected]
* 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
#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
src/libespeak-ng/numbers.c View File

/* /*
* Copyright (C) 2005 to 2015 by Jonathan Duddington * Copyright (C) 2005 to 2015 by Jonathan Duddington
* email: [email protected] * email: [email protected]
* 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
#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
src/libespeak-ng/phonemelist.c View File

/* /*
* Copyright (C) 2005 to 2014 by Jonathan Duddington * Copyright (C) 2005 to 2014 by Jonathan Duddington
* email: [email protected] * email: [email protected]
* 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
#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
src/libespeak-ng/readclause.c View File

/* /*
* Copyright (C) 2005 to 2015 by Jonathan Duddington * Copyright (C) 2005 to 2015 by Jonathan Duddington
* email: [email protected] * email: [email protected]
* 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
#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
src/libespeak-ng/setlengths.c View File

/* /*
* Copyright (C) 2005 to 2011 by Jonathan Duddington * Copyright (C) 2005 to 2011 by Jonathan Duddington
* email: [email protected] * email: [email protected]
* 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
#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
src/libespeak-ng/speak_lib.c View File

/* /*
* Copyright (C) 2005 to 2013 by Jonathan Duddington * Copyright (C) 2005 to 2013 by Jonathan Duddington
* email: [email protected] * email: [email protected]
* 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
#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"
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
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"); 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
src/libespeak-ng/spect.c View File

/* /*
* Copyright (C) 2005 to 2007 by Jonathan Duddington * Copyright (C) 2005 to 2007 by Jonathan Duddington
* email: [email protected] * email: [email protected]
* 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


#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
src/libespeak-ng/synth_mbrola.c View File

/* /*
* Copyright (C) 2005 to 2013 by Jonathan Duddington * Copyright (C) 2005 to 2013 by Jonathan Duddington
* email: [email protected] * email: [email protected]
* 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
#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
src/libespeak-ng/synthdata.c View File

/* /*
* Copyright (C) 2005 to 2014 by Jonathan Duddington * Copyright (C) 2005 to 2014 by Jonathan Duddington
* email: [email protected] * email: [email protected]
* 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
#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"
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);


} }


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;


if (srate != NULL) if (srate != NULL)
*srate = rate; *srate = rate;
return result;
return ENS_OK;
} }


void FreePhData(void) void FreePhData(void)

+ 3
- 1
src/libespeak-ng/synthesize.c View File

/* /*
* Copyright (C) 2005 to 2014 by Jonathan Duddington * Copyright (C) 2005 to 2014 by Jonathan Duddington
* email: [email protected] * email: [email protected]
* 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
#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
src/libespeak-ng/synthesize.h View File

/* /*
* Copyright (C) 2005 to 2014 by Jonathan Duddington * Copyright (C) 2005 to 2014 by Jonathan Duddington
* email: [email protected] * email: [email protected]
* 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
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
src/libespeak-ng/tr_languages.c View File

/* /*
* Copyright (C) 2005 to 2015 by Jonathan Duddington * Copyright (C) 2005 to 2015 by Jonathan Duddington
* email: [email protected] * email: [email protected]
* 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


#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
src/libespeak-ng/translate.c View File

/* /*
* Copyright (C) 2005 to 2014 by Jonathan Duddington * Copyright (C) 2005 to 2014 by Jonathan Duddington
* email: [email protected] * email: [email protected]
* 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
#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
src/libespeak-ng/voices.c View File

/* /*
* Copyright (C) 2005 to 2015 by Jonathan Duddington * Copyright (C) 2005 to 2015 by Jonathan Duddington
* email: [email protected] * email: [email protected]
* 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
#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
src/libespeak-ng/wavegen.c View File

/* /*
* Copyright (C) 2005 to 2013 by Jonathan Duddington * Copyright (C) 2005 to 2013 by Jonathan Duddington
* email: [email protected] * email: [email protected]
* 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
#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
src/speak-ng.c View File

/* /*
* Copyright (C) 2005 to 2013 by Jonathan Duddington * Copyright (C) 2005 to 2013 by Jonathan Duddington
* email: [email protected] * email: [email protected]
* 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
#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"
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
setlocale(LC_CTYPE, ""); 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"); 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();

Loading…
Cancel
Save