Exemplo n.º 1
0
void calc_pitch(SPN *ps, ACOUSTIC *as)
{
	int j,k;
	int y;
	int l = 0;
	int k_old = 0;
	int k_fine = 0;
	int x = 0;

	for(j=0;j<ps->t_sz;j++) 
		ps->abs_targ[j] = ps->cum_dur[ps->targ_phon[j]] + 
		ps->pc_targs[j]*ps->duration[ps->targ_phon[j]]/100;	// YK 2011-07-25 chgd 100.0 to 100

	for(k=0;k<ps->cum_dur[ps->p_sz];k+=100) {
		y = interpolated_freq(k,ps);
		x += 100*y;
		while(x>SR) {
			k_fine = k + interpolate(x-100*y,0,x,100,10000);
			x -= SR;
			as->pitch[l++] = k_fine-k_old;
			if(l == as->p_max) {
				as_realloc(as->f_max,as->p_max*2,as);
			}
			k_old = k_fine;
                }
	}
	as->p_sz = l;
	as->pitch[0] += FR_SZ/2;  /* to compensate for mismatch  */
}
Exemplo n.º 2
0
void tsFreePhoneImplementation::phonstoframes(SPN *ps, ACOUSTIC *as)
{
	int i,j;
	int ref;

	as->f_sz = 0;
	
	for(i=0;i<ps->p_sz-1;i++) 
		sprintf(ps->diphs[i],"%s-%s",ps->phons[i],ps->phons[i+1]);

	ps->pb[0] = 0;	/* Gets treated a little bit specially  */

	/* insert zero frame  */
	as->mcebuf[as->f_sz++] = &dico[0];

	for(i=0;i<ps->p_sz-1;i++) {
		ref = lookup(ps->diphs[i]);	/* gives back the reference no.  */
		if(ref == -1) {
			(void)fprintf(stderr,"Diphone not found -  %s\n",ps->diphs[i]);
			ref = 0;
		}
		if(as->f_sz+50 > as->f_max) {
			as_realloc(as->f_max*2,as->p_max,as);
		}
		for(j=indx[ref].beg;j<=indx[ref].end;j++) {
			if(j==indx[ref].mid)
				ps->pb[i+1] = as->f_sz;
			as->mcebuf[as->f_sz++] = &dico[j];
		}
	}
	as->mcebuf[as->f_sz++] = &dico[0];
	as->mcebuf[as->f_sz++] = &dico[0];
	as->mcebuf[as->f_sz++] = &dico[0];

	ps->pb[ps->p_sz] = as->f_sz-1;

}