1 #include <pocketsphinx.h>
6 #include "pocketsphinx_internal.h"
7 #include "ngram_search_fwdtree.h"
8 #include "ngram_search_fwdflat.h"
9 #include "test_macros.h"
12 main(int argc, char *argv[])
22 cmd_ln_init(NULL, ps_args(), TRUE,
23 "-hmm", MODELDIR "/hmm/en_US/hub4wsj_sc_8k",
24 "-lm", MODELDIR "/lm/en_US/wsj0vp.5000.DMP",
25 "-dict", MODELDIR "/lm/en_US/cmu07a.dic",
29 "-input_endian", "little",
30 "-samprate", "16000", NULL));
31 TEST_ASSERT(ps = ps_init(config));
33 ngs = (ngram_search_t *)ps->search;
35 acmod_set_grow(ps->acmod, TRUE);
39 for (i = 0; i < 5; ++i) {
46 TEST_ASSERT(rawfh = fopen(DATADIR "/goforward.raw", "rb"));
47 TEST_EQUAL(0, acmod_start_utt(acmod));
48 ngram_fwdtree_start(ngs);
49 while (!feof(rawfh)) {
50 nread = fread(buf, sizeof(*buf), 2048, rawfh);
52 while ((nfr = acmod_process_raw(acmod, &bptr, &nread, FALSE)) > 0) {
53 while (acmod->n_feat_frame > 0) {
54 ngram_fwdtree_search(ngs, acmod->output_frame);
60 TEST_ASSERT(acmod_end_utt(acmod) >= 0);
61 while (acmod->n_feat_frame > 0) {
62 ngram_fwdtree_search(ngs, acmod->output_frame);
65 ngram_fwdtree_finish(ngs);
66 printf("FWDTREE: %s\n",
67 ngram_search_bp_hyp(ngs, ngram_search_find_exit(ngs, -1, NULL)));
70 E_INFO("grow_feat %d output_frame %d n_mfc_alloc %d n_mfc_frame %d\n",
71 acmod->grow_feat, acmod->output_frame, acmod->n_mfc_alloc,
73 E_INFO("mfc_outidx %d n_feat_alloc %d n_feat_frame %d feat_outidx %d\n",
74 acmod->mfc_outidx, acmod->n_feat_alloc, acmod->n_feat_frame,
76 TEST_EQUAL(0, acmod_rewind(acmod));
77 ngram_fwdflat_start(ngs);
78 while (acmod->n_feat_frame > 0) {
79 ngram_fwdflat_search(ngs, acmod->output_frame);
82 ngram_fwdflat_finish(ngs);
83 printf("FWDFLAT: %s\n",
84 ngram_search_bp_hyp(ngs, ngram_search_find_exit(ngs, -1, NULL)));
86 TEST_EQUAL(0, strcmp("go forward ten years",
87 ngram_search_bp_hyp(ngs, ngram_search_find_exit(ngs, -1, NULL))));
89 printf("5 * fwdtree + fwdflat search in %.2f sec\n",
90 (double)c / CLOCKS_PER_SEC);