示例#1
0
文件: default.c 项目: xawirq/julius
/** 
 * <EN>
 * Fill in system default values to an AM parameter structure.
 * @param j [in] AM configuration parameter structure
 * </EN>
 * <JA>
 * AMパラメータ構造体に初期値を代入する.
 * 
 * @param j [in] AMパラメータ構造体
 * </JA>
 * 
 *
 * @callgraph
 * @callergraph
 * 
 */
void
jconf_set_default_values_am(JCONF_AM *j)
{
  j->name[0] = '\0';

  j->hmmfilename			= NULL;
  j->mapfilename			= NULL;
  j->gprune_method			= GPRUNE_SEL_UNDEF;
  j->mixnum_thres			= 2;
  j->spmodel_name			= NULL;
  j->hmm_gs_filename			= NULL;
  j->gs_statenum			= 24;
  j->iwcdmethod				= IWCD_UNDEF;
  j->iwcdmaxn				= 3;
  j->iwsp_penalty			= -1.0;
  j->force_multipath			= FALSE;
  undef_para(&(j->analysis.para));
  undef_para(&(j->analysis.para_hmm));
  undef_para(&(j->analysis.para_default));
  undef_para(&(j->analysis.para_htk));
  make_default_para(&(j->analysis.para_default));
  make_default_para_htk(&(j->analysis.para_htk));
  j->analysis.cmnload_filename		= NULL;
  j->analysis.cmn_update		= TRUE;
  j->analysis.cmnsave_filename		= NULL;
  j->analysis.cmn_map_weight		= 100.0;
  j->frontend.ss_alpha			= DEF_SSALPHA;
  j->frontend.ss_floor			= DEF_SSFLOOR;
  j->frontend.sscalc			= FALSE;
  j->frontend.sscalc_len		= 300;
  j->frontend.ssload_filename		= NULL;
}
示例#2
0
/** 
 * <EN>
 * Fill in system default values to an AM parameter structure.
 * @param j [in] AM configuration parameter structure
 * </EN>
 * <JA>
 * AMパラメータ構造体に初期値を代入する.
 * 
 * @param j [in] AMパラメータ構造体
 * </JA>
 * 
 *
 * @callgraph
 * @callergraph
 * 
 */
