@@ -1,7 +1,7 @@ | |||
/* | |||
* Copyright (C) 2005 to 2013 by Jonathan Duddington | |||
* email: [email protected] | |||
* Copyright (C) 2013-2016 Reece H. Dunn | |||
* Copyright (C) 2013-2017 Reece H. Dunn | |||
* | |||
* 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 | |||
@@ -400,7 +400,15 @@ static espeak_ng_STATUS Synthesize(unsigned int unique_identifier, const void *t | |||
if (translator == NULL) | |||
espeak_SetVoiceByName("default"); | |||
SpeakNextClause(text, 0); | |||
if (p_decoder == NULL) | |||
p_decoder = create_text_decoder(); | |||
espeak_ng_STATUS status; | |||
status = text_decoder_decode_string_multibyte(p_decoder, text, translator->encoding, flags); | |||
if (status != ENS_OK) | |||
return status; | |||
SpeakNextClause(0); | |||
for (;;) { | |||
out_ptr = outbuf; | |||
@@ -422,7 +430,7 @@ static espeak_ng_STATUS Synthesize(unsigned int unique_identifier, const void *t | |||
} else if (synth_callback) | |||
finished = synth_callback((short *)outbuf, length, event_list); | |||
if (finished) { | |||
SpeakNextClause(0, 2); // stop | |||
SpeakNextClause(2); // stop | |||
return ENS_SPEECH_STOPPED; | |||
} | |||
@@ -435,7 +443,7 @@ static espeak_ng_STATUS Synthesize(unsigned int unique_identifier, const void *t | |||
event_list[0].unique_identifier = my_unique_identifier; | |||
event_list[0].user_data = my_user_data; | |||
if (SpeakNextClause(NULL, 1) == 0) { | |||
if (SpeakNextClause(1) == 0) { | |||
finished = 0; | |||
if ((my_mode & ENOUTPUT_MODE_SPEAK_AUDIO) == ENOUTPUT_MODE_SPEAK_AUDIO) { | |||
if (dispatch_audio(NULL, 0, NULL) < 0) | |||
@@ -443,7 +451,7 @@ static espeak_ng_STATUS Synthesize(unsigned int unique_identifier, const void *t | |||
} else if (synth_callback) | |||
finished = synth_callback(NULL, 0, event_list); // NULL buffer ptr indicates end of data | |||
if (finished) { | |||
SpeakNextClause(0, 2); // stop | |||
SpeakNextClause(2); // stop | |||
return ENS_SPEECH_STOPPED; | |||
} | |||
return ENS_OK; | |||
@@ -813,8 +821,15 @@ ESPEAK_API const char *espeak_TextToPhonemes(const void **textptr, int textmode, | |||
bits 8-23: separator character, between phoneme names | |||
*/ | |||
option_multibyte = textmode & 7; | |||
*textptr = TranslateClause(translator, *textptr, NULL, NULL); | |||
if (p_decoder == NULL) | |||
p_decoder = create_text_decoder(); | |||
if (text_decoder_decode_string_multibyte(p_decoder, *textptr, translator->encoding, textmode) != ENS_OK) | |||
return NULL; | |||
TranslateClause(translator, NULL, NULL); | |||
*textptr = text_decoder_get_buffer(p_decoder); | |||
return GetTranslatedPhonemeString(phonememode); | |||
} | |||
@@ -1,7 +1,7 @@ | |||
/* | |||
* Copyright (C) 2005 to 2014 by Jonathan Duddington | |||
* email: [email protected] | |||
* Copyright (C) 2015-2016 Reece H. Dunn | |||
* Copyright (C) 2015-2017 Reece H. Dunn | |||
* | |||
* 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 | |||
@@ -1527,7 +1527,7 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume) | |||
return 0; // finished the phoneme list | |||
} | |||
int SpeakNextClause(const void *text_in, int control) | |||
int SpeakNextClause(int control) | |||
{ | |||
// Speak text from memory (text_in) | |||
// control 0: start | |||
@@ -1539,23 +1539,17 @@ int SpeakNextClause(const void *text_in, int control) | |||
int clause_tone; | |||
char *voice_change; | |||
static const void *p_text = NULL; | |||
const char *phon_out; | |||
if (control == 2) { | |||
// stop speaking | |||
p_text = NULL; | |||
n_phoneme_list = 0; | |||
WcmdqStop(); | |||
return 0; | |||
} | |||
if (text_in != NULL) { | |||
p_text = text_in; | |||
} | |||
if (p_text == NULL) { | |||
if (text_decoder_eof(p_decoder)) { | |||
skipping_text = 0; | |||
return 0; | |||
} | |||
@@ -1565,7 +1559,7 @@ int SpeakNextClause(const void *text_in, int control) | |||
// read the next clause from the input text file, translate it, and generate | |||
// entries in the wavegen command queue | |||
p_text = TranslateClause(translator, p_text, &clause_tone, &voice_change); | |||
TranslateClause(translator, &clause_tone, &voice_change); | |||
CalcPitches(translator, clause_tone); | |||
CalcLengths(translator); |
@@ -492,7 +492,7 @@ espeak_ng_STATUS LoadPhData(int *srate, espeak_ng_ERROR_CONTEXT *context); | |||
void SynthesizeInit(void); | |||
int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume); | |||
void MakeWave2(PHONEME_LIST *p, int n_ph); | |||
int SpeakNextClause(const void *text_in, int control); | |||
int SpeakNextClause(int control); | |||
void SetSpeed(int control); | |||
void SetEmbedded(int control, int value); | |||
void SelectPhonemeTable(int number); |
@@ -1916,7 +1916,7 @@ int UpperCaseInWord(Translator *tr, char *word, int c) | |||
return 0; | |||
} | |||
const void *TranslateClause(Translator *tr, const void *vp_input, int *tone_out, char **voice_change) | |||
void TranslateClause(Translator *tr, int *tone_out, char **voice_change) | |||
{ | |||
int ix; | |||
int c; | |||
@@ -1965,13 +1965,7 @@ const void *TranslateClause(Translator *tr, const void *vp_input, int *tone_out, | |||
int tone2; | |||
if (tr == NULL) | |||
return NULL; | |||
if (p_decoder == NULL) | |||
p_decoder = create_text_decoder(); | |||
if (text_decoder_decode_string_multibyte(p_decoder, vp_input, tr->encoding, option_multibyte) != ENS_OK) | |||
return NULL; | |||
return; | |||
embedded_ix = 0; | |||
embedded_read = 0; | |||
@@ -2683,11 +2677,6 @@ const void *TranslateClause(Translator *tr, const void *vp_input, int *tone_out, | |||
else | |||
*voice_change = NULL; | |||
} | |||
if (Eof() || (vp_input == NULL)) | |||
return NULL; | |||
return text_decoder_get_buffer(p_decoder); | |||
} | |||
void InitText(int control) |
@@ -760,7 +760,7 @@ int Unpronouncable(Translator *tr, char *word, int posn); | |||
void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, int tonic, int prev_stress); | |||
int TranslateRules(Translator *tr, char *p, char *phonemes, int size, char *end_phonemes, int end_flags, unsigned int *dict_flags); | |||
int TranslateWord(Translator *tr, char *word1, WORD_TAB *wtab, char *word_out); | |||
const void *TranslateClause(Translator *tr, const void *vp_input, int *tone, char **voice_change); | |||
void TranslateClause(Translator *tr, int *tone, char **voice_change); | |||
int ReadClause(Translator *tr, char *buf, short *charix, int *charix_top, int n_buf, int *tone_type, char *voice_change); | |||
void SetVoiceStack(espeak_VOICE *v, const char *variant_name); |