This reverts commitsmaster0cc0300328to38d15f8f90. The0cc03003commit breaks MBROLA voice support. As such, there may be other breakages in those commits.
| extern ESPEAK_NG_API void strncpy0(char *to, const char *from, int size); | extern ESPEAK_NG_API void strncpy0(char *to, const char *from, int size); | ||||
| extern ESPEAK_NG_API int utf8_in(int *c, const char *buf); | extern ESPEAK_NG_API int utf8_in(int *c, const char *buf); | ||||
| extern ESPEAK_NG_API size_t GetFileLength(const char *filename); | |||||
| extern ESPEAK_NG_API int GetFileLength(const char *filename); | |||||
| // This version of the command-line speak program uses the | // This version of the command-line speak program uses the | ||||
| // libespeak.so.1 library | // libespeak.so.1 library | ||||
| int samplerate; | int samplerate; | ||||
| int quiet = 0; | int quiet = 0; | ||||
| int samples_total = 0; | |||||
| int samples_split = 0; | |||||
| int samples_split_seconds = 0; | |||||
| unsigned int samples_total = 0; | |||||
| unsigned int samples_split = 0; | |||||
| unsigned int samples_split_seconds = 0; | |||||
| unsigned int wavefile_count = 0; | unsigned int wavefile_count = 0; | ||||
| FILE *f_wavfile = NULL; | FILE *f_wavfile = NULL; | ||||
| static void CloseWavFile() | static void CloseWavFile() | ||||
| { | { | ||||
| int pos; | |||||
| unsigned int pos; | |||||
| if ((f_wavfile == NULL) || (f_wavfile == stdout)) | if ((f_wavfile == NULL) || (f_wavfile == stdout)) | ||||
| return; | return; | ||||
| if (numsamples > 0) { | if (numsamples > 0) { | ||||
| samples_total += numsamples; | samples_total += numsamples; | ||||
| fwrite(wav, (size_t)(numsamples*2), 1, f_wavfile); | |||||
| fwrite(wav, numsamples*2, 1, f_wavfile); | |||||
| } | } | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| int option_index = 0; | int option_index = 0; | ||||
| int c; | int c; | ||||
| size_t ix; | |||||
| int ix; | |||||
| char *optarg2; | char *optarg2; | ||||
| unsigned int value; | |||||
| int value; | |||||
| int flag_stdin = 0; | int flag_stdin = 0; | ||||
| int flag_compile = 0; | int flag_compile = 0; | ||||
| size_t filesize = 0; | |||||
| unsigned int synth_flags = espeakCHARS_AUTO | espeakPHONEMES | espeakENDPAUSE; | |||||
| int filesize = 0; | |||||
| int synth_flags = espeakCHARS_AUTO | espeakPHONEMES | espeakENDPAUSE; | |||||
| int volume = -1; | int volume = -1; | ||||
| int speed = -1; | int speed = -1; | ||||
| strncpy0(wavefile, optarg2, sizeof(filename)); | strncpy0(wavefile, optarg2, sizeof(filename)); | ||||
| break; | break; | ||||
| case 'z': // remove pause from the end of a sentence | case 'z': // remove pause from the end of a sentence | ||||
| synth_flags &= (unsigned int)~espeakENDPAUSE; | |||||
| synth_flags &= ~espeakENDPAUSE; | |||||
| break; | break; | ||||
| case 0x100: // --stdin | case 0x100: // --stdin | ||||
| flag_stdin = 1; | flag_stdin = 1; | ||||
| } | } | ||||
| if (p_text != NULL) { | if (p_text != NULL) { | ||||
| size_t size = strlen(p_text); | |||||
| int size; | |||||
| size = strlen(p_text); | |||||
| espeak_Synth(p_text, size+1, 0, POS_CHARACTER, 0, synth_flags, NULL, NULL); | espeak_Synth(p_text, size+1, 0, POS_CHARACTER, 0, synth_flags, NULL, NULL); | ||||
| } else if (flag_stdin) { | } else if (flag_stdin) { | ||||
| size_t max = 1000; | |||||
| int max = 1000; | |||||
| p_text = (char *)malloc(max); | p_text = (char *)malloc(max); | ||||
| if (flag_stdin == 2) { | if (flag_stdin == 2) { |
| { | { | ||||
| // Pack 4 characters into a word | // Pack 4 characters into a word | ||||
| int ix; | int ix; | ||||
| unsigned char c; | |||||
| unsigned int word; | unsigned int word; | ||||
| if (string == NULL) | if (string == NULL) | ||||
| word = 0; | word = 0; | ||||
| for (ix = 0; ix < 4; ix++) { | for (ix = 0; ix < 4; ix++) { | ||||
| if (string[ix] == 0) break; | if (string[ix] == 0) break; | ||||
| word |= ((unsigned int)string[ix] << (ix*8)); | |||||
| c = string[ix]; | |||||
| word |= (c << (ix*8)); | |||||
| } | } | ||||
| return word; | return word; | ||||
| } | } |
| ts->tv_nsec = tv.tv_usec*1000; | ts->tv_nsec = tv.tv_usec*1000; | ||||
| } | } | ||||
| void add_time_in_ms(struct timespec *ts, uint64_t time_in_ms) | |||||
| void add_time_in_ms(struct timespec *ts, int time_in_ms) | |||||
| { | { | ||||
| if (!ts) | if (!ts) | ||||
| return; | return; | ||||
| uint64_t t_ns = (uint64_t)ts->tv_nsec + 1000000 * time_in_ms; | |||||
| uint64_t t_ns = (uint64_t)ts->tv_nsec + 1000000 * (uint64_t)time_in_ms; | |||||
| while (t_ns >= ONE_BILLION) { | while (t_ns >= ONE_BILLION) { | ||||
| ts->tv_sec += 1; | ts->tv_sec += 1; | ||||
| t_ns -= ONE_BILLION; | t_ns -= ONE_BILLION; |
| temp = (int)(out * wdata.amplitude * kt_globals.amp_gain0); // Convert back to integer | temp = (int)(out * wdata.amplitude * kt_globals.amp_gain0); // Convert back to integer | ||||
| // mix with a recorded WAV if required for this phoneme | // mix with a recorded WAV if required for this phoneme | ||||
| unsigned char c; | |||||
| signed char c; | |||||
| int sample; | int sample; | ||||
| if (wdata.mix_wavefile_ix < wdata.n_mix_wavefile) { | if (wdata.mix_wavefile_ix < wdata.n_mix_wavefile) { |
| int LoadFrame(SpectFrame *frame, FILE *stream, int file_format_type) | int LoadFrame(SpectFrame *frame, FILE *stream, int file_format_type) | ||||
| { | { | ||||
| short ix; | short ix; | ||||
| unsigned short x; | |||||
| short x; | |||||
| unsigned short *spect_data; | unsigned short *spect_data; | ||||
| frame->time = read_double(stream); | frame->time = read_double(stream); | ||||
| espeak_ng_STATUS LoadSpectSeq(SpectSeq *spect, const char *filename) | espeak_ng_STATUS LoadSpectSeq(SpectSeq *spect, const char *filename) | ||||
| { | { | ||||
| unsigned short n; | |||||
| short temp; | |||||
| short n, temp; | |||||
| int ix; | int ix; | ||||
| uint32_t id1, id2, name_len; | uint32_t id1, id2, name_len; | ||||
| int set_max_y = 0; | int set_max_y = 0; | ||||
| } else | } else | ||||
| spect->name = NULL; | spect->name = NULL; | ||||
| fread(&n, sizeof(unsigned short), 1, stream); | |||||
| fread(&n, sizeof(short), 1, stream); | |||||
| fread(&spect->amplitude, sizeof(short), 1, stream); | fread(&spect->amplitude, sizeof(short), 1, stream); | ||||
| fread(&spect->max_y, sizeof(short), 1, stream); | fread(&spect->max_y, sizeof(short), 1, stream); | ||||
| fread(&temp, sizeof(short), 1, stream); // unused | fread(&temp, sizeof(short), 1, stream); // unused |
| return ENS_OK; | return ENS_OK; | ||||
| } | } | ||||
| size_t GetFileLength(const char *filename) | |||||
| int GetFileLength(const char *filename) | |||||
| { | { | ||||
| struct stat statbuf; | struct stat statbuf; | ||||
| extern char path_home[N_PATH_HOME]; // this is the espeak-data directory | extern char path_home[N_PATH_HOME]; // this is the espeak-data directory | ||||
| extern ESPEAK_NG_API void strncpy0(char *to, const char *from, int size); | extern ESPEAK_NG_API void strncpy0(char *to, const char *from, int size); | ||||
| extern ESPEAK_NG_API size_t GetFileLength(const char *filename); | |||||
| extern ESPEAK_NG_API int GetFileLength(const char *filename); | |||||
| char *Alloc(int size); | char *Alloc(int size); | ||||
| void Free(void *ptr); | void Free(void *ptr); | ||||
| } SOUND_ICON; | } SOUND_ICON; | ||||
| typedef struct { | typedef struct { | ||||
| unsigned int name; | |||||
| int name; | |||||
| unsigned int next_phoneme; | unsigned int next_phoneme; | ||||
| unsigned int mbr_name; | |||||
| unsigned int mbr_name2; | |||||
| int mbr_name; | |||||
| int mbr_name2; | |||||
| int percent; // percentage length of first component | int percent; // percentage length of first component | ||||
| int control; | int control; | ||||
| } MBROLA_TAB; | } MBROLA_TAB; |
| // general functions | // general functions | ||||
| extern void clock_gettime2(struct timespec *ts); | extern void clock_gettime2(struct timespec *ts); | ||||
| extern void add_time_in_ms(struct timespec *ts, uint64_t time_in_ms); | |||||
| extern void add_time_in_ms(struct timespec *ts, int time_in_ms); | |||||
| // for tests | // for tests | ||||
| extern void *wave_test_get_write_buffer(); | extern void *wave_test_get_write_buffer(); |