/*
 * Append a new word to partially build phone-level sentence HMM.  (Handle alternative
 * pronunciations.)  Link new word to end phones of previous words.
 * Append optional filler words before w, if indicated.
 * Also Link prev_end into the global node list.
 * Return value: list of end phone nodes for w.  (NOTE: these are not yet linked into
 * the global node list.)
 */
static pnode_t *append_transcript_word
    (s3wid_t w,			/* Transcript word to be appended */
     pnode_t *prev_end,		/* Previous end points to be attached to w */
     s3wid_t nextw,		/* Next word to follow w (ignoring optional fillers) */
     int32 prefix_filler,	/* Whether optional filler words to precede w */
     int32 append_filler)	/* Whether optional filler words to follow w */
{
    int32 i, p;
    pnode_t *new_end, *tmp_end, *node;
    s3cipid_t pred_ci[256], succ_ci[256];
    s3wid_t fw;
    
    if (mdef->n_ciphone >= 256)
	E_FATAL("Increase pred_ci, succ_ci array sizes to > #CIphones (%d)\n",
		mdef->n_ciphone);
    assert (prev_end != NULL);
    
    /* Add optional silence/filler words before w, if indicated */
    if (prefix_filler) {
	build_pred_ci (prev_end, pred_ci);	/* Predecessor CI list for fillers */
	build_succ_ci (w, 0, succ_ci);		/* Successor CI list for fillers */
	
	new_end = NULL;
	for (i = 0; IS_WID(fillwid[i]); i++) {
	    for (fw = fillwid[i]; IS_WID(fw); fw = dict->word[fw].alt) {
		tmp_end = append_word (fw, prev_end, pred_ci, succ_ci);

		for (node = tmp_end; node->next; node = node->next);
		node->next = new_end;
		new_end = tmp_end;
	    }
	}
	
	/* Augment prev_end with new_end for filler words added above */
	for (node = prev_end; node->next; node = node->next);
	node->next = new_end;
    }

    /* Add w */
    build_pred_ci (prev_end, pred_ci);			/* Predecessor CI list for w */
    build_succ_ci (nextw, append_filler, succ_ci);	/* Successor CI list for w */

    new_end = NULL;
    for (; IS_WID(w); w = dict->word[w].alt) {
	tmp_end = append_word (w, prev_end, pred_ci, succ_ci);

	for (node = tmp_end; node->next; node = node->next);
	node->next = new_end;
	new_end = tmp_end;
    }
    
    return (new_end);
}
Ejemplo n.º 2
0
/*
 * Save the capability.  Updates @s->capability so that the CAPA() macro
 * will find the flag.  Saves the @param string if not NULL.
 */
static void save_capability(struct backend *s,
			    const struct capa_t *c,
			    const char *param)
{
    int i;

    s->capability |= c->flag;

    if (param) {
	/* find the matching cap_params entry */
	for (i = 0 ; i < s->num_cap_params ; i++)
	    if (s->cap_params[i].capa == c->flag)
		break;

	if (i == s->num_cap_params) {
	    /* not found, expand the array and add a params */
	    s->num_cap_params++;
	    s->cap_params = xrealloc(s->cap_params,
		     sizeof(*s->cap_params) * s->num_cap_params);

	    s->cap_params[i].capa = c->flag;
	    s->cap_params[i].params = xstrdup(param);
	} else {
	    /* append to the existing params */
	    s->cap_params[i].params = append_word(s->cap_params[i].params, param);
	}
    }
}
Ejemplo n.º 3
0
void test_put(Segment s, int n)
{
        for (int i = 0; i < n; i ++) {
                append_word(s, i, i);
        }

        return;
}
Ejemplo n.º 4
0
void test_append_word(Segment s, int n)
{
        int length = 0;
        for (int i = 0; i < n; i++) {
                for (int j = 0; j < TO_ADD; j++) {

                        length = get_words_in_seg(s, i);

                        append_word(s, i, j);

                        if (get_word(s, i, (length - 1)) != (unsigned) j) {
                                fprintf(stderr, "get_word: %u\n", get_word(s, i, length));
                                fprintf(stderr, "j: %d\n", j);
                                fprintf(stderr, "did not add...\n");
                        }
                }
        }

        return;
}
Ejemplo n.º 5
0
 void end_sentence()
 {
     append_word(nia.end);
 }
Ejemplo n.º 6
0
 void start_sentence()
 {
     append_word(nia.start);
 }