Esempio n. 1
0
static void ef_set(cst_features *f,const char *fv,const char *type)
{
    /* set feature from fv (F=V), guesses type if not explicit type given */
    const char *val;
    char *feat;

    if ((val = strchr(fv,'=')) == 0)
    {
	fprintf(stderr,
		"flite: can't find '=' in featval \"%s\", ignoring it\n",
		fv);
    }
    else
    {
	feat = cst_strdup(fv);
	feat[strlen(fv)-strlen(val)] = '\0';
	val = val+1;
	if ((type && cst_streq("int",type)) ||
	    ((type == 0) && (cst_regex_match(cst_rx_int,val))))
	    feat_set_int(f,feat,atoi(val));
	else if ((type && cst_streq("float",type)) ||
		 ((type == 0) && (cst_regex_match(cst_rx_double,val))))
	    feat_set_float(f,feat,atof(val));
	else
	    feat_set_string(f,feat,val);
	/* I don't free feat, because feats think featnames are const */
	/* which is true except in this particular case          */
    }
}
Esempio n. 2
0
float flite_process_output(cst_utterance *u, const char *outtype,
                           int append)
{
    /* Play or save (append) output to output file */
    cst_wave *w;
    float dur;

    if (!u) return 0.0;

    w = utt_wave(u);

    dur = (float)w->num_samples/(float)w->sample_rate;
	     
    if (cst_streq(outtype,"play"))
	play_wave(w);
    else if (cst_streq(outtype,"stream"))
    {
        /* It's already been played so do nothing */
        
    }
    else if (!cst_streq(outtype,"none"))
    {
        if (append)
            cst_wave_append_riff(w,outtype);
        else
            cst_wave_save_riff(w,outtype);
    }

    return dur;
}
int cmu_grapheme_syl_boundary(const cst_item *i,const cst_val *rest) 
{
    if (!rest)
        return TRUE;
    else if (!cmu_grapheme_contains_vowel(rest))
        return FALSE;
    else if (!cmu_grapheme_has_vowel_in_syl(i))
        return FALSE;
#if 0
    else if (rest && val_cdr(rest) &&
             cst_streq("n",val_string(val_car(rest))) &&
             !cmu_grapheme_is_vowel(val_string(val_car(rest))))
        return FALSE;
    else if (rest && val_cdr(rest) &&
             cmu_grapheme_is_vowel(ffeature_string(i,"name")) &&
             !cmu_grapheme_is_vowel(val_string(val_car(rest))) &&
             !cmu_grapheme_is_vowel(val_string(val_car(val_cdr(rest)))))
        return FALSE;
    else if (rest && val_cdr(rest) && val_cdr(val_cdr(rest)) &&
             !cmu_grapheme_is_vowel(val_string(val_car(rest))) &&
             !cmu_grapheme_is_vowel(val_string(val_car(val_cdr(rest)))) &&
             !cmu_grapheme_is_vowel(val_string(val_car(val_cdr(val_cdr(rest))))))
        return FALSE;
    else if (rest && val_cdr(rest) &&
             (cst_streq(val_string(val_car(rest)),
                        val_string(val_car(val_cdr(rest))))))
        return FALSE;
#endif
    else
        return TRUE;
}
Esempio n. 4
0
static int context_match(const cst_val *PATTERN, const cst_val *STRING,
			 const cst_val *sets)
{
    if (!PATTERN)
	return TRUE;
    else if (!STRING)
	return FALSE;
    else if (val_cdr(PATTERN) &&
	     (cst_streq("*",val_string(val_car(PATTERN)))))
	return
	    context_match(val_cdr(val_cdr(PATTERN)),STRING,sets) || /* skip */
	    context_match(val_cdr(PATTERN),STRING,sets) || /* last match */
	    (item_match(val_car(val_cdr(PATTERN)),val_car(STRING),sets) &&
	     context_match(val_cdr(val_cdr(PATTERN)),   /* loop match */
			   val_cdr(STRING),sets));
#if 0
    else if (val_cdr(PATTERN) &&
	     (cst_streq("+",val_string(val_car(PATTERN)))))
	return context_match(val_cdr(PATTERN),STRING,sets) || /* last match */
	    (item_match(val_car(val_cdr(PATTERN)),val_car(STRING),sets) &&
	    context_match(val_cdr(val_cdr(PATTERN)),  /* loop match */
			  val_cdr(STRING),sets));
#endif
    else if (item_match(val_car(PATTERN),val_car(STRING),sets))
	return context_match(val_cdr(PATTERN),val_cdr(STRING),sets);
    else
	return FALSE;
}
Esempio n. 5
0
cst_utterance *cart_intonation(cst_utterance *u)
{
    cst_cart *accents, *tones;
    cst_item *s;
    const cst_val *v;

    if (feat_present(u->features,"no_intonation_accent_model"))
        return u;  /* not all languages have intonation models */

    accents = val_cart(feat_val(u->features,"int_cart_accents"));
    tones = val_cart(feat_val(u->features,"int_cart_tones"));
    
    for (s=relation_head(utt_relation(u,"Syllable")); s; s=item_next(s))
    {
	v = cart_interpret(s,accents);
	if (!cst_streq("NONE",val_string(v)))
	    item_set_string(s,"accent",val_string(v));
	v = cart_interpret(s,tones);
	if (!cst_streq("NONE",val_string(v)))
	    item_set_string(s,"endtone",val_string(v));
	DPRINTF(0,("word %s gpos %s stress %s ssyl_in %s ssyl_out %s accent %s endtone %s\n",
		   ffeature_string(s,"R:SylStructure.parent.name"),
		   ffeature_string(s,"R:SylStructure.parent.gpos"),
		   ffeature_string(s,"stress"),
		   ffeature_string(s,"ssyl_in"),
		   ffeature_string(s,"ssyl_out"),
		   ffeature_string(s,"accent"),
		   ffeature_string(s,"endtone")));
    }

    return u;
}
Esempio n. 6
0
static void ef_set(cst_features *f,const char *fv,const char *type)
{
    /* set feature from fv (F=V), guesses type if not explicit type given */
    const char *val;
    char *feat;

    if ((val = strchr(fv,'=')) == 0)
    {
	fprintf(stderr,
		"flite: can't find '=' in featval \"%s\", ignoring it\n",
		fv);
    }
    else
    {
	feat = cst_strdup(fv);
	feat[cst_strlen(fv)-cst_strlen(val)] = '\0';
	val = val+1;
	if ((type && cst_streq("int",type)) ||
	    ((type == 0) && (cst_regex_match(cst_rx_int,val))))
	    feat_set_int(f,feat,atoi(val));
	else if ((type && cst_streq("float",type)) ||
		 ((type == 0) && (cst_regex_match(cst_rx_double,val))))
	    feat_set_float(f,feat,atof(val));
	else
	    feat_set_string(f,feat,val);
        cst_free(feat);
    }
}
Esempio n. 7
0
static int find_full_match(const cst_lexicon *l,
                           int i,const char *word)