void
jconf_set_default_values_am(JCONF_AM *j)
{
  j->name[0] = '\0';

  j->hmmfilename			= NULL;
  j->mapfilename			= NULL;
  j->gprune_method			= GPRUNE_SEL_UNDEF;
  j->mixnum_thres			= 2;
  j->spmodel_name			= NULL;
  j->hmm_gs_filename			= NULL;
  j->gs_statenum			= 24;
  j->iwcdmethod				= IWCD_UNDEF;
  j->iwcdmaxn				= 3;
  j->iwsp_penalty			= -1.0;
  j->force_multipath			= FALSE;
  undef_para(&(j->analysis.para));
  undef_para(&(j->analysis.para_hmm));
  undef_para(&(j->analysis.para_default));
  undef_para(&(j->analysis.para_htk));
  make_default_para(&(j->analysis.para_default));
  make_default_para_htk(&(j->analysis.para_htk));
  j->analysis.cmnload_filename		= NULL;
  j->analysis.map_cmn			= TRUE;
  j->analysis.cmn_update		= TRUE;
  j->analysis.cmnsave_filename		= NULL;
  j->analysis.cmn_map_weight		= 100.0;
  j->analysis.cmn_static_cvn_only	= FALSE;
  j->frontend.ss_alpha			= DEF_SSALPHA;
  j->frontend.ss_floor			= DEF_SSFLOOR;
  j->frontend.sscalc			= FALSE;
  j->frontend.sscalc_len		= 300;
  j->frontend.ssload_filename		= NULL;
  j->dnn.enabled                        = FALSE;
  j->dnn.paramtype			= F_ERR_INVALID;
  j->dnn.optionstring			= NULL;
  j->dnn.veclen                         = 0;
  j->dnn.contextlen                     = 0;
  j->dnn.inputnodes                     = 0;
  j->dnn.outputnodes                    = 0;
  j->dnn.hiddennodes                    = 0;
  j->dnn.hiddenlayernum                 = 0;
  j->dnn.wfile                          = NULL;
  j->dnn.bfile                          = NULL;
  j->dnn.output_wfile                   = NULL;
  j->dnn.output_bfile                   = NULL;
  j->dnn.priorfile                      = NULL;
  j->dnn.prior_factor                   = 1.0;
  j->dnn.batchsize                      = 1;
  j->dnn.num_threads                    = 2;
}
示例#3
0
int
main(int argc, char *argv[])
{
  FILE *fp;
  char *infile;
  char *outfile;
  char *conffile;
  int i;

  infile = outfile = conffile = NULL;
  for(i=1;i<argc;i++) {
    if (strmatch(argv[i], "-C") || strmatch(argv[i], "-htkconf")) {
      if (++i >= argc) {
	usage(argv[0]);
	return -1;
      }
      conffile = argv[i];
    } else {
      if (infile == NULL) {
	infile = argv[i];
      } else if (outfile == NULL) {
	outfile = argv[i];
      } else {
	usage(argv[0]);
	return -1;
      }
    }
  }
  if (infile == NULL || outfile == NULL) {
    usage(argv[0]);
    return -1;
  }

  hmminfo = hmminfo_new();

  printf("---- reading hmmdefs ----\n");
  printf("filename: %s\n", infile);

  /* read hmmdef file */
  undef_para(&para);
  if (init_hmminfo(hmminfo, infile, NULL, &para) == FALSE) {
    fprintf(stderr, "--- terminated\n");
    return -1;
  }

  if (conffile != NULL) {
    /* if input HMMDEFS already has embedded parameter
       they will be overridden by the parameters in the config file */
    printf("\n---- reading HTK Config ----\n");
    if (para.loaded == 1) {
      printf("Warning: input hmmdefs has acoustic analysis parameter information\n");
      printf("Warning: they are overridden by the HTK Config file...\n");
    }
    /* load HTK config file */
    undef_para(&para);
    if (htk_config_file_parse(conffile, &para) == FALSE) {
      fprintf(stderr, "Error: failed to read %s\n", conffile);
      return(-1);
    }
    /* set some parameters from HTK HMM header information */
    printf("\nsetting TARGETKIND and NUMCEPS from HMM definition header...");
    calc_para_from_header(&para, hmminfo->opt.param_type, hmminfo->opt.vec_size);
    printf("done\n");
    /* fulfill unspecified values with HTK defaults */
    printf("fulfill unspecified values with HTK defaults...");
    undef_para(&para_htk);
    make_default_para_htk(&para_htk);
    apply_para(&para, &para_htk);
    printf("done\n");
  }

  printf("\n------------------------------------------------------------\n");
  print_hmmdef_info(stdout, hmminfo);
  printf("\n");

  if (para.loaded == 1) {
    put_para(stdout, &para);
  }
  printf("------------------------------------------------------------\n");

  printf("---- writing ----\n");
  printf("filename: %s\n", outfile);
  
  if ((fp = fopen_writefile(outfile)) == NULL) {
    fprintf(stderr, "failed to open %s for writing\n", outfile);
    return -1;
  }
  if (write_binhmm(fp, hmminfo, (para.loaded == 1) ? &para : NULL) == FALSE) {
    fprintf(stderr, "failed to write to %s\n", outfile);
    return -1;
  }
  if (fclose_writefile(fp) != 0) {
    fprintf(stderr, "failed to close %s\n", outfile);
    return -1;
  }

  printf("\n");
  if (para.loaded == 1) {
    printf("binary HMM written to \"%s\", with acoustic parameters embedded for Julius.\n", outfile);
  } else {
    printf("binary HMM written to \"%s\"\n", outfile);
  }

  return 0;
}