Browse Source

Applied Klatt fixes from NV Access and added Edward variant.

master
datajake1999 4 years ago
parent
commit
a90a0fb2bd

+ 10
- 0
espeak-ng-data/voices/!v/edward View File

language variant
name Edward
klatt 5
voicing 100
consonants 70 80

formant 1 92 100 130
formant 2 103 100 80
formant 3 103 100 70
formant 4 114 100 60

+ 4
- 0
espeak-ng-data/voices/!v/klatt5 View File

language variant
name klatt5
klatt 5

+ 30
- 26
src/libespeak-ng/klatt.c View File



#define NUMBER_OF_SAMPLES 100 #define NUMBER_OF_SAMPLES 100


static int scale_wav_tab[] = { 45, 38, 45, 45, 55 }; // scale output from different voicing sources
static int scale_wav_tab[] = { 45, 38, 45, 45, 55, 45 }; // scale output from different voicing sources


// For testing, this can be overwritten in KlattInit() // For testing, this can be overwritten in KlattInit()
static short natural_samples2[256] = { static short natural_samples2[256] = {
return (double)x; return (double)x;
} }


static double resonator2(resonator_ptr r, double input)
{
double x;

x = (double)((double)r->a * (double)input + (double)r->b * (double)r->p1 + (double)r->c * (double)r->p2);
r->p2 = (double)r->p1;
r->p1 = (double)x;
/*
function ANTIRESONATOR


r->a += r->a_inc;
r->b += r->b_inc;
r->c += r->c_inc;
return (double)x;
}
This is a generic anti-resonator function. The code is the same as resonator
except that a,b,c need to be set with setzeroabc() and we save inputs in
p1/p2 rather than outputs. There is currently only one of these - "rnz"
Output = (rnz.a * input) + (rnz.b * oldin1) + (rnz.c * oldin2)
*/


static double antiresonator2(resonator_ptr r, double input)
static double antiresonator(resonator_ptr r, double input)
{ {
register double x = (double)r->a * (double)input + (double)r->b * (double)r->p1 + (double)r->c * (double)r->p2; register double x = (double)r->a * (double)input + (double)r->b * (double)r->p1 + (double)r->c * (double)r->p2;
r->p2 = (double)r->p1; r->p2 = (double)r->p1;
r->p1 = (double)input; r->p1 = (double)input;

r->a += r->a_inc;
r->b += r->b_inc;
r->c += r->c_inc;
return (double)x; return (double)x;
} }


kt_globals.nper++; kt_globals.nper++;
} }


if(kt_globals.glsource==5) {
double v=(kt_globals.nper/(double)kt_globals.T0);
v=(v*2)-1;
voice=v*6000;
}

// Tilt spectrum of voicing source down by soft low-pass filtering, amount // Tilt spectrum of voicing source down by soft low-pass filtering, amount
// of tilt determined by TLTdb // of tilt determined by TLTdb




out = 0; out = 0;
if (kt_globals.synthesis_model != ALL_PARALLEL) { if (kt_globals.synthesis_model != ALL_PARALLEL) {
casc_next_in = antiresonator2(&(kt_globals.rsn[Rnz]), glotout);
casc_next_in = antiresonator(&(kt_globals.rsn[Rnz]), glotout);
casc_next_in = resonator(&(kt_globals.rsn[Rnpc]), casc_next_in); casc_next_in = resonator(&(kt_globals.rsn[Rnpc]), casc_next_in);
casc_next_in = resonator(&(kt_globals.rsn[R8c]), casc_next_in); casc_next_in = resonator(&(kt_globals.rsn[R8c]), casc_next_in);
casc_next_in = resonator(&(kt_globals.rsn[R7c]), casc_next_in); casc_next_in = resonator(&(kt_globals.rsn[R7c]), casc_next_in);
casc_next_in = resonator(&(kt_globals.rsn[R6c]), casc_next_in); casc_next_in = resonator(&(kt_globals.rsn[R6c]), casc_next_in);
casc_next_in = resonator2(&(kt_globals.rsn[R5c]), casc_next_in);
casc_next_in = resonator2(&(kt_globals.rsn[R4c]), casc_next_in);
casc_next_in = resonator2(&(kt_globals.rsn[R3c]), casc_next_in);
casc_next_in = resonator2(&(kt_globals.rsn[R2c]), casc_next_in);
out = resonator2(&(kt_globals.rsn[R1c]), casc_next_in);
casc_next_in = resonator(&(kt_globals.rsn[R5c]), casc_next_in);
casc_next_in = resonator(&(kt_globals.rsn[R4c]), casc_next_in);
casc_next_in = resonator(&(kt_globals.rsn[R3c]), casc_next_in);
casc_next_in = resonator(&(kt_globals.rsn[R2c]), casc_next_in);
out = resonator(&(kt_globals.rsn[R1c]), casc_next_in);
} }


