static const cst_val *month_range(const cst_item *token) { int v = item_feat_int(token,"name"); if ((v > 0) && ( v < 32)) return VAL_STRING_1; else return VAL_STRING_0; }
cst_utterance *asis_to_pm(cst_utterance *utt) { /* Copy the PM structure from the units unchanged */ cst_item *u; cst_lpcres *target_lpcres; int unit_start, unit_end; int utt_pms, utt_size, i; cst_sts_list *sts_list; sts_list = val_sts_list(utt_feat_val(utt,"sts_list")); target_lpcres = new_lpcres(); /* Pass one to find the size */ utt_pms = utt_size = 0; for (u=relation_head(utt_relation(utt,"Unit")); u; u=item_next(u)) { unit_start = item_feat_int(u,"unit_start"); unit_end = item_feat_int(u,"unit_end"); utt_size += get_unit_size(sts_list,unit_start,unit_end); utt_pms += unit_end - unit_start; item_set_int(u,"target_end",utt_size); } lpcres_resize_frames(target_lpcres,utt_pms); /* Pass two to fill in the values */ utt_pms = utt_size = 0; for (u=relation_head(utt_relation(utt,"Unit")); u; u=item_next(u)) { unit_start = item_feat_int(u,"unit_start"); unit_end = item_feat_int(u,"unit_end"); for (i=unit_start; i<unit_end; i++,utt_pms++) { utt_size += get_frame_size(sts_list, i); target_lpcres->times[utt_pms] = utt_size; } } utt_set_feat(utt,"target_lpcres",lpcres_val(target_lpcres)); return utt; }
static cst_val* word_to_phones(const cst_item *word) { cst_val*phones=NULL; const char *name=item_feat_string(word, "name"); ustring32_t letters=ustring32_alloc(0); if(letters==NULL) return NULL; ustring32_assign8(letters,(const uint8_t*)name); if(ustring32_empty(letters)) { ustring32_free(letters); return NULL; } unsigned int flags=classify_characters(ustring32_str(letters),ustring32_length(letters)); int variant=item_feat_int(item_parent(item_as(word,"Token")),"variant"); if((flags&cs_lc)&&cst_streq(ffeature_string(word,"gpos"),"content")) { if(variant==variant_pseudo_english) phones=ustring32_lts_apply(letters,&en_consonants_lts); else phones=ustring32_lts_apply(letters,&ru_consonants_lts); item_set_int(word,"no_vr",1); } else if((variant==variant_pseudo_english)&&(flags&cs_en)) { cst_val *en_phones=lex_lookup(en_lex,name,(cst_streq(name,"a")?"n":NULL)); if(en_phones) { phones=ru_lts_apply(en_phones,&ru_en_lts); delete_val(en_phones); } item_set_int(word,"no_pl",1); } else { const ru_dict_entry *e=bsearch(name,ru_dict,ru_dict_size,sizeof(ru_dict_entry),compare_entries); if(e!=NULL) { if(e->stress > 0) ustring32_set(letters,e->stress-1,1105); else item_set_int(word,"stressed_syl_num",e->stress); } phones=ustring32_lts_apply(letters,&ru_lts); } ustring32_free(letters); return phones; }
static void assign_stress(cst_item *word) { int numsyls=ffeature_int(word,"word_numsyls"); const char *gpos=ffeature_string(word,"gpos"); const cst_item *word_in_phrase=item_as(word,"Phrase"); const cst_item *syls=item_as(word,"SylStructure"); const cst_item *syl=item_daughter(syls); const cst_item *transcription=item_as(word,"Transcription"); int stressed=FALSE; int n=item_feat_present(word,"stressed_syl_num")?item_feat_int(word,"stressed_syl_num"):0; const char *name=item_name(word); const char *pname=ffeature_string(word,"R:Phrase.p.name"); const char *nname=ffeature_string(word,"R:Phrase.n.name"); if(cst_streq(ffeature_string(word,"R:Token.p.name"),"по")&& (cst_streq(name,"моему")||cst_streq(name,"своему")||cst_streq(name,"твоему"))) { item_set_string(syl,"stress","1"); return; } else if((cst_streq(name,"не")||cst_streq(name,"ни"))&& (cst_streq(nname,"был")||cst_streq(nname,"были")||cst_streq(nname,"было"))) { item_set_string(syl,"stress","1"); return; } else if((cst_streq(name,"был")||cst_streq(name,"были")||cst_streq(name,"было"))&& (cst_streq(pname,"не")||cst_streq(pname,"ни"))) return; else if(cst_streq(gpos,"enc")&&item_prev(word_in_phrase)) return; else if(cst_streq(gpos,"proc")&&item_next(word_in_phrase)) return; if(!vowel_seg_between(item_daughter(transcription),item_last_daughter(transcription))) return; if(numsyls==1) { item_set_string(syl,"stress","1"); return; } for(;syl;syl=item_next(syl)) { if(is_stressed_vowel(item_feat_string(item_daughter(item_as(syl,"SylVowel")),"name"))) { item_set_string(syl,"stress","1"); stressed=TRUE; } } if(n==0) { if(stressed) return; n=val_int(cart_interpret(word,&ru_stress_cart)); if((numsyls+n) < 0) { if(numsyls <= 4) n=-2; else if(numsyls <= 6) n=-3; else n=-4; } } item_set_string(item_nth_daughter(syls,(numsyls+n)),"stress","1"); }
cst_utterance *flowm_utt_callback(cst_utterance *u) { char rst[FL_MAX_MSG_CHARS]; const char *tok; cst_item *item; char *space; int extend_length; /* In order to stop the synthesizer if the STOP button is pressed */ /* This stops the synthesis of the next utterance */ if ((flowm_play_status == FLOWM_PLAY) || (flowm_play_status == FLOWM_SKIP)) { if (TTSWindow) { rst[0] = '\0'; space = ""; for (item=relation_head(utt_relation(u,"Token")); item; item=item_next(item)) { tok = item_feat_string(item,"name"); if (cst_streq("",space)) /* Only do this on the first token/word */ flowm_file_pos = item_feat_int(item,"file_pos"); extend_length = cst_strlen(rst) + 1 + cst_strlen(item_feat_string(item,"prepunctuation"))+ cst_strlen(item_feat_string(item,"punc")); if (cst_strlen(tok)+extend_length+4 < FL_MAX_MSG_CHARS) cst_sprintf(rst,"%s%s%s%s%s",rst,space, item_feat_string(item,"prepunctuation"), tok, item_feat_string(item,"punc")); else { if (cst_strlen(rst)+4 < FL_MAX_MSG_CHARS) cst_sprintf(rst,"%s ...",rst); break; } space = " "; } if (flowm_file_pos > flowm_prev_utt_pos[flowm_utt_pos_pos]) { if ((flowm_utt_pos_pos+1) >= FLOWM_NUM_UTT_POS) { /* Filled it up, so move it down */ memmove(flowm_prev_utt_pos,&flowm_prev_utt_pos[1], sizeof(int)*(FLOWM_NUM_UTT_POS-10)); flowm_utt_pos_pos = (FLOWM_NUM_UTT_POS-10); } flowm_utt_pos_pos++; flowm_prev_utt_pos[flowm_utt_pos_pos] = flowm_file_pos; } /* Send text to TTSWindow */ mbstowcs(fl_tts_msg,rst,FL_MAX_MSG_CHARS); SetDlgItemText(TTSWindow, FL_SYNTHTEXT, fl_tts_msg); /* Update file pos percentage in FilePos window */ cst_sprintf(rst,"%2.3f",flowm_find_file_percentage()); mbstowcs(fl_fp_msg,rst,FL_MAX_MSG_CHARS); SetDlgItemText(TTSWindow, FL_FILEPOS, fl_fp_msg); SystemIdleTimerReset(); /* keep alive while synthesizing */ if (flowm_play_status == FLOWM_SKIP) flowm_play_status = FLOWM_PLAY; } return u; } else { delete_utterance(u); return 0; } }