Browse Source

Use the text decoder object at the top-level Synthesize/espeak_TextToPhonemes call, not in TranslateClause.

master
Reece H. Dunn 8 years ago
parent
commit
ec8a7b810f

+ 22
- 7
src/libespeak-ng/speech.c View File

/* /*
* Copyright (C) 2005 to 2013 by Jonathan Duddington * Copyright (C) 2005 to 2013 by Jonathan Duddington
* email: [email protected] * 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 * 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
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;
} 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;
} }


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)
} 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;
bits 8-23: separator character, between phoneme names 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); return GetTranslatedPhonemeString(phonememode);
} }



+ 4
- 10
src/libespeak-ng/synthesize.c View File

/* /*
* Copyright (C) 2005 to 2014 by Jonathan Duddington * Copyright (C) 2005 to 2014 by Jonathan Duddington
* email: [email protected] * 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 * 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
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


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) {
p_text = text_in;
}

if (p_text == NULL) {
if (text_decoder_eof(p_decoder)) {
skipping_text = 0; skipping_text = 0;
return 0; return 0;
} }


// 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);

+ 1
- 1
src/libespeak-ng/synthesize.h View File

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);

+ 2
- 13
src/libespeak-ng/translate.c View File

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;
int tone2; int tone2;


if (tr == NULL) 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_ix = 0;
embedded_read = 0; embedded_read = 0;
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)

+ 1
- 1
src/libespeak-ng/translate.h View File

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);

Loading…
Cancel
Save