Julius 4.1.5
|
00001 00024 /* 00025 * Copyright (c) 1991-2007 Kawahara Lab., Kyoto University 00026 * Copyright (c) 2000-2005 Shikano Lab., Nara Institute of Science and Technology 00027 * Copyright (c) 2005-2007 Julius project team, Nagoya Institute of Technology 00028 * All rights reserved 00029 */ 00030 00031 #include <julius/julius.h> 00032 00057 char * 00058 filepath(char *filename, char *dirname) 00059 { 00060 char *p; 00061 if (dirname != NULL && filename[0] != '/' 00062 #if defined(_WIN32) 00063 && filename[0] != '\\' && !(strlen(filename) >= 3 && filename[1] == ':') 00064 #endif 00065 ) { 00066 p = (char *)mymalloc(strlen(filename) + strlen(dirname) + 1); 00067 strcpy(p, dirname); 00068 strcat(p, filename); 00069 } else { 00070 p = strcpy((char *)mymalloc(strlen(filename)+1), filename); 00071 } 00072 return p; 00073 } 00074 00090 static char * 00091 next_arg(int *cur, int argc, char *argv[]) 00092 { 00093 (*cur)++; 00094 if (*cur >= argc) { 00095 jlog("ERROR: m_options: option requires argument -- %s\n", argv[*cur-1]); 00096 return NULL; 00097 } 00098 return(argv[*cur]); 00099 } 00100 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 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) { /* adin plugin */ 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) { /* vector input plugin */ 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")) { /* input file list */ 00405 if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; 00406 GET_TMPARG; 00407 FREE_MEMORY(jconf->input.inputlist_filename); 00408 //jconf->input.inputlist_filename = strcpy((char*)mymalloc(strlen(tmparg)+1),tmparg); 00409 jconf->input.inputlist_filename = filepath(tmparg, cwd); 00410 continue; 00411 } else if (strmatch(argv[i],"-rejectshort")) { /* short input rejection */ 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")) { /* short input rejection */ 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")) { /* 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")) { /* equal to "-force_realtime on" */ 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")) { /* equal to "-force_realtime off" */ 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")) { /* skip dict error */ 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")) { /* interactive model check mode */ 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")) { /* don't check param type */ 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")) { /* limit N token in a node */ 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")) { /* trellis neighbor range */ 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")) { /* enable graph output */ 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")) { /* enable graph output */ 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")) { /* disable graph output */ 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")) { /* enable confusion network */ 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")) { /* 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.confnet = FALSE; 00507 continue; 00508 } else if (strmatch(argv[i],"-graphrange")) { /* neighbor merge range frame */ 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")) { /* cut graph word by depth */ 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")) { /* neighbor merge range frame */ 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")) { /* not do graph search termination before the 1st sentence is found */ 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")) { /* not do graph search termination before the 1st sentence is found */ 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")) { /* activate loopuprange */ 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")) { /* enable per-grammar decoding on 2nd pass */ 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")) { /* disable per-grammar decoding on 2nd pass */ 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")) { /* use old tree function */ 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")) { /* score envelope width in 2nd pass */ 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")) { /* (bogus) */ 00563 jlog("WARNING: m_options: option \"-discount\" is now bogus, ignored\n"); 00564 continue; 00565 } else if (strmatch(argv[i],"-cutsilence")) { /* force (long) silence detection on */ 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")) { /* force (long) silence detection off */ 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")) { /* force (long) silence detection on (for backward compatibility) */ 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")) { /* force (long) silence detection off (for backward comatibility) */ 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")) { /* silence detection threshold level */ 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")) { /* silence detection zero cross num */ 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")) { /* head silence length */ 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")) { /* tail silence length */ 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")) { /* frequency of upper band limit */ 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")) { /* frequency of lower band limit */ 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")) { /* sample period (ns) */ 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")) { /* sample frequency (Hz) */ 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")) { /* Window size */ 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")) { /* Frame shiht */ 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")) { /* Delta window length */ 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")) { /* Acceleration window length */ 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")) { /* alpha coef. for SS */ 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")) { /* spectral floor for SS */ 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")) { /* 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")) { /* disable VTLN */ 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")) { /* use 48kHz input and down to 16kHz */ 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")) { /* print version and exit */ 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")) { /* minimum output */ 00726 debug2_flag = verbose_flag = FALSE; 00727 continue; 00728 } else if (strmatch(argv[i],"-debug")) { /* debug mode: output huge log */ 00729 debug2_flag = verbose_flag = TRUE; 00730 continue; 00731 } else if (strmatch(argv[i],"-callbackdebug")) { /* output callback debug message */ 00732 callback_debug_flag = TRUE; 00733 continue; 00734 } else if (strmatch(argv[i],"-progout")) { /* enable progressive output */ 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")) { /* interval for -progout */ 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")) { /* quiet + progout */ 00744 debug2_flag = verbose_flag = FALSE; 00745 jconf->searchnow->output.progout_flag = TRUE; 00746 continue; 00747 } else if (strmatch(argv[i],"-walign")) { /* do forced alignment by word */ 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")) { /* do forced alignment by phoneme */ 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")) { /* do forced alignment by state */ 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")) { /* output up to N candidate */ 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")) { /* do only 1st pass */ 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")) { /* HMM list file */ 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")) { /* word LR n-gram (ARPA) */ 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")) { /* word RL n-gram (ARPA) */ 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")) { /* LM weight and penalty (pass1) */ 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")) { /* LM weight and penalty (pass2) */ 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")) { /* penalty for transparent word */ 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")) { /* comma-separatedlist of grammar prefix */ 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")) { /* file of grammar prefix list */ 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 /* just set lm flags here */ 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")) { /* remove grammar list */ 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")) { /* DFA filename */ 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")) { /* word insertion penalty (pass1) */ 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")) { /* word insertion penalty (pass2) */ 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")) { /* name of short pause word */ 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")) { /* force multipath mode */ 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")) { /* enable inter-word short pause handing (for multipath) */ 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")) { /* set inter-word short pause transition penalty (for multipath) */ 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")) { /* head silence word name */ 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")) { /* tail silence word name */ 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")) { /* unknown word */ 00900 if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; 00901 GET_TMPARG; 00902 strncpy(jconf->lmnow->unknown_name, tmparg, UNK_WORD_MAXLEN); 00903 continue; 00904 } else if (strmatch(argv[i],"-iwspword")) { /* add short pause word */ 00905 if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; 00906 jconf->lmnow->enable_iwspword = TRUE; 00907 continue; 00908 } else if (strmatch(argv[i],"-iwspentry")) { /* content of the iwspword */ 00909 if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; 00910 FREE_MEMORY(jconf->lmnow->iwspentry); 00911 GET_TMPARG; 00912 jconf->lmnow->iwspentry = strcpy((char*)mymalloc(strlen(tmparg)+1),tmparg); 00913 continue; 00914 } else if (strmatch(argv[i],"-iwcache")) { /* control cross-word LM cache */ 00915 #ifdef HASH_CACHE_IW 00916 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 00917 GET_TMPARG; 00918 jconf->searchnow->pass1.iw_cache_rate = atof(tmparg); 00919 if (jconf->searchnow->pass1.iw_cache_rate > 100) jconf->searchnow->pass1.iw_cache_rate = 100; 00920 if (jconf->searchnow->pass1.iw_cache_rate < 1) jconf->searchnow->pass1.iw_cache_rate = 1; 00921 #else 00922 jlog("WARNING: m_options: HASH_CACHE_IW disabled, \"-iwcache\" ignored\n"); 00923 #endif 00924 continue; 00925 } else if (strmatch(argv[i],"-sepnum")) { /* N-best frequent word will be separated from tree */ 00926 #ifdef SEPARATE_BY_UNIGRAM 00927 if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; 00928 GET_TMPARG; 00929 jconf->lmnow->separate_wnum = atoi(tmparg); 00930 #else 00931 jlog("WARNING: m_options: SEPARATE_BY_UNIGRAM disabled, \"-sepnum\" ignored\n"); 00932 i++; 00933 #endif 00934 continue; 00935 #ifdef USE_NETAUDIO 00936 } else if (strmatch(argv[i],"-NA")) { /* netautio device name */ 00937 if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; 00938 FREE_MEMORY(jconf->input.netaudio_devname); 00939 GET_TMPARG; 00940 jconf->input.netaudio_devname = strcpy((char*)mymalloc(strlen(tmparg)+1),tmparg); 00941 continue; 00942 #endif 00943 } else if (strmatch(argv[i],"-adport")) { /* adinnet port num */ 00944 if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; 00945 GET_TMPARG; 00946 jconf->input.adinnet_port = atoi(tmparg); 00947 continue; 00948 } else if (strmatch(argv[i],"-nostrip")) { /* do not strip zero samples */ 00949 if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; 00950 jconf->preprocess.strip_zero_sample = FALSE; 00951 continue; 00952 } else if (strmatch(argv[i],"-zmean")) { /* enable DC offset by zero mean */ 00953 if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; 00954 jconf->preprocess.use_zmean = TRUE; 00955 continue; 00956 } else if (strmatch(argv[i],"-nozmean")) { /* disable DC offset by zero mean */ 00957 if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; 00958 jconf->preprocess.use_zmean = FALSE; 00959 continue; 00960 } else if (strmatch(argv[i],"-zmeanframe")) { /* enable frame-wise DC offset by zero mean */ 00961 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 00962 jconf->amnow->analysis.para.zmeanframe = TRUE; 00963 continue; 00964 } else if (strmatch(argv[i],"-nozmeanframe")) { /* disable frame-wise DC offset by zero mean */ 00965 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 00966 jconf->amnow->analysis.para.zmeanframe = FALSE; 00967 continue; 00968 } else if (strmatch(argv[i],"-usepower")) { /* use power instead of magnitude in filterbank analysis */ 00969 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 00970 jconf->amnow->analysis.para.usepower = TRUE; 00971 continue; 00972 } else if (strmatch(argv[i],"-nousepower")) { /* use magnitude in fbank analysis (default) */ 00973 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 00974 jconf->amnow->analysis.para.usepower = FALSE; 00975 continue; 00976 } else if (strmatch(argv[i],"-spsegment")) { /* enable short-pause segmentation */ 00977 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 00978 jconf->searchnow->successive.enabled = TRUE; 00979 continue; 00980 } else if (strmatch(argv[i],"-spdur")) { /* speech down-trigger duration threshold in frame */ 00981 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 00982 GET_TMPARG; 00983 jconf->searchnow->successive.sp_frame_duration = atoi(tmparg); 00984 continue; 00985 #ifdef SPSEGMENT_NAIST 00986 } else if (strmatch(argv[i],"-spmargin")) { /* speech up-trigger backstep margin in frame */ 00987 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 00988 GET_TMPARG; 00989 jconf->searchnow->successive.sp_margin = atoi(tmparg); 00990 continue; 00991 } else if (strmatch(argv[i],"-spdelay")) { /* speech up-trigger delay frame */ 00992 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 00993 GET_TMPARG; 00994 jconf->searchnow->successive.sp_delay = atoi(tmparg); 00995 continue; 00996 #endif 00997 } else if (strmatch(argv[i],"-pausemodels")) { /* short-pause duration threshold */ 00998 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 00999 FREE_MEMORY(jconf->searchnow->successive.pausemodelname); 01000 GET_TMPARG; 01001 jconf->searchnow->successive.pausemodelname = strcpy((char*)mymalloc(strlen(tmparg)+1),tmparg); 01002 continue; 01003 } else if (strmatch(argv[i],"-gprune")) { /* select Gaussian pruning method */ 01004 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 01005 GET_TMPARG; 01006 if (strmatch(tmparg,"safe")) { /* safest, slowest */ 01007 jconf->amnow->gprune_method = GPRUNE_SEL_SAFE; 01008 } else if (strmatch(tmparg,"heuristic")) { 01009 jconf->amnow->gprune_method = GPRUNE_SEL_HEURISTIC; 01010 } else if (strmatch(tmparg,"beam")) { /* fastest */ 01011 jconf->amnow->gprune_method = GPRUNE_SEL_BEAM; 01012 } else if (strmatch(tmparg,"none")) { /* no prune: compute all Gaussian */ 01013 jconf->amnow->gprune_method = GPRUNE_SEL_NONE; 01014 } else if (strmatch(tmparg,"default")) { 01015 jconf->amnow->gprune_method = GPRUNE_SEL_UNDEF; 01016 #ifdef ENABLE_PLUGIN 01017 } else if ((sid = plugin_find_optname("calcmix_get_optname", tmparg)) != -1) { /* mixture calculation plugin */ 01018 jconf->amnow->gprune_method = GPRUNE_SEL_USER; 01019 jconf->amnow->gprune_plugin_source = sid; 01020 #endif 01021 } else { 01022 jlog("ERROR: m_options: no such pruning method \"%s\"\n", argv[0], tmparg); 01023 return FALSE; 01024 } 01025 continue; 01026 /* 01027 * } else if (strmatch(argv[i],"-reorder")) { 01028 * result_reorder_flag = TRUE; 01029 * continue; 01030 */ 01031 } else if (strmatch(argv[i],"-no_ccd")) { /* force triphone handling = OFF */ 01032 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 01033 jconf->searchnow->ccd_handling = FALSE; 01034 jconf->searchnow->force_ccd_handling = TRUE; 01035 continue; 01036 } else if (strmatch(argv[i],"-force_ccd")) { /* force triphone handling = ON */ 01037 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 01038 jconf->searchnow->ccd_handling = TRUE; 01039 jconf->searchnow->force_ccd_handling = TRUE; 01040 continue; 01041 } else if (strmatch(argv[i],"-iwcd1")) { /* select cross-word triphone computation method */ 01042 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 01043 GET_TMPARG; 01044 if (strmatch(tmparg, "max")) { /* use maximum score in triphone variants */ 01045 jconf->amnow->iwcdmethod = IWCD_MAX; 01046 } else if (strmatch(tmparg, "avg")) { /* use average in variants */ 01047 jconf->amnow->iwcdmethod = IWCD_AVG; 01048 } else if (strmatch(tmparg, "best")) { /* use average in variants */ 01049 jconf->amnow->iwcdmethod = IWCD_NBEST; 01050 GET_TMPARG; 01051 jconf->amnow->iwcdmaxn = atoi(tmparg); 01052 } else { 01053 jlog("ERROR: m_options: -iwcd1: wrong argument (max|avg|best N): %s\n", argv[0], tmparg); 01054 return FALSE; 01055 } 01056 continue; 01057 } else if (strmatch(argv[i],"-tmix")) { /* num of mixture to select */ 01058 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 01059 if (i + 1 < argc && isdigit(argv[i+1][0])) { 01060 jconf->amnow->mixnum_thres = atoi(argv[++i]); 01061 } 01062 continue; 01063 } else if (strmatch(argv[i],"-b2") || strmatch(argv[i],"-bw") || strmatch(argv[i],"-wb")) { /* word beam width in 2nd pass */ 01064 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 01065 GET_TMPARG; 01066 jconf->searchnow->pass2.enveloped_bestfirst_width = atoi(tmparg); 01067 continue; 01068 } else if (strmatch(argv[i],"-hgs")) { /* Gaussian selection model file */ 01069 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 01070 FREE_MEMORY(jconf->amnow->hmm_gs_filename); 01071 GET_TMPARG; 01072 jconf->amnow->hmm_gs_filename = filepath(tmparg, cwd); 01073 continue; 01074 } else if (strmatch(argv[i],"-booknum")) { /* num of state to select in GS */ 01075 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 01076 GET_TMPARG; 01077 jconf->amnow->gs_statenum = atoi(tmparg); 01078 continue; 01079 } else if (strmatch(argv[i],"-gshmm")) { /* same as "-hgs" */ 01080 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 01081 FREE_MEMORY(jconf->amnow->hmm_gs_filename); 01082 GET_TMPARG; 01083 jconf->amnow->hmm_gs_filename = filepath(tmparg, cwd); 01084 continue; 01085 } else if (strmatch(argv[i],"-gsnum")) { /* same as "-booknum" */ 01086 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 01087 GET_TMPARG; 01088 jconf->amnow->gs_statenum = atoi(tmparg); 01089 continue; 01090 } else if (strmatch(argv[i],"-cmnload")) { /* load CMN parameter from file */ 01091 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 01092 FREE_MEMORY(jconf->amnow->analysis.cmnload_filename); 01093 GET_TMPARG; 01094 jconf->amnow->analysis.cmnload_filename = filepath(tmparg, cwd); 01095 continue; 01096 } else if (strmatch(argv[i],"-cmnsave")) { /* save CMN parameter to file */ 01097 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 01098 FREE_MEMORY(jconf->amnow->analysis.cmnsave_filename); 01099 GET_TMPARG; 01100 jconf->amnow->analysis.cmnsave_filename = filepath(tmparg, cwd); 01101 continue; 01102 } else if (strmatch(argv[i],"-cmnupdate")) { /* update CMN parameter */ 01103 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 01104 jconf->amnow->analysis.cmn_update = TRUE; 01105 continue; 01106 } else if (strmatch(argv[i],"-cmnnoupdate")) { /* not update CMN parameter */ 01107 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 01108 jconf->amnow->analysis.cmn_update = FALSE; 01109 continue; 01110 } else if (strmatch(argv[i],"-cmnmapweight")) { /* CMN weight for MAP */ 01111 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 01112 GET_TMPARG; 01113 jconf->amnow->analysis.cmn_map_weight = (float)atof(tmparg); 01114 continue; 01115 } else if (strmatch(argv[i],"-sscalc")) { /* do spectral subtraction (SS) for raw file input */ 01116 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 01117 jconf->amnow->frontend.sscalc = TRUE; 01118 FREE_MEMORY(jconf->amnow->frontend.ssload_filename); 01119 continue; 01120 } else if (strmatch(argv[i],"-sscalclen")) { /* head silence length used to compute SS (in msec) */ 01121 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 01122 GET_TMPARG; 01123 jconf->amnow->frontend.sscalc_len = atoi(tmparg); 01124 continue; 01125 } else if (strmatch(argv[i],"-ssload")) { /* load SS parameter from file */ 01126 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 01127 FREE_MEMORY(jconf->amnow->frontend.ssload_filename); 01128 GET_TMPARG; 01129 jconf->amnow->frontend.ssload_filename = filepath(tmparg, cwd); 01130 jconf->amnow->frontend.sscalc = FALSE; 01131 continue; 01132 #ifdef CONFIDENCE_MEASURE 01133 } else if (strmatch(argv[i],"-cmalpha")) { /* CM log score scaling factor */ 01134 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 01135 #ifdef CM_MULTIPLE_ALPHA 01136 GET_TMPARG; 01137 jconf->searchnow->annotate.cm_alpha_bgn = (LOGPROB)atof(tmparg); 01138 GET_TMPARG; 01139 jconf->searchnow->annotate.cm_alpha_end = (LOGPROB)atof(tmparg); 01140 GET_TMPARG; 01141 jconf->searchnow->annotate.cm_alpha_step = (LOGPROB)atof(tmparg); 01142 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; 01143 if (jconf->searchnow->annotate.cm_alpha_num > 100) { 01144 jlog("ERROR: m_option: cm_alpha step num exceeds limit (100)\n"); 01145 return FALSE; 01146 } 01147 #else 01148 GET_TMPARG; 01149 jconf->searchnow->annotate.cm_alpha = (LOGPROB)atof(tmparg); 01150 #endif 01151 continue; 01152 #ifdef CM_SEARCH_LIMIT 01153 } else if (strmatch(argv[i],"-cmthres")) { /* CM cut threshold for CM decoding */ 01154 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 01155 GET_TMPARG; 01156 jconf->searchnow->annotate.cm_cut_thres = (LOGPROB)atof(tmparg); 01157 continue; 01158 #endif 01159 #ifdef CM_SEARCH_LIMIT_POP 01160 } else if (strmatch(argv[i],"-cmthres2")) { /* CM cut threshold for CM decoding */ 01161 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 01162 GET_TMPARG; 01163 jconf->searchnow->annotate.cm_cut_thres_pop = (LOGPROB)atof(tmparg); 01164 continue; 01165 #endif 01166 #endif /* CONFIDENCE_MEASURE */ 01167 } else if (strmatch(argv[i],"-gmm")) { /* load SS parameter from file */ 01168 if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; 01169 FREE_MEMORY(jconf->reject.gmm_filename); 01170 GET_TMPARG; 01171 jconf->reject.gmm_filename = filepath(tmparg, cwd); 01172 continue; 01173 } else if (strmatch(argv[i],"-gmmnum")) { /* num of Gaussian pruning for GMM */ 01174 if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; 01175 GET_TMPARG; 01176 jconf->reject.gmm_gprune_num = atoi(tmparg); 01177 continue; 01178 } else if (strmatch(argv[i],"-gmmreject")) { 01179 if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; 01180 GET_TMPARG; 01181 FREE_MEMORY(jconf->reject.gmm_reject_cmn_string); 01182 jconf->reject.gmm_reject_cmn_string = strcpy((char *)mymalloc(strlen(tmparg)+1), tmparg); 01183 continue; 01184 #ifdef GMM_VAD 01185 } else if (strmatch(argv[i],"-gmmmargin")) { /* backstep margin */ 01186 if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; 01187 GET_TMPARG; 01188 jconf->detect.gmm_margin = atoi(tmparg); 01189 continue; 01190 } else if (strmatch(argv[i],"-gmmup")) { /* uptrigger threshold */ 01191 if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; 01192 GET_TMPARG; 01193 jconf->detect.gmm_uptrigger_thres = atof(tmparg); 01194 continue; 01195 } else if (strmatch(argv[i],"-gmmdown")) { /* uptrigger threshold */ 01196 if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; 01197 GET_TMPARG; 01198 jconf->detect.gmm_downtrigger_thres = atof(tmparg); 01199 continue; 01200 #endif 01201 } else if (strmatch(argv[i],"-htkconf")) { 01202 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 01203 GET_TMPARG; 01204 tmparg = filepath(tmparg, cwd); 01205 if (htk_config_file_parse(tmparg, &(jconf->amnow->analysis.para_htk)) == FALSE) { 01206 jlog("ERROR: m_options: failed to read %s\n", tmparg); 01207 free(tmparg); 01208 return FALSE; 01209 } 01210 free(tmparg); 01211 continue; 01212 } else if (strmatch(argv[i], "-wlist")) { 01213 if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; 01214 GET_TMPARG; 01215 tmparg = filepath(tmparg, cwd); 01216 if (multigram_add_prefix_filelist(tmparg, jconf->lmnow, LM_DFA_WORD) == FALSE) { 01217 jlog("ERROR: m_options: failed to read some word lists\n"); 01218 free(tmparg); 01219 return FALSE; 01220 } 01221 free(tmparg); 01222 continue; 01223 } else if (strmatch(argv[i], "-wsil")) { 01224 /* 01225 * if (jconf->lmnow->lmvar != LM_UNDEF && jconf->lmnow->lmvar != LM_DFA_WORD) { 01226 * jlog("ERROR: \"-wsil\" only valid for isolated word recognition mode\n"); 01227 * return FALSE; 01228 * } 01229 */ 01230 if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; 01231 GET_TMPARG; 01232 strncpy(jconf->lmnow->wordrecog_head_silence_model_name, tmparg, MAX_HMMNAME_LEN); 01233 GET_TMPARG; 01234 strncpy(jconf->lmnow->wordrecog_tail_silence_model_name, tmparg, MAX_HMMNAME_LEN); 01235 GET_TMPARG; 01236 if (strmatch(tmparg, "NULL")) { 01237 jconf->lmnow->wordrecog_silence_context_name[0] = '\0'; 01238 } else { 01239 strncpy(jconf->lmnow->wordrecog_silence_context_name, tmparg, MAX_HMMNAME_LEN); 01240 } 01241 continue; 01242 #ifdef DETERMINE 01243 } else if (strmatch(argv[i], "-wed")) { 01244 //if (jconf->lmnow->lmvar != LM_UNDEF && jconf->lmnow->lmvar != LM_DFA_WORD) { 01245 //jlog("ERROR: \"-wed\" only valid for isolated word recognition mode\n"); 01246 //return FALSE; 01247 //} 01248 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 01249 GET_TMPARG; 01250 jconf->searchnow->pass1.determine_score_thres = atof(tmparg); 01251 GET_TMPARG; 01252 jconf->searchnow->pass1.determine_duration_thres = atoi(tmparg); 01253 continue; 01254 #endif 01255 } else if (strmatch(argv[i], "-inactive")) { /* start inactive */ 01256 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 01257 jconf->searchnow->sw.start_inactive = TRUE; 01258 continue; 01259 } else if (strmatch(argv[i], "-active")) { /* start active (default) */ 01260 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 01261 jconf->searchnow->sw.start_inactive = FALSE; 01262 continue; 01263 } else if (strmatch(argv[i],"-fallback1pass")) { /* use 1st pass result on search failure */ 01264 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 01265 jconf->searchnow->sw.fallback_pass1_flag = TRUE; 01266 continue; 01267 #ifdef ENABLE_PLUGIN 01268 } else if (strmatch(argv[i],"-plugindir")) { 01269 GET_TMPARG; 01270 plugin_load_dirs(tmparg); 01271 continue; 01272 #endif 01273 } 01274 if (argv[i][0] == '-' && strlen(argv[i]) == 2) { 01275 /* 1-letter options */ 01276 switch(argv[i][1]) { 01277 case 'h': /* hmmdefs */ 01278 if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; 01279 FREE_MEMORY(jconf->amnow->hmmfilename); 01280 GET_TMPARG; 01281 jconf->amnow->hmmfilename = filepath(tmparg, cwd); 01282 break; 01283 case 'v': /* dictionary */ 01284 if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; 01285 FREE_MEMORY(jconf->lmnow->dictfilename); 01286 GET_TMPARG; 01287 jconf->lmnow->dictfilename = filepath(tmparg, cwd); 01288 break; 01289 case 'w': /* word list (isolated word recognition) */ 01290 if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; 01291 GET_TMPARG; 01292 if (multigram_add_prefix_list(tmparg, cwd, jconf->lmnow, LM_DFA_WORD) == FALSE) { 01293 jlog("ERROR: m_options: failed to read some word list\n"); 01294 return FALSE; 01295 } 01296 break; 01297 case 'd': /* binary N-gram */ 01298 /* lmvar should be overriden by the content of the binary N-gram */ 01299 if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; 01300 FREE_MEMORY(jconf->lmnow->ngram_filename); 01301 FREE_MEMORY(jconf->lmnow->ngram_filename_lr_arpa); 01302 FREE_MEMORY(jconf->lmnow->ngram_filename_rl_arpa); 01303 GET_TMPARG; 01304 jconf->lmnow->ngram_filename = filepath(tmparg, cwd); 01305 break; 01306 case 'b': /* beam width in 1st pass */ 01307 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 01308 GET_TMPARG; 01309 jconf->searchnow->pass1.specified_trellis_beam_width = atoi(tmparg); 01310 break; 01311 case 's': /* stack size in 2nd pass */ 01312 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 01313 GET_TMPARG; 01314 jconf->searchnow->pass2.stack_size = atoi(tmparg); 01315 break; 01316 case 'n': /* N-best search */ 01317 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 01318 GET_TMPARG; 01319 jconf->searchnow->pass2.nbest = atoi(tmparg); 01320 break; 01321 case 'm': /* upper limit of hypothesis generation */ 01322 if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; 01323 GET_TMPARG; 01324 jconf->searchnow->pass2.hypo_overflow = atoi(tmparg); 01325 break; 01326 default: 01327 //jlog("ERROR: m_options: wrong argument: %s\n", argv[0], argv[i]); 01328 //return FALSE; 01329 unknown_opt = TRUE; 01330 } 01331 } else { /* error */ 01332 //jlog("ERROR: m_options: wrong argument: %s\n", argv[0], argv[i]); 01333 //return FALSE; 01334 unknown_opt = TRUE; 01335 } 01336 if (unknown_opt) { 01337 /* call user-side option processing */ 01338 switch(useropt_exec(jconf, argv, argc, &i)) { 01339 case 0: /* does not match user-side options */ 01340 jlog("ERROR: m_options: wrong argument: \"%s\"\n", argv[i]); 01341 return FALSE; 01342 case -1: /* Error in user-side function */ 01343 jlog("ERROR: m_options: error in processing \"%s\"\n", argv[i]); 01344 return FALSE; 01345 } 01346 } 01347 } 01348 01349 /* set default values if not specified yet */ 01350 for(atmp=jconf->am_root;atmp;atmp=atmp->next) { 01351 if (!atmp->spmodel_name) { 01352 atmp->spmodel_name = strcpy((char*)mymalloc(strlen(SPMODEL_NAME_DEFAULT)+1), 01353 SPMODEL_NAME_DEFAULT); 01354 } 01355 } 01356 for(ltmp=jconf->lm_root;ltmp;ltmp=ltmp->next) { 01357 if (!ltmp->head_silname) { 01358 ltmp->head_silname = strcpy((char*)mymalloc(strlen(BEGIN_WORD_DEFAULT)+1), 01359 BEGIN_WORD_DEFAULT); 01360 } 01361 if (!ltmp->tail_silname) { 01362 ltmp->tail_silname = strcpy((char*)mymalloc(strlen(END_WORD_DEFAULT)+1), 01363 END_WORD_DEFAULT); 01364 } 01365 if (!ltmp->iwspentry) { 01366 ltmp->iwspentry = strcpy((char*)mymalloc(strlen(IWSPENTRY_DEFAULT)+1), 01367 IWSPENTRY_DEFAULT); 01368 } 01369 } 01370 #ifdef USE_NETAUDIO 01371 if (!jconf->input.netaudio_devname) { 01372 jconf->input.netaudio_devname = strcpy((char*)mymalloc(strlen(NETAUDIO_DEVNAME)+1), 01373 NETAUDIO_DEVNAME); 01374 } 01375 #endif /* USE_NETAUDIO */ 01376 01377 return TRUE; 01378 } 01379 01393 void 01394 opt_release(Jconf *jconf) 01395 { 01396 JCONF_AM *am; 01397 JCONF_LM *lm; 01398 JCONF_SEARCH *s; 01399 01400 FREE_MEMORY(jconf->input.inputlist_filename); 01401 #ifdef USE_NETAUDIO 01402 FREE_MEMORY(jconf->input.netaudio_devname); 01403 #endif /* USE_NETAUDIO */ 01404 FREE_MEMORY(jconf->reject.gmm_filename); 01405 FREE_MEMORY(jconf->reject.gmm_reject_cmn_string); 01406 01407 for(am=jconf->am_root;am;am=am->next) { 01408 FREE_MEMORY(am->hmmfilename); 01409 FREE_MEMORY(am->mapfilename); 01410 FREE_MEMORY(am->spmodel_name); 01411 FREE_MEMORY(am->hmm_gs_filename); 01412 FREE_MEMORY(am->analysis.cmnload_filename); 01413 FREE_MEMORY(am->analysis.cmnsave_filename); 01414 FREE_MEMORY(am->frontend.ssload_filename); 01415 } 01416 for(lm=jconf->lm_root;lm;lm=lm->next) { 01417 FREE_MEMORY(lm->ngram_filename); 01418 FREE_MEMORY(lm->ngram_filename_lr_arpa); 01419 FREE_MEMORY(lm->ngram_filename_rl_arpa); 01420 FREE_MEMORY(lm->dfa_filename); 01421 FREE_MEMORY(lm->head_silname); 01422 FREE_MEMORY(lm->tail_silname); 01423 FREE_MEMORY(lm->iwspentry); 01424 FREE_MEMORY(lm->dictfilename); 01425 multigram_remove_gramlist(lm); 01426 } 01427 for(s=jconf->search_root;s;s=s->next) { 01428 FREE_MEMORY(s->successive.pausemodelname); 01429 } 01430 } 01431 01432 /* end of file */