libjulius/src/m_options.c

Go to the documentation of this file.
00001 
00024 /*
00025  * Copyright (c) 1991-2007 Kawahara Lab., Kyoto University
00026  * Copyright (c) 2000-2005 Shikano Lab., Nara Institute of Science and Technology
00027  * Copyright (c) 2005-2007 Julius project team, Nagoya Institute of Technology
00028  * All rights reserved
00029  */
00030 
00031 #include <julius/julius.h>
00032 
00057 char *
00058 filepath(char *filename, char *dirname)
00059 {
00060   char *p;
00061   if (dirname != NULL && filename[0] != '/'
00062 #if defined(_WIN32)
00063       && filename[0] != '\\' && !(strlen(filename) >= 3 && filename[1] == ':')
00064 #endif
00065       ) {
00066     p = (char *)mymalloc(strlen(filename) + strlen(dirname) + 1);
00067     strcpy(p, dirname);
00068     strcat(p, filename);
00069   } else {
00070     p = strcpy((char *)mymalloc(strlen(filename)+1), filename);
00071   }
00072   return p;
00073 }
00074 
00090 static char *
00091 next_arg(int *cur, int argc, char *argv[])
00092 {
00093   (*cur)++;
00094   if (*cur >= argc) {
00095     jlog("ERROR: m_options: option requires argument -- %s\n", argv[*cur-1]);
00096     return NULL;
00097   }
00098   return(argv[*cur]);
00099 }
00100 
00113 #define FREE_MEMORY(p) \
00114   {if (p) {free(p); p = NULL;}}
00115 
00140 boolean
00141 opt_parse(int argc, char *argv[], char *cwd, Jconf *jconf)
00142 {
00143   char *tmparg;
00144   int i;
00145   boolean unknown_opt;
00146   JCONF_AM *amconf, *atmp;
00147   JCONF_LM *lmconf, *ltmp;
00148   JCONF_SEARCH *sconf, *stmp;
00149   static char sname[JCONF_MODULENAME_MAXLEN];
00150 #define GET_TMPARG  if ((tmparg = next_arg(&i, argc, argv)) == NULL) return FALSE
00151 
00152   for (i=1;i<argc;i++) {
00153     unknown_opt = FALSE;
00154     if (strmatch(argv[i],"-C")) { /* include jconf file  */
00155       GET_TMPARG;
00156       tmparg = filepath(tmparg, cwd);
00157       if (config_file_parse(tmparg, jconf) == FALSE) {
00158         return FALSE;
00159       }
00160       free(tmparg);
00161       continue;
00162     } else if (strmatch(argv[i],"-AM") || strmatch(argv[i], "[AM]")) {
00163       GET_TMPARG;
00164       if (tmparg[0] == '-') {
00165         jlog("ERROR: m_options: -AM needs an argument as module name\n");
00166         return FALSE;
00167       }
00168       if (tmparg[0] >= '0' && tmparg[0] <= '9') {
00169         jlog("ERROR: m_options: AM name \"%s\" not acceptable: first character should not be a digit\n", tmparg);
00170         return FALSE;
00171       }
00172       /* if not first time, create new module instance and switch to it */
00173       /* and switch current to this */
00174       amconf = j_jconf_am_new();
00175       if (j_jconf_am_regist(jconf, amconf, tmparg) == FALSE) {
00176         jlog("ERROR: failed to add new amconf as \"%s\"\n", tmparg);
00177         jlog("ERROR: m_options: failed to create amconf\n");
00178         j_jconf_am_free(amconf);
00179         return FALSE;
00180       }
00181       jconf->amnow = amconf;
00182       continue;
00183     } else if (strmatch(argv[i],"-AM_GMM") || strmatch(argv[i], "[AM_GMM]")) {
00184       /* switch current to GMM */
00185       jconf->amnow = jconf->gmm;
00186       continue;
00187     } else if (strmatch(argv[i],"-LM") || strmatch(argv[i], "[LM]")) {
00188       GET_TMPARG;
00189       if (tmparg[0] == '-') {
00190         jlog("ERROR: m_options: -LM needs an argument as module name\n");
00191         return FALSE;
00192       }
00193       if (tmparg[0] >= '0' && tmparg[0] <= '9') {
00194         jlog("ERROR: m_options: LM name \"%s\" not acceptable: first character should not be a digit\n", tmparg);
00195         return FALSE;
00196       }
00197       /* create new module instance and switch to it */
00198       /* and switch current to this */
00199       lmconf = j_jconf_lm_new();
00200       if (j_jconf_lm_regist(jconf, lmconf, tmparg) == FALSE) {
00201         jlog("ERROR: failed to add new lmconf as \"%s\"\n", tmparg);
00202         jlog("ERROR: m_options: failed to create lmconf\n");
00203         j_jconf_lm_free(lmconf);
00204         return FALSE;
00205       }
00206       jconf->lmnow = lmconf;
00207       continue;
00208     } else if (strmatch(argv[i],"-SR") || strmatch(argv[i], "[SR]")) {
00209       GET_TMPARG;
00210       if (tmparg[0] == '-') {
00211         jlog("ERROR: m_options: -SR needs three arguments: module name, AM name and LM name\n");
00212         return FALSE;
00213       }
00214       if (tmparg[0] >= '0' && tmparg[0] <= '9') {
00215         jlog("ERROR: m_options: SR name \"%s\" not acceptable: first character should not be a digit\n", tmparg);
00216         return FALSE;
00217       }
00218       /* store name temporarly */
00219       strncpy(sname, tmparg, JCONF_MODULENAME_MAXLEN);
00220       /* get link to jconf_am and jconf_lm */
00221       GET_TMPARG;
00222       if (tmparg[0] == '-') {
00223         jlog("ERROR: m_options: -SR needs three arguments: module name, AM name and LM name\n");
00224         return FALSE;
00225       }
00226       if (tmparg[0] >= '0' && tmparg[0] <= '9') { /* arg is number */
00227         if ((amconf = j_get_amconf_by_id(jconf, atoi(tmparg))) == NULL) return FALSE;
00228       } else {                  /* name string */
00229         if ((amconf = j_get_amconf_by_name(jconf, tmparg)) == NULL) return FALSE;
00230       }
00231       GET_TMPARG;
00232       if (tmparg[0] == '-') {
00233         jlog("ERROR: m_options: -SR needs three arguments: module name, AM name and LM name\n");
00234         return FALSE;
00235       }
00236       if (tmparg[0] >= '0' && tmparg[0] <= '9') { /* arg is number */
00237         if ((lmconf = j_get_lmconf_by_id(jconf, atoi(tmparg))) == NULL) return FALSE;
00238       } else {                  /* name string */
00239         if ((lmconf = j_get_lmconf_by_name(jconf, tmparg)) == NULL) return FALSE;
00240       }
00241 
00242       /* if not first time, create new module instance and switch to it */
00243       sconf = j_jconf_search_new();
00244       sconf->amconf = amconf;
00245       sconf->lmconf = lmconf;
00246       if (j_jconf_search_regist(jconf, sconf, sname) == FALSE) {
00247         jlog("ERROR: failed to add new amconf as \"%s\"\n", sname);
00248         jlog("ERROR: m_options: failed to create search conf\n");
00249         j_jconf_search_free(sconf);
00250         return FALSE;
00251       }
00252       jconf->searchnow = sconf;
00253       continue;
00254     } else if (strmatch(argv[i],"-input")) { /* speech input */
00255       GET_TMPARG;
00256       if (strmatch(tmparg,"file")) {
00257         jconf->input.speech_input = SP_RAWFILE;
00258         jconf->decodeopt.realtime_flag = FALSE;
00259       } else if (strmatch(tmparg,"rawfile")) {
00260         jconf->input.speech_input = SP_RAWFILE;
00261         jconf->decodeopt.realtime_flag = FALSE;
00262       } else if (strmatch(tmparg,"htkparam")) {
00263         jconf->input.speech_input = SP_MFCFILE;
00264         jconf->decodeopt.realtime_flag = FALSE;
00265       } else if (strmatch(tmparg,"mfcfile")) {
00266         jconf->input.speech_input = SP_MFCFILE;
00267         jconf->decodeopt.realtime_flag = FALSE;
00268       } else if (strmatch(tmparg,"stdin")) {
00269         jconf->input.speech_input = SP_STDIN;
00270         jconf->decodeopt.realtime_flag = FALSE;
00271       } else if (strmatch(tmparg,"adinnet")) {
00272         jconf->input.speech_input = SP_ADINNET;
00273         jconf->decodeopt.realtime_flag = TRUE;
00274 #ifdef USE_NETAUDIO
00275       } else if (strmatch(tmparg,"netaudio")) {
00276         jconf->input.speech_input = SP_NETAUDIO;
00277         jconf->decodeopt.realtime_flag = TRUE;
00278 #endif
00279 #ifdef USE_MIC
00280       } else if (strmatch(tmparg,"mic")) {
00281         jconf->input.speech_input = SP_MIC;
00282         jconf->decodeopt.realtime_flag = TRUE;
00283 #endif
00284       } else if (strmatch(tmparg,"file")) { /* for 1.1 compat */
00285         jconf->input.speech_input = SP_RAWFILE;
00286         jconf->decodeopt.realtime_flag = FALSE;
00287       } else if (strmatch(tmparg,"mfc")) { /* for 1.1 compat */
00288         jconf->input.speech_input = SP_MFCFILE;
00289         jconf->decodeopt.realtime_flag = FALSE;
00290       } else {
00291         jlog("ERROR: m_options: unknown speech input source \"%s\"\n", tmparg);
00292         return FALSE;
00293       }
00294       continue;
00295     } else if (strmatch(argv[i],"-filelist")) { /* input file list */
00296       FREE_MEMORY(jconf->input.inputlist_filename);
00297       GET_TMPARG;
00298       //jconf->input.inputlist_filename = strcpy((char*)mymalloc(strlen(tmparg)+1),tmparg);
00299       jconf->input.inputlist_filename = filepath(tmparg, cwd);
00300       continue;
00301     } else if (strmatch(argv[i],"-rejectshort")) { /* short input rejection */
00302       GET_TMPARG;
00303       jconf->reject.rejectshortlen = atoi(tmparg);
00304       continue;
00305 #ifdef POWER_REJECT
00306     } else if (strmatch(argv[i],"-powerthres")) { /* short input rejection */
00307       GET_TMPARG;
00308       jconf->reject.powerthres = atoi(tmparg);
00309       continue;
00310 #endif
00311     } else if (strmatch(argv[i],"-force_realtime")) { /* force realtime */
00312       GET_TMPARG;
00313       if (strmatch(tmparg, "on")) {
00314         jconf->decodeopt.forced_realtime = TRUE;
00315       } else if (strmatch(tmparg, "off")) {
00316         jconf->decodeopt.forced_realtime = FALSE;
00317       } else {
00318         jlog("ERROR: m_options: \"-force_realtime\" should be either \"on\" or \"off\"\n");
00319         return FALSE;
00320       }
00321       jconf->decodeopt.force_realtime_flag = TRUE;
00322       continue;
00323     } else if (strmatch(argv[i],"-realtime")) { /* equal to "-force_realtime on" */
00324       jconf->decodeopt.forced_realtime = TRUE;
00325       jconf->decodeopt.force_realtime_flag = TRUE;
00326       continue;
00327     } else if (strmatch(argv[i], "-norealtime")) { /* equal to "-force_realtime off" */
00328       jconf->decodeopt.forced_realtime = FALSE;
00329       jconf->decodeopt.force_realtime_flag = TRUE;
00330       continue;
00331     } else if (strmatch(argv[i],"-forcedict")) { /* skip dict error */
00332       jconf->lmnow->forcedict_flag = TRUE;
00333       continue;
00334     } else if (strmatch(argv[i],"-check")) { /* interactive model check mode */
00335       GET_TMPARG;
00336       if (strmatch(tmparg, "wchmm")) {
00337         jconf->searchnow->sw.wchmm_check_flag = TRUE;
00338       } else if (strmatch(tmparg, "trellis")) {
00339         jconf->searchnow->sw.trellis_check_flag = TRUE;
00340       } else if (strmatch(tmparg, "triphone")) {
00341         jconf->searchnow->sw.triphone_check_flag = TRUE;
00342       } else {
00343         jlog("ERROR: m_options: invalid argument for \"-check\": %s\n", tmparg);
00344         return FALSE;
00345       }
00346       continue;
00347     } else if (strmatch(argv[i],"-notypecheck")) { /* don't check param type */
00348       jconf->input.paramtype_check_flag = FALSE;
00349       continue;
00350     } else if (strmatch(argv[i],"-nlimit")) { /* limit N token in a node */
00351 #ifdef WPAIR_KEEP_NLIMIT
00352       GET_TMPARG;
00353       jconf->searchnow->pass1.wpair_keep_nlimit = atoi(tmparg);
00354 #else
00355       jlog("WARNING: m_options: WPAIR_KEEP_NLIMIT disabled, \"-nlimit\" ignored\n");
00356 #endif
00357       continue;
00358     } else if (strmatch(argv[i],"-lookuprange")) { /* trellis neighbor range */
00359       GET_TMPARG;
00360       jconf->searchnow->pass2.lookup_range = atoi(tmparg);
00361       continue;
00362     } else if (strmatch(argv[i],"-graphout")) { /* enable graph output */
00363       jconf->searchnow->graph.enabled = TRUE;
00364       jconf->searchnow->graph.lattice = TRUE;
00365       jconf->searchnow->graph.confnet = FALSE;
00366       continue;
00367     } else if (strmatch(argv[i],"-lattice")) { /* enable graph output */
00368       jconf->searchnow->graph.enabled = TRUE;
00369       jconf->searchnow->graph.lattice = TRUE;
00370       continue;
00371     } else if (strmatch(argv[i],"-nolattice")) { /* disable graph output */
00372       jconf->searchnow->graph.enabled = FALSE;
00373       jconf->searchnow->graph.lattice = FALSE;
00374       continue;
00375     } else if (strmatch(argv[i],"-confnet")) { /* enable confusion network */
00376       jconf->searchnow->graph.enabled = TRUE;
00377       jconf->searchnow->graph.confnet = TRUE;
00378       continue;
00379     } else if (strmatch(argv[i],"-noconfnet")) { /* disable graph output */
00380       jconf->searchnow->graph.enabled = FALSE;
00381       jconf->searchnow->graph.confnet = FALSE;
00382       continue;
00383     } else if (strmatch(argv[i],"-graphrange")) { /* neighbor merge range frame */
00384       GET_TMPARG;
00385       jconf->searchnow->graph.graph_merge_neighbor_range = atoi(tmparg);
00386       continue;
00387 #ifdef GRAPHOUT_DEPTHCUT
00388     } else if (strmatch(argv[i],"-graphcut")) { /* cut graph word by depth */
00389       GET_TMPARG;
00390       jconf->searchnow->graph.graphout_cut_depth = atoi(tmparg);
00391       continue;
00392 #endif
00393 #ifdef GRAPHOUT_LIMIT_BOUNDARY_LOOP
00394     } else if (strmatch(argv[i],"-graphboundloop")) { /* neighbor merge range frame */
00395       GET_TMPARG;
00396       jconf->searchnow->graph.graphout_limit_boundary_loop_num = atoi(tmparg);
00397       continue;
00398 #endif
00399 #ifdef GRAPHOUT_SEARCH_DELAY_TERMINATION
00400     } else if (strmatch(argv[i],"-graphsearchdelay")) { /* not do graph search termination before the 1st sentence is found */
00401       jconf->searchnow->graph.graphout_search_delay = TRUE;
00402       continue;
00403     } else if (strmatch(argv[i],"-nographsearchdelay")) { /* not do graph search termination before the 1st sentence is found */
00404       jconf->searchnow->graph.graphout_search_delay = FALSE;
00405       continue;
00406 #endif
00407     } else if (strmatch(argv[i],"-looktrellis")) { /* activate loopuprange */
00408       jconf->searchnow->pass2.looktrellis_flag = TRUE;
00409       continue;
00410     } else if (strmatch(argv[i],"-multigramout")) { /* enable per-grammar decoding on 2nd pass */
00411       jconf->searchnow->output.multigramout_flag = TRUE;
00412       continue;
00413     } else if (strmatch(argv[i],"-nomultigramout")) { /* disable per-grammar decoding on 2nd pass */
00414       jconf->searchnow->output.multigramout_flag = FALSE;
00415       continue;
00416     } else if (strmatch(argv[i],"-oldtree")) { /* use old tree function */
00417       jconf->searchnow->pass1.old_tree_function_flag = TRUE;
00418       continue;
00419     } else if (strmatch(argv[i],"-sb")) { /* score envelope width in 2nd pass */
00420 #ifdef SCAN_BEAM
00421       GET_TMPARG;
00422       jconf->searchnow->pass2.scan_beam_thres = atof(tmparg);
00423 #else
00424       jlog("WARNING: m_options: SCAN_BEAM disabled, \"-sb\" ignored\n");
00425 #endif
00426       continue;
00427     } else if (strmatch(argv[i],"-discount")) { /* (bogus) */
00428       jlog("WARNING: m_options: option \"-discount\" is now bogus, ignored\n");
00429       continue;
00430     } else if (strmatch(argv[i],"-cutsilence")) { /* force (long) silence detection on */
00431       jconf->detect.silence_cut = 1;
00432       continue;
00433     } else if (strmatch(argv[i],"-nocutsilence")) { /* force (long) silence detection off */
00434       jconf->detect.silence_cut = 0;
00435       continue;
00436     } else if (strmatch(argv[i],"-pausesegment")) { /* force (long) silence detection on (for backward compatibility) */
00437       jconf->detect.silence_cut = 1;
00438       continue;
00439     } else if (strmatch(argv[i],"-nopausesegment")) { /* force (long) silence detection off (for backward comatibility) */
00440       jconf->detect.silence_cut = 0;
00441       continue;
00442     } else if (strmatch(argv[i],"-lv")) { /* silence detection threshold level */
00443       GET_TMPARG;
00444       jconf->detect.level_thres = atoi(tmparg);
00445       continue;
00446     } else if (strmatch(argv[i],"-zc")) { /* silence detection zero cross num */
00447       GET_TMPARG;
00448       jconf->detect.zero_cross_num = atoi(tmparg);
00449       continue;
00450     } else if (strmatch(argv[i],"-headmargin")) { /* head silence length */
00451       GET_TMPARG;
00452       jconf->detect.head_margin_msec = atoi(tmparg);
00453       continue;
00454     } else if (strmatch(argv[i],"-tailmargin")) { /* tail silence length */
00455       GET_TMPARG;
00456       jconf->detect.tail_margin_msec = atoi(tmparg);
00457       continue;
00458     } else if (strmatch(argv[i],"-hipass")||strmatch(argv[i],"-hifreq")) { /* frequency of upper band limit */
00459       GET_TMPARG;
00460       jconf->amnow->analysis.para.hipass = atoi(tmparg);
00461       continue;
00462     } else if (strmatch(argv[i],"-lopass")||strmatch(argv[i],"-lofreq")) { /* frequency of lower band limit */
00463       GET_TMPARG;
00464       jconf->amnow->analysis.para.lopass = atoi(tmparg);
00465       continue;
00466     } else if (strmatch(argv[i],"-smpPeriod")) { /* sample period (ns) */
00467       GET_TMPARG;
00468       jconf->amnow->analysis.para.smp_period = atoi(tmparg);
00469       jconf->amnow->analysis.para.smp_freq = period2freq(jconf->amnow->analysis.para.smp_period);
00470       continue;
00471     } else if (strmatch(argv[i],"-smpFreq")) { /* sample frequency (Hz) */
00472       GET_TMPARG;
00473       jconf->amnow->analysis.para.smp_freq = atoi(tmparg);
00474       jconf->amnow->analysis.para.smp_period = freq2period(jconf->amnow->analysis.para.smp_freq);
00475       continue;
00476     } else if (strmatch(argv[i],"-fsize")) { /* Window size */
00477       GET_TMPARG;
00478       jconf->amnow->analysis.para.framesize = atoi(tmparg);
00479       continue;
00480     } else if (strmatch(argv[i],"-fshift")) { /* Frame shiht */
00481       GET_TMPARG;
00482       jconf->amnow->analysis.para.frameshift = atoi(tmparg);
00483       continue;
00484     } else if (strmatch(argv[i],"-preemph")) {
00485       GET_TMPARG;
00486       jconf->amnow->analysis.para.preEmph = atof(tmparg);
00487       continue;
00488     } else if (strmatch(argv[i],"-fbank")) {
00489       GET_TMPARG;
00490       jconf->amnow->analysis.para.fbank_num = atoi(tmparg);
00491       continue;
00492     } else if (strmatch(argv[i],"-ceplif")) {
00493       GET_TMPARG;
00494       jconf->amnow->analysis.para.lifter = atoi(tmparg);
00495       continue;
00496     } else if (strmatch(argv[i],"-rawe")) {
00497       jconf->amnow->analysis.para.raw_e = TRUE;
00498       continue;
00499     } else if (strmatch(argv[i],"-norawe")) {
00500       jconf->amnow->analysis.para.raw_e = FALSE;
00501       continue;
00502     } else if (strmatch(argv[i],"-enormal")) {
00503       jconf->amnow->analysis.para.enormal = TRUE;
00504       continue;
00505     } else if (strmatch(argv[i],"-noenormal")) {
00506       jconf->amnow->analysis.para.enormal = FALSE;
00507       continue;
00508     } else if (strmatch(argv[i],"-escale")) {
00509       GET_TMPARG;
00510       jconf->amnow->analysis.para.escale = atof(tmparg);
00511       continue;
00512     } else if (strmatch(argv[i],"-silfloor")) {
00513       GET_TMPARG;
00514       jconf->amnow->analysis.para.silFloor = atof(tmparg);
00515       continue;
00516     } else if (strmatch(argv[i],"-delwin")) { /* Delta window length */
00517       GET_TMPARG;
00518       jconf->amnow->analysis.para.delWin = atoi(tmparg);
00519       continue;
00520     } else if (strmatch(argv[i],"-accwin")) { /* Acceleration window length */
00521       GET_TMPARG;
00522       jconf->amnow->analysis.para.accWin = atoi(tmparg);
00523       continue;
00524     } else if (strmatch(argv[i],"-ssalpha")) { /* alpha coef. for SS */
00525       GET_TMPARG;
00526       jconf->amnow->frontend.ss_alpha = atof(tmparg);
00527       continue;
00528     } else if (strmatch(argv[i],"-ssfloor")) { /* spectral floor for SS */
00529       GET_TMPARG;
00530       jconf->amnow->frontend.ss_floor = atof(tmparg);
00531       continue;
00532     } else if (strmatch(argv[i],"-48")) { /* use 48kHz input and down to 16kHz */
00533       jconf->input.use_ds48to16 = TRUE;
00534       continue;
00535     } else if (strmatch(argv[i],"-version") || strmatch(argv[i], "--version") || strmatch(argv[i], "-setting") || strmatch(argv[i], "--setting")) { /* print version and exit */
00536       j_put_header(stderr);
00537       j_put_compile_defs(stderr);
00538       fprintf(stderr, "\n");
00539       j_put_library_defs(stderr);
00540       return FALSE;
00541     } else if (strmatch(argv[i],"-quiet")) { /* minimum output */
00542       debug2_flag = verbose_flag = FALSE;
00543       continue;
00544     } else if (strmatch(argv[i],"-debug")) { /* debug mode: output huge log */
00545       debug2_flag = verbose_flag = TRUE;
00546       continue;
00547     } else if (strmatch(argv[i],"-progout")) { /* enable progressive output */
00548       jconf->searchnow->output.progout_flag = TRUE;
00549       continue;
00550     } else if (strmatch(argv[i],"-proginterval")) { /* interval for -progout */
00551       GET_TMPARG;
00552       jconf->searchnow->output.progout_interval = atoi(tmparg);
00553       continue;
00554     } else if (strmatch(argv[i],"-demo")) { /* quiet + progout */
00555       debug2_flag = verbose_flag = FALSE;
00556       jconf->searchnow->output.progout_flag = TRUE;
00557       continue;
00558     } else if (strmatch(argv[i],"-walign")) { /* do forced alignment by word */
00559       jconf->searchnow->annotate.align_result_word_flag = TRUE;
00560       continue;
00561     } else if (strmatch(argv[i],"-palign")) { /* do forced alignment by phoneme */
00562       jconf->searchnow->annotate.align_result_phoneme_flag = TRUE;
00563       continue;
00564     } else if (strmatch(argv[i],"-salign")) { /* do forced alignment by state */
00565       jconf->searchnow->annotate.align_result_state_flag = TRUE;
00566       continue;
00567     } else if (strmatch(argv[i],"-output")) { /* output up to N candidate */
00568       GET_TMPARG;
00569       jconf->searchnow->output.output_hypo_maxnum = atoi(tmparg);
00570       continue;
00571     } else if (strmatch(argv[i],"-1pass")) { /* do only 1st pass */
00572       jconf->searchnow->compute_only_1pass = TRUE;
00573       continue;
00574     } else if (strmatch(argv[i],"-hlist")) { /* HMM list file */
00575       FREE_MEMORY(jconf->amnow->mapfilename);
00576       GET_TMPARG;
00577       jconf->amnow->mapfilename = filepath(tmparg, cwd);
00578       continue;
00579     } else if (strmatch(argv[i],"-nlr")) { /* word LR n-gram (ARPA) */
00580       FREE_MEMORY(jconf->lmnow->ngram_filename_lr_arpa);
00581       GET_TMPARG;
00582       jconf->lmnow->ngram_filename_lr_arpa = filepath(tmparg, cwd);
00583       FREE_MEMORY(jconf->lmnow->ngram_filename);
00584       continue;
00585     } else if (strmatch(argv[i],"-nrl")) { /* word RL n-gram (ARPA) */
00586       FREE_MEMORY(jconf->lmnow->ngram_filename_rl_arpa);
00587       GET_TMPARG;
00588       jconf->lmnow->ngram_filename_rl_arpa = filepath(tmparg, cwd);
00589       FREE_MEMORY(jconf->lmnow->ngram_filename);
00590       continue;
00591     } else if (strmatch(argv[i],"-lmp")) { /* LM weight and penalty (pass1) */
00592       GET_TMPARG;
00593       jconf->searchnow->lmp.lm_weight = (LOGPROB)atof(tmparg);
00594       GET_TMPARG;
00595       jconf->searchnow->lmp.lm_penalty = (LOGPROB)atof(tmparg);
00596       jconf->searchnow->lmp.lmp_specified = TRUE;
00597       continue;
00598     } else if (strmatch(argv[i],"-lmp2")) { /* LM weight and penalty (pass2) */
00599       GET_TMPARG;
00600       jconf->searchnow->lmp.lm_weight2 = (LOGPROB)atof(tmparg);
00601       GET_TMPARG;
00602       jconf->searchnow->lmp.lm_penalty2 = (LOGPROB)atof(tmparg);
00603       jconf->searchnow->lmp.lmp2_specified = TRUE;
00604       continue;
00605     } else if (strmatch(argv[i],"-transp")) { /* penalty for transparent word */
00606       GET_TMPARG;
00607       jconf->searchnow->lmp.lm_penalty_trans = (LOGPROB)atof(tmparg);
00608       continue;
00609     } else if (strmatch(argv[i],"-gram")) { /* comma-separatedlist of grammar prefix */
00610       GET_TMPARG;
00611       if (multigram_add_prefix_list(tmparg, cwd, jconf->lmnow, LM_DFA_GRAMMAR) == FALSE) {
00612         jlog("ERROR: m_options: failed to read some grammars\n");
00613         return FALSE;
00614       }
00615       continue;
00616     } else if (strmatch(argv[i],"-gramlist")) { /* file of grammar prefix list */
00617       GET_TMPARG;
00618       tmparg = filepath(tmparg, cwd);
00619       if (multigram_add_prefix_filelist(tmparg, jconf->lmnow, LM_DFA_GRAMMAR) == FALSE) {
00620         jlog("ERROR: m_options: failed to read some grammars\n");
00621         free(tmparg);
00622         return FALSE;
00623       }
00624       free(tmparg);
00625       continue;
00626     } else if (strmatch(argv[i],"-userlm")) {
00627       /* just set lm flags here */
00628       if (jconf->lmnow->lmtype != LM_PROB && jconf->lmnow->lmtype != LM_UNDEF) {
00629         jlog("ERROR: m_options: LM type conflicts: multiple LM specified?\n");
00630         return FALSE;
00631       }
00632       jconf->lmnow->lmtype = LM_PROB;
00633       if (jconf->lmnow->lmvar != LM_UNDEF && jconf->lmnow->lmvar != LM_NGRAM_USER) {
00634         jlog("ERROR: m_options: statistical model conflict\n");
00635         return FALSE;
00636       }
00637       jconf->lmnow->lmvar  = LM_NGRAM_USER;
00638       continue;
00639     } else if (strmatch(argv[i],"-nogram")) { /* remove grammar list */
00640       multigram_remove_gramlist(jconf->lmnow);
00641       FREE_MEMORY(jconf->lmnow->dfa_filename);
00642       FREE_MEMORY(jconf->lmnow->dictfilename);
00643       continue;
00644     } else if (strmatch(argv[i],"-dfa")) { /* DFA filename */
00645       FREE_MEMORY(jconf->lmnow->dfa_filename);
00646       GET_TMPARG;
00647       jconf->lmnow->dfa_filename = filepath(tmparg, cwd);
00648       continue;
00649     } else if (strmatch(argv[i],"-penalty1")) { /* word insertion penalty (pass1) */
00650       GET_TMPARG;
00651       jconf->searchnow->lmp.penalty1 = (LOGPROB)atof(tmparg);
00652       continue;
00653     } else if (strmatch(argv[i],"-penalty2")) { /* word insertion penalty (pass2) */
00654       GET_TMPARG;
00655       jconf->searchnow->lmp.penalty2 = (LOGPROB)atof(tmparg);
00656       continue;
00657     } else if (strmatch(argv[i],"-spmodel") || strmatch(argv[i], "-sp")) { /* name of short pause word */
00658       FREE_MEMORY(jconf->amnow->spmodel_name);
00659       GET_TMPARG;
00660       jconf->amnow->spmodel_name = strcpy((char*)mymalloc(strlen(tmparg)+1),tmparg);
00661       continue;
00662     } else if (strmatch(argv[i],"-multipath")) { /* force multipath mode */
00663       jconf->amnow->force_multipath = TRUE;
00664       continue;
00665     } else if (strmatch(argv[i],"-iwsp")) { /* enable inter-word short pause handing (for multipath) */
00666       jconf->lmnow->enable_iwsp = TRUE;
00667       continue;
00668     } else if (strmatch(argv[i],"-iwsppenalty")) { /* set inter-word short pause transition penalty (for multipath) */
00669       GET_TMPARG;
00670       jconf->amnow->iwsp_penalty = atof(tmparg);
00671       continue;
00672     } else if (strmatch(argv[i],"-silhead")) { /* head silence word name */
00673       FREE_MEMORY(jconf->lmnow->head_silname);
00674       GET_TMPARG;
00675       jconf->lmnow->head_silname = strcpy((char*)mymalloc(strlen(tmparg)+1),tmparg);
00676       continue;
00677     } else if (strmatch(argv[i],"-siltail")) { /* tail silence word name */
00678       FREE_MEMORY(jconf->lmnow->tail_silname);
00679       GET_TMPARG;
00680       jconf->lmnow->tail_silname = strcpy((char*)mymalloc(strlen(tmparg)+1),tmparg);
00681       continue;
00682     } else if (strmatch(argv[i],"-iwspword")) { /* add short pause word */
00683       jconf->lmnow->enable_iwspword = TRUE;
00684       continue;
00685     } else if (strmatch(argv[i],"-iwspentry")) { /* content of the iwspword */
00686       FREE_MEMORY(jconf->lmnow->iwspentry);
00687       GET_TMPARG;
00688       jconf->lmnow->iwspentry = strcpy((char*)mymalloc(strlen(tmparg)+1),tmparg);
00689       continue;
00690     } else if (strmatch(argv[i],"-iwcache")) { /* control cross-word LM cache */
00691 #ifdef HASH_CACHE_IW
00692       GET_TMPARG;
00693       jconf->searchnow->pass1.iw_cache_rate = atof(tmparg);
00694       if (jconf->searchnow->pass1.iw_cache_rate > 100) jconf->searchnow->pass1.iw_cache_rate = 100;
00695       if (jconf->searchnow->pass1.iw_cache_rate < 1) jconf->searchnow->pass1.iw_cache_rate = 1;
00696 #else
00697       jlog("WARNING: m_options: HASH_CACHE_IW disabled, \"-iwcache\" ignored\n");
00698 #endif
00699       continue;
00700     } else if (strmatch(argv[i],"-sepnum")) { /* N-best frequent word will be separated from tree */
00701 #ifdef SEPARATE_BY_UNIGRAM
00702       GET_TMPARG;
00703       jconf->lmnow->separate_wnum = atoi(tmparg);
00704 #else
00705       jlog("WARNING: m_options: SEPARATE_BY_UNIGRAM disabled, \"-sepnum\" ignored\n");
00706       i++;
00707 #endif
00708       continue;
00709 #ifdef USE_NETAUDIO
00710     } else if (strmatch(argv[i],"-NA")) { /* netautio device name */
00711       FREE_MEMORY(jconf->input.netaudio_devname);
00712       GET_TMPARG;
00713       jconf->input.netaudio_devname = strcpy((char*)mymalloc(strlen(tmparg)+1),tmparg);
00714       continue;
00715 #endif
00716     } else if (strmatch(argv[i],"-adport")) { /* adinnet port num */
00717       GET_TMPARG;
00718       jconf->input.adinnet_port = atoi(tmparg);
00719       continue;
00720     } else if (strmatch(argv[i],"-nostrip")) { /* do not strip zero samples */
00721       jconf->preprocess.strip_zero_sample = FALSE;
00722       continue;
00723     } else if (strmatch(argv[i],"-zmean")) { /* enable DC offset by zero mean */
00724       jconf->preprocess.use_zmean = TRUE;
00725       continue;
00726     } else if (strmatch(argv[i],"-nozmean")) { /* disable DC offset by zero mean */
00727       jconf->preprocess.use_zmean = FALSE;
00728       continue;
00729     } else if (strmatch(argv[i],"-zmeanframe")) { /* enable frame-wise DC offset by zero mean */
00730       jconf->amnow->analysis.para.zmeanframe = TRUE;
00731       continue;
00732     } else if (strmatch(argv[i],"-nozmeanframe")) { /* disable frame-wise DC offset by zero mean */
00733       jconf->amnow->analysis.para.zmeanframe = FALSE;
00734       continue;
00735     } else if (strmatch(argv[i],"-spsegment")) { /* enable short-pause segmentation */
00736       jconf->searchnow->successive.enabled = TRUE;
00737       continue;
00738     } else if (strmatch(argv[i],"-spdur")) { /* speech down-trigger duration threshold in frame */
00739       GET_TMPARG;
00740       jconf->searchnow->successive.sp_frame_duration = atoi(tmparg);
00741       continue;
00742 #ifdef SPSEGMENT_NAIST
00743     } else if (strmatch(argv[i],"-spmargin")) { /* speech up-trigger backstep margin in frame */
00744       GET_TMPARG;
00745       jconf->searchnow->successive.sp_margin = atoi(tmparg);
00746       continue;
00747     } else if (strmatch(argv[i],"-spdelay")) { /* speech up-trigger delay frame */
00748       GET_TMPARG;
00749       jconf->searchnow->successive.sp_delay = atoi(tmparg);
00750       continue;
00751 #endif
00752     } else if (strmatch(argv[i],"-pausemodels")) { /* short-pause duration threshold */
00753       FREE_MEMORY(jconf->searchnow->successive.pausemodelname);
00754       GET_TMPARG;
00755       jconf->searchnow->successive.pausemodelname = strcpy((char*)mymalloc(strlen(tmparg)+1),tmparg);
00756       continue;
00757     } else if (strmatch(argv[i],"-gprune")) { /* select Gaussian pruning method */
00758       GET_TMPARG;
00759       if (strmatch(tmparg,"safe")) { /* safest, slowest */
00760         jconf->amnow->gprune_method = GPRUNE_SEL_SAFE;
00761       } else if (strmatch(tmparg,"heuristic")) {
00762         jconf->amnow->gprune_method = GPRUNE_SEL_HEURISTIC;
00763       } else if (strmatch(tmparg,"beam")) { /* fastest */
00764         jconf->amnow->gprune_method = GPRUNE_SEL_BEAM;
00765       } else if (strmatch(tmparg,"none")) { /* no prune: compute all Gaussian */
00766         jconf->amnow->gprune_method = GPRUNE_SEL_NONE;
00767       } else if (strmatch(tmparg,"default")) {
00768         jconf->amnow->gprune_method = GPRUNE_SEL_UNDEF;
00769       } else {
00770         jlog("ERROR: m_options: no such pruning method \"%s\"\n", argv[0], tmparg);
00771         return FALSE;
00772       }
00773       continue;
00774 /* 
00775  *     } else if (strmatch(argv[i],"-reorder")) {
00776  *       result_reorder_flag = TRUE;
00777  *       continue;
00778  */
00779     } else if (strmatch(argv[i],"-no_ccd")) { /* force triphone handling = OFF */
00780       jconf->searchnow->ccd_handling = FALSE;
00781       jconf->searchnow->force_ccd_handling = TRUE;
00782       continue;
00783     } else if (strmatch(argv[i],"-force_ccd")) { /* force triphone handling = ON */
00784       jconf->searchnow->ccd_handling = TRUE;
00785       jconf->searchnow->force_ccd_handling = TRUE;
00786       continue;
00787     } else if (strmatch(argv[i],"-iwcd1")) { /* select cross-word triphone computation method */
00788       GET_TMPARG;
00789       if (strmatch(tmparg, "max")) { /* use maximum score in triphone variants */
00790         jconf->amnow->iwcdmethod = IWCD_MAX;
00791       } else if (strmatch(tmparg, "avg")) { /* use average in variants */
00792         jconf->amnow->iwcdmethod = IWCD_AVG;
00793       } else if (strmatch(tmparg, "best")) { /* use average in variants */
00794         jconf->amnow->iwcdmethod = IWCD_NBEST;
00795         GET_TMPARG;
00796         jconf->amnow->iwcdmaxn = atoi(tmparg);
00797       } else {
00798         jlog("ERROR: m_options: -iwcd1: wrong argument (max|avg|best N): %s\n", argv[0], tmparg);
00799         return FALSE;
00800       }
00801       continue;
00802     } else if (strmatch(argv[i],"-tmix")) { /* num of mixture to select */
00803       if (i + 1 < argc && isdigit(argv[i+1][0])) {
00804         jconf->amnow->mixnum_thres = atoi(argv[++i]);
00805       }
00806       continue;
00807     } else if (strmatch(argv[i],"-b2") || strmatch(argv[i],"-bw") || strmatch(argv[i],"-wb")) { /* word beam width in 2nd pass */
00808       GET_TMPARG;
00809       jconf->searchnow->pass2.enveloped_bestfirst_width = atoi(tmparg);
00810       continue;
00811     } else if (strmatch(argv[i],"-hgs")) { /* Gaussian selection model file */
00812       FREE_MEMORY(jconf->amnow->hmm_gs_filename);
00813       GET_TMPARG;
00814       jconf->amnow->hmm_gs_filename = filepath(tmparg, cwd);
00815       continue;
00816     } else if (strmatch(argv[i],"-booknum")) { /* num of state to select in GS */
00817       GET_TMPARG;
00818       jconf->amnow->gs_statenum = atoi(tmparg);
00819       continue;
00820     } else if (strmatch(argv[i],"-gshmm")) { /* same as "-hgs" */
00821       FREE_MEMORY(jconf->amnow->hmm_gs_filename);
00822       GET_TMPARG;
00823       jconf->amnow->hmm_gs_filename = filepath(tmparg, cwd);
00824       continue;
00825     } else if (strmatch(argv[i],"-gsnum")) { /* same as "-booknum" */
00826       GET_TMPARG;
00827       jconf->amnow->gs_statenum = atoi(tmparg);
00828       continue;
00829     } else if (strmatch(argv[i],"-cmnload")) { /* load CMN parameter from file */
00830       FREE_MEMORY(jconf->amnow->analysis.cmnload_filename);
00831       GET_TMPARG;
00832       jconf->amnow->analysis.cmnload_filename = filepath(tmparg, cwd);
00833       continue;
00834     } else if (strmatch(argv[i],"-cmnsave")) { /* save CMN parameter to file */
00835       FREE_MEMORY(jconf->amnow->analysis.cmnsave_filename);
00836       GET_TMPARG;
00837       jconf->amnow->analysis.cmnsave_filename = filepath(tmparg, cwd);
00838       continue;
00839     } else if (strmatch(argv[i],"-cmnupdate")) { /* update CMN parameter */
00840       jconf->amnow->analysis.cmn_update = TRUE;
00841       continue;
00842     } else if (strmatch(argv[i],"-cmnnoupdate")) { /* not update CMN parameter */
00843       jconf->amnow->analysis.cmn_update = FALSE;
00844       continue;
00845     } else if (strmatch(argv[i],"-cmnmapweight")) { /* CMN weight for MAP */
00846       GET_TMPARG;
00847       jconf->amnow->analysis.cmn_map_weight = (float)atof(tmparg);
00848       continue;
00849     } else if (strmatch(argv[i],"-sscalc")) { /* do spectral subtraction (SS) for raw file input */
00850       jconf->amnow->frontend.sscalc = TRUE;
00851       FREE_MEMORY(jconf->amnow->frontend.ssload_filename);
00852       continue;
00853     } else if (strmatch(argv[i],"-sscalclen")) { /* head silence length used to compute SS (in msec) */
00854       GET_TMPARG;
00855       jconf->amnow->frontend.sscalc_len = atoi(tmparg);
00856       continue;
00857     } else if (strmatch(argv[i],"-ssload")) { /* load SS parameter from file */
00858       FREE_MEMORY(jconf->amnow->frontend.ssload_filename);
00859       GET_TMPARG;
00860       jconf->amnow->frontend.ssload_filename = filepath(tmparg, cwd);
00861       jconf->amnow->frontend.sscalc = FALSE;
00862       continue;
00863 #ifdef CONFIDENCE_MEASURE
00864     } else if (strmatch(argv[i],"-cmalpha")) { /* CM log score scaling factor */
00865 #ifdef CM_MULTIPLE_ALPHA
00866       GET_TMPARG;
00867       jconf->searchnow->annotate.cm_alpha_bgn = (LOGPROB)atof(tmparg);
00868       GET_TMPARG;
00869       jconf->searchnow->annotate.cm_alpha_end = (LOGPROB)atof(tmparg);
00870       GET_TMPARG;
00871       jconf->searchnow->annotate.cm_alpha_step = (LOGPROB)atof(tmparg);
00872       jconf->searchnow->annotate.cm_alpha_num = (int)((jconf->searchnow->annotate.cm_alpha_end - jconf->searchnow->annotate.cm_alpha_bgn) / jconf->searchnow->annotate.cm_alpha_step) + 1;
00873       if (jconf->searchnow->annotate.cm_alpha_num > 100) {
00874         jlog("ERROR: m_option: cm_alpha step num exceeds limit (100)\n");
00875         return FALSE;
00876       }
00877 #else
00878       GET_TMPARG;
00879       jconf->searchnow->annotate.cm_alpha = (LOGPROB)atof(tmparg);
00880 #endif
00881       continue;
00882 #ifdef CM_SEARCH_LIMIT
00883     } else if (strmatch(argv[i],"-cmthres")) { /* CM cut threshold for CM decoding */
00884       GET_TMPARG;
00885       jconf->searchnow->annotate.cm_cut_thres = (LOGPROB)atof(tmparg);
00886       continue;
00887 #endif
00888 #ifdef CM_SEARCH_LIMIT_POP
00889     } else if (strmatch(argv[i],"-cmthres2")) { /* CM cut threshold for CM decoding */
00890       GET_TMPARG;
00891       jconf->searchnow->annotate.cm_cut_thres_pop = (LOGPROB)atof(tmparg);
00892       continue;
00893 #endif
00894 #endif /* CONFIDENCE_MEASURE */
00895     } else if (strmatch(argv[i],"-gmm")) { /* load SS parameter from file */
00896       FREE_MEMORY(jconf->reject.gmm_filename);
00897       GET_TMPARG;
00898       jconf->reject.gmm_filename = filepath(tmparg, cwd);
00899       continue;
00900     } else if (strmatch(argv[i],"-gmmnum")) { /* num of Gaussian pruning for GMM */
00901       GET_TMPARG;
00902       jconf->reject.gmm_gprune_num = atoi(tmparg);
00903       continue;
00904     } else if (strmatch(argv[i],"-gmmreject")) {
00905       GET_TMPARG;
00906       FREE_MEMORY(jconf->reject.gmm_reject_cmn_string);
00907       jconf->reject.gmm_reject_cmn_string = strcpy((char *)mymalloc(strlen(tmparg)+1), tmparg);
00908       continue;
00909 #ifdef GMM_VAD
00910     } else if (strmatch(argv[i],"-gmmmargin")) { /* backstep margin */
00911       GET_TMPARG;
00912       jconf->detect.gmm_margin = atoi(tmparg);
00913       continue;
00914 #endif
00915     } else if (strmatch(argv[i],"-htkconf")) {
00916       GET_TMPARG;
00917       if (htk_config_file_parse(tmparg, &(jconf->amnow->analysis.para_htk)) == FALSE) {
00918         jlog("ERROR: m_options: failed to read %s\n", tmparg);
00919         return FALSE;
00920       }
00921       continue;
00922     } else if (strmatch(argv[i], "-wlist")) {
00923       GET_TMPARG;
00924       tmparg = filepath(tmparg, cwd);
00925       if (multigram_add_prefix_filelist(tmparg, jconf->lmnow, LM_DFA_WORD) == FALSE) {
00926         jlog("ERROR: m_options: failed to read some word lists\n");
00927         free(tmparg);
00928         return FALSE;
00929       }
00930       free(tmparg);
00931       continue;
00932     } else if (strmatch(argv[i], "-wsil")) {
00933       /* 
00934        * if (jconf->lmnow->lmvar != LM_UNDEF && jconf->lmnow->lmvar != LM_DFA_WORD) {
00935        *   jlog("ERROR: \"-wsil\" only valid for isolated word recognition mode\n");
00936        *   return FALSE;
00937        * }
00938        */
00939       GET_TMPARG;
00940       strncpy(jconf->lmnow->wordrecog_head_silence_model_name, tmparg, MAX_HMMNAME_LEN);
00941       GET_TMPARG;
00942       strncpy(jconf->lmnow->wordrecog_tail_silence_model_name, tmparg, MAX_HMMNAME_LEN);
00943       GET_TMPARG;
00944       if (strmatch(tmparg, "NULL")) {
00945         jconf->lmnow->wordrecog_silence_context_name[0] = '\0';
00946       } else {
00947         strncpy(jconf->lmnow->wordrecog_silence_context_name, tmparg, MAX_HMMNAME_LEN);
00948       }
00949       continue;
00950 #ifdef DETERMINE
00951     } else if (strmatch(argv[i], "-wed")) {
00952       //if (jconf->lmnow->lmvar != LM_UNDEF && jconf->lmnow->lmvar != LM_DFA_WORD) {
00953       //jlog("ERROR: \"-wed\" only valid for isolated word recognition mode\n");
00954       //return FALSE;
00955       //}
00956       GET_TMPARG;
00957       jconf->searchnow->pass1.determine_score_thres = atof(tmparg);
00958       GET_TMPARG;
00959       jconf->searchnow->pass1.determine_duration_thres = atoi(tmparg);
00960       continue;
00961 #endif
00962     } else if (strmatch(argv[i], "-inactive")) { /* start inactive */
00963       jconf->searchnow->sw.start_inactive = TRUE;
00964       continue;
00965     } else if (strmatch(argv[i], "-active")) { /* start active (default) */
00966       jconf->searchnow->sw.start_inactive = FALSE;
00967       continue;
00968     }
00969     if (argv[i][0] == '-' && strlen(argv[i]) == 2) {
00970       /* 1-letter options */
00971       switch(argv[i][1]) {
00972       case 'h':                 /* hmmdefs */
00973         FREE_MEMORY(jconf->amnow->hmmfilename);
00974         GET_TMPARG;
00975         jconf->amnow->hmmfilename = filepath(tmparg, cwd);
00976         break;
00977       case 'v':                 /* dictionary */
00978         FREE_MEMORY(jconf->lmnow->dictfilename);
00979         GET_TMPARG;
00980         jconf->lmnow->dictfilename = filepath(tmparg, cwd);
00981         break;
00982       case 'w':                 /* word list (isolated word recognition) */
00983         GET_TMPARG;
00984         if (multigram_add_prefix_list(tmparg, cwd, jconf->lmnow, LM_DFA_WORD) == FALSE) {
00985           jlog("ERROR: m_options: failed to read some word list\n");
00986           return FALSE;
00987         }
00988         break;
00989       case 'd':                 /* binary N-gram */
00990         /* lmvar should be overriden by the content of the binary N-gram */
00991         FREE_MEMORY(jconf->lmnow->ngram_filename);
00992         FREE_MEMORY(jconf->lmnow->ngram_filename_lr_arpa);
00993         FREE_MEMORY(jconf->lmnow->ngram_filename_rl_arpa);
00994         GET_TMPARG;
00995         jconf->lmnow->ngram_filename = filepath(tmparg, cwd);
00996         break;
00997       case 'b':                 /* beam width in 1st pass */
00998         GET_TMPARG;
00999         jconf->searchnow->pass1.specified_trellis_beam_width = atoi(tmparg);
01000         break;
01001       case 's':                 /* stack size in 2nd pass */
01002         GET_TMPARG;
01003         jconf->searchnow->pass2.stack_size = atoi(tmparg);
01004         break;
01005       case 'n':                 /* N-best search */
01006         GET_TMPARG;
01007         jconf->searchnow->pass2.nbest = atoi(tmparg);
01008         break;
01009       case 'm':                 /* upper limit of hypothesis generation */
01010         GET_TMPARG;
01011         jconf->searchnow->pass2.hypo_overflow = atoi(tmparg);
01012         break;
01013       default:
01014         //jlog("ERROR: m_options: wrong argument: %s\n", argv[0], argv[i]);
01015         //return FALSE;
01016         unknown_opt = TRUE;
01017       }
01018     } else {                    /* error */
01019       //jlog("ERROR: m_options: wrong argument: %s\n", argv[0], argv[i]);
01020       //return FALSE;
01021       unknown_opt = TRUE;
01022     }
01023     if (unknown_opt) {
01024       /* call user-side option processing */
01025       switch(useropt_exec(jconf, argv, argc, &i)) {
01026       case 0:                   /* does not match user-side options */
01027         jlog("ERROR: m_options: wrong argument: \"%s\"\n", argv[i]);
01028         return FALSE;
01029       case -1:                  /* Error in user-side function */
01030         jlog("ERROR: m_options: error in processing \"%s\"\n", argv[i]);
01031         return FALSE;
01032       }
01033     }
01034   }
01035   
01036   /* set default values if not specified yet */
01037   for(atmp=jconf->am_root;atmp;atmp=atmp->next) {
01038     if (!atmp->spmodel_name) {
01039       atmp->spmodel_name = strcpy((char*)mymalloc(strlen(SPMODEL_NAME_DEFAULT)+1),
01040                           SPMODEL_NAME_DEFAULT);
01041     }
01042   }
01043   for(ltmp=jconf->lm_root;ltmp;ltmp=ltmp->next) {
01044     if (!ltmp->head_silname) {
01045       ltmp->head_silname = strcpy((char*)mymalloc(strlen(BEGIN_WORD_DEFAULT)+1),
01046                                   BEGIN_WORD_DEFAULT);
01047     }
01048     if (!ltmp->tail_silname) {
01049       ltmp->tail_silname = strcpy((char*)mymalloc(strlen(END_WORD_DEFAULT)+1),
01050                                   END_WORD_DEFAULT);
01051     }
01052     if (!ltmp->iwspentry) {
01053       ltmp->iwspentry = strcpy((char*)mymalloc(strlen(IWSPENTRY_DEFAULT)+1),
01054                                IWSPENTRY_DEFAULT);
01055     }
01056   }
01057 #ifdef USE_NETAUDIO
01058   if (!jconf->input.netaudio_devname) {
01059     jconf->input.netaudio_devname = strcpy((char*)mymalloc(strlen(NETAUDIO_DEVNAME)+1),
01060                               NETAUDIO_DEVNAME);
01061   }
01062 #endif  /* USE_NETAUDIO */
01063 
01064   return TRUE;
01065 }
01066 
01080 void
01081 opt_release(Jconf *jconf)
01082 {
01083   JCONF_AM *am;
01084   JCONF_LM *lm;
01085   JCONF_SEARCH *s;
01086 
01087   FREE_MEMORY(jconf->input.inputlist_filename);
01088 #ifdef USE_NETAUDIO
01089   FREE_MEMORY(jconf->input.netaudio_devname);
01090 #endif  /* USE_NETAUDIO */
01091   FREE_MEMORY(jconf->reject.gmm_filename);
01092   FREE_MEMORY(jconf->reject.gmm_reject_cmn_string);
01093 
01094   for(am=jconf->am_root;am;am=am->next) {
01095     FREE_MEMORY(am->hmmfilename);
01096     FREE_MEMORY(am->mapfilename);
01097     FREE_MEMORY(am->spmodel_name);
01098     FREE_MEMORY(am->hmm_gs_filename);
01099     FREE_MEMORY(am->analysis.cmnload_filename);
01100     FREE_MEMORY(am->analysis.cmnsave_filename);
01101     FREE_MEMORY(am->frontend.ssload_filename);
01102   }
01103   for(lm=jconf->lm_root;lm;lm=lm->next) {
01104     FREE_MEMORY(lm->ngram_filename);
01105     FREE_MEMORY(lm->ngram_filename_lr_arpa);
01106     FREE_MEMORY(lm->ngram_filename_rl_arpa);
01107     FREE_MEMORY(lm->dfa_filename);
01108     FREE_MEMORY(lm->head_silname);
01109     FREE_MEMORY(lm->tail_silname);
01110     FREE_MEMORY(lm->iwspentry);
01111     FREE_MEMORY(lm->dictfilename);
01112     multigram_remove_gramlist(lm);
01113   }
01114   for(s=jconf->search_root;s;s=s->next) {
01115     FREE_MEMORY(s->successive.pausemodelname);
01116   }
01117 }
01118 
01119 /* end of file */

Generated on Tue Dec 18 15:59:52 2007 for Julius by  doxygen 1.5.4