ENS_MBROLA_VOICE_NOT_FOUND = 0x100008FF, | ENS_MBROLA_VOICE_NOT_FOUND = 0x100008FF, | ||||
ENS_EVENT_BUFFER_FULL = 0x100009FF, | ENS_EVENT_BUFFER_FULL = 0x100009FF, | ||||
ENS_NOT_SUPPORTED = 0x10000AFF, | ENS_NOT_SUPPORTED = 0x10000AFF, | ||||
ENS_UNSUPPORTED_SPECT_FORMAT = 0x10000BFF, | |||||
ENS_NO_SPECT_FRAMES = 0x10000CFF, | |||||
} espeak_ng_STATUS; | } espeak_ng_STATUS; | ||||
typedef enum { | typedef enum { |
} | } | ||||
snprintf(filename, sizeof(filename), "%s/../phsource/%s", path_home, path); | snprintf(filename, sizeof(filename), "%s/../phsource/%s", path_home, path); | ||||
LoadSpectSeq(spectseq, filename); | |||||
if (spectseq->frames == NULL) { | |||||
error("Bad vowel file, no frames: '%s'", path); | |||||
if (LoadSpectSeq(spectseq, filename) != ENS_OK) { | |||||
error("Bad vowel file: '%s'", path); | |||||
SpectSeqDestroy(spectseq); | SpectSeqDestroy(spectseq); | ||||
return 0; | return 0; | ||||
} | } |
#include "config.h" | #include "config.h" | ||||
#include <errno.h> | |||||
#include <stdio.h> | #include <stdio.h> | ||||
#if HAVE_STDINT_H | #if HAVE_STDINT_H | ||||
#include <stdint.h> | #include <stdint.h> | ||||
return (spect->frames[ix]->time - spect->frames[frame]->time) * 1000.0 + adjust; | return (spect->frames[ix]->time - spect->frames[frame]->time) * 1000.0 + adjust; | ||||
} | } | ||||
int LoadSpectSeq(SpectSeq *spect, const char *filename) | |||||
espeak_ng_STATUS LoadSpectSeq(SpectSeq *spect, const char *filename) | |||||
{ | { | ||||
short n, temp; | short n, temp; | ||||
int ix; | int ix; | ||||
FILE *stream = fopen(filename, "rb"); | FILE *stream = fopen(filename, "rb"); | ||||
if (stream == NULL) { | if (stream == NULL) { | ||||
fprintf(stderr, "Failed to open: '%s'", filename); | fprintf(stderr, "Failed to open: '%s'", filename); | ||||
return 0; | |||||
return errno; | |||||
} | } | ||||
fread(&id1, sizeof(uint32_t), 1, stream); | fread(&id1, sizeof(uint32_t), 1, stream); | ||||
else { | else { | ||||
fprintf(stderr, "Unsupported spectral file format.\n"); | fprintf(stderr, "Unsupported spectral file format.\n"); | ||||
fclose(stream); | fclose(stream); | ||||
return 1; | |||||
return ENS_UNSUPPORTED_SPECT_FORMAT; | |||||
} | } | ||||
fread(&name_len, sizeof(uint32_t), 1, stream); | fread(&name_len, sizeof(uint32_t), 1, stream); | ||||
if (n == 0) { | if (n == 0) { | ||||
fclose(stream); | fclose(stream); | ||||
return 0; | |||||
return ENS_NO_SPECT_FRAMES; | |||||
} | } | ||||
if (spect->frames != NULL) { | if (spect->frames != NULL) { | ||||
spect->frames[ix]->length_adjust = spect->frames[ix]->length - GetFrameLength(spect, ix); | spect->frames[ix]->length_adjust = spect->frames[ix]->length - GetFrameLength(spect, ix); | ||||
} | } | ||||
fclose(stream); | fclose(stream); | ||||
return 0; | |||||
return ENS_OK; | |||||
} | } |
/* | /* | ||||
* 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 | ||||
SpectSeq *SpectSeqCreate(); | SpectSeq *SpectSeqCreate(); | ||||
void SpectSeqDestroy(SpectSeq *spect); | void SpectSeqDestroy(SpectSeq *spect); | ||||
int LoadSpectSeq(SpectSeq *spect, const char *filename); | |||||
espeak_ng_STATUS LoadSpectSeq(SpectSeq *spect, const char *filename); | |||||
#ifdef __cplusplus | #ifdef __cplusplus | ||||
} | } |