mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-12-03 14:59:52 +00:00
Use the text decoder object at the top-level Synthesize/espeak_TextToPhonemes call, not in TranslateClause.
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2005 to 2013 by Jonathan Duddington
|
* Copyright (C) 2005 to 2013 by Jonathan Duddington
|
||||||
* email: jonsd@users.sourceforge.net
|
* email: jonsd@users.sourceforge.net
|
||||||
* 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
|
* 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
|
||||||
@@ -400,7 +400,15 @@ static espeak_ng_STATUS Synthesize(unsigned int unique_identifier, const void *t
|
|||||||
if (translator == NULL)
|
if (translator == NULL)
|
||||||
espeak_SetVoiceByName("default");
|
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 (;;) {
|
for (;;) {
|
||||||
out_ptr = outbuf;
|
out_ptr = outbuf;
|
||||||
@@ -422,7 +430,7 @@ static espeak_ng_STATUS Synthesize(unsigned int unique_identifier, const void *t
|
|||||||
} else if (synth_callback)
|
} else if (synth_callback)
|
||||||
finished = synth_callback((short *)outbuf, length, event_list);
|
finished = synth_callback((short *)outbuf, length, event_list);
|
||||||
if (finished) {
|
if (finished) {
|
||||||
SpeakNextClause(0, 2); // stop
|
SpeakNextClause(2); // stop
|
||||||
return ENS_SPEECH_STOPPED;
|
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].unique_identifier = my_unique_identifier;
|
||||||
event_list[0].user_data = my_user_data;
|
event_list[0].user_data = my_user_data;
|
||||||
|
|
||||||
if (SpeakNextClause(NULL, 1) == 0) {
|
if (SpeakNextClause(1) == 0) {
|
||||||
finished = 0;
|
finished = 0;
|
||||||
if ((my_mode & ENOUTPUT_MODE_SPEAK_AUDIO) == ENOUTPUT_MODE_SPEAK_AUDIO) {
|
if ((my_mode & ENOUTPUT_MODE_SPEAK_AUDIO) == ENOUTPUT_MODE_SPEAK_AUDIO) {
|
||||||
if (dispatch_audio(NULL, 0, NULL) < 0)
|
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)
|
} else if (synth_callback)
|
||||||
finished = synth_callback(NULL, 0, event_list); // NULL buffer ptr indicates end of data
|
finished = synth_callback(NULL, 0, event_list); // NULL buffer ptr indicates end of data
|
||||||
if (finished) {
|
if (finished) {
|
||||||
SpeakNextClause(0, 2); // stop
|
SpeakNextClause(2); // stop
|
||||||
return ENS_SPEECH_STOPPED;
|
return ENS_SPEECH_STOPPED;
|
||||||
}
|
}
|
||||||
return ENS_OK;
|
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
|
bits 8-23: separator character, between phoneme names
|
||||||
*/
|
*/
|
||||||
|
|
||||||
option_multibyte = textmode & 7;
|
if (p_decoder == NULL)
|
||||||
*textptr = TranslateClause(translator, *textptr, NULL, 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);
|
return GetTranslatedPhonemeString(phonememode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2005 to 2014 by Jonathan Duddington
|
* Copyright (C) 2005 to 2014 by Jonathan Duddington
|
||||||
* email: jonsd@users.sourceforge.net
|
* email: jonsd@users.sourceforge.net
|
||||||
* 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
|
* 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
|
||||||
@@ -1527,7 +1527,7 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
|
|||||||
return 0; // finished the phoneme list
|
return 0; // finished the phoneme list
|
||||||
}
|
}
|
||||||
|
|
||||||
int SpeakNextClause(const void *text_in, int control)
|
int SpeakNextClause(int control)
|
||||||
{
|
{
|
||||||
// Speak text from memory (text_in)
|
// Speak text from memory (text_in)
|
||||||
// control 0: start
|
// control 0: start
|
||||||
@@ -1539,23 +1539,17 @@ int SpeakNextClause(const void *text_in, int control)
|
|||||||
|
|
||||||
int clause_tone;
|
int clause_tone;
|
||||||
char *voice_change;
|
char *voice_change;
|
||||||
static const void *p_text = NULL;
|
|
||||||
const char *phon_out;
|
const char *phon_out;
|
||||||
|
|
||||||
if (control == 2) {
|
if (control == 2) {
|
||||||
// stop speaking
|
// stop speaking
|
||||||
p_text = NULL;
|
|
||||||
n_phoneme_list = 0;
|
n_phoneme_list = 0;
|
||||||
WcmdqStop();
|
WcmdqStop();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (text_in != NULL) {
|
if (text_decoder_eof(p_decoder)) {
|
||||||
p_text = text_in;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (p_text == NULL) {
|
|
||||||
skipping_text = 0;
|
skipping_text = 0;
|
||||||
return 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
|
// read the next clause from the input text file, translate it, and generate
|
||||||
// entries in the wavegen command queue
|
// 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);
|
CalcPitches(translator, clause_tone);
|
||||||
CalcLengths(translator);
|
CalcLengths(translator);
|
||||||
|
|||||||
@@ -492,7 +492,7 @@ espeak_ng_STATUS LoadPhData(int *srate, espeak_ng_ERROR_CONTEXT *context);
|
|||||||
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);
|
||||||
void MakeWave2(PHONEME_LIST *p, int n_ph);
|
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 SetSpeed(int control);
|
||||||
void SetEmbedded(int control, int value);
|
void SetEmbedded(int control, int value);
|
||||||
void SelectPhonemeTable(int number);
|
void SelectPhonemeTable(int number);
|
||||||
|
|||||||
@@ -1916,7 +1916,7 @@ int UpperCaseInWord(Translator *tr, char *word, int c)
|
|||||||
return 0;
|
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 ix;
|
||||||
int c;
|
int c;
|
||||||
@@ -1965,13 +1965,7 @@ const void *TranslateClause(Translator *tr, const void *vp_input, int *tone_out,
|
|||||||
int tone2;
|
int tone2;
|
||||||
|
|
||||||
if (tr == NULL)
|
if (tr == NULL)
|
||||||
return NULL;
|
return;
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
embedded_ix = 0;
|
embedded_ix = 0;
|
||||||
embedded_read = 0;
|
embedded_read = 0;
|
||||||
@@ -2683,11 +2677,6 @@ const void *TranslateClause(Translator *tr, const void *vp_input, int *tone_out,
|
|||||||
else
|
else
|
||||||
*voice_change = NULL;
|
*voice_change = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Eof() || (vp_input == NULL))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return text_decoder_get_buffer(p_decoder);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitText(int control)
|
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);
|
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 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);
|
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);
|
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);
|
void SetVoiceStack(espeak_VOICE *v, const char *variant_name);
|
||||||
|
|||||||
Reference in New Issue
Block a user