00001
00024
00025
00026
00027
00028
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")) {
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
00210
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
00223 if (jconf->gmm == NULL) {
00224
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
00241
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
00263 strncpy(sname, tmparg, JCONF_MODULENAME_MAXLEN);
00264
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') {
00271 if ((amconf = j_get_amconf_by_id(jconf, atoi(tmparg))) == NULL) return FALSE;
00272 } else {
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') {
00281 if ((lmconf = j_get_lmconf_by_id(jconf, atoi(tmparg))) == NULL) return FALSE;
00282 } else {
00283 if ((lmconf = j_get_lmconf_by_name(jconf, tmparg)) == NULL) return FALSE;
00284 }
00285
00286
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
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")) {
00313 jconf->optsectioning = TRUE;
00314 continue;
00315 } else if (strmatch(argv[i],"-nosectioncheck")) {
00316 jconf->optsectioning = FALSE;
00317 continue;
00318 } else if (strmatch(argv[i],"-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 oss\": OSS support is not built-in\n");
00378 return FALSE;
00379 #endif
00380 #endif
00381 #ifdef ENABLE_PLUGIN
00382 } else if ((sid = plugin_find_optname("adin_get_optname", tmparg)) != -1) {
00383 jconf->input.plugin_source = sid;
00384 jconf->input.type = INPUT_WAVEFORM;
00385 jconf->input.speech_input = SP_MIC;
00386 func = (FUNC_INT) plugin_get_func(sid, "adin_get_configuration");
00387 if (func == NULL) {
00388 jlog("ERROR: invalid plugin: adin_get_configuration() not exist\n");
00389 jlog("ERROR: skip option \"-input %s\"\n", tmparg);
00390 continue;
00391 }
00392 jconf->decodeopt.realtime_flag = (*func)(0);
00393 } else if ((sid = plugin_find_optname("fvin_get_optname", tmparg)) != -1) {
00394 jconf->input.plugin_source = sid;
00395 jconf->input.type = INPUT_VECTOR;
00396 jconf->input.speech_input = SP_MFCMODULE;
00397 jconf->decodeopt.realtime_flag = FALSE;
00398 #endif
00399 } else {
00400 jlog("ERROR: m_options: unknown speech input source \"%s\"\n", tmparg);
00401 return FALSE;
00402 }
00403 continue;
00404 } else if (strmatch(argv[i],"-filelist")) {
00405 if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE;
00406 GET_TMPARG;
00407 FREE_MEMORY(jconf->input.inputlist_filename);
00408
00409 jconf->input.inputlist_filename = filepath(tmparg, cwd);
00410 continue;
00411 } else if (strmatch(argv[i],"-rejectshort")) {
00412 if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE;
00413 GET_TMPARG;
00414 jconf->reject.rejectshortlen = atoi(tmparg);
00415 continue;
00416 #ifdef POWER_REJECT
00417 } else if (strmatch(argv[i],"-powerthres")) {
00418 if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE;
00419 GET_TMPARG;
00420 jconf->reject.powerthres = atoi(tmparg);
00421 continue;
00422 #endif
00423 } else if (strmatch(argv[i],"-force_realtime")) {
00424 if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE;
00425 GET_TMPARG;
00426 if (strmatch(tmparg, "on")) {
00427 jconf->decodeopt.forced_realtime = TRUE;
00428 } else if (strmatch(tmparg, "off")) {
00429 jconf->decodeopt.forced_realtime = FALSE;
00430 } else {
00431 jlog("ERROR: m_options: \"-force_realtime\" should be either \"on\" or \"off\"\n");
00432 return FALSE;
00433 }
00434 jconf->decodeopt.force_realtime_flag = TRUE;
00435 continue;
00436 } else if (strmatch(argv[i],"-realtime")) {
00437 if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE;
00438 jconf->decodeopt.forced_realtime = TRUE;
00439 jconf->decodeopt.force_realtime_flag = TRUE;
00440 continue;
00441 } else if (strmatch(argv[i], "-norealtime")) {
00442 if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE;
00443 jconf->decodeopt.forced_realtime = FALSE;
00444 jconf->decodeopt.force_realtime_flag = TRUE;
00445 continue;
00446 } else if (strmatch(argv[i],"-forcedict")) {
00447 if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE;
00448 jconf->lmnow->forcedict_flag = TRUE;
00449 continue;
00450 } else if (strmatch(argv[i],"-check")) {
00451 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
00452 GET_TMPARG;
00453 if (strmatch(tmparg, "wchmm")) {
00454 jconf->searchnow->sw.wchmm_check_flag = TRUE;
00455 } else if (strmatch(tmparg, "trellis")) {
00456 jconf->searchnow->sw.trellis_check_flag = TRUE;
00457 } else if (strmatch(tmparg, "triphone")) {
00458 jconf->searchnow->sw.triphone_check_flag = TRUE;
00459 } else {
00460 jlog("ERROR: m_options: invalid argument for \"-check\": %s\n", tmparg);
00461 return FALSE;
00462 }
00463 continue;
00464 } else if (strmatch(argv[i],"-notypecheck")) {
00465 if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE;
00466 jconf->input.paramtype_check_flag = FALSE;
00467 continue;
00468 } else if (strmatch(argv[i],"-nlimit")) {
00469 #ifdef WPAIR_KEEP_NLIMIT
00470 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
00471 GET_TMPARG;
00472 jconf->searchnow->pass1.wpair_keep_nlimit = atoi(tmparg);
00473 #else
00474 jlog("WARNING: m_options: WPAIR_KEEP_NLIMIT disabled, \"-nlimit\" ignored\n");
00475 #endif
00476 continue;
00477 } else if (strmatch(argv[i],"-lookuprange")) {
00478 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
00479 GET_TMPARG;
00480 jconf->searchnow->pass2.lookup_range = atoi(tmparg);
00481 continue;
00482 } else if (strmatch(argv[i],"-graphout")) {
00483 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
00484 jconf->searchnow->graph.enabled = TRUE;
00485 jconf->searchnow->graph.lattice = TRUE;
00486 jconf->searchnow->graph.confnet = FALSE;
00487 continue;
00488 } else if (strmatch(argv[i],"-lattice")) {
00489 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
00490 jconf->searchnow->graph.enabled = TRUE;
00491 jconf->searchnow->graph.lattice = TRUE;
00492 continue;
00493 } else if (strmatch(argv[i],"-nolattice")) {
00494 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
00495 jconf->searchnow->graph.enabled = FALSE;
00496 jconf->searchnow->graph.lattice = FALSE;
00497 continue;
00498 } else if (strmatch(argv[i],"-confnet")) {
00499 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
00500 jconf->searchnow->graph.enabled = TRUE;
00501 jconf->searchnow->graph.confnet = TRUE;
00502 continue;
00503 } else if (strmatch(argv[i],"-noconfnet")) {
00504 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
00505 jconf->searchnow->graph.enabled = FALSE;
00506 jconf->searchnow->graph.confnet = FALSE;
00507 continue;
00508 } else if (strmatch(argv[i],"-graphrange")) {
00509 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
00510 GET_TMPARG;
00511 jconf->searchnow->graph.graph_merge_neighbor_range = atoi(tmparg);
00512 continue;
00513 #ifdef GRAPHOUT_DEPTHCUT
00514 } else if (strmatch(argv[i],"-graphcut")) {
00515 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
00516 GET_TMPARG;
00517 jconf->searchnow->graph.graphout_cut_depth = atoi(tmparg);
00518 continue;
00519 #endif
00520 #ifdef GRAPHOUT_LIMIT_BOUNDARY_LOOP
00521 } else if (strmatch(argv[i],"-graphboundloop")) {
00522 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
00523 GET_TMPARG;
00524 jconf->searchnow->graph.graphout_limit_boundary_loop_num = atoi(tmparg);
00525 continue;
00526 #endif
00527 #ifdef GRAPHOUT_SEARCH_DELAY_TERMINATION
00528 } else if (strmatch(argv[i],"-graphsearchdelay")) {
00529 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
00530 jconf->searchnow->graph.graphout_search_delay = TRUE;
00531 continue;
00532 } else if (strmatch(argv[i],"-nographsearchdelay")) {
00533 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
00534 jconf->searchnow->graph.graphout_search_delay = FALSE;
00535 continue;
00536 #endif
00537 } else if (strmatch(argv[i],"-looktrellis")) {
00538 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
00539 jconf->searchnow->pass2.looktrellis_flag = TRUE;
00540 continue;
00541 } else if (strmatch(argv[i],"-multigramout")) {
00542 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
00543 jconf->searchnow->output.multigramout_flag = TRUE;
00544 continue;
00545 } else if (strmatch(argv[i],"-nomultigramout")) {
00546 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
00547 jconf->searchnow->output.multigramout_flag = FALSE;
00548 continue;
00549 } else if (strmatch(argv[i],"-oldtree")) {
00550 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
00551 jconf->searchnow->pass1.old_tree_function_flag = TRUE;
00552 continue;
00553 } else if (strmatch(argv[i],"-sb")) {
00554 #ifdef SCAN_BEAM
00555 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
00556 GET_TMPARG;
00557 jconf->searchnow->pass2.scan_beam_thres = atof(tmparg);
00558 #else
00559 jlog("WARNING: m_options: SCAN_BEAM disabled, \"-sb\" ignored\n");
00560 #endif
00561 continue;
00562 } else if (strmatch(argv[i],"-discount")) {
00563 jlog("WARNING: m_options: option \"-discount\" is now bogus, ignored\n");
00564 continue;
00565 } else if (strmatch(argv[i],"-cutsilence")) {
00566 if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE;
00567 jconf->detect.silence_cut = 1;
00568 continue;
00569 } else if (strmatch(argv[i],"-nocutsilence")) {
00570 if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE;
00571 jconf->detect.silence_cut = 0;
00572 continue;
00573 } else if (strmatch(argv[i],"-pausesegment")) {
00574 if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE;
00575 jconf->detect.silence_cut = 1;
00576 continue;
00577 } else if (strmatch(argv[i],"-nopausesegment")) {
00578 if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE;
00579 jconf->detect.silence_cut = 0;
00580 continue;
00581 } else if (strmatch(argv[i],"-lv")) {
00582 if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE;
00583 GET_TMPARG;
00584 jconf->detect.level_thres = atoi(tmparg);
00585 continue;
00586 } else if (strmatch(argv[i],"-zc")) {
00587 if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE;
00588 GET_TMPARG;
00589 jconf->detect.zero_cross_num = atoi(tmparg);
00590 continue;
00591 } else if (strmatch(argv[i],"-headmargin")) {
00592 if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE;
00593 GET_TMPARG;
00594 jconf->detect.head_margin_msec = atoi(tmparg);
00595 continue;
00596 } else if (strmatch(argv[i],"-tailmargin")) {
00597 if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE;
00598 GET_TMPARG;
00599 jconf->detect.tail_margin_msec = atoi(tmparg);
00600 continue;
00601 } else if (strmatch(argv[i],"-hipass")||strmatch(argv[i],"-hifreq")) {
00602 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
00603 GET_TMPARG;
00604 jconf->amnow->analysis.para.hipass = atoi(tmparg);
00605 continue;
00606 } else if (strmatch(argv[i],"-lopass")||strmatch(argv[i],"-lofreq")) {
00607 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
00608 GET_TMPARG;
00609 jconf->amnow->analysis.para.lopass = atoi(tmparg);
00610 continue;
00611 } else if (strmatch(argv[i],"-smpPeriod")) {
00612 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
00613 GET_TMPARG;
00614 jconf->amnow->analysis.para.smp_period = atoi(tmparg);
00615 jconf->amnow->analysis.para.smp_freq = period2freq(jconf->amnow->analysis.para.smp_period);
00616 continue;
00617 } else if (strmatch(argv[i],"-smpFreq")) {
00618 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
00619 GET_TMPARG;
00620 jconf->amnow->analysis.para.smp_freq = atoi(tmparg);
00621 jconf->amnow->analysis.para.smp_period = freq2period(jconf->amnow->analysis.para.smp_freq);
00622 continue;
00623 } else if (strmatch(argv[i],"-fsize")) {
00624 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
00625 GET_TMPARG;
00626 jconf->amnow->analysis.para.framesize = atoi(tmparg);
00627 continue;
00628 } else if (strmatch(argv[i],"-fshift")) {
00629 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
00630 GET_TMPARG;
00631 jconf->amnow->analysis.para.frameshift = atoi(tmparg);
00632 continue;
00633 } else if (strmatch(argv[i],"-preemph")) {
00634 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
00635 GET_TMPARG;
00636 jconf->amnow->analysis.para.preEmph = atof(tmparg);
00637 continue;
00638 } else if (strmatch(argv[i],"-fbank")) {
00639 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
00640 GET_TMPARG;
00641 jconf->amnow->analysis.para.fbank_num = atoi(tmparg);
00642 continue;
00643 } else if (strmatch(argv[i],"-ceplif")) {
00644 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
00645 GET_TMPARG;
00646 jconf->amnow->analysis.para.lifter = atoi(tmparg);
00647 continue;
00648 } else if (strmatch(argv[i],"-rawe")) {
00649 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
00650 jconf->amnow->analysis.para.raw_e = TRUE;
00651 continue;
00652 } else if (strmatch(argv[i],"-norawe")) {
00653 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
00654 jconf->amnow->analysis.para.raw_e = FALSE;
00655 continue;
00656 } else if (strmatch(argv[i],"-enormal")) {
00657 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
00658 jconf->amnow->analysis.para.enormal = TRUE;
00659 continue;
00660 } else if (strmatch(argv[i],"-noenormal")) {
00661 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
00662 jconf->amnow->analysis.para.enormal = FALSE;
00663 continue;
00664 } else if (strmatch(argv[i],"-escale")) {
00665 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
00666 GET_TMPARG;
00667 jconf->amnow->analysis.para.escale = atof(tmparg);
00668 continue;
00669 } else if (strmatch(argv[i],"-silfloor")) {
00670 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
00671 GET_TMPARG;
00672 jconf->amnow->analysis.para.silFloor = atof(tmparg);
00673 continue;
00674 } else if (strmatch(argv[i],"-delwin")) {
00675 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
00676 GET_TMPARG;
00677 jconf->amnow->analysis.para.delWin = atoi(tmparg);
00678 continue;
00679 } else if (strmatch(argv[i],"-accwin")) {
00680 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
00681 GET_TMPARG;
00682 jconf->amnow->analysis.para.accWin = atoi(tmparg);
00683 continue;
00684 } else if (strmatch(argv[i],"-ssalpha")) {
00685 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
00686 GET_TMPARG;
00687 jconf->amnow->frontend.ss_alpha = atof(tmparg);
00688 continue;
00689 } else if (strmatch(argv[i],"-ssfloor")) {
00690 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
00691 GET_TMPARG;
00692 jconf->amnow->frontend.ss_floor = atof(tmparg);
00693 continue;
00694 } else if (strmatch(argv[i],"-cvn")) {
00695 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
00696 jconf->amnow->analysis.para.cvn = 1;
00697 continue;
00698 } else if (strmatch(argv[i],"-nocvn")) {
00699 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
00700 jconf->amnow->analysis.para.cvn = 0;
00701 continue;
00702 } else if (strmatch(argv[i],"-vtln")) {
00703 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
00704 GET_TMPARG;
00705 jconf->amnow->analysis.para.vtln_alpha = (float)atof(tmparg);
00706 GET_TMPARG;
00707 jconf->amnow->analysis.para.vtln_lower = (float)atof(tmparg);
00708 GET_TMPARG;
00709 jconf->amnow->analysis.para.vtln_upper = (float)atof(tmparg);
00710 continue;
00711 } else if (strmatch(argv[i],"-novtln")) {
00712 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
00713 jconf->amnow->analysis.para.vtln_alpha = 1.0;
00714 continue;
00715 } else if (strmatch(argv[i],"-48")) {
00716 if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE;
00717 jconf->input.use_ds48to16 = TRUE;
00718 continue;
00719 } else if (strmatch(argv[i],"-version") || strmatch(argv[i], "--version") || strmatch(argv[i], "-setting") || strmatch(argv[i], "--setting")) {
00720 j_put_header(stderr);
00721 j_put_compile_defs(stderr);
00722 fprintf(stderr, "\n");
00723 j_put_library_defs(stderr);
00724 return FALSE;
00725 } else if (strmatch(argv[i],"-quiet")) {
00726 debug2_flag = verbose_flag = FALSE;
00727 continue;
00728 } else if (strmatch(argv[i],"-debug")) {
00729 debug2_flag = verbose_flag = TRUE;
00730 continue;
00731 } else if (strmatch(argv[i],"-callbackdebug")) {
00732 callback_debug_flag = TRUE;
00733 continue;
00734 } else if (strmatch(argv[i],"-progout")) {
00735 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
00736 jconf->searchnow->output.progout_flag = TRUE;
00737 continue;
00738 } else if (strmatch(argv[i],"-proginterval")) {
00739 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
00740 GET_TMPARG;
00741 jconf->searchnow->output.progout_interval = atoi(tmparg);
00742 continue;
00743 } else if (strmatch(argv[i],"-demo")) {
00744 debug2_flag = verbose_flag = FALSE;
00745 jconf->searchnow->output.progout_flag = TRUE;
00746 continue;
00747 } else if (strmatch(argv[i],"-walign")) {
00748 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
00749 jconf->searchnow->annotate.align_result_word_flag = TRUE;
00750 continue;
00751 } else if (strmatch(argv[i],"-palign")) {
00752 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
00753 jconf->searchnow->annotate.align_result_phoneme_flag = TRUE;
00754 continue;
00755 } else if (strmatch(argv[i],"-salign")) {
00756 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
00757 jconf->searchnow->annotate.align_result_state_flag = TRUE;
00758 continue;
00759 } else if (strmatch(argv[i],"-output")) {
00760 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
00761 GET_TMPARG;
00762 jconf->searchnow->output.output_hypo_maxnum = atoi(tmparg);
00763 continue;
00764 } else if (strmatch(argv[i],"-1pass")) {
00765 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
00766 jconf->searchnow->compute_only_1pass = TRUE;
00767 continue;
00768 } else if (strmatch(argv[i],"-hlist")) {
00769 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
00770 FREE_MEMORY(jconf->amnow->mapfilename);
00771 GET_TMPARG;
00772 jconf->amnow->mapfilename = filepath(tmparg, cwd);
00773 continue;
00774 } else if (strmatch(argv[i],"-nlr")) {
00775 if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE;
00776 FREE_MEMORY(jconf->lmnow->ngram_filename_lr_arpa);
00777 GET_TMPARG;
00778 jconf->lmnow->ngram_filename_lr_arpa = filepath(tmparg, cwd);
00779 FREE_MEMORY(jconf->lmnow->ngram_filename);
00780 continue;
00781 } else if (strmatch(argv[i],"-nrl")) {
00782 if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE;
00783 FREE_MEMORY(jconf->lmnow->ngram_filename_rl_arpa);
00784 GET_TMPARG;
00785 jconf->lmnow->ngram_filename_rl_arpa = filepath(tmparg, cwd);
00786 FREE_MEMORY(jconf->lmnow->ngram_filename);
00787 continue;
00788 } else if (strmatch(argv[i],"-lmp")) {
00789 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
00790 GET_TMPARG;
00791 jconf->searchnow->lmp.lm_weight = (LOGPROB)atof(tmparg);
00792 GET_TMPARG;
00793 jconf->searchnow->lmp.lm_penalty = (LOGPROB)atof(tmparg);
00794 jconf->searchnow->lmp.lmp_specified = TRUE;
00795 continue;
00796 } else if (strmatch(argv[i],"-lmp2")) {
00797 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
00798 GET_TMPARG;
00799 jconf->searchnow->lmp.lm_weight2 = (LOGPROB)atof(tmparg);
00800 GET_TMPARG;
00801 jconf->searchnow->lmp.lm_penalty2 = (LOGPROB)atof(tmparg);
00802 jconf->searchnow->lmp.lmp2_specified = TRUE;
00803 continue;
00804 } else if (strmatch(argv[i],"-transp")) {
00805 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
00806 GET_TMPARG;
00807 jconf->searchnow->lmp.lm_penalty_trans = (LOGPROB)atof(tmparg);
00808 continue;
00809 } else if (strmatch(argv[i],"-gram")) {
00810 if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE;
00811 GET_TMPARG;
00812 if (multigram_add_prefix_list(tmparg, cwd, jconf->lmnow, LM_DFA_GRAMMAR) == FALSE) {
00813 jlog("ERROR: m_options: failed to read some grammars\n");
00814 return FALSE;
00815 }
00816 continue;
00817 } else if (strmatch(argv[i],"-gramlist")) {
00818 if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE;
00819 GET_TMPARG;
00820 tmparg = filepath(tmparg, cwd);
00821 if (multigram_add_prefix_filelist(tmparg, jconf->lmnow, LM_DFA_GRAMMAR) == FALSE) {
00822 jlog("ERROR: m_options: failed to read some grammars\n");
00823 free(tmparg);
00824 return FALSE;
00825 }
00826 free(tmparg);
00827 continue;
00828 } else if (strmatch(argv[i],"-userlm")) {
00829 if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE;
00830
00831 if (jconf->lmnow->lmtype != LM_PROB && jconf->lmnow->lmtype != LM_UNDEF) {
00832 jlog("ERROR: m_options: LM type conflicts: multiple LM specified?\n");
00833 return FALSE;
00834 }
00835 jconf->lmnow->lmtype = LM_PROB;
00836 if (jconf->lmnow->lmvar != LM_UNDEF && jconf->lmnow->lmvar != LM_NGRAM_USER) {
00837 jlog("ERROR: m_options: statistical model conflict\n");
00838 return FALSE;
00839 }
00840 jconf->lmnow->lmvar = LM_NGRAM_USER;
00841 continue;
00842 } else if (strmatch(argv[i],"-nogram")) {
00843 if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE;
00844 multigram_remove_gramlist(jconf->lmnow);
00845 FREE_MEMORY(jconf->lmnow->dfa_filename);
00846 FREE_MEMORY(jconf->lmnow->dictfilename);
00847 if (jconf->lmnow->lmtype == LM_UNDEF) {
00848 jconf->lmnow->lmtype = LM_DFA;
00849 jconf->lmnow->lmvar = LM_DFA_GRAMMAR;
00850 }
00851 continue;
00852 } else if (strmatch(argv[i],"-dfa")) {
00853 if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE;
00854 FREE_MEMORY(jconf->lmnow->dfa_filename);
00855 GET_TMPARG;
00856 jconf->lmnow->dfa_filename = filepath(tmparg, cwd);
00857 continue;
00858 } else if (strmatch(argv[i],"-penalty1")) {
00859 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
00860 GET_TMPARG;
00861 jconf->searchnow->lmp.penalty1 = (LOGPROB)atof(tmparg);
00862 continue;
00863 } else if (strmatch(argv[i],"-penalty2")) {
00864 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
00865 GET_TMPARG;
00866 jconf->searchnow->lmp.penalty2 = (LOGPROB)atof(tmparg);
00867 continue;
00868 } else if (strmatch(argv[i],"-spmodel") || strmatch(argv[i], "-sp")) {
00869 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
00870 FREE_MEMORY(jconf->amnow->spmodel_name);
00871 GET_TMPARG;
00872 jconf->amnow->spmodel_name = strcpy((char*)mymalloc(strlen(tmparg)+1),tmparg);
00873 continue;
00874 } else if (strmatch(argv[i],"-multipath")) {
00875 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
00876 jconf->amnow->force_multipath = TRUE;
00877 continue;
00878 } else if (strmatch(argv[i],"-iwsp")) {
00879 if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE;
00880 jconf->lmnow->enable_iwsp = TRUE;
00881 continue;
00882 } else if (strmatch(argv[i],"-iwsppenalty")) {
00883 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
00884 GET_TMPARG;
00885 jconf->amnow->iwsp_penalty = atof(tmparg);
00886 continue;
00887 } else if (strmatch(argv[i],"-silhead")) {
00888 if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE;
00889 FREE_MEMORY(jconf->lmnow->head_silname);
00890 GET_TMPARG;
00891 jconf->lmnow->head_silname = strcpy((char*)mymalloc(strlen(tmparg)+1),tmparg);
00892 continue;
00893 } else if (strmatch(argv[i],"-siltail")) {
00894 if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE;
00895 FREE_MEMORY(jconf->lmnow->tail_silname);
00896 GET_TMPARG;
00897 jconf->lmnow->tail_silname = strcpy((char*)mymalloc(strlen(tmparg)+1),tmparg);
00898 continue;
00899 } else if (strmatch(argv[i],"-mapunk")) {
00900 if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE;
00901 strncpy(jconf->lmnow->unknown_name, tmparg, UNK_WORD_MAXLEN);
00902 continue;
00903 } else if (strmatch(argv[i],"-iwspword")) {
00904 if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE;
00905 jconf->lmnow->enable_iwspword = TRUE;
00906 continue;
00907 } else if (strmatch(argv[i],"-iwspentry")) {
00908 if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE;
00909 FREE_MEMORY(jconf->lmnow->iwspentry);
00910 GET_TMPARG;
00911 jconf->lmnow->iwspentry = strcpy((char*)mymalloc(strlen(tmparg)+1),tmparg);
00912 continue;
00913 } else if (strmatch(argv[i],"-iwcache")) {
00914 #ifdef HASH_CACHE_IW
00915 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
00916 GET_TMPARG;
00917 jconf->searchnow->pass1.iw_cache_rate = atof(tmparg);
00918 if (jconf->searchnow->pass1.iw_cache_rate > 100) jconf->searchnow->pass1.iw_cache_rate = 100;
00919 if (jconf->searchnow->pass1.iw_cache_rate < 1) jconf->searchnow->pass1.iw_cache_rate = 1;
00920 #else
00921 jlog("WARNING: m_options: HASH_CACHE_IW disabled, \"-iwcache\" ignored\n");
00922 #endif
00923 continue;
00924 } else if (strmatch(argv[i],"-sepnum")) {
00925 #ifdef SEPARATE_BY_UNIGRAM
00926 if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE;
00927 GET_TMPARG;
00928 jconf->lmnow->separate_wnum = atoi(tmparg);
00929 #else
00930 jlog("WARNING: m_options: SEPARATE_BY_UNIGRAM disabled, \"-sepnum\" ignored\n");
00931 i++;
00932 #endif
00933 continue;
00934 #ifdef USE_NETAUDIO
00935 } else if (strmatch(argv[i],"-NA")) {
00936 if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE;
00937 FREE_MEMORY(jconf->input.netaudio_devname);
00938 GET_TMPARG;
00939 jconf->input.netaudio_devname = strcpy((char*)mymalloc(strlen(tmparg)+1),tmparg);
00940 continue;
00941 #endif
00942 } else if (strmatch(argv[i],"-adport")) {
00943 if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE;
00944 GET_TMPARG;
00945 jconf->input.adinnet_port = atoi(tmparg);
00946 continue;
00947 } else if (strmatch(argv[i],"-nostrip")) {
00948 if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE;
00949 jconf->preprocess.strip_zero_sample = FALSE;
00950 continue;
00951 } else if (strmatch(argv[i],"-zmean")) {
00952 if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE;
00953 jconf->preprocess.use_zmean = TRUE;
00954 continue;
00955 } else if (strmatch(argv[i],"-nozmean")) {
00956 if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE;
00957 jconf->preprocess.use_zmean = FALSE;
00958 continue;
00959 } else if (strmatch(argv[i],"-zmeanframe")) {
00960 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
00961 jconf->amnow->analysis.para.zmeanframe = TRUE;
00962 continue;
00963 } else if (strmatch(argv[i],"-nozmeanframe")) {
00964 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
00965 jconf->amnow->analysis.para.zmeanframe = FALSE;
00966 continue;
00967 } else if (strmatch(argv[i],"-usepower")) {
00968 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
00969 jconf->amnow->analysis.para.usepower = TRUE;
00970 continue;
00971 } else if (strmatch(argv[i],"-nousepower")) {
00972 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
00973 jconf->amnow->analysis.para.usepower = FALSE;
00974 continue;
00975 } else if (strmatch(argv[i],"-spsegment")) {
00976 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
00977 jconf->searchnow->successive.enabled = TRUE;
00978 continue;
00979 } else if (strmatch(argv[i],"-spdur")) {
00980 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
00981 GET_TMPARG;
00982 jconf->searchnow->successive.sp_frame_duration = atoi(tmparg);
00983 continue;
00984 #ifdef SPSEGMENT_NAIST
00985 } else if (strmatch(argv[i],"-spmargin")) {
00986 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
00987 GET_TMPARG;
00988 jconf->searchnow->successive.sp_margin = atoi(tmparg);
00989 continue;
00990 } else if (strmatch(argv[i],"-spdelay")) {
00991 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
00992 GET_TMPARG;
00993 jconf->searchnow->successive.sp_delay = atoi(tmparg);
00994 continue;
00995 #endif
00996 } else if (strmatch(argv[i],"-pausemodels")) {
00997 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
00998 FREE_MEMORY(jconf->searchnow->successive.pausemodelname);
00999 GET_TMPARG;
01000 jconf->searchnow->successive.pausemodelname = strcpy((char*)mymalloc(strlen(tmparg)+1),tmparg);
01001 continue;
01002 } else if (strmatch(argv[i],"-gprune")) {
01003 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
01004 GET_TMPARG;
01005 if (strmatch(tmparg,"safe")) {
01006 jconf->amnow->gprune_method = GPRUNE_SEL_SAFE;
01007 } else if (strmatch(tmparg,"heuristic")) {
01008 jconf->amnow->gprune_method = GPRUNE_SEL_HEURISTIC;
01009 } else if (strmatch(tmparg,"beam")) {
01010 jconf->amnow->gprune_method = GPRUNE_SEL_BEAM;
01011 } else if (strmatch(tmparg,"none")) {
01012 jconf->amnow->gprune_method = GPRUNE_SEL_NONE;
01013 } else if (strmatch(tmparg,"default")) {
01014 jconf->amnow->gprune_method = GPRUNE_SEL_UNDEF;
01015 #ifdef ENABLE_PLUGIN
01016 } else if ((sid = plugin_find_optname("calcmix_get_optname", tmparg)) != -1) {
01017 jconf->amnow->gprune_method = GPRUNE_SEL_USER;
01018 jconf->amnow->gprune_plugin_source = sid;
01019 #endif
01020 } else {
01021 jlog("ERROR: m_options: no such pruning method \"%s\"\n", argv[0], tmparg);
01022 return FALSE;
01023 }
01024 continue;
01025
01026
01027
01028
01029
01030 } else if (strmatch(argv[i],"-no_ccd")) {
01031 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
01032 jconf->searchnow->ccd_handling = FALSE;
01033 jconf->searchnow->force_ccd_handling = TRUE;
01034 continue;
01035 } else if (strmatch(argv[i],"-force_ccd")) {
01036 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
01037 jconf->searchnow->ccd_handling = TRUE;
01038 jconf->searchnow->force_ccd_handling = TRUE;
01039 continue;
01040 } else if (strmatch(argv[i],"-iwcd1")) {
01041 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
01042 GET_TMPARG;
01043 if (strmatch(tmparg, "max")) {
01044 jconf->amnow->iwcdmethod = IWCD_MAX;
01045 } else if (strmatch(tmparg, "avg")) {
01046 jconf->amnow->iwcdmethod = IWCD_AVG;
01047 } else if (strmatch(tmparg, "best")) {
01048 jconf->amnow->iwcdmethod = IWCD_NBEST;
01049 GET_TMPARG;
01050 jconf->amnow->iwcdmaxn = atoi(tmparg);
01051 } else {
01052 jlog("ERROR: m_options: -iwcd1: wrong argument (max|avg|best N): %s\n", argv[0], tmparg);
01053 return FALSE;
01054 }
01055 continue;
01056 } else if (strmatch(argv[i],"-tmix")) {
01057 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
01058 if (i + 1 < argc && isdigit(argv[i+1][0])) {
01059 jconf->amnow->mixnum_thres = atoi(argv[++i]);
01060 }
01061 continue;
01062 } else if (strmatch(argv[i],"-b2") || strmatch(argv[i],"-bw") || strmatch(argv[i],"-wb")) {
01063 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
01064 GET_TMPARG;
01065 jconf->searchnow->pass2.enveloped_bestfirst_width = atoi(tmparg);
01066 continue;
01067 } else if (strmatch(argv[i],"-hgs")) {
01068 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
01069 FREE_MEMORY(jconf->amnow->hmm_gs_filename);
01070 GET_TMPARG;
01071 jconf->amnow->hmm_gs_filename = filepath(tmparg, cwd);
01072 continue;
01073 } else if (strmatch(argv[i],"-booknum")) {
01074 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
01075 GET_TMPARG;
01076 jconf->amnow->gs_statenum = atoi(tmparg);
01077 continue;
01078 } else if (strmatch(argv[i],"-gshmm")) {
01079 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
01080 FREE_MEMORY(jconf->amnow->hmm_gs_filename);
01081 GET_TMPARG;
01082 jconf->amnow->hmm_gs_filename = filepath(tmparg, cwd);
01083 continue;
01084 } else if (strmatch(argv[i],"-gsnum")) {
01085 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
01086 GET_TMPARG;
01087 jconf->amnow->gs_statenum = atoi(tmparg);
01088 continue;
01089 } else if (strmatch(argv[i],"-cmnload")) {
01090 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
01091 FREE_MEMORY(jconf->amnow->analysis.cmnload_filename);
01092 GET_TMPARG;
01093 jconf->amnow->analysis.cmnload_filename = filepath(tmparg, cwd);
01094 continue;
01095 } else if (strmatch(argv[i],"-cmnsave")) {
01096 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
01097 FREE_MEMORY(jconf->amnow->analysis.cmnsave_filename);
01098 GET_TMPARG;
01099 jconf->amnow->analysis.cmnsave_filename = filepath(tmparg, cwd);
01100 continue;
01101 } else if (strmatch(argv[i],"-cmnupdate")) {
01102 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
01103 jconf->amnow->analysis.cmn_update = TRUE;
01104 continue;
01105 } else if (strmatch(argv[i],"-cmnnoupdate")) {
01106 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
01107 jconf->amnow->analysis.cmn_update = FALSE;
01108 continue;
01109 } else if (strmatch(argv[i],"-cmnmapweight")) {
01110 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
01111 GET_TMPARG;
01112 jconf->amnow->analysis.cmn_map_weight = (float)atof(tmparg);
01113 continue;
01114 } else if (strmatch(argv[i],"-sscalc")) {
01115 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
01116 jconf->amnow->frontend.sscalc = TRUE;
01117 FREE_MEMORY(jconf->amnow->frontend.ssload_filename);
01118 continue;
01119 } else if (strmatch(argv[i],"-sscalclen")) {
01120 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
01121 GET_TMPARG;
01122 jconf->amnow->frontend.sscalc_len = atoi(tmparg);
01123 continue;
01124 } else if (strmatch(argv[i],"-ssload")) {
01125 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
01126 FREE_MEMORY(jconf->amnow->frontend.ssload_filename);
01127 GET_TMPARG;
01128 jconf->amnow->frontend.ssload_filename = filepath(tmparg, cwd);
01129 jconf->amnow->frontend.sscalc = FALSE;
01130 continue;
01131 #ifdef CONFIDENCE_MEASURE
01132 } else if (strmatch(argv[i],"-cmalpha")) {
01133 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
01134 #ifdef CM_MULTIPLE_ALPHA
01135 GET_TMPARG;
01136 jconf->searchnow->annotate.cm_alpha_bgn = (LOGPROB)atof(tmparg);
01137 GET_TMPARG;
01138 jconf->searchnow->annotate.cm_alpha_end = (LOGPROB)atof(tmparg);
01139 GET_TMPARG;
01140 jconf->searchnow->annotate.cm_alpha_step = (LOGPROB)atof(tmparg);
01141 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;
01142 if (jconf->searchnow->annotate.cm_alpha_num > 100) {
01143 jlog("ERROR: m_option: cm_alpha step num exceeds limit (100)\n");
01144 return FALSE;
01145 }
01146 #else
01147 GET_TMPARG;
01148 jconf->searchnow->annotate.cm_alpha = (LOGPROB)atof(tmparg);
01149 #endif
01150 continue;
01151 #ifdef CM_SEARCH_LIMIT
01152 } else if (strmatch(argv[i],"-cmthres")) {
01153 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
01154 GET_TMPARG;
01155 jconf->searchnow->annotate.cm_cut_thres = (LOGPROB)atof(tmparg);
01156 continue;
01157 #endif
01158 #ifdef CM_SEARCH_LIMIT_POP
01159 } else if (strmatch(argv[i],"-cmthres2")) {
01160 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
01161 GET_TMPARG;
01162 jconf->searchnow->annotate.cm_cut_thres_pop = (LOGPROB)atof(tmparg);
01163 continue;
01164 #endif
01165 #endif
01166 } else if (strmatch(argv[i],"-gmm")) {
01167 if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE;
01168 FREE_MEMORY(jconf->reject.gmm_filename);
01169 GET_TMPARG;
01170 jconf->reject.gmm_filename = filepath(tmparg, cwd);
01171 continue;
01172 } else if (strmatch(argv[i],"-gmmnum")) {
01173 if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE;
01174 GET_TMPARG;
01175 jconf->reject.gmm_gprune_num = atoi(tmparg);
01176 continue;
01177 } else if (strmatch(argv[i],"-gmmreject")) {
01178 if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE;
01179 GET_TMPARG;
01180 FREE_MEMORY(jconf->reject.gmm_reject_cmn_string);
01181 jconf->reject.gmm_reject_cmn_string = strcpy((char *)mymalloc(strlen(tmparg)+1), tmparg);
01182 continue;
01183 #ifdef GMM_VAD
01184 } else if (strmatch(argv[i],"-gmmmargin")) {
01185 if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE;
01186 GET_TMPARG;
01187 jconf->detect.gmm_margin = atoi(tmparg);
01188 continue;
01189 } else if (strmatch(argv[i],"-gmmup")) {
01190 if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE;
01191 GET_TMPARG;
01192 jconf->detect.gmm_uptrigger_thres = atof(tmparg);
01193 continue;
01194 } else if (strmatch(argv[i],"-gmmdown")) {
01195 if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE;
01196 GET_TMPARG;
01197 jconf->detect.gmm_downtrigger_thres = atof(tmparg);
01198 continue;
01199 #endif
01200 } else if (strmatch(argv[i],"-htkconf")) {
01201 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
01202 GET_TMPARG;
01203 if (htk_config_file_parse(tmparg, &(jconf->amnow->analysis.para_htk)) == FALSE) {
01204 jlog("ERROR: m_options: failed to read %s\n", tmparg);
01205 return FALSE;
01206 }
01207 continue;
01208 } else if (strmatch(argv[i], "-wlist")) {
01209 if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE;
01210 GET_TMPARG;
01211 tmparg = filepath(tmparg, cwd);
01212 if (multigram_add_prefix_filelist(tmparg, jconf->lmnow, LM_DFA_WORD) == FALSE) {
01213 jlog("ERROR: m_options: failed to read some word lists\n");
01214 free(tmparg);
01215 return FALSE;
01216 }
01217 free(tmparg);
01218 continue;
01219 } else if (strmatch(argv[i], "-wsil")) {
01220
01221
01222
01223
01224
01225
01226 if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE;
01227 GET_TMPARG;
01228 strncpy(jconf->lmnow->wordrecog_head_silence_model_name, tmparg, MAX_HMMNAME_LEN);
01229 GET_TMPARG;
01230 strncpy(jconf->lmnow->wordrecog_tail_silence_model_name, tmparg, MAX_HMMNAME_LEN);
01231 GET_TMPARG;
01232 if (strmatch(tmparg, "NULL")) {
01233 jconf->lmnow->wordrecog_silence_context_name[0] = '\0';
01234 } else {
01235 strncpy(jconf->lmnow->wordrecog_silence_context_name, tmparg, MAX_HMMNAME_LEN);
01236 }
01237 continue;
01238 #ifdef DETERMINE
01239 } else if (strmatch(argv[i], "-wed")) {
01240
01241
01242
01243
01244 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
01245 GET_TMPARG;
01246 jconf->searchnow->pass1.determine_score_thres = atof(tmparg);
01247 GET_TMPARG;
01248 jconf->searchnow->pass1.determine_duration_thres = atoi(tmparg);
01249 continue;
01250 #endif
01251 } else if (strmatch(argv[i], "-inactive")) {
01252 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
01253 jconf->searchnow->sw.start_inactive = TRUE;
01254 continue;
01255 } else if (strmatch(argv[i], "-active")) {
01256 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
01257 jconf->searchnow->sw.start_inactive = FALSE;
01258 continue;
01259 } else if (strmatch(argv[i],"-fallback1pass")) {
01260 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
01261 jconf->searchnow->sw.fallback_pass1_flag = TRUE;
01262 continue;
01263 #ifdef ENABLE_PLUGIN
01264 } else if (strmatch(argv[i],"-plugindir")) {
01265 GET_TMPARG;
01266 plugin_load_dirs(tmparg);
01267 continue;
01268 #endif
01269 }
01270 if (argv[i][0] == '-' && strlen(argv[i]) == 2) {
01271
01272 switch(argv[i][1]) {
01273 case 'h':
01274 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE;
01275 FREE_MEMORY(jconf->amnow->hmmfilename);
01276 GET_TMPARG;
01277 jconf->amnow->hmmfilename = filepath(tmparg, cwd);
01278 break;
01279 case 'v':
01280 if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE;
01281 FREE_MEMORY(jconf->lmnow->dictfilename);
01282 GET_TMPARG;
01283 jconf->lmnow->dictfilename = filepath(tmparg, cwd);
01284 break;
01285 case 'w':
01286 if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE;
01287 GET_TMPARG;
01288 if (multigram_add_prefix_list(tmparg, cwd, jconf->lmnow, LM_DFA_WORD) == FALSE) {
01289 jlog("ERROR: m_options: failed to read some word list\n");
01290 return FALSE;
01291 }
01292 break;
01293 case 'd':
01294
01295 if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE;
01296 FREE_MEMORY(jconf->lmnow->ngram_filename);
01297 FREE_MEMORY(jconf->lmnow->ngram_filename_lr_arpa);
01298 FREE_MEMORY(jconf->lmnow->ngram_filename_rl_arpa);
01299 GET_TMPARG;
01300 jconf->lmnow->ngram_filename = filepath(tmparg, cwd);
01301 break;
01302 case 'b':
01303 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
01304 GET_TMPARG;
01305 jconf->searchnow->pass1.specified_trellis_beam_width = atoi(tmparg);
01306 break;
01307 case 's':
01308 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
01309 GET_TMPARG;
01310 jconf->searchnow->pass2.stack_size = atoi(tmparg);
01311 break;
01312 case 'n':
01313 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
01314 GET_TMPARG;
01315 jconf->searchnow->pass2.nbest = atoi(tmparg);
01316 break;
01317 case 'm':
01318 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE;
01319 GET_TMPARG;
01320 jconf->searchnow->pass2.hypo_overflow = atoi(tmparg);
01321 break;
01322 default:
01323
01324
01325 unknown_opt = TRUE;
01326 }
01327 } else {
01328
01329
01330 unknown_opt = TRUE;
01331 }
01332 if (unknown_opt) {
01333
01334 switch(useropt_exec(jconf, argv, argc, &i)) {
01335 case 0:
01336 jlog("ERROR: m_options: wrong argument: \"%s\"\n", argv[i]);
01337 return FALSE;
01338 case -1:
01339 jlog("ERROR: m_options: error in processing \"%s\"\n", argv[i]);
01340 return FALSE;
01341 }
01342 }
01343 }
01344
01345
01346 for(atmp=jconf->am_root;atmp;atmp=atmp->next) {
01347 if (!atmp->spmodel_name) {
01348 atmp->spmodel_name = strcpy((char*)mymalloc(strlen(SPMODEL_NAME_DEFAULT)+1),
01349 SPMODEL_NAME_DEFAULT);
01350 }
01351 }
01352 for(ltmp=jconf->lm_root;ltmp;ltmp=ltmp->next) {
01353 if (!ltmp->head_silname) {
01354 ltmp->head_silname = strcpy((char*)mymalloc(strlen(BEGIN_WORD_DEFAULT)+1),
01355 BEGIN_WORD_DEFAULT);
01356 }
01357 if (!ltmp->tail_silname) {
01358 ltmp->tail_silname = strcpy((char*)mymalloc(strlen(END_WORD_DEFAULT)+1),
01359 END_WORD_DEFAULT);
01360 }
01361 if (!ltmp->iwspentry) {
01362 ltmp->iwspentry = strcpy((char*)mymalloc(strlen(IWSPENTRY_DEFAULT)+1),
01363 IWSPENTRY_DEFAULT);
01364 }
01365 }
01366 #ifdef USE_NETAUDIO
01367 if (!jconf->input.netaudio_devname) {
01368 jconf->input.netaudio_devname = strcpy((char*)mymalloc(strlen(NETAUDIO_DEVNAME)+1),
01369 NETAUDIO_DEVNAME);
01370 }
01371 #endif
01372
01373 return TRUE;
01374 }
01375
01389 void
01390 opt_release(Jconf *jconf)
01391 {
01392 JCONF_AM *am;
01393 JCONF_LM *lm;
01394 JCONF_SEARCH *s;
01395
01396 FREE_MEMORY(jconf->input.inputlist_filename);
01397 #ifdef USE_NETAUDIO
01398 FREE_MEMORY(jconf->input.netaudio_devname);
01399 #endif
01400 FREE_MEMORY(jconf->reject.gmm_filename);
01401 FREE_MEMORY(jconf->reject.gmm_reject_cmn_string);
01402
01403 for(am=jconf->am_root;am;am=am->next) {
01404 FREE_MEMORY(am->hmmfilename);
01405 FREE_MEMORY(am->mapfilename);
01406 FREE_MEMORY(am->spmodel_name);
01407 FREE_MEMORY(am->hmm_gs_filename);
01408 FREE_MEMORY(am->analysis.cmnload_filename);
01409 FREE_MEMORY(am->analysis.cmnsave_filename);
01410 FREE_MEMORY(am->frontend.ssload_filename);
01411 }
01412 for(lm=jconf->lm_root;lm;lm=lm->next) {
01413 FREE_MEMORY(lm->ngram_filename);
01414 FREE_MEMORY(lm->ngram_filename_lr_arpa);
01415 FREE_MEMORY(lm->ngram_filename_rl_arpa);
01416 FREE_MEMORY(lm->dfa_filename);
01417 FREE_MEMORY(lm->head_silname);
01418 FREE_MEMORY(lm->tail_silname);
01419 FREE_MEMORY(lm->iwspentry);
01420 FREE_MEMORY(lm->dictfilename);
01421 multigram_remove_gramlist(lm);
01422 }
01423 for(s=jconf->search_root;s;s=s->next) {
01424 FREE_MEMORY(s->successive.pausemodelname);
01425 }
01426 }
01427
01428