Browse Source

Update translate.c

master
Dane Madsen 1 year ago
parent
commit
84e967c0a2
1 changed files with 14 additions and 4 deletions
  1. 14
    4
      src/libespeak-ng/translate.c

+ 14
- 4
src/libespeak-ng/translate.c View File

return 0; return 0;
} }


void TranslateClause(Translator *tr, int *tone_out, char **voice_change)
// Same as TranslateClause except we also get the clause terminator used (full stop, comma, etc.).
// Used by espeak_TextToPhonemesWithTerminator.
void TranslateClauseWithTerminator(Translator *tr, int *tone_out, char **voice_change, int *terminator_out)
{ {
int ix; int ix;
int c; int c;
MAKE_MEM_UNDEFINED(&source, sizeof(source)); MAKE_MEM_UNDEFINED(&source, sizeof(source));
terminator = ReadClause(tr, source, charix, &charix_top, N_TR_SOURCE, &tone, voice_change_name); terminator = ReadClause(tr, source, charix, &charix_top, N_TR_SOURCE, &tone, voice_change_name);


if (terminator_out != NULL) {
*terminator_out = terminator;
}

if (tone_out != NULL) { if (tone_out != NULL) {
if (tone == 0) if (tone == 0)
*tone_out = (terminator & CLAUSE_INTONATION_TYPE) >> 12; // tone type not overridden in ReadClause, use default *tone_out = (terminator & CLAUSE_INTONATION_TYPE) >> 12; // tone type not overridden in ReadClause, use default
} else { } else {
if (iswlower(prev_in)) { if (iswlower(prev_in)) {
// lower case followed by upper case, possibly CamelCase // lower case followed by upper case, possibly CamelCase
if ((prev_out != ' ') && UpperCaseInWord(tr, &sbuf[ix], c) == 0) { // start a new word
if (UpperCaseInWord(tr, &sbuf[ix], c) == 0) { // start a new word
c = ' '; c = ' ';
space_inserted = true; space_inserted = true;
prev_in_save = c; prev_in_save = c;


if ((tr->translator_name == L('n', 'l')) && (letter_count == 2) && (c == 'j') && (prev_in == 'I')) { if ((tr->translator_name == L('n', 'l')) && (letter_count == 2) && (c == 'j') && (prev_in == 'I')) {
// Dutch words may capitalise initial IJ, don't split // Dutch words may capitalise initial IJ, don't split
} else if ((prev_out != ' ') && IsAlpha(next2_in)) {
} else if (IsAlpha(next2_in)) {
// changing from upper to lower case, start new word at the last uppercase, if 3 or more letters // changing from upper to lower case, start new word at the last uppercase, if 3 or more letters
c = ' '; c = ' ';
space_inserted = true; space_inserted = true;
if (dict_flags & FLAG_SPELLWORD) { if (dict_flags & FLAG_SPELLWORD) {
// redo the word, speaking single letters // redo the word, speaking single letters
for (pw = word; *pw != ' ';) { for (pw = word; *pw != ' ';) {
memset(number_buf, 0, sizeof(number_buf));
memset(number_buf, ' ', 9); memset(number_buf, ' ', 9);
nx = utf8_in(&c_temp, pw); nx = utf8_in(&c_temp, pw);
memcpy(&number_buf[2], pw, nx); memcpy(&number_buf[2], pw, nx);
} }
} }


void TranslateClause(Translator *tr, int *tone_out, char **voice_change)
{
TranslateClauseWithTerminator(tr, tone_out, voice_change, NULL);
}

static int CalcWordLength(int source_index, int charix_top, short int *charix, WORD_TAB *words, int word_count) { static int CalcWordLength(int source_index, int charix_top, short int *charix, WORD_TAB *words, int word_count) {
int j; int j;
int k; int k;

Loading…
Cancel
Save