Phonetables: Use "length" field in Tone phonemes to adjust the lengths of the vowel.

git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@206 d46cf337-b52f-0410-862d-fd96e6ae7743
This commit is contained in:
jonsd
2008-12-04 15:40:32 +00:00
parent f90a4e369e
commit 897237bcf1
29 changed files with 76 additions and 47 deletions
+19 -2
View File
@@ -80,6 +80,8 @@
#define tPHONEMENUMBER 29
#define tPHONEMETABLE 30
#define tINCLUDE 31
#define tSTRESSTYPE 32
static const int flags_alternative[] = {phBEFOREVOWEL,phBEFOREVOWELPAUSE,phBEFORENOTVOWEL,phBEFORENOTVOWEL2,phSWITCHVOICING};
@@ -251,6 +253,7 @@ static keywtab_t keywords[] = {
{"appendph",tAPPENDPH},
{"import_phoneme",tIMPORTPH},
{"beforepause",tBEFOREPAUSE},
{"stress_type",tSTRESSTYPE},
// flags
{"wavef", 0x2000000+phWAVE},
@@ -880,7 +883,7 @@ int Compile::LoadWavefile(FILE *f, const char *fname)
//fprintf(f_errors," sample len=%d max=%4x shift=%d\n",length,max,scale_factor);
#define MIN_FACTOR 6
#define MIN_FACTOR -1 // was 6, disable use of 16 bit samples
if(scale_factor > MIN_FACTOR)
{
length = length/2 + (scale_factor << 16);
@@ -1397,6 +1400,10 @@ int Compile::CPhoneme()
ph->std_length = NextItem(tNUMBER);
break;
case tSTRESSTYPE:
ph->std_length = NextItem(tNUMBER);
break;
case tWAVE:
ph->phflags |= phWAVE; // drop through to tSPECT
case tSPECT:
@@ -1778,11 +1785,12 @@ void Compile::CPhonemeFiles()
int LoadEnvelope2(FILE *f, const char *fname)
{//===================================================
int ix;
int ix, ix2;
int n;
int x, y;
int displ;
int n_points;
double yy;
char line_buf[128];
float env_x[20];
float env_y[20];
@@ -1808,11 +1816,20 @@ int LoadEnvelope2(FILE *f, const char *fname)
env_y[n_points] = env_y[n_points-1];
ix = -1;
ix2 = 0;
for(x=0; x<ENV_LEN; x++)
{
if(x > env_x[ix+4])
ix++;
if(x >= env_x[ix2+1])
ix2++;
if(env_lin[ix2] > 0)
{
yy = env_y[ix2] + (env_y[ix2+1] - env_y[ix2]) * (float(x) - env_x[ix2]) / (env_x[ix2+1] - env_x[ix2]);
y = int(yy * 2.55);
}
else
if(n_points > 3)
y = (int)(polint(&env_x[ix],&env_y[ix],4,x) * 2.55); // convert to range 0-255
else
+1 -1
View File
@@ -755,7 +755,7 @@ void Translator::CalcPitches_Tone(int clause_tone)
// LANG=vi
p = &phoneme_list[final_stressed];
if(p->tone_ph == 0)
p->tone_ph = LookupPh("7"); // change tone 1 to falling tone at end of clause
p->tone_ph = LookupPh("7"); // change default tone (tone 1) to falling tone at end of clause
}
+10
View File
@@ -278,6 +278,7 @@ void Translator::CalcLengths()
int embedded_ix = 0;
int min_drop;
int emphasized;
int tone_mod;
unsigned char *pitch_env=NULL;
for(ix=1; ix<n_phoneme_list; ix++)
@@ -550,6 +551,15 @@ void Translator::CalcLengths()
length_mod = (length_mod * len)/128;
if(p->tone_ph != 0)
{
if((tone_mod = phoneme_tab[p->tone_ph]->std_length) > 0)
{
// a tone phoneme specifies a percentage change to the length
length_mod = (length_mod * tone_mod) / 100;
}
}
if(end_of_clause == 2)
{
// this is the last syllable in the clause, lengthen it - more for short vowels
+7 -1
View File
@@ -823,6 +823,7 @@ SetLengthMods(tr,3); // all equal
case L('t','a'): // Tamil
case L('m','l'): // Malayalam
case L('k','n'): // Kannada
case L('m','r'): // Marathi
{
static const short stress_lengths_ta[8] = {200, 200, 210, 210, 0, 0, 230, 230};
static const unsigned char stress_amps_ta[8] = {18,18, 18,18, 20,20, 22,22 };
@@ -835,6 +836,11 @@ SetLengthMods(tr,3); // all equal
tr->langopts.stress_flags = 0x10004; // use 'diminished' for unstressed final syllable
tr->letter_bits_offset = OFFSET_TAMIL;
if(name2 == L('m','r'))
{
tr->letter_bits_offset = OFFSET_DEVANAGARI;
}
else
if(name2 == L('m','l'))
{
tr->letter_bits_offset = OFFSET_MALAYALAM;
@@ -915,7 +921,7 @@ SetLengthMods(tr,3); // all equal
tr->letter_groups[0] = vowels_vi;
tr->langopts.tone_language = 1; // Tone language, use CalcPitches_Tone() rather than CalcPitches()
tr->langopts.unstressed_wd1 = 2;
tr->langopts.numbers = 0x0049;
tr->langopts.numbers = 0x0049 + 0x8000;
}
break;
+1 -1
View File
@@ -1244,7 +1244,7 @@ int Wavegen()
// amplitude envelope is only used for creaky voice effect on certain vowels/tones
if((ix = amp_ix>>8) > 127) ix = 127;
amp = amplitude_env[ix];
amplitude2 = (amplitude2 * amp)/255;
amplitude2 = (amplitude2 * amp)/128;
// if(amp < 255)
// modulation_type = 7;
}