Browse Source

Make LoadSpect return an espeak_ng_STATUS code.

master
Reece H. Dunn 9 years ago
parent
commit
32655d264d
2 changed files with 16 additions and 13 deletions
  1. 14
    13
      src/libespeak-ng/compiledata.c
  2. 2
    0
      src/libespeak-ng/spect.c

+ 14
- 13
src/libespeak-ng/compiledata.c View File

return 0; return 0;
} }


int LoadSpect(const char *path, int control)
espeak_ng_STATUS LoadSpect(const char *path, int control, int *addr)
{ {
SpectSeq *spectseq; SpectSeq *spectseq;
int peak; int peak;
int displ;
int frame; int frame;
int n_frames; int n_frames;
int ix; int ix;


// create SpectSeq and import data // create SpectSeq and import data
spectseq = SpectSeqCreate(); spectseq = SpectSeqCreate();
if (spectseq == NULL) {
error("Failed to create SpectSeq");
return 0;
}
if (spectseq == NULL)
return ENOMEM;


snprintf(filename, sizeof(filename), "%s/../phsource/%s", path_home, path); snprintf(filename, sizeof(filename), "%s/../phsource/%s", path_home, path);
if (LoadSpectSeq(spectseq, filename) != ENS_OK) {
espeak_ng_STATUS status = LoadSpectSeq(spectseq, filename);
if (status != ENS_OK) {
error("Bad vowel file: '%s'", path); error("Bad vowel file: '%s'", path);
SpectSeqDestroy(spectseq); SpectSeqDestroy(spectseq);
return 0;
return status;
} }


// do we need additional klatt data ? // do we need additional klatt data ?
} }
} }


displ = ftell(f_phdata);
*addr = ftell(f_phdata);


seq_out.n_frames = 0; seq_out.n_frames = 0;
seq_out.sqflags = 0; seq_out.sqflags = 0;
} }


SpectSeqDestroy(spectseq); SpectSeqDestroy(spectseq);
return displ;
return ENS_OK;
} }


static int LoadWavefile(FILE *f, const char *fname) static int LoadWavefile(FILE *f, const char *fname)
id = Read4Bytes(f); id = Read4Bytes(f);
rewind(f); rewind(f);


espeak_ng_STATUS status = ENS_OK;
if (id == 0x43455053) { if (id == 0x43455053) {
*addr = LoadSpect(path, control);
status = LoadSpect(path, control, addr);
type_code = 'S'; type_code = 'S';
} else if (id == 0x46464952) { } else if (id == 0x46464952) {
*addr = LoadWavefile(f, path); *addr = LoadWavefile(f, path);
} else { } else {
error("File not SPEC or RIFF: %s", path); error("File not SPEC or RIFF: %s", path);
*addr = -1; *addr = -1;
fclose(f);
return ENS_UNSUPPORTED_PHON_FORMAT;
status = ENS_UNSUPPORTED_PHON_FORMAT;
} }
fclose(f); fclose(f);


if (status != ENS_OK)
return status;

if (*addr > 0) if (*addr > 0)
fprintf(f_phcontents, "%c 0x%.5x %s\n", type_code, *addr & 0x7fffff, path); fprintf(f_phcontents, "%c 0x%.5x %s\n", type_code, *addr & 0x7fffff, path);
} }

+ 2
- 0
src/libespeak-ng/spect.c View File

SpectSeq *SpectSeqCreate() SpectSeq *SpectSeqCreate()
{ {
SpectSeq *spect = malloc(sizeof(SpectSeq)); SpectSeq *spect = malloc(sizeof(SpectSeq));
if (!spect)
return NULL;


spect->numframes = 0; spect->numframes = 0;
spect->frames = NULL; spect->frames = NULL;

Loading…
Cancel
Save