[1.36.06]

TranslateChar(): Break Korean hangul syllables into individual jamo characters.
Remove Translator_Afrikaans class.


git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@170 d46cf337-b52f-0410-862d-fd96e6ae7743
This commit is contained in:
jonsd
2008-03-23 11:05:33 +00:00
parent f45ec8f36b
commit fddf2e7265
30 changed files with 454 additions and 152 deletions
+10 -3
View File
@@ -550,7 +550,7 @@ void Translator::LookupLetter(unsigned int letter, int next_byte, char *ph_buf1)
single_letter[1] = ' ';
if(Lookup(&single_letter[2],ph_buf3) == 0)
{
TranslateRules(&single_letter[2], ph_buf3, sizeof(ph_buf3), NULL,0,NULL);
TranslateRules(&single_letter[2], ph_buf3, sizeof(ph_buf3), NULL,FLAG_NO_TRACE,NULL);
}
}
@@ -591,6 +591,7 @@ int Translator::TranslateLetter(char *word, char *phonemes, int control, int wor
int n_bytes;
int letter;
int len;
int save_option_phonemes;
char *p2;
char *pbuf;
char capital[20];
@@ -627,12 +628,15 @@ int Translator::TranslateLetter(char *word, char *phonemes, int control, int wor
}
if((ph_buf[0] == 0) && (translator_name != L('e','n')))
// if((ph_buf[0] == 0) && (word_length == 1) && (translator_name != L('e','n')))
{
// speak as English, check whether there is a translation for this character
SetTranslator2("en");
save_option_phonemes = option_phonemes;
option_phonemes = 0;
translator2->LookupLetter(letter, word[n_bytes], ph_buf);
SelectPhonemeTable(voice->phoneme_tab_ix); // revert to original phoneme table
option_phonemes = save_option_phonemes;
if(ph_buf[0] != 0)
{
sprintf(phonemes,"%cen",phonSWITCH);
@@ -664,7 +668,10 @@ int Translator::TranslateLetter(char *word, char *phonemes, int control, int wor
}
len = strlen(phonemes);
sprintf(ph_buf2,"%c%s%s",0xff,capital,ph_buf); // the 0xff marker will be removed or replaced in SetSpellingStress()
if(langopts.accents & 2)
sprintf(ph_buf2,"%c%s%s",0xff,ph_buf,capital);
else
sprintf(ph_buf2,"%c%s%s",0xff,capital,ph_buf); // the 0xff marker will be removed or replaced in SetSpellingStress()
if((len + strlen(ph_buf2)) < N_WORD_PHONEMES)
{
strcpy(&phonemes[len],ph_buf2);
+1
View File
@@ -437,6 +437,7 @@ void speak_text_string(char *data, int terminator, int len, int wait, int voice_
regs.r[1] = (int)module_data;
_kernel_swi(0x5f, &regs, &regs);
option_endpause = 1;
if((voice_num >= 0) && (voice_num != current_voice_num) && (voice_num < N_VOICE_NAMES))
{
+1 -1
View File
@@ -35,7 +35,7 @@
#include "translate.h"
#include "wave.h"
const char *version_string = "1.36.02 13.Mar.08";
const char *version_string = "1.36.06 22.Mar.08";
const int version_phdata = 0x013400;
int option_device_number = -1;
+20 -39
View File
@@ -108,7 +108,20 @@ Translator *SelectTranslator(const char *name)
switch(name2)
{
case L('a','f'):
tr = new Translator_Afrikaans();
{
static const short stress_lengths_af[8] = {170,140, 220,220, 0, 0, 250,270};
tr = new Translator();
SetupTranslator(tr,stress_lengths_af,NULL);
tr->langopts.stress_rule = 0;
tr->langopts.vowel_pause = 0x30;
tr->langopts.param[LOPT_DIERESES] = 1;
tr->langopts.param[LOPT_PREFIXES] = 1;
SetLetterVowel(tr,'y'); // add 'y' to vowels
tr->langopts.numbers = 0x8d1 + NUM_ROMAN;
tr->langopts.accents = 1;
}
break;
case L('c','y'): // Welsh
@@ -375,6 +388,7 @@ SetLengthMods(tr,3); // all equal
tr->langopts.stress_rule = 2;
tr->langopts.numbers = 0x1009 + NUM_ROMAN;
tr->langopts.stress_flags = 0x6 | 0x10;
tr->langopts.accents = 2; // "capital" after letter name
}
break;
@@ -441,6 +455,11 @@ SetLengthMods(tr,3); // all equal
}
break;
case L('k','o'): // Korean, TEST
tr = new Translator();
tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
break;
case L('k','u'): // Kurdish
{
static const unsigned char stress_amps_ku[8] = {18,18, 20,20, 20,24, 24,22 };
@@ -1043,41 +1062,3 @@ if(prev->mnemonic == 'j')
}
#endif
//**********************************************************************************************************
Translator_Afrikaans::Translator_Afrikaans() : Translator()
{//=========================================
// Initialise options for this language
static const short stress_lengths2[8] = {170,140, 220,220, 0, 0, 250,270};
langopts.stress_rule = 0;
langopts.vowel_pause = 0x30;
langopts.param[LOPT_DIERESES] = 1;
langopts.param[LOPT_PREFIXES] = 1;
SetLetterVowel(this,'y'); // add 'y' to vowels
langopts.numbers = 0x8d1 + NUM_ROMAN;
langopts.accents = 1;
memcpy(stress_lengths,stress_lengths2,sizeof(stress_lengths));
}
int Translator_Afrikaans::TranslateChar(char *ptr, int prev_in, unsigned int c, unsigned int next_in, int *insert)
{//===============================================================================================================
// look for 'n and replace by a special character (unicode: schwa)
if(!iswalpha(prev_in))
{
if((c == '\'') && (next_in == 'n'))
{
// n preceded by either apostrophe or U2019 "right single quotation mark"
ptr[0] = ' '; // delete the n
return(0x0259); // replace ' by unicode schwa character
}
}
return(c);
}
-13
View File
@@ -43,16 +43,3 @@ private:
class Translator_Afrikaans: public Translator
{//==========================================
public:
Translator_Afrikaans();
private:
int TranslateChar(char *ptr, int prev_in, unsigned int c, unsigned int next_in, int *insert);
}; // end of class Translator_Afrikaans
+66
View File
@@ -370,6 +370,9 @@ int IsAlpha(unsigned int c)
if((c >= 0x300) && (c <= 0x36f))
return(1); // combining accents
if((c >= 0x1100) && (c <= 0x11ff))
return(1); //Korean jamo
return(0);
}
@@ -1908,6 +1911,69 @@ int SubstituteChar(Translator *tr, unsigned int c, unsigned int next_in, int *in
int Translator::TranslateChar(char *ptr, int prev_in, unsigned int c, unsigned int next_in, int *insert)
{//=====================================================================================================
// To allow language specific examination and replacement of characters
int code;
int initial;
int medial;
int final;
static const unsigned char hangul_compatibility[0x34] = {
0, 0x00,0x01,0x82,0x02,0x84,0x85,0x03,
0x04,0x05,0x88,0x89,0x8a,0x8b,0x8c,0x8d,
0x8e,0x06,0x07,0x08,0x91,0x09,0x0a,0x94,
0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,0x40,
0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,
0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0x50,
0x51,0x52,0x53,0x54 };
switch(translator_name)
{
case L('a','f'):
// look for 'n and replace by a special character (unicode: schwa)
if(!iswalpha(prev_in))
{
if((c == '\'') && (next_in == 'n'))
{
// n preceded by either apostrophe or U2019 "right single quotation mark"
ptr[0] = ' '; // delete the n
return(0x0259); // replace ' by unicode schwa character
}
}
break;
case L('k','o'):
if(((code = c - 0xac00) >= 0) && (c <= 0xd7af))
{
// break a syllable hangul into 2 or 3 individual jamo
initial = (code/28)/21;
medial = (code/28) % 21;
final = code % 28;
if(initial == 11)
{
// null initial
c = medial + 0x1161;
if(final > 0)
*insert = final + 0x11a7;
}
else
{
// extact the initial and insert the remainder with a null initial
c = initial + 0x1100;
*insert = (11*28*21) + (medial*28) + final + 0xac00;
}
return(c);
}
else
if(((code = c - 0x3130) >= 0) && (code < 0x34))
{
// Hangul compatibility jamo
return(hangul_compatibility[code] + 0x1100);
}
break;
}
return(SubstituteChar(this,c,next_in,insert));
}
+2 -2
View File
@@ -348,7 +348,7 @@ typedef struct {
int thousands_sep;
int decimal_sep;
// bit 0, accent name before the letter name
// bit 0, accent name before the letter name, bit 1 "capital" after letter name
int accents;
int tone_language; // 1=tone language
@@ -448,6 +448,7 @@ private:
int LookupThousands(int value, int thousandplex, char *ph_out);
int TranslateNumber_1(char *word1, char *ph_out, unsigned int *flags, int wflags);
int TranslateRoman(char *word, char *ph_out);
int TranslateChar(char *ptr, int prev_in, unsigned int c, unsigned int next_in, int *insert);
void InitGroups(void);
void AppendPhonemes(char *string, int size, const char *ph);
@@ -465,7 +466,6 @@ protected:
virtual int Unpronouncable(char *word);
virtual void SetWordStress(char *output, unsigned int dictionary_flags, int tonic, int prev_stress);
virtual int RemoveEnding(char *word, int end_type, char *word_copy);
virtual int TranslateChar(char *ptr, int prev_in, unsigned int c, unsigned int next_in, int *insert);
virtual int TranslateNumber(char *word1, char *ph_out, unsigned int *flags, int wflags);
virtual int ChangePhonemes(PHONEME_LIST2 *phlist, int n_ph, int index, PHONEME_TAB *ph, CHANGEPH *ch);
+1 -1
View File
@@ -1583,7 +1583,7 @@ espeak_ERROR SetVoiceByName(const char *name)
memset(&voice_selector,0,sizeof(voice_selector));
// voice_selector.name = buf;
voice_selector.name = name; // include variant name in voice stack ??
voice_selector.name = (char *)name; // include variant name in voice stack ??
// first check for a voice with this filename
// This may avoid the need to call espeak_ListVoices().