void ps_default_search_args(cmd_ln_t *config) { #ifdef MODELDIR /* Set default acoustic and language models. */ const char *hmmdir = cmd_ln_str_r(config, "-hmm"); if (hmmdir == NULL && hmmdir_exists(MODELDIR "/en-us/en-us")) { hmmdir = MODELDIR "/en-us/en-us"; cmd_ln_set_str_r(config, "-hmm", hmmdir); } const char *lmfile = cmd_ln_str_r(config, "-lm"); if (lmfile == NULL && !cmd_ln_str_r(config, "-fsg") && !cmd_ln_str_r(config, "-jsgf") && !cmd_ln_str_r(config, "-lmctl") && !cmd_ln_str_r(config, "-kws") && !cmd_ln_str_r(config, "-keyphrase") && file_exists(MODELDIR "/en-us/en-us.lm.dmp")) { lmfile = MODELDIR "/en-us/en-us.lm.dmp"; cmd_ln_set_str_r(config, "-lm", lmfile); } const char *dictfile = cmd_ln_str_r(config, "-dict"); if (dictfile == NULL && file_exists(MODELDIR "/en-us/cmudict-en-us.dict")) { dictfile = MODELDIR "/en-us/cmudict-en-us.dict"; cmd_ln_set_str_r(config, "-dict", dictfile); } /* Expand acoustic and language model filenames relative to installation * path. */ if (hmmdir && !path_is_absolute(hmmdir) && !hmmdir_exists(hmmdir)) { char *tmphmm = string_join(MODELDIR "/hmm/", hmmdir, NULL); if (hmmdir_exists(tmphmm)) { cmd_ln_set_str_r(config, "-hmm", tmphmm); } else { E_ERROR("Failed to find mdef file inside the model folder " "specified with -hmm `%s'\n", hmmdir); } ckd_free(tmphmm); } if (lmfile && !path_is_absolute(lmfile) && !file_exists(lmfile)) { char *tmplm = string_join(MODELDIR "/lm/", lmfile, NULL); cmd_ln_set_str_r(config, "-lm", tmplm); ckd_free(tmplm); } if (dictfile && !path_is_absolute(dictfile) && !file_exists(dictfile)) { char *tmpdict = string_join(MODELDIR "/lm/", dictfile, NULL); cmd_ln_set_str_r(config, "-dict", tmpdict); ckd_free(tmpdict); } #endif }
/* Set default acoustic and language models if they are not defined in configuration. */ void ps_default_search_args(cmd_ln_t *config) { #ifdef MODELDIR const char *hmmdir = cmd_ln_str_r(config, "-hmm"); const char *lmfile = cmd_ln_str_r(config, "-lm"); const char *dictfile = cmd_ln_str_r(config, "-dict"); if (hmmdir == NULL && hmmdir_exists(MODELDIR "/en-us/en-us")) { hmmdir = MODELDIR "/en-us/en-us"; cmd_ln_set_str_r(config, "-hmm", hmmdir); } if (lmfile == NULL && !cmd_ln_str_r(config, "-fsg") && !cmd_ln_str_r(config, "-jsgf") && !cmd_ln_str_r(config, "-lmctl") && !cmd_ln_str_r(config, "-kws") && !cmd_ln_str_r(config, "-keyphrase") && file_exists(MODELDIR "/en-us/en-us.lm.bin")) { lmfile = MODELDIR "/en-us/en-us.lm.bin"; cmd_ln_set_str_r(config, "-lm", lmfile); } if (dictfile == NULL && file_exists(MODELDIR "/en-us/cmudict-en-us.dict")) { dictfile = MODELDIR "/en-us/cmudict-en-us.dict"; cmd_ln_set_str_r(config, "-dict", dictfile); } #endif }
static void ps_init_defaults(ps_decoder_t *ps) { char const *hmmdir, *lmfile, *dictfile; /* Disable memory mapping on Blackfin (FIXME: should be uClinux in general). */ #ifdef __ADSPBLACKFIN__ E_INFO("Will not use mmap() on uClinux/Blackfin."); cmd_ln_set_boolean_r(ps->config, "-mmap", FALSE); #endif #ifdef MODELDIR /* Set default acoustic and language models. */ hmmdir = cmd_ln_str_r(ps->config, "-hmm"); lmfile = cmd_ln_str_r(ps->config, "-lm"); dictfile = cmd_ln_str_r(ps->config, "-dict"); if (hmmdir == NULL && hmmdir_exists(MODELDIR "/hmm/en_US/hub4wsj_sc_8k")) { hmmdir = MODELDIR "/hmm/en_US/hub4wsj_sc_8k"; cmd_ln_set_str_r(ps->config, "-hmm", hmmdir); } if (lmfile == NULL && !cmd_ln_str_r(ps->config, "-fsg") && !cmd_ln_str_r(ps->config, "-jsgf") && file_exists(MODELDIR "/lm/en_US/hub4.5000.DMP")) { lmfile = MODELDIR "/lm/en_US/hub4.5000.DMP"; cmd_ln_set_str_r(ps->config, "-lm", lmfile); } if (dictfile == NULL && file_exists(MODELDIR "/lm/en_US/cmu07a.dic")) { dictfile = MODELDIR "/lm/en_US/cmu07a.dic"; cmd_ln_set_str_r(ps->config, "-dict", dictfile); } /* Expand acoustic and language model filenames relative to installation path. */ if (hmmdir && !path_is_absolute(hmmdir) && !hmmdir_exists(hmmdir)) { char *tmphmm = string_join(MODELDIR "/hmm/", hmmdir, NULL); cmd_ln_set_str_r(ps->config, "-hmm", tmphmm); ckd_free(tmphmm); } if (lmfile && !path_is_absolute(lmfile) && !file_exists(lmfile)) { char *tmplm = string_join(MODELDIR "/lm/", lmfile, NULL); cmd_ln_set_str_r(ps->config, "-lm", tmplm); ckd_free(tmplm); } if (dictfile && !path_is_absolute(dictfile) && !file_exists(dictfile)) { char *tmpdict = string_join(MODELDIR "/lm/", dictfile, NULL); cmd_ln_set_str_r(ps->config, "-dict", tmpdict); ckd_free(tmpdict); } #endif /* Get acoustic model filenames and add them to the command-line */ if ((hmmdir = cmd_ln_str_r(ps->config, "-hmm")) != NULL) { ps_add_file(ps, "-mdef", hmmdir, "mdef"); ps_add_file(ps, "-mean", hmmdir, "means"); ps_add_file(ps, "-var", hmmdir, "variances"); ps_add_file(ps, "-tmat", hmmdir, "transition_matrices"); ps_add_file(ps, "-mixw", hmmdir, "mixture_weights"); ps_add_file(ps, "-sendump", hmmdir, "sendump"); ps_add_file(ps, "-fdict", hmmdir, "noisedict"); ps_add_file(ps, "-lda", hmmdir, "feature_transform"); ps_add_file(ps, "-featparams", hmmdir, "feat.params"); ps_add_file(ps, "-senmgau", hmmdir, "senmgau"); } }