int mdef_phone_id(mdef_t * m, int ci, int lc, int rc, word_posn_t wpos) { ph_lc_t *lcptr; ph_rc_t *rcptr; int newl, newr; assert(m); assert((ci >= 0) && (ci < m->n_ciphone)); assert((lc >= 0) && (lc < m->n_ciphone)); assert((rc >= 0) && (rc < m->n_ciphone)); assert((wpos >= 0) && (wpos < N_WORD_POSN)); if (((lcptr = find_ph_lc(m->wpos_ci_lclist[wpos][(int) ci], lc)) == NULL) || ((rcptr = find_ph_rc(lcptr->rclist, rc)) == NULL)) { /* Not found; backoff to silence context if non-silence filler context */ if (m->sil < 0) return -1; newl = m->ciphone[(int) lc].filler ? m->sil : lc; newr = m->ciphone[(int) rc].filler ? m->sil : rc; if ((newl == lc) && (newr == rc)) return -1; return (mdef_phone_id(m, ci, newl, newr, wpos)); } return (rcptr->pid); }
static int32 triphone_add(mdef_t * m, s3cipid_t ci, s3cipid_t lc, s3cipid_t rc, word_posn_t wpos, s3pid_t p) { ph_lc_t *lcptr; ph_rc_t *rcptr; if (mdef->n_phone >= max_phone) E_FATAL("Max phones (%d) exceeded\n", max_phone); assert(p == mdef->n_phone); /* Fill in phone[p] information */ mdef->phone[p].ci = ci; mdef->phone[p].lc = lc; mdef->phone[p].rc = rc; mdef->phone[p].wpos = wpos; if (p >= max_ciphone) { /* Create <ci,lc,rc,wpos> -> p mapping */ if ((lcptr = find_ph_lc(m->wpos_ci_lclist[wpos][ci], lc)) == NULL) { temp++; lcptr = (ph_lc_t *) ckd_calloc(1, sizeof(ph_lc_t)); lcptr->lc = lc; lcptr->next = m->wpos_ci_lclist[wpos][ci]; m->wpos_ci_lclist[wpos][ci] = lcptr; } if ((rcptr = find_ph_rc(lcptr->rclist, rc)) != NULL) return -1; /* Duplicate triphone */ rcptr = (ph_rc_t *) ckd_calloc(1, sizeof(ph_rc_t)); temp2++; rcptr->rc = rc; rcptr->pid = p; rcptr->next = lcptr->rclist; lcptr->rclist = rcptr; } mdef->n_phone++; return 0; }
s3pid_t mdef_phone_id (mdef_t *m, s3cipid_t ci, s3cipid_t lc, s3cipid_t rc, word_posn_t wpos) { ph_lc_t *lcptr; ph_rc_t *rcptr; assert (m); assert ((ci >= 0) && (ci < mdef->n_ciphone)); assert ((lc >= 0) && (lc < mdef->n_ciphone)); assert ((rc >= 0) && (rc < mdef->n_ciphone)); assert ((wpos >= 0) && (wpos < N_WORD_POSN)); if (((lcptr = find_ph_lc (m->wpos_ci_lclist[wpos][ci], lc)) == NULL) || ((rcptr = find_ph_rc (lcptr->rclist, rc)) == NULL)) return (BAD_PID); return (rcptr->pid); }
static void triphone_add(mdef_t * m, int ci, int lc, int rc, word_posn_t wpos, int p) { ph_lc_t *lcptr; ph_rc_t *rcptr; assert(p < m->n_phone); /* Fill in phone[p] information (state and tmat mappings added later) */ m->phone[p].ci = ci; m->phone[p].lc = lc; m->phone[p].rc = rc; m->phone[p].wpos = wpos; /* Create <ci,lc,rc,wpos> -> p mapping if not a CI phone */ if (p >= m->n_ciphone) { if ((lcptr = find_ph_lc(m->wpos_ci_lclist[wpos][(int) ci], lc)) == NULL) { lcptr = (ph_lc_t *) ckd_calloc(1, sizeof(ph_lc_t)); /* freed at mdef_free, I believe */ lcptr->lc = lc; lcptr->next = m->wpos_ci_lclist[wpos][(int) ci]; m->wpos_ci_lclist[wpos][(int) ci] = lcptr; /* This is what needs to be freed */ } if ((rcptr = find_ph_rc(lcptr->rclist, rc)) != NULL) { __BIGSTACKVARIABLE__ char buf[4096]; mdef_phone_str(m, rcptr->pid, buf); E_FATAL("Duplicate triphone: %s\n", buf); } rcptr = (ph_rc_t *) ckd_calloc(1, sizeof(ph_rc_t)); /* freed in mdef_free, I believe */ rcptr->rc = rc; rcptr->pid = p; rcptr->next = lcptr->rclist; lcptr->rclist = rcptr; } }