[1.29.29] Add inital draft of language "ta", Tamil

lang=en: Don't treat "Mc" prefix as a separate word, combine it with the following word.


git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@113 d46cf337-b52f-0410-862d-fd96e6ae7743
This commit is contained in:
jonsd
2007-12-20 13:45:16 +00:00
parent 6c7e8ae54f
commit fb7230a912
25 changed files with 819 additions and 92 deletions
+17 -14
View File
@@ -976,7 +976,7 @@ void Translator::SetWordStress(char *output, unsigned int dictionary_flags, int
int done;
unsigned char vowel_stress[N_WORD_PHONEMES/2];
char syllable_type[N_WORD_PHONEMES/2];
char syllable_weight[N_WORD_PHONEMES/2];
unsigned char phonetic[N_WORD_PHONEMES];
static char consonant_types[16] = {0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0};
@@ -1040,7 +1040,7 @@ void Translator::SetWordStress(char *output, unsigned int dictionary_flags, int
// followed by two consonants, a long consonant, or consonant and end-of-word
weight++;
}
syllable_type[ix] = weight;
syllable_weight[ix] = weight;
ix++;
}
}
@@ -1164,16 +1164,14 @@ void Translator::SetWordStress(char *output, unsigned int dictionary_flags, int
{
int wt;
int max_weight = -1;
int min_weight = 10;
int prev_stressed;
for(ix = 1; ix < vowel_count; ix++)
// find the heaviest syllable, excluding the final syllable
for(ix = 1; ix < (vowel_count-1); ix++)
{
if(vowel_stress[ix] == 0)
{
if((wt = syllable_type[ix]) < min_weight)
min_weight = wt;
if(wt >= max_weight)
if((wt = syllable_weight[ix]) >= max_weight)
{
max_weight = wt;
prev_stressed = stressed_syllable;
@@ -1181,14 +1179,19 @@ void Translator::SetWordStress(char *output, unsigned int dictionary_flags, int
}
}
}
if(max_weight > min_weight)
if((syllable_weight[vowel_count-1] == 2) && (max_weight< 2))
{
// different weights, don't stress the final syllable
if((stressed_syllable == vowel_count-1) && (syllable_type[vowel_count-2] > 0))
{
stressed_syllable = vowel_count-2;
}
// the only double=heavy syllable is the final syllable, so stress this
stressed_syllable = vowel_count-1;
}
else
if(max_weight <= 0)
{
// all syllables, exclusing the last, are light. Stress the first syllable
stressed_syllable = 1;
}
vowel_stress[stressed_syllable] = 4;
max_stress = 4;
}
@@ -1253,7 +1256,7 @@ void Translator::SetWordStress(char *output, unsigned int dictionary_flags, int
if((stress == 3) && (langopts.stress_flags & 0x20))
continue; // don't use secondary stress
if((v > 1) && (langopts.stress_flags & 0x40) && (syllable_type[v]==0) && (syllable_type[v+1]>0))
if((v > 1) && (langopts.stress_flags & 0x40) && (syllable_weight[v]==0) && (syllable_weight[v+1]>0))
{
// don't put secondary stress on a light syllable which is followed by a heavy syllable
continue;
+10 -5
View File
@@ -43,7 +43,7 @@ typedef struct {
short pitch2;
} SYLLABLE;
SYLLABLE syllable_tab[N_PHONEME_LIST];
SYLLABLE *syllable_tab;
static int tone_pitch_env; /* used to return pitch envelope */
@@ -242,7 +242,7 @@ static int drops_0[8] = {0x400,0x400,0x700,0x700,0x700,0xa00,0x1800,0x0e00};
static short oflow[] = {0, 20, 12, 4, 0};
static short oflow_emf[] = {5, 24, 15, 10, 5};
static short oflow_less[] = {1, 17, 10, 5, 1};
static short back_emf[] = {36, 32, 0};
static short back_emf[] = {35, 32, 0};
typedef struct {
unsigned char pitch_env0; /* pitch envelope, tonic syllable at end */
@@ -285,7 +285,7 @@ static TONE_TABLE tone_table[N_TONE_TABLE] = {
20, 25, 34, 20, drops_0, 3, 3, 5, oflow, NULL, 15, 29, 0},
{PITCHfall, 41, 4, PITCHfall, 41, 27, // exclamation
20, 25, 34, 24, drops_0, 3, 4, 5, oflow_emf, back_emf, 18, 5, 0},
20, 25, 34, 24, drops_0, 3, 4, 5, oflow_emf, back_emf, 16, 5, 0},
{PITCHfall, 38, 2, PITCHfall, 42, 30, // statement, emphatic
20, 25, 34, 22, drops_0, 3, 3, 5, oflow, NULL, 15, 5, 0},
@@ -376,7 +376,7 @@ static void count_pitch_vowels(int start, int end, int clause_end)
if(no_tonic)
{
tone_posn = tone_posn2 = end-1;
tone_posn = tone_posn2 = end; // next position after the end of the truncated clause
}
else
if(last_primary >= 0)
@@ -880,6 +880,10 @@ void Translator::CalcPitches(int clause_type)
int count_primary;
int ph_end=n_phoneme_list;
SYLLABLE syllable_tab2[N_PHONEME_LIST];
syllable_tab = syllable_tab2; // don't use permanent storage. it's only needed during the call of CalcPitches()
if(langopts.intonation == 1)
{
CalcPitches_Tone(clause_type);
@@ -892,7 +896,7 @@ void Translator::CalcPitches(int clause_type)
option = 0;
group_tone_emph = group_tone = punct_to_tone[option][clause_type];
group_tone_emph = punct_to_tone[option][4]; // emphatic form of statement
group_tone_emph = punct_to_tone[option][5]; // emphatic form of statement
if(clause_type == 4)
no_tonic = 1; /* incomplete clause, used for abbreviations such as Mr. Dr. Mrs. */
@@ -907,6 +911,7 @@ void Translator::CalcPitches(int clause_type)
if(p->synthflags & SFLAG_SYLLABLE)
{
syllable_tab[n_st].flags = 0;
syllable_tab[n_st].env = PITCHfall;
syllable_tab[n_st++].stress = p->tone; // stress level
if(p->tone >= 4)
+2 -9
View File
@@ -1967,22 +1967,15 @@ if(option_ssml) parag=1;
}
ix += utf8_out(c1,&buf[ix]); // buf[ix++] = c1;
if(!iswalnum(c1) && (ix > (n_buf-20)))
if(((ix > (n_buf-20)) && !IsAlpha(c1) && !iswdigit(c1)) || (ix >= (n_buf-2)))
{
// clause too long, getting near end of buffer, so break here
// try to break at a word boundary (unless we actually reach the end of buffer).
buf[ix] = ' ';
buf[ix+1] = 0;
UngetC(c2);
return(CLAUSE_NONE);
}
if(ix >= (n_buf-2))
{
// reached end of buffer, must break now
buf[n_buf-2] = ' ';
buf[n_buf-1] = 0;
UngetC(c2);
return(CLAUSE_NONE);
}
}
buf[ix] = ' ';
buf[ix+1] = 0;
+1 -1
View File
@@ -35,7 +35,7 @@
#include "translate.h"
#include "wave.h"
const char *version_string = "1.29.26 18.Dec.07";
const char *version_string = "1.29.29 20.Dec.07";
const int version_phdata = 0x012924;
int option_device_number = -1;
-3
View File
@@ -33,9 +33,6 @@
#include "voice.h"
#include "translate.h"
#define PITCHfall 0
#define PITCHrise 1
extern FILE *f_log;
static void SmoothSpect(void);
+1 -1
View File
@@ -18,7 +18,7 @@
***************************************************************************/
#define N_PHONEME_LIST 700 // enough for source[] full of text, else it will truncate
#define N_PHONEME_LIST 1000 // enough for source[N_TR_SOURCE] full of text, else it will truncate
#define MAX_HARMONIC 400 // 400 * 50Hz = 20 kHz, more than enough
#define N_SEQ_FRAMES 25 // max frames in a spectrum sequence (real max is ablut 8)
+2 -1
View File
@@ -43,6 +43,7 @@ Translator_English::Translator_English() : Translator()
langopts.stress_rule = 0;
langopts.numbers = 0x41 + NUM_ROMAN;
langopts.param[LOPT_COMBINE_WORDS] = 5; // allow "mc" to cmbine with the following word
}
@@ -52,7 +53,7 @@ static unsigned char initials_bitmap[86] = {
0x20, 0x24, 0x20, 0x80, 0x10, 0x00, 0x00, 0x00,
0x00, 0x28, 0x08, 0x00, 0x88, 0x22, 0x04, 0x00, // 16
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x88, 0x22, 0x04, 0x00, 0x02, 0x00, 0x00, // 32
0x00, 0x88, 0x22, 0x04, 0x00, 0x02, 0x00, 0x04, // 32
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x28, 0x8a, 0x03, 0x00, 0x00, 0x40, 0x00, // 48
0x02, 0x00, 0x41, 0xca, 0x9b, 0x06, 0x20, 0x80,
+32 -2
View File
@@ -45,6 +45,7 @@
#define OFFSET_GREEK 0x380
#define OFFSET_CYRILLIC 0x420
#define OFFSET_DEVANAGARI 0x900
#define OFFSET_TAMIL 0xb80
static const unsigned int replace_cyrillic_latin[] =
@@ -292,7 +293,7 @@ Translator *SelectTranslator(const char *name)
tr->charset_a0 = charsets[19]; // ISCII
tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
tr->langopts.stress_rule = 6; // stress on last heaviest syllable
tr->langopts.stress_rule = 6; // stress on last heaviest syllable, excluding final syllable
tr->langopts.stress_flags = 0x10004; // use 'diminished' for unstressed final syllable
tr->langopts.numbers = 0x811;
tr->langopts.numbers2 = 0x100;
@@ -314,9 +315,14 @@ Translator *SelectTranslator(const char *name)
{
static const unsigned char stress_amps_hr[8] = {16,16, 20,20, 20,24, 24,22 };
static const short stress_lengths_hr[8] = {180,160, 200,200, 0,0, 220,230};
static const short stress_lengths_sr[8] = {160,150, 200,200, 0,0, 250,260};
tr = new Translator();
SetupTranslator(tr,stress_lengths_hr,stress_amps_hr);
if(name2 == L('s','r'))
SetupTranslator(tr,stress_lengths_sr,stress_amps_hr);
else
SetupTranslator(tr,stress_lengths_hr,stress_amps_hr);
tr->charset_a0 = charsets[2]; // ISO-8859-2
tr->langopts.stress_rule = 0;
@@ -590,6 +596,30 @@ SetLengthMods(tr,3); // all equal
}
break;
case L('t','a'):
{
static const short stress_lengths_ta[8] = {190, 190, 210, 210, 0, 0, 230, 250};
static const unsigned char stress_amps_ta[8] = {17,14, 20,19, 20,24, 24,22 };
tr = new Translator();
SetupTranslator(tr,stress_lengths_ta,stress_amps_ta);
tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
tr->langopts.stress_rule = 6; // stress on last heaviest syllable, excluding final syllable
tr->langopts.stress_flags = 0x10004; // use 'diminished' for unstressed final syllable
tr->langopts.numbers = 0x811;
tr->langopts.numbers2 = 0x100;
tr->letter_bits_offset = OFFSET_TAMIL;
memset(tr->letter_bits,0,sizeof(tr->letter_bits));
SetLetterBitsRange(tr,LETTERGP_A,0x05,0x14); // vowel letters
SetLetterBitsRange(tr,LETTERGP_A,0x3e,0x4c); // vowel signs
SetLetterBitsRange(tr,LETTERGP_B,0x3e,0x4d); // vowel signs, and virama
SetLetterBitsRange(tr,LETTERGP_C,0x15,0x39); // the main consonant range
tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
}
break;
case L('t','r'): // Turkish
{
static const unsigned char stress_amps_tr[8] = {16,16, 20,20, 20,24, 24,22 };
+11 -8
View File
@@ -88,8 +88,8 @@ static int embedded_ix;
static int embedded_read;
unsigned int embedded_list[N_EMBEDDED_LIST];
// the source text of a single clause
#define N_TR_SOURCE 350
// the source text of a single clause (UTF8 bytes)
#define N_TR_SOURCE 700
static char source[N_TR_SOURCE+40]; // extra space for embedded command & voice change info at end
int n_replace_phonemes;
@@ -339,12 +339,12 @@ unsigned char *length_mod_tabs[6] = {
};
/* index by 0=. 1=, 2=?, 3=! 4=none */
static unsigned char punctuation_to_tone[4][5] = {
{0,1,2,3,4},
{5,6,2,0,4},
{0,1,2,3,0},
{0,1,2,3,0} };
/* index by 0=. 1=, 2=?, 3=! 4=none, 5=emphasized */
static unsigned char punctuation_to_tone[4][6] = {
{0,1,2,3,0,4},
{5,6,2,0,0,4},
{0,1,2,3,0,0},
{0,1,2,3,0,0} };
void SetLengthMods(Translator *tr, int value)
@@ -369,6 +369,9 @@ int IsAlpha(unsigned int c)
if((c >= 0x901) && (c <= 0x957))
return(1); // Devanagari vowel signs and other signs
if((c >= 0xb81) && (c <= 0xbe5))
return(1); // Devanagari vowel signs and other signs
if((c >= 0x300) && (c <= 0x36f))
return(1); // combining accents
+1 -1
View File
@@ -25,7 +25,7 @@
#define N_WORD_PHONEMES 160 // max phonemes in a word
#define N_WORD_BYTES 160 // max bytes for the UTF8 characters in a word
#define N_CLAUSE_WORDS 256 // max words in a clause
#define N_CLAUSE_WORDS 300 // max words in a clause
#define N_RULE_GROUP2 120 // max num of two-letter rule chains
#define N_HASH_DICT 1024
#define N_CHARSETS 20