The file will be organized to have one callable function only. This should make code structure simpler. Existing code will be changed to use function parameters instead of global variables. Possible problems include too much dependencies with numbers.c.master
src/libespeak-ng/synthesize.c \ | src/libespeak-ng/synthesize.c \ | ||||
src/libespeak-ng/synth_mbrola.c \ | src/libespeak-ng/synth_mbrola.c \ | ||||
src/libespeak-ng/translate.c \ | src/libespeak-ng/translate.c \ | ||||
src/libespeak-ng/translateword.c \ | |||||
src/libespeak-ng/tr_languages.c \ | src/libespeak-ng/tr_languages.c \ | ||||
src/libespeak-ng/voices.c \ | src/libespeak-ng/voices.c \ | ||||
src/libespeak-ng/wavegen.c | src/libespeak-ng/wavegen.c | ||||
src/libespeak-ng/synthdata.h \ | src/libespeak-ng/synthdata.h \ | ||||
src/libespeak-ng/synthesize.h \ | src/libespeak-ng/synthesize.h \ | ||||
src/libespeak-ng/translate.h \ | src/libespeak-ng/translate.h \ | ||||
src/libespeak-ng/translateword.h \ | |||||
src/libespeak-ng/voice.h \ | src/libespeak-ng/voice.h \ | ||||
src/libespeak-ng/wavegen.h \ | src/libespeak-ng/wavegen.h \ | ||||
src/speechPlayer/include/speechPlayer.h \ | src/speechPlayer/include/speechPlayer.h \ |
src/libespeak-ng/synthesize.c \ | src/libespeak-ng/synthesize.c \ | ||||
src/libespeak-ng/synth_mbrola.c \ | src/libespeak-ng/synth_mbrola.c \ | ||||
src/libespeak-ng/translate.c \ | src/libespeak-ng/translate.c \ | ||||
src/libespeak-ng/translateword.c \ | |||||
src/libespeak-ng/tr_languages.c \ | src/libespeak-ng/tr_languages.c \ | ||||
src/libespeak-ng/voices.c \ | src/libespeak-ng/voices.c \ | ||||
src/libespeak-ng/wavegen.c | src/libespeak-ng/wavegen.c |
#include "ucd/ucd.h" // for ucd_toupper | #include "ucd/ucd.h" // for ucd_toupper | ||||
#include "voice.h" // for voice, voice_t | #include "voice.h" // for voice, voice_t | ||||
#include "speech.h" // for MAKE_MEM_UNDEFINED | #include "speech.h" // for MAKE_MEM_UNDEFINED | ||||
#include "translateword.h" | |||||
Translator *translator = NULL; // the main translator | Translator *translator = NULL; // the main translator | ||||
Translator *translator2 = NULL; // secondary translator for certain words | Translator *translator2 = NULL; // secondary translator for certain words | ||||
} | } | ||||
} | } | ||||
static char *SpeakIndividualLetters(Translator *tr, char *word, char *phonemes, int spell_word) | |||||
{ | |||||
int posn = 0; | |||||
int capitals = 0; | |||||
bool non_initial = false; | |||||
if (spell_word > 2) | |||||
capitals = 2; // speak 'capital' | |||||
if (spell_word > 1) | |||||
capitals |= 4; // speak character code for unknown letters | |||||
while ((*word != ' ') && (*word != 0)) { | |||||
word += TranslateLetter(tr, word, phonemes, capitals | non_initial, current_alphabet); | |||||
posn++; | |||||
non_initial = true; | |||||
if (phonemes[0] == phonSWITCH) { | |||||
// change to another language in order to translate this word | |||||
strcpy(word_phonemes, phonemes); | |||||
return NULL; | |||||
} | |||||
} | |||||
SetSpellingStress(tr, phonemes, spell_word, posn); | |||||
return word; | |||||
} | |||||
static int CheckDottedAbbrev(char *word1) | static int CheckDottedAbbrev(char *word1) | ||||
{ | { | ||||
int wc; | int wc; | ||||
// Speak as individual letters | // Speak as individual letters | ||||
phonemes[0] = 0; | phonemes[0] = 0; | ||||
if (SpeakIndividualLetters(tr, word1, phonemes, spell_word) == NULL) { | |||||
if (SpeakIndividualLetters(tr, word1, phonemes, spell_word, current_alphabet, word_phonemes) == NULL) { | |||||
if (word_length > 1) | if (word_length > 1) | ||||
return FLAG_SPELLWORD; // a mixture of languages, retranslate as individual letters, separated by spaces | return FLAG_SPELLWORD; // a mixture of languages, retranslate as individual letters, separated by spaces | ||||
return 0; | return 0; | ||||
// ?? should we say super/sub-script numbers and letters here? | // ?? should we say super/sub-script numbers and letters here? | ||||
utf8_in(&wc, wordx); | utf8_in(&wc, wordx); | ||||
if ((word_length == 1) && (IsAlpha(wc) || IsSuperscript(wc))) { | if ((word_length == 1) && (IsAlpha(wc) || IsSuperscript(wc))) { | ||||
if ((wordx = SpeakIndividualLetters(tr, wordx, phonemes, spell_word)) == NULL) | |||||
if ((wordx = SpeakIndividualLetters(tr, wordx, phonemes, spell_word, current_alphabet, word_phonemes)) == NULL) | |||||
return 0; | return 0; | ||||
strcpy(word_phonemes, phonemes); | strcpy(word_phonemes, phonemes); | ||||
return 0; | return 0; | ||||
strcpy(prefix_phonemes, phonemes); | strcpy(prefix_phonemes, phonemes); | ||||
if (dictionary_flags[0] & FLAG_ABBREV) { | if (dictionary_flags[0] & FLAG_ABBREV) { | ||||
prefix_phonemes[0] = 0; | prefix_phonemes[0] = 0; | ||||
SpeakIndividualLetters(tr, wordpf, prefix_phonemes, 1); | |||||
SpeakIndividualLetters(tr, wordpf, prefix_phonemes, 1, current_alphabet, word_phonemes); | |||||
} | } | ||||
} else | } else | ||||
strcat(prefix_phonemes, end_phonemes); | strcat(prefix_phonemes, end_phonemes); |
/* | |||||
* Copyright (C) 2005 to 2014 by Jonathan Duddington | |||||
* email: [email protected] | |||||
* 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 | |||||
* the Free Software Foundation; either version 3 of the License, or | |||||
* (at your option) any later version. | |||||
* | |||||
* This program is distributed in the hope that it will be useful, | |||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
* GNU General Public License for more details. | |||||
* | |||||
* You should have received a copy of the GNU General Public License | |||||
* along with this program; if not, see: <http://www.gnu.org/licenses/>. | |||||
*/ | |||||
#include "config.h" | |||||
#include <ctype.h> | |||||
#include <stdbool.h> | |||||
#include <stdint.h> | |||||
#include <stdio.h> | |||||
#include <stdlib.h> | |||||
#include <string.h> | |||||
#include <wchar.h> | |||||
#include <wctype.h> | |||||
#include <espeak-ng/espeak_ng.h> | |||||
#include <espeak-ng/speak_lib.h> | |||||
#include <espeak-ng/encoding.h> | |||||
#include "translate.h" | |||||
#include "dictionary.h" // for TranslateRules, LookupDictList, Cha... | |||||
#include "numbers.h" // for SetSpellingStress, TranslateLetter | |||||
#include "phoneme.h" // for phonSWITCH, PHONEME_TAB, phonPAUSE_... | |||||
#include "phonemelist.h" // for MakePhonemeList | |||||
#include "readclause.h" // for towlower2, Eof, ReadClause, is_str_... | |||||
#include "synthdata.h" // for SelectPhonemeTable, LookupPhonemeTable | |||||
#include "synthesize.h" // for PHONEME_LIST2, N_PHONEME_LIST, PHON... | |||||
#include "ucd/ucd.h" // for ucd_toupper | |||||
#include "voice.h" // for voice, voice_t | |||||
#include "speech.h" // for MAKE_MEM_UNDEFINED | |||||
char *SpeakIndividualLetters(Translator *tr, char *word, char *phonemes, int spell_word, ALPHABET *current_alphabet, char word_phonemes[]) | |||||
{ | |||||
int posn = 0; | |||||
int capitals = 0; | |||||
bool non_initial = false; | |||||
if (spell_word > 2) | |||||
capitals = 2; // speak 'capital' | |||||
if (spell_word > 1) | |||||
capitals |= 4; // speak character code for unknown letters | |||||
while ((*word != ' ') && (*word != 0)) { | |||||
word += TranslateLetter(tr, word, phonemes, capitals | non_initial, current_alphabet); | |||||
posn++; | |||||
non_initial = true; | |||||
if (phonemes[0] == phonSWITCH) { | |||||
// change to another language in order to translate this word | |||||
strcpy(word_phonemes, phonemes); | |||||
return NULL; | |||||
} | |||||
} | |||||
SetSpellingStress(tr, phonemes, spell_word, posn); | |||||
return word; | |||||
} |
/* | |||||
* Copyright (C) 2005 to 2014 by Jonathan Duddington | |||||
* email: [email protected] | |||||
* Copyright (C) 2015-2017, 2020 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 | |||||
* the Free Software Foundation; either version 3 of the License, or | |||||
* (at your option) any later version. | |||||
* | |||||
* This program is distributed in the hope that it will be useful, | |||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
* GNU General Public License for more details. | |||||
* | |||||
* You should have received a copy of the GNU General Public License | |||||
* along with this program; if not, see: <http://www.gnu.org/licenses/>. | |||||
*/ | |||||
#ifndef ESPEAK_NG_TRANSLATEWORD_H | |||||
#define ESPEAK_NG_TRANSLATEWORd_H | |||||
#include <stdbool.h> | |||||
#include <espeak-ng/espeak_ng.h> | |||||
#include <espeak-ng/encoding.h> | |||||
#ifdef __cplusplus | |||||
extern "C" | |||||
{ | |||||
#endif | |||||
char *SpeakIndividualLetters(Translator *tr, char *word, char *phonemes, int spell_word, ALPHABET *current_alphabet, char word_phonemes[]); | |||||
#ifdef __cplusplus | |||||
} | |||||
#endif | |||||
#endif |