int main(int argc, char *argv[]) { ps_decoder_t *ps; dict_t *dict; dict2pid_t *d2p; acmod_t *acmod; ps_alignment_t *al; ps_alignment_iter_t *itor; ps_search_t *search; cmd_ln_t *config; int i; config = cmd_ln_init(NULL, ps_args(), FALSE, "-hmm", MODELDIR "/en-us/en-us", "-dict", MODELDIR "/en-us/cmudict-en-us.dict", "-input_endian", "little", "-samprate", "16000", NULL); TEST_ASSERT(ps = ps_init(config)); dict = ps->dict; d2p = ps->d2p; acmod = ps->acmod; al = ps_alignment_init(d2p); TEST_EQUAL(1, ps_alignment_add_word(al, dict_wordid(dict, "<s>"), 0)); TEST_EQUAL(2, ps_alignment_add_word(al, dict_wordid(dict, "go"), 0)); TEST_EQUAL(3, ps_alignment_add_word(al, dict_wordid(dict, "forward"), 0)); TEST_EQUAL(4, ps_alignment_add_word(al, dict_wordid(dict, "ten"), 0)); TEST_EQUAL(5, ps_alignment_add_word(al, dict_wordid(dict, "meters"), 0)); TEST_EQUAL(6, ps_alignment_add_word(al, dict_wordid(dict, "</s>"), 0)); TEST_EQUAL(0, ps_alignment_populate(al)); TEST_ASSERT(search = state_align_search_init(config, acmod, al)); for (i = 0; i < 5; ++i) do_search(search, acmod); itor = ps_alignment_words(al); TEST_EQUAL(ps_alignment_iter_get(itor)->start, 0); TEST_EQUAL(ps_alignment_iter_get(itor)->duration, 3); itor = ps_alignment_iter_next(itor); TEST_EQUAL(ps_alignment_iter_get(itor)->start, 3); TEST_EQUAL(ps_alignment_iter_get(itor)->duration, 12); itor = ps_alignment_iter_next(itor); TEST_EQUAL(ps_alignment_iter_get(itor)->start, 15); TEST_EQUAL(ps_alignment_iter_get(itor)->duration, 53); itor = ps_alignment_iter_next(itor); TEST_EQUAL(ps_alignment_iter_get(itor)->start, 68); TEST_EQUAL(ps_alignment_iter_get(itor)->duration, 36); itor = ps_alignment_iter_next(itor); TEST_EQUAL(ps_alignment_iter_get(itor)->start, 104); TEST_EQUAL(ps_alignment_iter_get(itor)->duration, 59); itor = ps_alignment_iter_next(itor); TEST_EQUAL(ps_alignment_iter_get(itor)->start, 163); TEST_EQUAL(ps_alignment_iter_get(itor)->duration, 51); itor = ps_alignment_iter_next(itor); TEST_EQUAL(itor, NULL); ps_search_free(search); ps_alignment_free(al); ps_free(ps); cmd_ln_free_r(config); return 0; }
int main(int argc, char *argv[]) { ps_decoder_t *ps; bin_mdef_t *mdef; dict_t *dict; dict2pid_t *d2p; acmod_t *acmod; ps_alignment_t *al; ps_alignment_iter_t *itor; ps_search_t *search; state_align_search_t *sas; cmd_ln_t *config; int i; config = cmd_ln_init(NULL, ps_args(), FALSE, "-hmm", MODELDIR "/hmm/en_US/hub4wsj_sc_8k", "-dict", MODELDIR "/lm/en_US/cmu07a.dic", "-input_endian", "little", "-samprate", "16000", NULL); TEST_ASSERT(ps = ps_init(config)); dict = ps->dict; d2p = ps->d2p; acmod = ps->acmod; mdef = d2p->mdef; al = ps_alignment_init(d2p); TEST_EQUAL(1, ps_alignment_add_word(al, dict_wordid(dict, "<s>"), 0)); TEST_EQUAL(2, ps_alignment_add_word(al, dict_wordid(dict, "go"), 0)); TEST_EQUAL(3, ps_alignment_add_word(al, dict_wordid(dict, "forward"), 0)); TEST_EQUAL(4, ps_alignment_add_word(al, dict_wordid(dict, "ten"), 0)); TEST_EQUAL(5, ps_alignment_add_word(al, dict_wordid(dict, "meters"), 0)); TEST_EQUAL(6, ps_alignment_add_word(al, dict_wordid(dict, "</s>"), 0)); TEST_EQUAL(0, ps_alignment_populate(al)); TEST_ASSERT(search = state_align_search_init(config, acmod, al)); sas = (state_align_search_t *)search; for (i = 0; i < 5; ++i) do_search(search, acmod); itor = ps_alignment_words(al); TEST_EQUAL(ps_alignment_iter_get(itor)->start, 0); TEST_EQUAL(ps_alignment_iter_get(itor)->duration, 46); itor = ps_alignment_iter_next(itor); TEST_EQUAL(ps_alignment_iter_get(itor)->start, 46); TEST_EQUAL(ps_alignment_iter_get(itor)->duration, 18); itor = ps_alignment_iter_next(itor); TEST_EQUAL(ps_alignment_iter_get(itor)->start, 64); TEST_EQUAL(ps_alignment_iter_get(itor)->duration, 53); itor = ps_alignment_iter_next(itor); TEST_EQUAL(ps_alignment_iter_get(itor)->start, 117); TEST_EQUAL(ps_alignment_iter_get(itor)->duration, 29); itor = ps_alignment_iter_next(itor); TEST_EQUAL(ps_alignment_iter_get(itor)->start, 146); TEST_EQUAL(ps_alignment_iter_get(itor)->duration, 67); itor = ps_alignment_iter_next(itor); TEST_EQUAL(ps_alignment_iter_get(itor)->start, 213); TEST_EQUAL(ps_alignment_iter_get(itor)->duration, 61); itor = ps_alignment_iter_next(itor); TEST_EQUAL(itor, NULL); ps_search_free(search); ps_alignment_free(al); ps_free(ps); return 0; }