{
    /* found word, now look for actual match including pos */
    int w, match=i;
    /* needs to be longer than longest word in lexicon */
    char word_pos[WP_SIZE];

    for (w=i; w > 0; )
    {
        lex_uncompress_word(word_pos,WP_SIZE,w,l);
        if (!cst_streq(word+1,word_pos+1))
            break;
        else if (cst_streq(word,word_pos))
            return w;
        match = w;  /* if we can't find an exact match we'll take this one */
        /* go back to last entry */
        w = lex_data_prev_entry(l,w,0);
    }

    for (w=i; w < l->num_bytes;)
    {
        lex_uncompress_word(word_pos,WP_SIZE,w,l);
        if (!cst_streq(word+1,word_pos+1))
            break;
        else if (cst_streq(word,word_pos))
            return w;
        /* go to next entry */
        w = lex_data_next_entry(l,w,l->num_bytes);
    }

    return match;
}
Esempio n. 8
0
int relation_load(cst_relation *r, const char *filename)
{
    cst_tokenstream *fd;
    cst_item *item;
    const char *token=0;

    if ((fd = ts_open(filename,NULL,";","","")) == 0)
    {
	cst_errmsg("relation_load: can't open file \"%s\" for reading\n",
		   filename);
	return CST_ERROR_FORMAT;
    }

    for ( ; !ts_eof(fd); )
    {
	token = ts_get(fd);
	if (cst_streq("#",token))
	    break;
    }
#import "OpenEarsStaticAnalysisToggle.h"
#ifdef STATICANALYZEDEPENDENCIES
#define __clang_analyzer__ 1
#endif
#if !defined(__clang_analyzer__) || defined(STATICANALYZEDEPENDENCIES)
#undef __clang_analyzer__
    if (!cst_streq("#",token))
#endif        
    {
	cst_errmsg("relation_load: no end of header marker in \"%s\"\n",
		   filename);
	ts_close(fd);
	return CST_ERROR_FORMAT;
    }

    while (!ts_eof(fd))
    {
	token = ts_get(fd);
	if (cst_streq(token,""))
	    continue;
	item = relation_append(r,NULL);
	item_set_float(item,"end",(float)cst_atof(token));
#import "OpenEarsStaticAnalysisToggle.h"
#ifdef STATICANALYZEDEPENDENCIES
#define __clang_analyzer__ 1
#endif
#if !defined(__clang_analyzer__) || defined(STATICANALYZEDEPENDENCIES)
#undef __clang_analyzer__
        
	token = ts_get(fd);
#endif        
	token = ts_get(fd);
	item_set_string(item,"name",token);
    }

    ts_close(fd);
    return CST_OK_FORMAT;
}
static const char *__VOICENAME___nextvoicing(cst_item *s)
{
    if (cst_streq("+",flite_ffeature_string(s,"n.ph_vc")))
        return "V";
    else if (cst_streq("+",flite_ffeature_string(s,"n.ph_cvox")))
        return "CVox";
    else
        return "UV";
}
Esempio n. 10
0
const char *russian_vpair(const char *ph)
{
  int i;
  for(i=0;vpairs[i][0];++i)
    {
      if(cst_streq(vpairs[i][0],ph))
        return vpairs[i][1];
      if(cst_streq(vpairs[i][1],ph))
        return vpairs[i][0];
    }
  return NULL;
}
Esempio n. 11
0
static int voiced_frame(cst_item *m)
{
    const char *ph_vc;
    const char *ph_cvox;

    ph_vc = ffeature_string(m,"R:mcep_link.parent.R:segstate.parent.ph_vc");
    ph_cvox = ffeature_string(m,"R:mcep_link.parent.R:segstate.parent.ph_cvox");

    if (cst_streq("-",ph_vc) &&
        cst_streq("-",ph_cvox))
        return 0; /* unvoiced */
    else
        return 1; /* voiced */
}
Esempio n. 12
0
int relation_load(cst_relation *r, const char *filename)
{
    cst_tokenstream *fd;
    cst_item *item;
    const char *token=0;

    if ((fd = ts_open(filename,NULL,";","","")) == 0)
    {
	cst_errmsg("relation_load: can't open file \"%s\" for reading\n",
		   filename);
	return CST_ERROR_FORMAT;
    }

    for ( ; !ts_eof(fd); )
    {
	token = ts_get(fd);
	if (cst_streq("#",token))
	    break;
    }
 

    if (!cst_streq("#",token))
        
    {
	cst_errmsg("relation_load: no end of header marker in \"%s\"\n",
		   filename);
	ts_close(fd);
	return CST_ERROR_FORMAT;
    }

    while (!ts_eof(fd))
    {
	token = ts_get(fd);
	if (cst_streq(token,""))
	    continue;
	item = relation_append(r,NULL);
	item_set_float(item,"end",(float)cst_atof(token));
 

        
	token = ts_get(fd);
       
	token = ts_get(fd);
	item_set_string(item,"name",token);
    }

    ts_close(fd);
    return CST_OK_FORMAT;
}
static int cmu_is_silence(const char *p)
{
    if (cst_streq(p,"pau"))
	return TRUE;
    else
	return FALSE;
}
Esempio n. 14
0
cst_val *en_exp_letters(const char *lets)
{
    /* returns these as list of single char symbols */
    char *aaa;
    cst_val *r;
    int i;

    aaa = cst_alloc(char,2);
    aaa[1] = '\0';
    for (r=0,i=0; lets[i] != '\0'; i++)
    {
	aaa[0] = lets[i];
	if (isupper((int)aaa[0])) 
	    aaa[0] = tolower((int)aaa[0]);
	if (strchr("0123456789",aaa[0]))
	    r = cons_val(string_val(digit2num[aaa[0]-'0']),r);
	else if (cst_streq(aaa,"a"))
	    r = cons_val(string_val("_a"),r);
	else
	    r = cons_val(string_val(aaa),r);
    }
    cst_free(aaa);

    return val_reverse(r);
}
Esempio n. 15
0
int relation_save(cst_relation *r, const char *filename)
{
    cst_file fd;
    cst_item *item;

    if (cst_streq(filename, "-"))
        fd = stdout;
    else

    if ((fd = cst_fopen(filename, CST_OPEN_WRITE)) == 0)
    {
        cst_errmsg("relation_save: can't open file \"%s\" for writing\n",
                   filename);
        return CST_ERROR_FORMAT;
    }

    for (item = relation_head(r); item; item = item_next(item))
    {
        if (item_feat_present(item, "end"))
            cst_fprintf(fd, "%f ", item_feat_float(item, "end"));
        else
            cst_fprintf(fd, "%f ", 0.00);
        if (item_feat_present(item, "name"))
            cst_fprintf(fd, "%s ", item_feat_string(item, "name"));
        else
            cst_fprintf(fd, "%s ", "_");
        cst_fprintf(fd, "\n");
    }
    if (fd != stdout)
        cst_fclose(fd);

    return CST_OK_FORMAT;
}
Esempio n. 16
0
int feat_remove(cst_features *f, const char *name)
{
    cst_featvalpair *n,*p,*np;
    
    if (f == NULL)
	return FALSE; /* didn't remove it */
    else
    {
	for (p=NULL,n=f->head; n; p=n,n=np)
	{
	    np = n->next;
	    if (cst_streq(name,n->name))
	    {
		if (p == 0)
		    f->head = np;
		else
		    p->next = np;
		delete_val(n->val);
		cst_local_free(f->ctx,n);
		return TRUE;
	    }
	}
	return FALSE;
    }
}
static char *__VOICENAME___unit_name(cst_item *s)
{
    const char *name;
    /* This *is* long enough as long as you don't change external things */
    char cname[30];

    name = flite_ffeature_string(s,"name");
    /* Comment this out if you have more complex unit names */
#if 1
    if (1 == 1)
        return cst_strdup(name);
    else 
#endif
    if (cst_streq("+",flite_ffeature_string(s,"ph_vc")))
    {
        cst_sprintf(cname,"%s_%s_%s",name,
                    flite_ffeature_string(s,"R:SylStructure.parent.stress"),
                    __VOICENAME___nextvoicing(s));
    }
    else 
    {
        cst_sprintf(cname,"%s_%s",name,
                    __VOICENAME___nextvoicing(s));
    }

    return cst_strdup(cname);
}
Esempio n. 18
0
static cst_val *lex_lookup_addenda(const char *wp,const cst_lexicon *l,
                                   int *found)
{
    /* For those other words */
    int i,j;
    cst_val *phones;

    phones = NULL;

    for (i=0; l->addenda[i]; i++)
    {
        if (((wp[0] == '0') ||
                (wp[0] == l->addenda[i][0][0]) ||
                (l->addenda[i][0][0] == '0')) &&
                (cst_streq(wp+1,l->addenda[i][0]+1)))
        {
            for (j=1; l->addenda[i][j]; j++)
                phones = cons_val(string_val(l->addenda[i][j]),phones);
            *found = TRUE;
            return val_reverse(phones);
        }
    }

    return NULL;
}
Esempio n. 19
0
int in_lex(const cst_lexicon *l, const char *word, const char *pos,
           const cst_features *feats)
{
    /* return TRUE is its in the lexicon */
    int r = FALSE, i;
    char *wp;

    wp = cst_alloc(char,cst_strlen(word)+2);
    cst_sprintf(wp,"%c%s",(pos ? pos[0] : '0'),word);

    for (i=0; l->addenda && l->addenda[i]; i++)
    {
        if (((wp[0] == '0') || (wp[0] == l->addenda[i][0][0])) &&
                (cst_streq(wp+1,l->addenda[i][0]+1)))
        {
            r = TRUE;
            break;
        }
    }

    if (!r && (lex_lookup_bsearch(l,wp) >= 0))
        r = TRUE;

    cst_free(wp);
    return r;
}
Esempio n. 20
0
static int bbb_relation_load(cst_relation *r,const char *filename)
{
    const char *token;
    cst_item *item;
    cst_tokenstream *fd;

    fd = ts_open(filename);
    if (fd == 0)
	return 0;

    while (!ts_eof(fd))
    {
	token = ts_get(fd);
	if (cst_streq(token,""))
	    continue;
	item = relation_append(r,NULL);
	item_set_string(item,"name",token);
	item_set_string(item,"whitespace",fd->whitespace);
	item_set_string(item,"prepunctuation",fd->prepunctuation);
	item_set_string(item,"punc",fd->postpunctuation);
	item_set_int(item,"file_pos",fd->file_pos);
	item_set_int(item,"line_number",fd->line_number);
    }
    
    ts_close(fd);

    return 1;
}
Esempio n. 21
0
static float cg_state_duration(cst_item *s, cst_cg_db *cg_db)
{
    float zdur, dur;
    const char *n;
    int i, x;

    zdur = val_float(cart_interpret(s,cg_db->dur_cart));
    n = item_feat_string(s,"name");

    for (x=i=0; cg_db->dur_stats[i]; i++)
    {
        if (cst_streq(cg_db->dur_stats[i]->phone,n))
        {
            x=i;
            break;
        }
    }
    if (!cg_db->dur_stats[i])  /* unknown type name */
        x = 0;

    dur = (zdur*cg_db->dur_stats[x]->stddev)+cg_db->dur_stats[x]->mean;

    /*    dur = 1.2 * (float)exp((float)dur); */

    return dur;
    
}
Esempio n. 22
0
cst_tokenstream *ts_open(const char *filename,
			 const cst_string *whitespace,
			 const cst_string *singlechars,
			 const cst_string *prepunct,
			 const cst_string *postpunct)
{
    cst_tokenstream *ts = new_tokenstream(whitespace,
					  singlechars,
					  prepunct,
					  postpunct);

#ifndef UNDER_CE
    if (cst_streq("-",filename))
	ts->fd = stdin;
    else
#endif
	ts->fd = cst_fopen(filename,CST_OPEN_READ|CST_OPEN_BINARY);
    ts_getc(ts);

    if (ts->fd == NULL)
    {
	delete_tokenstream(ts);
	return NULL;
    }
    else
	return ts;
}
Esempio n. 23
0
cst_utterance *join_units_simple(cst_utterance *utt)
{
    cst_wave *w = 0;
    cst_lpcres *lpcres;
    const char *resynth_type;
    const cst_val *streaming_info_val;

    resynth_type = get_param_string(utt->features, "resynth_type", "fixed");

    asis_to_pm(utt);
    concat_units(utt);

    lpcres = val_lpcres(utt_feat_val(utt, "target_lpcres"));

    streaming_info_val = get_param_val(utt->features, "streaming_info", NULL);
    if (streaming_info_val)
    {
        lpcres->asi = val_audio_streaming_info(streaming_info_val);
        lpcres->asi->utt = utt;
    }

    if (cst_streq(resynth_type, "fixed"))
        w = lpc_resynth_fixedpoint(lpcres);
    else
    {
        cst_errmsg("unknown resynthesis type %s\n", resynth_type);
        cst_error();            /* Should not happen */
    }

    utt_set_wave(utt, w);

    return utt;
}
Esempio n. 24
0
static cst_utterance *cg_make_hmmstates(cst_utterance *utt)
{
    /* Build HMM state structure below the segment structure */
    cst_cg_db *cg_db;
    cst_relation *hmmstate, *segstate;
    cst_item *seg, *s, *ss;
    const char *segname;
    int sp,p;

    cg_db = val_cg_db(utt_feat_val(utt,"cg_db"));
    hmmstate = utt_relation_create(utt,"HMMstate");
    segstate = utt_relation_create(utt,"segstate");

    for (seg = utt_rel_head(utt,"Segment"); seg; seg=item_next(seg))
    {
        ss = relation_append(segstate,seg);
        segname = item_feat_string(seg,"name");
        for (p=0; cg_db->phone_states[p]; p++)
            if (cst_streq(segname,cg_db->phone_states[p][0]))
                break;
        if (cg_db->phone_states[p] == NULL)
            p = 0;  /* unknown phoneme */
        for (sp=1; cg_db->phone_states[p][sp]; sp++)
        {
            s = relation_append(hmmstate,NULL);
            item_add_daughter(ss,s);
            item_set_string(s,"name",cg_db->phone_states[p][sp]);
            item_set_int(s,"statepos",sp);
        }
    }

    return utt;
}
Esempio n. 25
0
cst_utterance *default_phrasing(cst_utterance *u)
{
    cst_relation *r;
    cst_item *w, *p, *lp=NULL;
    const cst_val *v;
    cst_cart *phrasing_cart;

    r = utt_relation_create(u,"Phrase");
    phrasing_cart = val_cart(feat_val(u->features,"phrasing_cart"));

    for (p=NULL,w=relation_head(utt_relation(u,"Word")); w; w=item_next(w))
    {
	if (p == NULL)
	{
	    p = relation_append(r,NULL);
            lp = p;
#ifdef FLITE_PLUS_HTS_ENGINE
            item_set_string(p,"name","BB");
#else
            item_set_string(p,"name","B");
#endif /* FLITE_PLUS_HTS_ENGINE */
	}
	item_add_daughter(p,w);
	v = cart_interpret(w,phrasing_cart);
	if (cst_streq(val_string(v),"BB"))
	    p = NULL;
    }

    if (lp && item_prev(lp)) /* follow festival */
        item_set_string(lp,"name","BB");
    
    return u;
}
Esempio n. 26
0
cst_utterance *default_phrasing(cst_utterance *u)
{
    cst_relation *r;
    cst_item *w, *p;
    const cst_val *v;
    cst_cart *phrasing_cart;

    r = utt_relation_create(u,"Phrase");
    phrasing_cart = val_cart(feat_val(u->features,"phrasing_cart"));

    for (p=NULL,w=relation_head(utt_relation(u,"Word")); w; w=item_next(w))
    {
	if (p == NULL)
	{
	    p = relation_append(r,NULL);
	    item_set_string(p,"name","BB");
	}
	item_add_daughter(p,w);
	v = cart_interpret(w,phrasing_cart);
	if (cst_streq(val_string(v),"BB"))
	    p = NULL;
    }
    
    return u;
}
Esempio n. 27
0
cst_val *lts_apply_val(const cst_val *wlist,const char *feats,const cst_lts_rules *r)
{
    /* for symbol to symbol mapping */
    const cst_val *v;
    cst_val *p;
    char *word;
    int i,j;

    word = cst_alloc(char,val_length(wlist)+1);

    for (v=wlist,i=0; v; v=val_cdr(v),i++)
    {
	for (j=0; r->letter_table[j]; j++)
	    if (cst_streq(val_string(val_car(v)),r->letter_table[j]))
	    {
		word[i] = j;
		break;
	    }
        if (!r->letter_table[j])
        {
#if 0
            printf("awb_debug unknown letter >%s<\n",val_string(val_car(v)));
#endif
            i--;  /* can't find this letter so skip it */
        }
    }

    p = lts_apply(word,feats,r);
    cst_free(word);

    return p;
}
Esempio n. 28
0
static int ifd_is_silence(const char *p)
{
    if (cst_streq(p,"#"))
	return TRUE;
    else
	return FALSE;
}
Esempio n. 29
0
static float cg_state_duration(cst_item *s, cst_cg_db *cg_db)
{
    float zdur, dur;
    const char *n;
    int i, x;
#ifdef STATICANALYZEDEPENDENCIES
#define __clang_analyzer__ 1
#endif
#if !defined(__clang_analyzer__) || defined(STATICANALYZEDEPENDENCIES)
#undef __clang_analyzer__
    zdur = val_float(cart_interpret(s,cg_db->dur_cart));
    n = item_feat_string(s,"name");

    for (x=i=0; cg_db->dur_stats[i]; i++)
    {
        if (cst_streq(cg_db->dur_stats[i]->phone,n))
        {
            x=i;
            break;
        }
    }
    if (!cg_db->dur_stats[i])  /* unknown type name */
        x = 0;

    dur = (zdur*cg_db->dur_stats[x]->stddev)+cg_db->dur_stats[x]->mean;

    /*    dur = 1.2 * (float)exp((float)dur); */

    return dur;
    
}
Esempio n. 30
0
cst_utterance *cst_spamf0(cst_utterance *utt)
{
    cst_track *spamf0_track = NULL;
    cst_track *param_track = NULL;
    cst_item *s;
    cst_cg_db *cg_db;
    const cst_cart *acc_tree, *phrase_tree;
    float end, f0val, syldur;
    int num_frames, f, i;
    cg_db = val_cg_db(utt_feat_val(utt, "cg_db"));

    spamf0_track = new_track();
    cst_track_resize(spamf0_track,
                     (utt_feat_int(utt, "param_track_num_frames")), 1);
    acc_tree = cg_db->spamf0_accent_tree;
    phrase_tree = cg_db->spamf0_phrase_tree;
    end = 0.0;
    num_frames = 0;
    for (s = utt_rel_head(utt, "Segment"); s; s = item_next(s))
    {
        end = ffeature_float(s, "end");
        if (cst_streq("pau", ffeature_string(s, "name")))
        {
            f0val = 0;
        }
        else
        {
            f0val = val_float(cart_interpret(s, phrase_tree));
        }

        for (;
             ((num_frames * cg_db->frame_advance) <= end)
             && (num_frames < utt_feat_int(utt, "param_track_num_frames"));
             num_frames++)
        {
            spamf0_track->frames[num_frames][0] = f0val;
        }
    }

    for (s = utt_rel_head(utt, "Syllable"); s; s = item_next(s))
    {
        f = val_int(cart_interpret(s, acc_tree));
        syldur = ffeature_float(s, "R:SylStructure.daughtern.R:Segment.end")
            - ffeature_float(s, "R:SylStructure.daughter1.R:Segment.p.end");
        cst_synthtilt(cg_db,
                      ffeature_float(s,
                                     "R:SylStructure.daughter1.R:Segment.p.end"),
                      cg_db->spamf0_accent_vectors[f][0],
                      cg_db->spamf0_accent_vectors[f][2], syldur,
                      cg_db->spamf0_accent_vectors[f][6], spamf0_track);
    }
    param_track = val_track(utt_feat_val(utt, "param_track"));
    for (i = 0; i < utt_feat_int(utt, "param_track_num_frames"); i++)
    {
        param_track->frames[i][0] = spamf0_track->frames[i][0];
    }
    delete_track(spamf0_track);
    return utt;
}