// Excite parallel F1 and FNP by voicing waveform // Excite parallel F1 and FNP by voicing waveform
temp += z2; temp += z2;
} }


if (kt_globals.fadein < 64) {
temp = (temp * kt_globals.fadein) / 64;
++kt_globals.fadein;
}

// if fadeout is set, fade to zero over 64 samples, to avoid clicks at end of synthesis // if fadeout is set, fade to zero over 64 samples, to avoid clicks at end of synthesis
if (kt_globals.fadeout > 0) { if (kt_globals.fadeout > 0) {
kt_globals.fadeout--; kt_globals.fadeout--;
temp = (temp * kt_globals.fadeout) / 64; temp = (temp * kt_globals.fadeout) / 64;
if (kt_globals.fadeout == 0)
kt_globals.fadein = 0;
} }


value = (int)temp + ((echo_buf[echo_tail++]*echo_amp) >> 8); value = (int)temp + ((echo_buf[echo_tail++]*echo_amp) >> 8);
static frame_t prev_fr; static frame_t prev_fr;


if (wvoice != NULL) { if (wvoice != NULL) {
if ((wvoice->klattv[0] > 0) && (wvoice->klattv[0] <= 4 )) {
if ((wvoice->klattv[0] > 0) && (wvoice->klattv[0] <= 5 )) {
kt_globals.glsource = wvoice->klattv[0]; kt_globals.glsource = wvoice->klattv[0];
kt_globals.scale_wav = scale_wav_tab[kt_globals.glsource]; kt_globals.scale_wav = scale_wav_tab[kt_globals.glsource];
} }


if (ix < 4) { if (ix < 4) {
// klatt bandwidth for f1, f2, f3 (others are fixed) // klatt bandwidth for f1, f2, f3 (others are fixed)
peaks[ix].bw1 = fr1->bw[ix] * 2;
peaks[ix].bw1 = fr1->bw[ix] * 2 * (wvoice->width[ix] / 256.0);
peaks[ix].bw = (int)peaks[ix].bw1; peaks[ix].bw = (int)peaks[ix].bw1;
next = fr2->bw[ix] * 2; next = fr2->bw[ix] * 2;
peaks[ix].bw_inc = ((next - peaks[ix].bw1) * STEPSIZE) / length; peaks[ix].bw_inc = ((next - peaks[ix].bw1) * STEPSIZE) / length;

+ 1
- 0
src/libespeak-ng/klatt.h View File

short *natural_samples; /* pointer to an array of glottal samples */ short *natural_samples; /* pointer to an array of glottal samples */
long original_f0; /* original value of f0 not modified by flutter */ long original_f0; /* original value of f0 not modified by flutter */


int fadein;
int fadeout; // set to 64 to cause fadeout over 64 samples int fadeout; // set to 64 to cause fadeout over 64 samples
int scale_wav; // depends on the voicing source int scale_wav; // depends on the voicing source



Loading…
Cancel
Save