Julius 4.2
libjulius/src/m_options.c
説明を見る。
00001 
00024 /*
00025  * Copyright (c) 1991-2011 Kawahara Lab., Kyoto University
00026  * Copyright (c) 2000-2005 Shikano Lab., Nara Institute of Science and Technology
00027  * Copyright (c) 2005-2011 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 
00101 static boolean
00102 check_section(Jconf *jconf, char *optname, short sec)
00103 {
00104   if (! jconf->optsectioning) return TRUE;
00105 
00106   if (jconf->optsection == sec) return TRUE;
00107 
00108   if (jconf->optsection == JCONF_OPT_DEFAULT) return TRUE;
00109 
00110   switch(sec) {
00111   case JCONF_OPT_GLOBAL:
00112     jlog("ERROR: \"%s\" is global option (should be before any instance declaration)", optname); break;
00113   case JCONF_OPT_AM:
00114     jlog("ERROR: \"%s\" is AM option", optname); break;
00115   case JCONF_OPT_LM:
00116     jlog("ERROR: \"%s\" is LM option", optname); break;
00117   case JCONF_OPT_SR:
00118     jlog("ERROR: \"%s\" is SR (search) option", optname); break;
00119   }
00120   switch(jconf->optsection) {
00121   case JCONF_OPT_GLOBAL:
00122     jlog(", but exists at global section (-GLOBAL)\n"); break;
00123   case JCONF_OPT_AM:
00124     jlog(", but exists at AM section (-AM \"%s\")\n", jconf->amnow->name); break;
00125   case JCONF_OPT_LM:
00126     jlog(", but exists at LM section (-LM \"%s\")\n", jconf->lmnow->name); break;
00127   case JCONF_OPT_SR:
00128     jlog(", but exists at recognizer section (-SR \"%s\")\n", jconf->searchnow->name); break;
00129   }
00130   jlog("ERROR: fix it, or you can disable this check by \"-nosectioncheck\"\n");
00131   return FALSE;
00132 }
00133 
00146 #define FREE_MEMORY(p) \
00147   {if (p) {free(p); p = NULL;}}
00148 
00173 boolean
00174 opt_parse(int argc, char *argv[], char *cwd, Jconf *jconf)
00175 {
00176   char *tmparg;
00177   int i;
00178   boolean unknown_opt;
00179   JCONF_AM *amconf, *atmp;
00180   JCONF_LM *lmconf, *ltmp;
00181   JCONF_SEARCH *sconf;
00182   char sname[JCONF_MODULENAME_MAXLEN];
00183 #ifdef ENABLE_PLUGIN
00184   int sid;
00185   FUNC_INT func;
00186 #endif
00187 #define GET_TMPARG  if ((tmparg = next_arg(&i, argc, argv)) == NULL) return FALSE
00188 
00189   for (i=1;i<argc;i++) {
00190     unknown_opt = FALSE;
00191     if (strmatch(argv[i],"-C")) { /* include jconf file  */
00192       GET_TMPARG;
00193       tmparg = filepath(tmparg, cwd);
00194       if (config_file_parse(tmparg, jconf) == FALSE) {
00195         return FALSE;
00196       }
00197       free(tmparg);
00198       continue;
00199     } else if (strmatch(argv[i],"-AM") || strmatch(argv[i], "[AM]")) {
00200       GET_TMPARG;
00201       if (tmparg[0] == '-') {
00202         jlog("ERROR: m_options: -AM needs an argument as module name\n");
00203         return FALSE;
00204       }
00205       if (tmparg[0] >= '0' && tmparg[0] <= '9') {
00206         jlog("ERROR: m_options: AM name \"%s\" not acceptable: first character should not be a digit\n", tmparg);
00207         return FALSE;
00208       }
00209       /* if not first time, create new module instance and switch to it */
00210       /* and switch current to this */
00211       amconf = j_jconf_am_new();
00212       if (j_jconf_am_regist(jconf, amconf, tmparg) == FALSE) {
00213         jlog("ERROR: failed to add new amconf as \"%s\"\n", tmparg);
00214         jlog("ERROR: m_options: failed to create amconf\n");
00215         j_jconf_am_free(amconf);
00216         return FALSE;
00217       }
00218       jconf->amnow = amconf;
00219       jconf->optsection = JCONF_OPT_AM;
00220       continue;
00221     } else if (strmatch(argv[i],"-AM_GMM") || strmatch(argv[i], "[AM_GMM]")) {
00222       /* switch current to GMM */
00223       if (jconf->gmm == NULL) {
00224         /* if new, allocate jconf for GMM */
00225         jconf->gmm = j_jconf_am_new();
00226       }
00227       jconf->amnow = jconf->gmm;
00228       jconf->optsection = JCONF_OPT_AM;
00229       continue;
00230     } else if (strmatch(argv[i],"-LM") || strmatch(argv[i], "[LM]")) {
00231       GET_TMPARG;
00232       if (tmparg[0] == '-') {
00233         jlog("ERROR: m_options: -LM needs an argument as module name\n");
00234         return FALSE;
00235       }
00236       if (tmparg[0] >= '0' && tmparg[0] <= '9') {
00237         jlog("ERROR: m_options: LM name \"%s\" not acceptable: first character should not be a digit\n", tmparg);
00238         return FALSE;
00239       }
00240       /* create new module instance and switch to it */
00241       /* and switch current to this */
00242       lmconf = j_jconf_lm_new();
00243       if (j_jconf_lm_regist(jconf, lmconf, tmparg) == FALSE) {
00244         jlog("ERROR: failed to add new lmconf as \"%s\"\n", tmparg);
00245         jlog("ERROR: m_options: failed to create lmconf\n");
00246         j_jconf_lm_free(lmconf);
00247         return FALSE;
00248       }
00249       jconf->lmnow = lmconf;
00250       jconf->optsection = JCONF_OPT_LM;
00251       continue;
00252     } else if (strmatch(argv[i],"-SR") || strmatch(argv[i], "[SR]")) {
00253       GET_TMPARG;
00254       if (tmparg[0] == '-') {
00255         jlog("ERROR: m_options: -SR needs three arguments: module name, AM name and LM name\n");
00256         return FALSE;
00257       }
00258       if (tmparg[0] >= '0' && tmparg[0] <= '9') {
00259         jlog("ERROR: m_options: SR name \"%s\" not acceptable: first character should not be a digit\n", tmparg);
00260         return FALSE;
00261       }
00262       /* store name temporarly */
00263       strncpy(sname, tmparg, JCONF_MODULENAME_MAXLEN);
00264       /* get link to jconf_am and jconf_lm */
00265       GET_TMPARG;
00266       if (tmparg[0] == '-') {
00267         jlog("ERROR: m_options: -SR needs three arguments: module name, AM name and LM name\n");
00268         return FALSE;
00269       }
00270       if (tmparg[0] >= '0' && tmparg[0] <= '9') { /* arg is number */
00271         if ((amconf = j_get_amconf_by_id(jconf, atoi(tmparg))) == NULL) return FALSE;
00272       } else {                  /* name string */
00273         if ((amconf = j_get_amconf_by_name(jconf, tmparg)) == NULL) return FALSE;
00274       }
00275       GET_TMPARG;
00276       if (tmparg[0] == '-') {
00277         jlog("ERROR: m_options: -SR needs three arguments: module name, AM name and LM name\n");
00278         return FALSE;
00279       }
00280       if (tmparg[0] >= '0' && tmparg[0] <= '9') { /* arg is number */
00281         if ((lmconf = j_get_lmconf_by_id(jconf, atoi(tmparg))) == NULL) return FALSE;
00282       } else {                  /* name string */
00283         if ((lmconf = j_get_lmconf_by_name(jconf, tmparg)) == NULL) return FALSE;
00284       }
00285 
00286       /* check to avoid assigning an LM for multiple SR */
00287       for(sconf=jconf->search_root;sconf;sconf=sconf->next) {
00288         if (sconf->lmconf == lmconf) {
00289           jlog("ERROR: you are going to share LM \"%s\" among multiple SRs\n");
00290           jlog("ERROR: current Julius cannot share LM among SRs\n");
00291           jlog("ERROR: you should define LM for each SR\n");
00292           return FALSE;
00293         }
00294       }
00295 
00296       /* if not first time, create new module instance and switch to it */
00297       sconf = j_jconf_search_new();
00298       sconf->amconf = amconf;
00299       sconf->lmconf = lmconf;
00300       if (j_jconf_search_regist(jconf, sconf, sname) == FALSE) {
00301         jlog("ERROR: failed to add new amconf as \"%s\"\n", sname);
00302         jlog("ERROR: m_options: failed to create search conf\n");
00303         j_jconf_search_free(sconf);
00304         return FALSE;
00305       }
00306       jconf->searchnow = sconf;
00307       jconf->optsection = JCONF_OPT_SR;
00308       continue;
00309     } else if (strmatch(argv[i],"-GLOBAL")) {
00310       jconf->optsection = JCONF_OPT_GLOBAL;
00311       continue;
00312     } else if (strmatch(argv[i],"-sectioncheck")) { /* enable section check */
00313       jconf->optsectioning = TRUE;
00314       continue;
00315     } else if (strmatch(argv[i],"-nosectioncheck")) { /* disable section check */
00316       jconf->optsectioning = FALSE;
00317       continue;
00318     } else if (strmatch(argv[i],"-input")) { /* speech input */
00319       if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; 
00320       GET_TMPARG;
00321       jconf->input.plugin_source = -1;
00322       if (strmatch(tmparg,"file") || strmatch(tmparg,"rawfile")) {
00323         jconf->input.type = INPUT_WAVEFORM;
00324         jconf->input.speech_input = SP_RAWFILE;
00325         jconf->decodeopt.realtime_flag = FALSE;
00326       } else if (strmatch(tmparg,"htkparam") || strmatch(tmparg,"mfcfile") || strmatch(tmparg,"mfc")) {
00327         jconf->input.type = INPUT_VECTOR;
00328         jconf->input.speech_input = SP_MFCFILE;
00329         jconf->decodeopt.realtime_flag = FALSE;
00330       } else if (strmatch(tmparg,"stdin")) {
00331         jconf->input.type = INPUT_WAVEFORM;
00332         jconf->input.speech_input = SP_STDIN;
00333         jconf->decodeopt.realtime_flag = FALSE;
00334       } else if (strmatch(tmparg,"adinnet")) {
00335         jconf->input.type = INPUT_WAVEFORM;
00336         jconf->input.speech_input = SP_ADINNET;
00337         jconf->decodeopt.realtime_flag = TRUE;
00338 #ifdef USE_NETAUDIO
00339       } else if (strmatch(tmparg,"netaudio")) {
00340         jconf->input.type = INPUT_WAVEFORM;
00341         jconf->input.speech_input = SP_NETAUDIO;
00342         jconf->decodeopt.realtime_flag = TRUE;
00343 #endif
00344 #ifdef USE_MIC
00345       } else if (strmatch(tmparg,"mic")) {
00346         jconf->input.type = INPUT_WAVEFORM;
00347         jconf->input.speech_input = SP_MIC;
00348         jconf->input.device = SP_INPUT_DEFAULT;
00349         jconf->decodeopt.realtime_flag = TRUE;
00350       } else if (strmatch(tmparg,"alsa")) {
00351 #ifdef HAS_ALSA
00352         jconf->input.type = INPUT_WAVEFORM;
00353         jconf->input.speech_input = SP_MIC;
00354         jconf->input.device = SP_INPUT_ALSA;
00355         jconf->decodeopt.realtime_flag = TRUE;
00356 #else
00357         jlog("ERROR: m_options: \"-input alsa\": ALSA support is not built-in\n");
00358         return FALSE;
00359 #endif
00360       } else if (strmatch(tmparg,"oss")) {
00361 #ifdef HAS_OSS
00362         jconf->input.type = INPUT_WAVEFORM;
00363         jconf->input.speech_input = SP_MIC;
00364         jconf->input.device = SP_INPUT_OSS;
00365         jconf->decodeopt.realtime_flag = TRUE;
00366 #else
00367         jlog("ERROR: m_options: \"-input oss\": OSS support is not built-in\n");
00368         return FALSE;
00369 #endif
00370       } else if (strmatch(tmparg,"esd")) {
00371 #ifdef HAS_ESD
00372         jconf->input.type = INPUT_WAVEFORM;
00373         jconf->input.speech_input = SP_MIC;
00374         jconf->input.device = SP_INPUT_ESD;
00375         jconf->decodeopt.realtime_flag = TRUE;
00376 #else
00377         jlog("ERROR: m_options: \"-input esd\": ESounD support is not built-in\n");
00378         return FALSE;
00379 #endif
00380       } else if (strmatch(tmparg,"pulseaudio")) {
00381 #ifdef HAS_PULSEAUDIO
00382         jconf->input.type = INPUT_WAVEFORM;
00383         jconf->input.speech_input = SP_MIC;
00384         jconf->input.device = SP_INPUT_PULSEAUDIO;
00385         jconf->decodeopt.realtime_flag = TRUE;
00386 #else
00387         jlog("ERROR: m_options: \"-input pulseaudio\": PulseAudio support is not built-in\n");
00388         return FALSE;
00389 #endif
00390 #endif
00391 #ifdef ENABLE_PLUGIN
00392       } else if ((sid = plugin_find_optname("adin_get_optname", tmparg)) != -1) { /* adin plugin */
00393         jconf->input.plugin_source = sid;
00394         jconf->input.type = INPUT_WAVEFORM;
00395         jconf->input.speech_input = SP_MIC;
00396         func = (FUNC_INT) plugin_get_func(sid, "adin_get_configuration");
00397         if (func == NULL) {
00398           jlog("ERROR: invalid plugin: adin_get_configuration() not exist\n");
00399           jlog("ERROR: skip option \"-input %s\"\n", tmparg);
00400           continue;
00401         }
00402         jconf->decodeopt.realtime_flag = (*func)(0);
00403       } else if ((sid = plugin_find_optname("fvin_get_optname", tmparg)) != -1) { /* vector input plugin */
00404         jconf->input.plugin_source = sid;
00405         jconf->input.type = INPUT_VECTOR;
00406         jconf->input.speech_input = SP_MFCMODULE;
00407         jconf->decodeopt.realtime_flag = FALSE;
00408 #endif
00409       } else {
00410         jlog("ERROR: m_options: unknown speech input source \"%s\"\n", tmparg);
00411         return FALSE;
00412       }
00413       continue;
00414     } else if (strmatch(argv[i],"-filelist")) { /* input file list */
00415       if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; 
00416       GET_TMPARG;
00417       FREE_MEMORY(jconf->input.inputlist_filename);
00418       //jconf->input.inputlist_filename = strcpy((char*)mymalloc(strlen(tmparg)+1),tmparg);
00419       jconf->input.inputlist_filename = filepath(tmparg, cwd);
00420       continue;
00421     } else if (strmatch(argv[i],"-rejectshort")) { /* short input rejection */
00422       if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; 
00423       GET_TMPARG;
00424       jconf->reject.rejectshortlen = atoi(tmparg);
00425       continue;
00426 #ifdef POWER_REJECT
00427     } else if (strmatch(argv[i],"-powerthres")) { /* short input rejection */
00428       if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; 
00429       GET_TMPARG;
00430       jconf->reject.powerthres = atoi(tmparg);
00431       continue;
00432 #endif
00433     } else if (strmatch(argv[i],"-force_realtime")) { /* force realtime */
00434       if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; 
00435       GET_TMPARG;
00436       if (strmatch(tmparg, "on")) {
00437         jconf->decodeopt.forced_realtime = TRUE;
00438       } else if (strmatch(tmparg, "off")) {
00439         jconf->decodeopt.forced_realtime = FALSE;
00440       } else {
00441         jlog("ERROR: m_options: \"-force_realtime\" should be either \"on\" or \"off\"\n");
00442         return FALSE;
00443       }
00444       jconf->decodeopt.force_realtime_flag = TRUE;
00445       continue;
00446     } else if (strmatch(argv[i],"-realtime")) { /* equal to "-force_realtime on" */
00447       if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; 
00448       jconf->decodeopt.forced_realtime = TRUE;
00449       jconf->decodeopt.force_realtime_flag = TRUE;
00450       continue;
00451     } else if (strmatch(argv[i], "-norealtime")) { /* equal to "-force_realtime off" */
00452       if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; 
00453       jconf->decodeopt.forced_realtime = FALSE;
00454       jconf->decodeopt.force_realtime_flag = TRUE;
00455       continue;
00456     } else if (strmatch(argv[i],"-forcedict")) { /* skip dict error */
00457       if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; 
00458       jconf->lmnow->forcedict_flag = TRUE;
00459       continue;
00460     } else if (strmatch(argv[i],"-check")) { /* interactive model check mode */
00461       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
00462       GET_TMPARG;
00463       if (strmatch(tmparg, "wchmm")) {
00464         jconf->searchnow->sw.wchmm_check_flag = TRUE;
00465       } else if (strmatch(tmparg, "trellis")) {
00466         jconf->searchnow->sw.trellis_check_flag = TRUE;
00467       } else if (strmatch(tmparg, "triphone")) {
00468         jconf->searchnow->sw.triphone_check_flag = TRUE;
00469       } else {
00470         jlog("ERROR: m_options: invalid argument for \"-check\": %s\n", tmparg);
00471         return FALSE;
00472       }
00473       continue;
00474     } else if (strmatch(argv[i],"-notypecheck")) { /* don't check param type */
00475       if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; 
00476       jconf->input.paramtype_check_flag = FALSE;
00477       continue;
00478     } else if (strmatch(argv[i],"-nlimit")) { /* limit N token in a node */
00479 #ifdef WPAIR_KEEP_NLIMIT
00480       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
00481       GET_TMPARG;
00482       jconf->searchnow->pass1.wpair_keep_nlimit = atoi(tmparg);
00483 #else
00484       jlog("WARNING: m_options: WPAIR_KEEP_NLIMIT disabled, \"-nlimit\" ignored\n");
00485 #endif
00486       continue;
00487     } else if (strmatch(argv[i],"-lookuprange")) { /* trellis neighbor range */
00488       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
00489       GET_TMPARG;
00490       jconf->searchnow->pass2.lookup_range = atoi(tmparg);
00491       continue;
00492     } else if (strmatch(argv[i],"-graphout")) { /* enable graph output */
00493       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
00494       jconf->searchnow->graph.enabled = TRUE;
00495       jconf->searchnow->graph.lattice = TRUE;
00496       jconf->searchnow->graph.confnet = FALSE;
00497       continue;
00498     } else if (strmatch(argv[i],"-lattice")) { /* enable graph output */
00499       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
00500       jconf->searchnow->graph.enabled = TRUE;
00501       jconf->searchnow->graph.lattice = TRUE;
00502       continue;
00503     } else if (strmatch(argv[i],"-nolattice")) { /* disable graph output */
00504       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
00505       jconf->searchnow->graph.enabled = FALSE;
00506       jconf->searchnow->graph.lattice = FALSE;
00507       continue;
00508     } else if (strmatch(argv[i],"-confnet")) { /* enable confusion network */
00509       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
00510       jconf->searchnow->graph.enabled = TRUE;
00511       jconf->searchnow->graph.confnet = TRUE;
00512       continue;
00513     } else if (strmatch(argv[i],"-noconfnet")) { /* disable graph output */
00514       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
00515       jconf->searchnow->graph.enabled = FALSE;
00516       jconf->searchnow->graph.confnet = FALSE;
00517       continue;
00518     } else if (strmatch(argv[i],"-graphrange")) { /* neighbor merge range frame */
00519       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
00520       GET_TMPARG;
00521       jconf->searchnow->graph.graph_merge_neighbor_range = atoi(tmparg);
00522       continue;
00523 #ifdef GRAPHOUT_DEPTHCUT
00524     } else if (strmatch(argv[i],"-graphcut")) { /* cut graph word by depth */
00525       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
00526       GET_TMPARG;
00527       jconf->searchnow->graph.graphout_cut_depth = atoi(tmparg);
00528       continue;
00529 #endif
00530 #ifdef GRAPHOUT_LIMIT_BOUNDARY_LOOP
00531     } else if (strmatch(argv[i],"-graphboundloop")) { /* neighbor merge range frame */
00532       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
00533       GET_TMPARG;
00534       jconf->searchnow->graph.graphout_limit_boundary_loop_num = atoi(tmparg);
00535       continue;
00536 #endif
00537 #ifdef GRAPHOUT_SEARCH_DELAY_TERMINATION
00538     } else if (strmatch(argv[i],"-graphsearchdelay")) { /* not do graph search termination before the 1st sentence is found */
00539       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
00540       jconf->searchnow->graph.graphout_search_delay = TRUE;
00541       continue;
00542     } else if (strmatch(argv[i],"-nographsearchdelay")) { /* not do graph search termination before the 1st sentence is found */
00543       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
00544       jconf->searchnow->graph.graphout_search_delay = FALSE;
00545       continue;
00546 #endif
00547     } else if (strmatch(argv[i],"-looktrellis")) { /* activate loopuprange */
00548       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
00549       jconf->searchnow->pass2.looktrellis_flag = TRUE;
00550       continue;
00551     } else if (strmatch(argv[i],"-multigramout")) { /* enable per-grammar decoding on 2nd pass */
00552       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
00553       jconf->searchnow->output.multigramout_flag = TRUE;
00554       continue;
00555     } else if (strmatch(argv[i],"-nomultigramout")) { /* disable per-grammar decoding on 2nd pass */
00556       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
00557       jconf->searchnow->output.multigramout_flag = FALSE;
00558       continue;
00559     } else if (strmatch(argv[i],"-oldtree")) { /* use old tree function */
00560       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
00561       jconf->searchnow->pass1.old_tree_function_flag = TRUE;
00562       continue;
00563     } else if (strmatch(argv[i],"-sb")) { /* score envelope width in 2nd pass */
00564 #ifdef SCAN_BEAM
00565       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
00566       GET_TMPARG;
00567       jconf->searchnow->pass2.scan_beam_thres = atof(tmparg);
00568 #else
00569       jlog("WARNING: m_options: SCAN_BEAM disabled, \"-sb\" ignored\n");
00570 #endif
00571       continue;
00572 #ifdef SCORE_PRUNING
00573     } else if (strmatch(argv[i],"-bs")) { /* score beam width for 1st pass */
00574       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
00575       GET_TMPARG;
00576       jconf->searchnow->pass1.score_pruning_width = atof(tmparg);
00577       continue;
00578 #endif
00579     } else if (strmatch(argv[i],"-discount")) { /* (bogus) */
00580       jlog("WARNING: m_options: option \"-discount\" is now bogus, ignored\n");
00581       continue;
00582     } else if (strmatch(argv[i],"-cutsilence")) { /* force (long) silence detection on */
00583       if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; 
00584       jconf->detect.silence_cut = 1;
00585       continue;
00586     } else if (strmatch(argv[i],"-nocutsilence")) { /* force (long) silence detection off */
00587       if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; 
00588       jconf->detect.silence_cut = 0;
00589       continue;
00590     } else if (strmatch(argv[i],"-pausesegment")) { /* force (long) silence detection on (for backward compatibility) */
00591       if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; 
00592       jconf->detect.silence_cut = 1;
00593       continue;
00594     } else if (strmatch(argv[i],"-nopausesegment")) { /* force (long) silence detection off (for backward comatibility) */
00595       if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; 
00596       jconf->detect.silence_cut = 0;
00597       continue;
00598     } else if (strmatch(argv[i],"-lv")) { /* silence detection threshold level */
00599       if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; 
00600       GET_TMPARG;
00601       jconf->detect.level_thres = atoi(tmparg);
00602       continue;
00603     } else if (strmatch(argv[i],"-zc")) { /* silence detection zero cross num */
00604       if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; 
00605       GET_TMPARG;
00606       jconf->detect.zero_cross_num = atoi(tmparg);
00607       continue;
00608     } else if (strmatch(argv[i],"-headmargin")) { /* head silence length */
00609       if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; 
00610       GET_TMPARG;
00611       jconf->detect.head_margin_msec = atoi(tmparg);
00612       continue;
00613     } else if (strmatch(argv[i],"-tailmargin")) { /* tail silence length */
00614       if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; 
00615       GET_TMPARG;
00616       jconf->detect.tail_margin_msec = atoi(tmparg);
00617       continue;
00618     } else if (strmatch(argv[i],"-hipass")||strmatch(argv[i],"-hifreq")) { /* frequency of upper band limit */
00619       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
00620       GET_TMPARG;
00621       jconf->amnow->analysis.para.hipass = atoi(tmparg);
00622       continue;
00623     } else if (strmatch(argv[i],"-lopass")||strmatch(argv[i],"-lofreq")) { /* frequency of lower band limit */
00624       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
00625       GET_TMPARG;
00626       jconf->amnow->analysis.para.lopass = atoi(tmparg);
00627       continue;
00628     } else if (strmatch(argv[i],"-smpPeriod")) { /* sample period (ns) */
00629       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
00630       GET_TMPARG;
00631       jconf->amnow->analysis.para.smp_period = atoi(tmparg);
00632       jconf->amnow->analysis.para.smp_freq = period2freq(jconf->amnow->analysis.para.smp_period);
00633       continue;
00634     } else if (strmatch(argv[i],"-smpFreq")) { /* sample frequency (Hz) */
00635       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
00636       GET_TMPARG;
00637       jconf->amnow->analysis.para.smp_freq = atoi(tmparg);
00638       jconf->amnow->analysis.para.smp_period = freq2period(jconf->amnow->analysis.para.smp_freq);
00639       continue;
00640     } else if (strmatch(argv[i],"-fsize")) { /* Window size */
00641       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
00642       GET_TMPARG;
00643       jconf->amnow->analysis.para.framesize = atoi(tmparg);
00644       continue;
00645     } else if (strmatch(argv[i],"-fshift")) { /* Frame shiht */
00646       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
00647       GET_TMPARG;
00648       jconf->amnow->analysis.para.frameshift = atoi(tmparg);
00649       continue;
00650     } else if (strmatch(argv[i],"-preemph")) {
00651       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
00652       GET_TMPARG;
00653       jconf->amnow->analysis.para.preEmph = atof(tmparg);
00654       continue;
00655     } else if (strmatch(argv[i],"-fbank")) {
00656       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
00657       GET_TMPARG;
00658       jconf->amnow->analysis.para.fbank_num = atoi(tmparg);
00659       continue;
00660     } else if (strmatch(argv[i],"-ceplif")) {
00661       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
00662       GET_TMPARG;
00663       jconf->amnow->analysis.para.lifter = atoi(tmparg);
00664       continue;
00665     } else if (strmatch(argv[i],"-rawe")) {
00666       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
00667       jconf->amnow->analysis.para.raw_e = TRUE;
00668       continue;
00669     } else if (strmatch(argv[i],"-norawe")) {
00670       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
00671       jconf->amnow->analysis.para.raw_e = FALSE;
00672       continue;
00673     } else if (strmatch(argv[i],"-enormal")) {
00674       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
00675       jconf->amnow->analysis.para.enormal = TRUE;
00676       continue;
00677     } else if (strmatch(argv[i],"-noenormal")) {
00678       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
00679       jconf->amnow->analysis.para.enormal = FALSE;
00680       continue;
00681     } else if (strmatch(argv[i],"-escale")) {
00682       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
00683       GET_TMPARG;
00684       jconf->amnow->analysis.para.escale = atof(tmparg);
00685       continue;
00686     } else if (strmatch(argv[i],"-silfloor")) {
00687       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
00688       GET_TMPARG;
00689       jconf->amnow->analysis.para.silFloor = atof(tmparg);
00690       continue;
00691     } else if (strmatch(argv[i],"-delwin")) { /* Delta window length */
00692       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
00693       GET_TMPARG;
00694       jconf->amnow->analysis.para.delWin = atoi(tmparg);
00695       continue;
00696     } else if (strmatch(argv[i],"-accwin")) { /* Acceleration window length */
00697       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
00698       GET_TMPARG;
00699       jconf->amnow->analysis.para.accWin = atoi(tmparg);
00700       continue;
00701     } else if (strmatch(argv[i],"-ssalpha")) { /* alpha coef. for SS */
00702       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
00703       GET_TMPARG;
00704       jconf->amnow->frontend.ss_alpha = atof(tmparg);
00705       continue;
00706     } else if (strmatch(argv[i],"-ssfloor")) { /* spectral floor for SS */
00707       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
00708       GET_TMPARG;
00709       jconf->amnow->frontend.ss_floor = atof(tmparg);
00710       continue;
00711     } else if (strmatch(argv[i],"-cvn")) {
00712       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
00713       jconf->amnow->analysis.para.cvn = 1;
00714       continue;
00715     } else if (strmatch(argv[i],"-nocvn")) {
00716       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
00717       jconf->amnow->analysis.para.cvn = 0;
00718       continue;
00719     } else if (strmatch(argv[i],"-vtln")) { /* VTLN */
00720       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
00721       GET_TMPARG;
00722       jconf->amnow->analysis.para.vtln_alpha = (float)atof(tmparg);
00723       GET_TMPARG;
00724       jconf->amnow->analysis.para.vtln_lower = (float)atof(tmparg);
00725       GET_TMPARG;
00726       jconf->amnow->analysis.para.vtln_upper = (float)atof(tmparg);
00727       continue;
00728     } else if (strmatch(argv[i],"-novtln")) { /* disable VTLN */
00729       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
00730       jconf->amnow->analysis.para.vtln_alpha = 1.0;
00731       continue;
00732     } else if (strmatch(argv[i],"-48")) { /* use 48kHz input and down to 16kHz */
00733       if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; 
00734       jconf->input.use_ds48to16 = TRUE;
00735       continue;
00736     } else if (strmatch(argv[i],"-version") || strmatch(argv[i], "--version") || strmatch(argv[i], "-setting") || strmatch(argv[i], "--setting")) { /* print version and exit */
00737       j_put_header(stderr);
00738       j_put_compile_defs(stderr);
00739       fprintf(stderr, "\n");
00740       j_put_library_defs(stderr);
00741       return FALSE;
00742     } else if (strmatch(argv[i],"-quiet")) { /* minimum output */
00743       debug2_flag = verbose_flag = FALSE;
00744       continue;
00745     } else if (strmatch(argv[i],"-debug")) { /* debug mode: output huge log */
00746       debug2_flag = verbose_flag = TRUE;
00747       continue;
00748     } else if (strmatch(argv[i],"-callbackdebug")) { /* output callback debug message */
00749       callback_debug_flag = TRUE;
00750       continue;
00751     } else if (strmatch(argv[i],"-progout")) { /* enable progressive output */
00752       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
00753       jconf->searchnow->output.progout_flag = TRUE;
00754       continue;
00755     } else if (strmatch(argv[i],"-proginterval")) { /* interval for -progout */
00756       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
00757       GET_TMPARG;
00758       jconf->searchnow->output.progout_interval = atoi(tmparg);
00759       continue;
00760     } else if (strmatch(argv[i],"-demo")) { /* quiet + progout */
00761       debug2_flag = verbose_flag = FALSE;
00762       jconf->searchnow->output.progout_flag = TRUE;
00763       continue;
00764     } else if (strmatch(argv[i],"-walign")) { /* do forced alignment by word */
00765       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
00766       jconf->searchnow->annotate.align_result_word_flag = TRUE;
00767       continue;
00768     } else if (strmatch(argv[i],"-palign")) { /* do forced alignment by phoneme */
00769       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
00770       jconf->searchnow->annotate.align_result_phoneme_flag = TRUE;
00771       continue;
00772     } else if (strmatch(argv[i],"-salign")) { /* do forced alignment by state */
00773       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
00774       jconf->searchnow->annotate.align_result_state_flag = TRUE;
00775       continue;
00776     } else if (strmatch(argv[i],"-output")) { /* output up to N candidate */
00777       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
00778       GET_TMPARG;
00779       jconf->searchnow->output.output_hypo_maxnum = atoi(tmparg);
00780       continue;
00781     } else if (strmatch(argv[i],"-1pass")) { /* do only 1st pass */
00782       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
00783       jconf->searchnow->compute_only_1pass = TRUE;
00784       continue;
00785     } else if (strmatch(argv[i],"-hlist")) { /* HMM list file */
00786       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
00787       FREE_MEMORY(jconf->amnow->mapfilename);
00788       GET_TMPARG;
00789       jconf->amnow->mapfilename = filepath(tmparg, cwd);
00790       continue;
00791     } else if (strmatch(argv[i],"-nlr")) { /* word LR n-gram (ARPA) */
00792       if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; 
00793       FREE_MEMORY(jconf->lmnow->ngram_filename_lr_arpa);
00794       GET_TMPARG;
00795       jconf->lmnow->ngram_filename_lr_arpa = filepath(tmparg, cwd);
00796       FREE_MEMORY(jconf->lmnow->ngram_filename);
00797       continue;
00798     } else if (strmatch(argv[i],"-nrl")) { /* word RL n-gram (ARPA) */
00799       if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; 
00800       FREE_MEMORY(jconf->lmnow->ngram_filename_rl_arpa);
00801       GET_TMPARG;
00802       jconf->lmnow->ngram_filename_rl_arpa = filepath(tmparg, cwd);
00803       FREE_MEMORY(jconf->lmnow->ngram_filename);
00804       continue;
00805     } else if (strmatch(argv[i],"-lmp")) { /* LM weight and penalty (pass1) */
00806       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
00807       GET_TMPARG;
00808       jconf->searchnow->lmp.lm_weight = (LOGPROB)atof(tmparg);
00809       GET_TMPARG;
00810       jconf->searchnow->lmp.lm_penalty = (LOGPROB)atof(tmparg);
00811       jconf->searchnow->lmp.lmp_specified = TRUE;
00812       continue;
00813     } else if (strmatch(argv[i],"-lmp2")) { /* LM weight and penalty (pass2) */
00814       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
00815       GET_TMPARG;
00816       jconf->searchnow->lmp.lm_weight2 = (LOGPROB)atof(tmparg);
00817       GET_TMPARG;
00818       jconf->searchnow->lmp.lm_penalty2 = (LOGPROB)atof(tmparg);
00819       jconf->searchnow->lmp.lmp2_specified = TRUE;
00820       continue;
00821     } else if (strmatch(argv[i],"-transp")) { /* penalty for transparent word */
00822       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
00823       GET_TMPARG;
00824       jconf->searchnow->lmp.lm_penalty_trans = (LOGPROB)atof(tmparg);
00825       continue;
00826     } else if (strmatch(argv[i],"-gram")) { /* comma-separatedlist of grammar prefix */
00827       if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; 
00828       GET_TMPARG;
00829       if (multigram_add_prefix_list(tmparg, cwd, jconf->lmnow, LM_DFA_GRAMMAR) == FALSE) {
00830         jlog("ERROR: m_options: failed to read some grammars\n");
00831         return FALSE;
00832       }
00833       continue;
00834     } else if (strmatch(argv[i],"-gramlist")) { /* file of grammar prefix list */
00835       if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; 
00836       GET_TMPARG;
00837       tmparg = filepath(tmparg, cwd);
00838       if (multigram_add_prefix_filelist(tmparg, jconf->lmnow, LM_DFA_GRAMMAR) == FALSE) {
00839         jlog("ERROR: m_options: failed to read some grammars\n");
00840         free(tmparg);
00841         return FALSE;
00842       }
00843       free(tmparg);
00844       continue;
00845     } else if (strmatch(argv[i],"-userlm")) {
00846       if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; 
00847       /* just set lm flags here */
00848       if (jconf->lmnow->lmtype != LM_PROB && jconf->lmnow->lmtype != LM_UNDEF) {
00849         jlog("ERROR: m_options: LM type conflicts: multiple LM specified?\n");
00850         return FALSE;
00851       }
00852       jconf->lmnow->lmtype = LM_PROB;
00853       if (jconf->lmnow->lmvar != LM_UNDEF && jconf->lmnow->lmvar != LM_NGRAM_USER) {
00854         jlog("ERROR: m_options: statistical model conflict\n");
00855         return FALSE;
00856       }
00857       jconf->lmnow->lmvar  = LM_NGRAM_USER;
00858       continue;
00859     } else if (strmatch(argv[i],"-nogram")) { /* remove grammar list */
00860       if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; 
00861       multigram_remove_gramlist(jconf->lmnow);
00862       FREE_MEMORY(jconf->lmnow->dfa_filename);
00863       FREE_MEMORY(jconf->lmnow->dictfilename);
00864       if (jconf->lmnow->lmtype == LM_UNDEF) {
00865         jconf->lmnow->lmtype = LM_DFA;
00866         jconf->lmnow->lmvar  = LM_DFA_GRAMMAR;
00867       }
00868       continue;
00869     } else if (strmatch(argv[i],"-dfa")) { /* DFA filename */
00870       if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; 
00871       FREE_MEMORY(jconf->lmnow->dfa_filename);
00872       GET_TMPARG;
00873       jconf->lmnow->dfa_filename = filepath(tmparg, cwd);
00874       continue;
00875     } else if (strmatch(argv[i],"-penalty1")) { /* word insertion penalty (pass1) */
00876       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
00877       GET_TMPARG;
00878       jconf->searchnow->lmp.penalty1 = (LOGPROB)atof(tmparg);
00879       continue;
00880     } else if (strmatch(argv[i],"-penalty2")) { /* word insertion penalty (pass2) */
00881       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
00882       GET_TMPARG;
00883       jconf->searchnow->lmp.penalty2 = (LOGPROB)atof(tmparg);
00884       continue;
00885     } else if (strmatch(argv[i],"-spmodel") || strmatch(argv[i], "-sp")) { /* name of short pause word */
00886       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
00887       FREE_MEMORY(jconf->amnow->spmodel_name);
00888       GET_TMPARG;
00889       jconf->amnow->spmodel_name = strcpy((char*)mymalloc(strlen(tmparg)+1),tmparg);
00890       continue;
00891     } else if (strmatch(argv[i],"-multipath")) { /* force multipath mode */
00892       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
00893       jconf->amnow->force_multipath = TRUE;
00894       continue;
00895     } else if (strmatch(argv[i],"-iwsp")) { /* enable inter-word short pause handing (for multipath) */
00896       if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; 
00897       jconf->lmnow->enable_iwsp = TRUE;
00898       continue;
00899     } else if (strmatch(argv[i],"-iwsppenalty")) { /* set inter-word short pause transition penalty (for multipath) */
00900       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
00901       GET_TMPARG;
00902       jconf->amnow->iwsp_penalty = atof(tmparg);
00903       continue;
00904     } else if (strmatch(argv[i],"-silhead")) { /* head silence word name */
00905       if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; 
00906       FREE_MEMORY(jconf->lmnow->head_silname);
00907       GET_TMPARG;
00908       jconf->lmnow->head_silname = strcpy((char*)mymalloc(strlen(tmparg)+1),tmparg);
00909       continue;
00910     } else if (strmatch(argv[i],"-siltail")) { /* tail silence word name */
00911       if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; 
00912       FREE_MEMORY(jconf->lmnow->tail_silname);
00913       GET_TMPARG;
00914       jconf->lmnow->tail_silname = strcpy((char*)mymalloc(strlen(tmparg)+1),tmparg);
00915       continue;
00916     } else if (strmatch(argv[i],"-mapunk")) { /* unknown word */
00917       if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; 
00918       GET_TMPARG;
00919       strncpy(jconf->lmnow->unknown_name, tmparg, UNK_WORD_MAXLEN);
00920       continue;
00921     } else if (strmatch(argv[i],"-iwspword")) { /* add short pause word */
00922       if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; 
00923       jconf->lmnow->enable_iwspword = TRUE;
00924       continue;
00925     } else if (strmatch(argv[i],"-iwspentry")) { /* content of the iwspword */
00926       if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; 
00927       FREE_MEMORY(jconf->lmnow->iwspentry);
00928       GET_TMPARG;
00929       jconf->lmnow->iwspentry = strcpy((char*)mymalloc(strlen(tmparg)+1),tmparg);
00930       continue;
00931     } else if (strmatch(argv[i],"-iwcache")) { /* control cross-word LM cache */
00932 #ifdef HASH_CACHE_IW
00933       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
00934       GET_TMPARG;
00935       jconf->searchnow->pass1.iw_cache_rate = atof(tmparg);
00936       if (jconf->searchnow->pass1.iw_cache_rate > 100) jconf->searchnow->pass1.iw_cache_rate = 100;
00937       if (jconf->searchnow->pass1.iw_cache_rate < 1) jconf->searchnow->pass1.iw_cache_rate = 1;
00938 #else
00939       jlog("WARNING: m_options: HASH_CACHE_IW disabled, \"-iwcache\" ignored\n");
00940 #endif
00941       continue;
00942     } else if (strmatch(argv[i],"-sepnum")) { /* N-best frequent word will be separated from tree */
00943 #ifdef SEPARATE_BY_UNIGRAM
00944       if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; 
00945       GET_TMPARG;
00946       jconf->lmnow->separate_wnum = atoi(tmparg);
00947 #else
00948       jlog("WARNING: m_options: SEPARATE_BY_UNIGRAM disabled, \"-sepnum\" ignored\n");
00949       i++;
00950 #endif
00951       continue;
00952 #ifdef USE_NETAUDIO
00953     } else if (strmatch(argv[i],"-NA")) { /* netautio device name */
00954       if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; 
00955       FREE_MEMORY(jconf->input.netaudio_devname);
00956       GET_TMPARG;
00957       jconf->input.netaudio_devname = strcpy((char*)mymalloc(strlen(tmparg)+1),tmparg);
00958       continue;
00959 #endif
00960     } else if (strmatch(argv[i],"-adport")) { /* adinnet port num */
00961       if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; 
00962       GET_TMPARG;
00963       jconf->input.adinnet_port = atoi(tmparg);
00964       continue;
00965     } else if (strmatch(argv[i],"-nostrip")) { /* do not strip zero samples */
00966       if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; 
00967       jconf->preprocess.strip_zero_sample = FALSE;
00968       continue;
00969     } else if (strmatch(argv[i],"-zmean")) { /* enable DC offset by zero mean */
00970       if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; 
00971       jconf->preprocess.use_zmean = TRUE;
00972       continue;
00973     } else if (strmatch(argv[i],"-nozmean")) { /* disable DC offset by zero mean */
00974       if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; 
00975       jconf->preprocess.use_zmean = FALSE;
00976       continue;
00977     } else if (strmatch(argv[i],"-zmeanframe")) { /* enable frame-wise DC offset by zero mean */
00978       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
00979       jconf->amnow->analysis.para.zmeanframe = TRUE;
00980       continue;
00981     } else if (strmatch(argv[i],"-nozmeanframe")) { /* disable frame-wise DC offset by zero mean */
00982       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
00983       jconf->amnow->analysis.para.zmeanframe = FALSE;
00984       continue;
00985     } else if (strmatch(argv[i],"-usepower")) { /* use power instead of magnitude in filterbank analysis */
00986       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
00987       jconf->amnow->analysis.para.usepower = TRUE;
00988       continue;
00989     } else if (strmatch(argv[i],"-nousepower")) { /* use magnitude in fbank analysis (default)  */
00990       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
00991       jconf->amnow->analysis.para.usepower = FALSE;
00992       continue;
00993     } else if (strmatch(argv[i],"-spsegment")) { /* enable short-pause segmentation */
00994       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
00995       jconf->searchnow->successive.enabled = TRUE;
00996       continue;
00997     } else if (strmatch(argv[i],"-spdur")) { /* speech down-trigger duration threshold in frame */
00998       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
00999       GET_TMPARG;
01000       jconf->searchnow->successive.sp_frame_duration = atoi(tmparg);
01001       continue;
01002 #ifdef SPSEGMENT_NAIST
01003     } else if (strmatch(argv[i],"-spmargin")) { /* speech up-trigger backstep margin in frame */
01004       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
01005       GET_TMPARG;
01006       jconf->searchnow->successive.sp_margin = atoi(tmparg);
01007       continue;
01008     } else if (strmatch(argv[i],"-spdelay")) { /* speech up-trigger delay frame */
01009       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
01010       GET_TMPARG;
01011       jconf->searchnow->successive.sp_delay = atoi(tmparg);
01012       continue;
01013 #endif
01014     } else if (strmatch(argv[i],"-pausemodels")) { /* short-pause duration threshold */
01015       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
01016       FREE_MEMORY(jconf->searchnow->successive.pausemodelname);
01017       GET_TMPARG;
01018       jconf->searchnow->successive.pausemodelname = strcpy((char*)mymalloc(strlen(tmparg)+1),tmparg);
01019       continue;
01020     } else if (strmatch(argv[i],"-gprune")) { /* select Gaussian pruning method */
01021       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
01022       GET_TMPARG;
01023       if (strmatch(tmparg,"safe")) { /* safest, slowest */
01024         jconf->amnow->gprune_method = GPRUNE_SEL_SAFE;
01025       } else if (strmatch(tmparg,"heuristic")) {
01026         jconf->amnow->gprune_method = GPRUNE_SEL_HEURISTIC;
01027       } else if (strmatch(tmparg,"beam")) { /* fastest */
01028         jconf->amnow->gprune_method = GPRUNE_SEL_BEAM;
01029       } else if (strmatch(tmparg,"none")) { /* no prune: compute all Gaussian */
01030         jconf->amnow->gprune_method = GPRUNE_SEL_NONE;
01031       } else if (strmatch(tmparg,"default")) {
01032         jconf->amnow->gprune_method = GPRUNE_SEL_UNDEF;
01033 #ifdef ENABLE_PLUGIN
01034       } else if ((sid = plugin_find_optname("calcmix_get_optname", tmparg)) != -1) { /* mixture calculation plugin */
01035         jconf->amnow->gprune_method = GPRUNE_SEL_USER;
01036         jconf->amnow->gprune_plugin_source = sid;
01037 #endif
01038       } else {
01039         jlog("ERROR: m_options: no such pruning method \"%s\"\n", argv[0], tmparg);
01040         return FALSE;
01041       }
01042       continue;
01043 /* 
01044  *     } else if (strmatch(argv[i],"-reorder")) {
01045  *       result_reorder_flag = TRUE;
01046  *       continue;
01047  */
01048     } else if (strmatch(argv[i],"-no_ccd")) { /* force triphone handling = OFF */
01049       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
01050       jconf->searchnow->ccd_handling = FALSE;
01051       jconf->searchnow->force_ccd_handling = TRUE;
01052       continue;
01053     } else if (strmatch(argv[i],"-force_ccd")) { /* force triphone handling = ON */
01054       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
01055       jconf->searchnow->ccd_handling = TRUE;
01056       jconf->searchnow->force_ccd_handling = TRUE;
01057       continue;
01058     } else if (strmatch(argv[i],"-iwcd1")) { /* select cross-word triphone computation method */
01059       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
01060       GET_TMPARG;
01061       if (strmatch(tmparg, "max")) { /* use maximum score in triphone variants */
01062         jconf->amnow->iwcdmethod = IWCD_MAX;
01063       } else if (strmatch(tmparg, "avg")) { /* use average in variants */
01064         jconf->amnow->iwcdmethod = IWCD_AVG;
01065       } else if (strmatch(tmparg, "best")) { /* use average in variants */
01066         jconf->amnow->iwcdmethod = IWCD_NBEST;
01067         GET_TMPARG;
01068         jconf->amnow->iwcdmaxn = atoi(tmparg);
01069       } else {
01070         jlog("ERROR: m_options: -iwcd1: wrong argument (max|avg|best N): %s\n", argv[0], tmparg);
01071         return FALSE;
01072       }
01073       continue;
01074     } else if (strmatch(argv[i],"-tmix")) { /* num of mixture to select */
01075       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
01076       if (i + 1 < argc && isdigit(argv[i+1][0])) {
01077         jconf->amnow->mixnum_thres = atoi(argv[++i]);
01078       }
01079       continue;
01080     } else if (strmatch(argv[i],"-b2") || strmatch(argv[i],"-bw") || strmatch(argv[i],"-wb")) { /* word beam width in 2nd pass */
01081       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
01082       GET_TMPARG;
01083       jconf->searchnow->pass2.enveloped_bestfirst_width = atoi(tmparg);
01084       continue;
01085     } else if (strmatch(argv[i],"-hgs")) { /* Gaussian selection model file */
01086       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
01087       FREE_MEMORY(jconf->amnow->hmm_gs_filename);
01088       GET_TMPARG;
01089       jconf->amnow->hmm_gs_filename = filepath(tmparg, cwd);
01090       continue;
01091     } else if (strmatch(argv[i],"-booknum")) { /* num of state to select in GS */
01092       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
01093       GET_TMPARG;
01094       jconf->amnow->gs_statenum = atoi(tmparg);
01095       continue;
01096     } else if (strmatch(argv[i],"-gshmm")) { /* same as "-hgs" */
01097       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
01098       FREE_MEMORY(jconf->amnow->hmm_gs_filename);
01099       GET_TMPARG;
01100       jconf->amnow->hmm_gs_filename = filepath(tmparg, cwd);
01101       continue;
01102     } else if (strmatch(argv[i],"-gsnum")) { /* same as "-booknum" */
01103       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
01104       GET_TMPARG;
01105       jconf->amnow->gs_statenum = atoi(tmparg);
01106       continue;
01107     } else if (strmatch(argv[i],"-cmnload")) { /* load CMN parameter from file */
01108       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
01109       FREE_MEMORY(jconf->amnow->analysis.cmnload_filename);
01110       GET_TMPARG;
01111       jconf->amnow->analysis.cmnload_filename = filepath(tmparg, cwd);
01112       continue;
01113     } else if (strmatch(argv[i],"-cmnsave")) { /* save CMN parameter to file */
01114       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
01115       FREE_MEMORY(jconf->amnow->analysis.cmnsave_filename);
01116       GET_TMPARG;
01117       jconf->amnow->analysis.cmnsave_filename = filepath(tmparg, cwd);
01118       continue;
01119     } else if (strmatch(argv[i],"-cmnupdate")) { /* update CMN parameter */
01120       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
01121       jconf->amnow->analysis.cmn_update = TRUE;
01122       continue;
01123     } else if (strmatch(argv[i],"-cmnnoupdate")) { /* not update CMN parameter */
01124       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
01125       jconf->amnow->analysis.cmn_update = FALSE;
01126       continue;
01127     } else if (strmatch(argv[i],"-cmnmapweight")) { /* CMN weight for MAP */
01128       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
01129       GET_TMPARG;
01130       jconf->amnow->analysis.cmn_map_weight = (float)atof(tmparg);
01131       continue;
01132     } else if (strmatch(argv[i],"-sscalc")) { /* do spectral subtraction (SS) for raw file input */
01133       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
01134       jconf->amnow->frontend.sscalc = TRUE;
01135       FREE_MEMORY(jconf->amnow->frontend.ssload_filename);
01136       continue;
01137     } else if (strmatch(argv[i],"-sscalclen")) { /* head silence length used to compute SS (in msec) */
01138       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
01139       GET_TMPARG;
01140       jconf->amnow->frontend.sscalc_len = atoi(tmparg);
01141       continue;
01142     } else if (strmatch(argv[i],"-ssload")) { /* load SS parameter from file */
01143       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
01144       FREE_MEMORY(jconf->amnow->frontend.ssload_filename);
01145       GET_TMPARG;
01146       jconf->amnow->frontend.ssload_filename = filepath(tmparg, cwd);
01147       jconf->amnow->frontend.sscalc = FALSE;
01148       continue;
01149 #ifdef CONFIDENCE_MEASURE
01150     } else if (strmatch(argv[i],"-cmalpha")) { /* CM log score scaling factor */
01151       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
01152 #ifdef CM_MULTIPLE_ALPHA
01153       GET_TMPARG;
01154       jconf->searchnow->annotate.cm_alpha_bgn = (LOGPROB)atof(tmparg);
01155       GET_TMPARG;
01156       jconf->searchnow->annotate.cm_alpha_end = (LOGPROB)atof(tmparg);
01157       GET_TMPARG;
01158       jconf->searchnow->annotate.cm_alpha_step = (LOGPROB)atof(tmparg);
01159       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;
01160       if (jconf->searchnow->annotate.cm_alpha_num > 100) {
01161         jlog("ERROR: m_option: cm_alpha step num exceeds limit (100)\n");
01162         return FALSE;
01163       }
01164 #else
01165       GET_TMPARG;
01166       jconf->searchnow->annotate.cm_alpha = (LOGPROB)atof(tmparg);
01167 #endif
01168       continue;
01169 #ifdef CM_SEARCH_LIMIT
01170     } else if (strmatch(argv[i],"-cmthres")) { /* CM cut threshold for CM decoding */
01171       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
01172       GET_TMPARG;
01173       jconf->searchnow->annotate.cm_cut_thres = (LOGPROB)atof(tmparg);
01174       continue;
01175 #endif
01176 #ifdef CM_SEARCH_LIMIT_POP
01177     } else if (strmatch(argv[i],"-cmthres2")) { /* CM cut threshold for CM decoding */
01178       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
01179       GET_TMPARG;
01180       jconf->searchnow->annotate.cm_cut_thres_pop = (LOGPROB)atof(tmparg);
01181       continue;
01182 #endif
01183 #endif /* CONFIDENCE_MEASURE */
01184     } else if (strmatch(argv[i],"-gmm")) { /* load SS parameter from file */
01185       if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; 
01186       FREE_MEMORY(jconf->reject.gmm_filename);
01187       GET_TMPARG;
01188       jconf->reject.gmm_filename = filepath(tmparg, cwd);
01189       continue;
01190     } else if (strmatch(argv[i],"-gmmnum")) { /* num of Gaussian pruning for GMM */
01191       if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; 
01192       GET_TMPARG;
01193       jconf->reject.gmm_gprune_num = atoi(tmparg);
01194       continue;
01195     } else if (strmatch(argv[i],"-gmmreject")) {
01196       if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; 
01197       GET_TMPARG;
01198       FREE_MEMORY(jconf->reject.gmm_reject_cmn_string);
01199       jconf->reject.gmm_reject_cmn_string = strcpy((char *)mymalloc(strlen(tmparg)+1), tmparg);
01200       continue;
01201 #ifdef GMM_VAD
01202     } else if (strmatch(argv[i],"-gmmmargin")) { /* backstep margin */
01203       if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; 
01204       GET_TMPARG;
01205       jconf->detect.gmm_margin = atoi(tmparg);
01206       continue;
01207     } else if (strmatch(argv[i],"-gmmup")) { /* uptrigger threshold */
01208       if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; 
01209       GET_TMPARG;
01210       jconf->detect.gmm_uptrigger_thres = atof(tmparg);
01211       continue;
01212     } else if (strmatch(argv[i],"-gmmdown")) { /* uptrigger threshold */
01213       if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; 
01214       GET_TMPARG;
01215       jconf->detect.gmm_downtrigger_thres = atof(tmparg);
01216       continue;
01217 #endif
01218     } else if (strmatch(argv[i],"-htkconf")) {
01219       if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
01220       GET_TMPARG;
01221       tmparg = filepath(tmparg, cwd);
01222       if (htk_config_file_parse(tmparg, &(jconf->amnow->analysis.para_htk)) == FALSE) {
01223         jlog("ERROR: m_options: failed to read %s\n", tmparg);
01224         free(tmparg);
01225         return FALSE;
01226       }
01227       free(tmparg);
01228       continue;
01229     } else if (strmatch(argv[i], "-wlist")) {
01230       if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; 
01231       GET_TMPARG;
01232       tmparg = filepath(tmparg, cwd);
01233       if (multigram_add_prefix_filelist(tmparg, jconf->lmnow, LM_DFA_WORD) == FALSE) {
01234         jlog("ERROR: m_options: failed to read some word lists\n");
01235         free(tmparg);
01236         return FALSE;
01237       }
01238       free(tmparg);
01239       continue;
01240     } else if (strmatch(argv[i], "-wsil")) {
01241       /* 
01242        * if (jconf->lmnow->lmvar != LM_UNDEF && jconf->lmnow->lmvar != LM_DFA_WORD) {
01243        *   jlog("ERROR: \"-wsil\" only valid for isolated word recognition mode\n");
01244        *   return FALSE;
01245        * }
01246        */
01247       if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; 
01248       GET_TMPARG;
01249       strncpy(jconf->lmnow->wordrecog_head_silence_model_name, tmparg, MAX_HMMNAME_LEN);
01250       GET_TMPARG;
01251       strncpy(jconf->lmnow->wordrecog_tail_silence_model_name, tmparg, MAX_HMMNAME_LEN);
01252       GET_TMPARG;
01253       if (strmatch(tmparg, "NULL")) {
01254         jconf->lmnow->wordrecog_silence_context_name[0] = '\0';
01255       } else {
01256         strncpy(jconf->lmnow->wordrecog_silence_context_name, tmparg, MAX_HMMNAME_LEN);
01257       }
01258       continue;
01259 #ifdef DETERMINE
01260     } else if (strmatch(argv[i], "-wed")) {
01261       //if (jconf->lmnow->lmvar != LM_UNDEF && jconf->lmnow->lmvar != LM_DFA_WORD) {
01262       //jlog("ERROR: \"-wed\" only valid for isolated word recognition mode\n");
01263       //return FALSE;
01264       //}
01265       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
01266       GET_TMPARG;
01267       jconf->searchnow->pass1.determine_score_thres = atof(tmparg);
01268       GET_TMPARG;
01269       jconf->searchnow->pass1.determine_duration_thres = atoi(tmparg);
01270       continue;
01271 #endif
01272     } else if (strmatch(argv[i], "-inactive")) { /* start inactive */
01273       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
01274       jconf->searchnow->sw.start_inactive = TRUE;
01275       continue;
01276     } else if (strmatch(argv[i], "-active")) { /* start active (default) */
01277       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
01278       jconf->searchnow->sw.start_inactive = FALSE;
01279       continue;
01280     } else if (strmatch(argv[i],"-fallback1pass")) { /* use 1st pass result on search failure */
01281       if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
01282       jconf->searchnow->sw.fallback_pass1_flag = TRUE;
01283       continue;
01284 #ifdef ENABLE_PLUGIN
01285     } else if (strmatch(argv[i],"-plugindir")) {
01286       GET_TMPARG;
01287       plugin_load_dirs(tmparg);
01288       continue;
01289 #endif
01290     } else if (strmatch(argv[i],"-adddict")) {
01291         if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; 
01292         GET_TMPARG;
01293         tmparg = filepath(tmparg, cwd);
01294         j_add_dict(jconf->lmnow, tmparg);
01295         free(tmparg);
01296         continue;
01297     } else if (strmatch(argv[i],"-addentry")) {
01298         if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; 
01299         GET_TMPARG;
01300         j_add_word(jconf->lmnow, tmparg);
01301         continue;
01302     }
01303     if (argv[i][0] == '-' && strlen(argv[i]) == 2) {
01304       /* 1-letter options */
01305       switch(argv[i][1]) {
01306       case 'h':                 /* hmmdefs */
01307         if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 
01308         FREE_MEMORY(jconf->amnow->hmmfilename);
01309         GET_TMPARG;
01310         jconf->amnow->hmmfilename = filepath(tmparg, cwd);
01311         break;
01312       case 'v':                 /* dictionary */
01313         if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; 
01314         FREE_MEMORY(jconf->lmnow->dictfilename);
01315         GET_TMPARG;
01316         jconf->lmnow->dictfilename = filepath(tmparg, cwd);
01317         break;
01318       case 'w':                 /* word list (isolated word recognition) */
01319         if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; 
01320         GET_TMPARG;
01321         if (multigram_add_prefix_list(tmparg, cwd, jconf->lmnow, LM_DFA_WORD) == FALSE) {
01322           jlog("ERROR: m_options: failed to read some word list\n");
01323           return FALSE;
01324         }
01325         break;
01326       case 'd':                 /* binary N-gram */
01327         /* lmvar should be overriden by the content of the binary N-gram */
01328         if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; 
01329         FREE_MEMORY(jconf->lmnow->ngram_filename);
01330         FREE_MEMORY(jconf->lmnow->ngram_filename_lr_arpa);
01331         FREE_MEMORY(jconf->lmnow->ngram_filename_rl_arpa);
01332         GET_TMPARG;
01333         jconf->lmnow->ngram_filename = filepath(tmparg, cwd);
01334         break;
01335       case 'b':                 /* beam width in 1st pass */
01336         if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
01337         GET_TMPARG;
01338         jconf->searchnow->pass1.specified_trellis_beam_width = atoi(tmparg);
01339         break;
01340       case 's':                 /* stack size in 2nd pass */
01341         if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
01342         GET_TMPARG;
01343         jconf->searchnow->pass2.stack_size = atoi(tmparg);
01344         break;
01345       case 'n':                 /* N-best search */
01346         if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
01347         GET_TMPARG;
01348         jconf->searchnow->pass2.nbest = atoi(tmparg);
01349         break;
01350       case 'm':                 /* upper limit of hypothesis generation */
01351         if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 
01352         GET_TMPARG;
01353         jconf->searchnow->pass2.hypo_overflow = atoi(tmparg);
01354         break;
01355       default:
01356         //jlog("ERROR: m_options: wrong argument: %s\n", argv[0], argv[i]);
01357         //return FALSE;
01358         unknown_opt = TRUE;
01359       }
01360     } else {                    /* error */
01361       //jlog("ERROR: m_options: wrong argument: %s\n", argv[0], argv[i]);
01362       //return FALSE;
01363       unknown_opt = TRUE;
01364     }
01365     if (unknown_opt) {
01366       /* call user-side option processing */
01367       switch(useropt_exec(jconf, argv, argc, &i)) {
01368       case 0:                   /* does not match user-side options */
01369         jlog("ERROR: m_options: wrong argument: \"%s\"\n", argv[i]);
01370         return FALSE;
01371       case -1:                  /* Error in user-side function */
01372         jlog("ERROR: m_options: error in processing \"%s\"\n", argv[i]);
01373         return FALSE;
01374       }
01375     }
01376   }
01377   
01378   /* set default values if not specified yet */
01379   for(atmp=jconf->am_root;atmp;atmp=atmp->next) {
01380     if (!atmp->spmodel_name) {
01381       atmp->spmodel_name = strcpy((char*)mymalloc(strlen(SPMODEL_NAME_DEFAULT)+1),
01382                           SPMODEL_NAME_DEFAULT);
01383     }
01384   }
01385   for(ltmp=jconf->lm_root;ltmp;ltmp=ltmp->next) {
01386     if (!ltmp->head_silname) {
01387       ltmp->head_silname = strcpy((char*)mymalloc(strlen(BEGIN_WORD_DEFAULT)+1),
01388                                   BEGIN_WORD_DEFAULT);
01389     }
01390     if (!ltmp->tail_silname) {
01391       ltmp->tail_silname = strcpy((char*)mymalloc(strlen(END_WORD_DEFAULT)+1),
01392                                   END_WORD_DEFAULT);
01393     }
01394     if (!ltmp->iwspentry) {
01395       ltmp->iwspentry = strcpy((char*)mymalloc(strlen(IWSPENTRY_DEFAULT)+1),
01396                                IWSPENTRY_DEFAULT);
01397     }
01398   }
01399 #ifdef USE_NETAUDIO
01400   if (!jconf->input.netaudio_devname) {
01401     jconf->input.netaudio_devname = strcpy((char*)mymalloc(strlen(NETAUDIO_DEVNAME)+1),
01402                               NETAUDIO_DEVNAME);
01403   }
01404 #endif  /* USE_NETAUDIO */
01405 
01406   return TRUE;
01407 }
01408 
01422 void
01423 opt_release(Jconf *jconf)
01424 {
01425   JCONF_AM *am;
01426   JCONF_LM *lm;
01427   JCONF_SEARCH *s;
01428 
01429   FREE_MEMORY(jconf->input.inputlist_filename);
01430 #ifdef USE_NETAUDIO
01431   FREE_MEMORY(jconf->input.netaudio_devname);
01432 #endif  /* USE_NETAUDIO */
01433   FREE_MEMORY(jconf->reject.gmm_filename);
01434   FREE_MEMORY(jconf->reject.gmm_reject_cmn_string);
01435 
01436   for(am=jconf->am_root;am;am=am->next) {
01437     FREE_MEMORY(am->hmmfilename);
01438     FREE_MEMORY(am->mapfilename);
01439     FREE_MEMORY(am->spmodel_name);
01440     FREE_MEMORY(am->hmm_gs_filename);
01441     FREE_MEMORY(am->analysis.cmnload_filename);
01442     FREE_MEMORY(am->analysis.cmnsave_filename);
01443     FREE_MEMORY(am->frontend.ssload_filename);
01444   }
01445   for(lm=jconf->lm_root;lm;lm=lm->next) {
01446     FREE_MEMORY(lm->ngram_filename);
01447     FREE_MEMORY(lm->ngram_filename_lr_arpa);
01448     FREE_MEMORY(lm->ngram_filename_rl_arpa);
01449     FREE_MEMORY(lm->dfa_filename);
01450     FREE_MEMORY(lm->head_silname);
01451     FREE_MEMORY(lm->tail_silname);
01452     FREE_MEMORY(lm->iwspentry);
01453     FREE_MEMORY(lm->dictfilename);
01454     multigram_remove_gramlist(lm);
01455   }
01456   for(s=jconf->search_root;s;s=s->next) {
01457     FREE_MEMORY(s->successive.pausemodelname);
01458   }
01459 }
01460 
01461 /* end of file */