Browse Source

refactor setting tone_out in TranslateClause

master
Juho Hiltunen 7 years ago
parent
commit
cd35a6fd07
1 changed files with 10 additions and 12 deletions
  1. 10
    12
      src/libespeak-ng/translate.c

+ 10
- 12
src/libespeak-ng/translate.c View File



int terminator; int terminator;
int tone; int tone;
int tone2;


if (tr == NULL) if (tr == NULL)
return; return;


for (ix = 0; ix < N_TR_SOURCE; ix++) for (ix = 0; ix < N_TR_SOURCE; ix++)
charix[ix] = 0; charix[ix] = 0;
terminator = ReadClause(tr, source, charix, &charix_top, N_TR_SOURCE, &tone2, voice_change_name);
terminator = ReadClause(tr, source, charix, &charix_top, N_TR_SOURCE, &tone, voice_change_name);

if (tone_out != NULL) {
if (tone == 0)
*tone_out = (terminator & CLAUSE_INTONATION_TYPE) >> 12; // tone type not overridden in ReadClause, use default
else
*tone_out = tone; // override tone type
}


charix[charix_top+1] = 0; charix[charix_top+1] = 0;
charix[charix_top+2] = 0x7fff; charix[charix_top+2] = 0x7fff;
if (terminator & CLAUSE_PAUSE_LONG) if (terminator & CLAUSE_PAUSE_LONG)
clause_pause = clause_pause * 32; // pause value is *320mS not *10mS clause_pause = clause_pause * 32; // pause value is *320mS not *10mS


tone = (terminator & CLAUSE_INTONATION_TYPE) >> 12;
if (tone2 != 0) {
// override the tone type
tone = tone2;
}

for (p = source; *p != 0; p++) { for (p = source; *p != 0; p++) {
if (!isspace2(*p)) if (!isspace2(*p))
break; break;
if ((dict_flags & (FLAG_ALLOW_DOT | FLAG_NEEDS_DOT)) && (ix == word_count - 1 - dictionary_skipwords) && (terminator & CLAUSE_DOT_AFTER_LAST_WORD)) { if ((dict_flags & (FLAG_ALLOW_DOT | FLAG_NEEDS_DOT)) && (ix == word_count - 1 - dictionary_skipwords) && (terminator & CLAUSE_DOT_AFTER_LAST_WORD)) {
// probably an abbreviation such as Mr. or B. rather than end of sentence // probably an abbreviation such as Mr. or B. rather than end of sentence
clause_pause = 10; clause_pause = 10;
tone = 4;
if (tone_out != NULL)
*tone_out = 4;
} }
} }




prev_clause_pause = clause_pause; prev_clause_pause = clause_pause;


if (tone_out != NULL)
*tone_out = tone;

new_sentence = false; new_sentence = false;
if (terminator & CLAUSE_TYPE_SENTENCE) if (terminator & CLAUSE_TYPE_SENTENCE)
new_sentence = true; // next clause is a new sentence new_sentence = true; // next clause is a new sentence

Loading…
Cancel
Save