00001
00017
00018
00019
00020
00021
00022
00023
00024 #include <julius.h>
00025
00050 char *
00051 filepath(char *filename, char *dirname)
00052 {
00053 char *p;
00054 if (dirname != NULL && filename[0] != '/'
00055 #if defined(_WIN32)
00056 && filename[0] != '\\' && !(strlen(filename) >= 3 && filename[1] == ':')
00057 #endif
00058 ) {
00059 p = (char *)mymalloc(strlen(filename) + strlen(dirname) + 1);
00060 strcpy(p, dirname);
00061 strcat(p, filename);
00062 } else {
00063 p = strcpy((char *)mymalloc(strlen(filename)+1), filename);
00064 }
00065 return p;
00066 }
00067
00084 static char *
00085 args_needed_exit(char *opt)
00086 {
00087 j_printerr("%s: option requires argument -- %s\n", EXECNAME, opt);
00088 opt_terminate();
00089 return(NULL);
00090 }
00091
00108 void
00109 opt_parse(int argc, char *argv[], char *cwd)
00110 {
00111 char *tmparg;
00112 int i;
00113
00114 #define NEXTARG (++i >= argc) ? (char *)args_needed_exit(argv[i-1]) : argv[i]
00115
00116 if (argc == 1) {
00117 usage();
00118 }
00119
00120 for (i=1;i<argc;i++) {
00121 if (strmatch(argv[i],"-C")) {
00122 tmparg = filepath(NEXTARG, cwd);
00123 config_file_parse(tmparg);
00124 free(tmparg);
00125 continue;
00126 } else if (strmatch(argv[i],"-input")) {
00127 tmparg = NEXTARG;
00128 if (strmatch(tmparg,"file")) {
00129 speech_input = SP_RAWFILE;
00130 realtime_flag = FALSE;
00131 } else if (strmatch(tmparg,"rawfile")) {
00132 speech_input = SP_RAWFILE;
00133 realtime_flag = FALSE;
00134 } else if (strmatch(tmparg,"htkparam")) {
00135 speech_input = SP_MFCFILE;
00136 realtime_flag = FALSE;
00137 } else if (strmatch(tmparg,"mfcfile")) {
00138 speech_input = SP_MFCFILE;
00139 realtime_flag = FALSE;
00140 } else if (strmatch(tmparg,"stdin")) {
00141 speech_input = SP_STDIN;
00142 realtime_flag = FALSE;
00143 } else if (strmatch(tmparg,"adinnet")) {
00144 speech_input = SP_ADINNET;
00145 realtime_flag = TRUE;
00146 #ifdef USE_NETAUDIO
00147 } else if (strmatch(tmparg,"netaudio")) {
00148 speech_input = SP_NETAUDIO;
00149 realtime_flag = TRUE;
00150 #endif
00151 #ifdef USE_MIC
00152 } else if (strmatch(tmparg,"mic")) {
00153 speech_input = SP_MIC;
00154 realtime_flag = TRUE;
00155 #endif
00156 } else if (strmatch(tmparg,"file")) {
00157 speech_input = SP_RAWFILE;
00158 realtime_flag = FALSE;
00159 } else if (strmatch(tmparg,"mfc")) {
00160 speech_input = SP_MFCFILE;
00161 realtime_flag = FALSE;
00162 } else {
00163 j_printerr("%s: no such speech input source \"%s\" supported\n", argv[0], tmparg);
00164 opt_terminate();
00165 }
00166 continue;
00167 } else if (strmatch(argv[i],"-filelist")) {
00168 if (inputlist_filename) free(inputlist_filename);
00169 tmparg = NEXTARG;
00170 inputlist_filename = strcpy((char*)mymalloc(strlen(tmparg)+1),tmparg);
00171 continue;
00172 } else if (strmatch(argv[i],"-record")) {
00173 if (record_dirname) free(record_dirname);
00174 tmparg = NEXTARG;
00175 record_dirname = strcpy((char*)mymalloc(strlen(tmparg)+1),tmparg);
00176 continue;
00177 } else if (strmatch(argv[i],"-rejectshort")) {
00178 rejectshortlen = atoi(NEXTARG);
00179 continue;
00180 } else if (strmatch(argv[i],"-module")) {
00181 module_mode = TRUE;
00182 if (i+1 < argc) {
00183 if (argv[i+1][0] >= '0' && argv[i+1][0] <= '9') {
00184 module_port = atoi(NEXTARG);
00185 }
00186 }
00187
00188 result_output = SP_RESULT_MSOCK;
00189 continue;
00190 } else if (strmatch(argv[i],"-result")) {
00191 tmparg = NEXTARG;
00192 if (strmatch(tmparg,"tty")) {
00193 result_output = SP_RESULT_TTY;
00194 } else if (strmatch(tmparg,"msock")) {
00195 result_output = SP_RESULT_MSOCK;
00196 } else {
00197 j_printerr("%s: no such result output \"%s\"\n", argv[0], tmparg);
00198 opt_terminate();
00199 }
00200 continue;
00201 } else if (strmatch(argv[i],"-outcode")) {
00202 decode_output_selection(NEXTARG);
00203 continue;
00204 } else if (strmatch(argv[i],"-force_realtime")) {
00205 tmparg = NEXTARG;
00206 if (strmatch(tmparg, "on")) {
00207 forced_realtime = TRUE;
00208 } else if (strmatch(tmparg, "off")) {
00209 forced_realtime = FALSE;
00210 } else {
00211 j_printerr("%s: \"-force_realtime\" allows \"on\" or \"off\" only\n", EXECNAME);
00212 opt_terminate();
00213 }
00214 force_realtime_flag = TRUE;
00215 continue;
00216 } else if (strmatch(argv[i],"-realtime")) {
00217 forced_realtime = TRUE;
00218 force_realtime_flag = TRUE;
00219 continue;
00220 } else if (strmatch(argv[i], "-norealtime")) {
00221 forced_realtime = FALSE;
00222 force_realtime_flag = TRUE;
00223 continue;
00224 } else if (strmatch(argv[i],"-forcedict")) {
00225 forcedict_flag = TRUE;
00226 continue;
00227 } else if (strmatch(argv[i],"-check")) {
00228 tmparg = NEXTARG;
00229 if (strmatch(tmparg, "wchmm")) {
00230 wchmm_check_flag = TRUE;
00231 } else if (strmatch(tmparg, "trellis")) {
00232 trellis_check_flag = TRUE;
00233 } else if (strmatch(tmparg, "triphone")) {
00234 triphone_check_flag = TRUE;
00235 } else {
00236 j_printerr("%s: invalid check style: %s\n", argv[0], tmparg);
00237 opt_terminate();
00238 }
00239 continue;
00240 } else if (strmatch(argv[i],"-notypecheck")) {
00241 paramtype_check_flag = FALSE;
00242 continue;
00243 } else if (strmatch(argv[i],"-separatescore")) {
00244 #ifdef USE_NGRAM
00245 separate_score_flag = TRUE;
00246 #else
00247 j_printerr("Warning: option \"-separatescore\" ignored\n");
00248 #endif
00249 continue;
00250 } else if (strmatch(argv[i],"-nlimit")) {
00251 #ifdef WPAIR_KEEP_NLIMIT
00252 wpair_keep_nlimit = atoi(NEXTARG);
00253 #else
00254 j_printerr("Warning: option \"-nlimit\" ignored\n");
00255 #endif
00256 continue;
00257 } else if (strmatch(argv[i],"-lookuprange")) {
00258 lookup_range = atoi(NEXTARG);
00259 continue;
00260 #ifdef GRAPHOUT
00261 } else if (strmatch(argv[i],"-graphrange")) {
00262 graph_merge_neighbor_range = atoi(NEXTARG);
00263 continue;
00264 #ifdef GRAPHOUT_DEPTHCUT
00265 } else if (strmatch(argv[i],"-graphcut")) {
00266 graphout_cut_depth = atoi(NEXTARG);
00267 continue;
00268 #endif
00269 #ifdef GRAPHOUT_LIMIT_BOUNDARY_LOOP
00270 } else if (strmatch(argv[i],"-graphboundloop")) {
00271 graphout_limit_boundary_loop_num = atoi(NEXTARG);
00272 continue;
00273 #endif
00274 #ifdef GRAPHOUT_SEARCH_DELAY_TERMINATION
00275 } else if (strmatch(argv[i],"-graphsearchdelay")) {
00276 graphout_search_delay = TRUE;
00277 continue;
00278 } else if (strmatch(argv[i],"-nographsearchdelay")) {
00279 graphout_search_delay = FALSE;
00280 continue;
00281 #endif
00282 #endif
00283 #ifdef USE_DFA
00284 } else if (strmatch(argv[i],"-looktrellis")) {
00285 looktrellis_flag = TRUE;
00286 continue;
00287 } else if (strmatch(argv[i],"-multigramout")) {
00288 multigramout_flag = TRUE;
00289 continue;
00290 } else if (strmatch(argv[i],"-nomultigramout")) {
00291 multigramout_flag = FALSE;
00292 continue;
00293 #endif
00294 #ifdef CATEGORY_TREE
00295 } else if (strmatch(argv[i],"-oldtree")) {
00296 old_tree_function_flag = TRUE;
00297 continue;
00298 #ifdef PASS1_IWCD
00299 } else if (strmatch(argv[i],"-oldiwcd")) {
00300 old_iwcd_flag = TRUE;
00301 continue;
00302 #endif
00303 #endif
00304 } else if (strmatch(argv[i],"-sb")) {
00305 #ifdef SCAN_BEAM
00306 scan_beam_thres = atof(NEXTARG);
00307 #else
00308 j_printerr("Warning: option \"-sb\" ignored\n");
00309 #endif
00310 continue;
00311 } else if (strmatch(argv[i],"-discount")) {
00312 j_printerr("Warning: option \"-discount\" ignored\n");
00313 continue;
00314 } else if (strmatch(argv[i],"-cutsilence")) {
00315 silence_cut = 1;
00316 continue;
00317 } else if (strmatch(argv[i],"-nocutsilence")) {
00318 silence_cut = 0;
00319 continue;
00320 } else if (strmatch(argv[i],"-pausesegment")) {
00321 silence_cut = 1;
00322 continue;
00323 } else if (strmatch(argv[i],"-nopausesegment")) {
00324 silence_cut = 0;
00325 continue;
00326 } else if (strmatch(argv[i],"-lv")) {
00327 level_thres = atoi(NEXTARG);
00328 continue;
00329 } else if (strmatch(argv[i],"-zc")) {
00330 zero_cross_num = atoi(NEXTARG);
00331 continue;
00332 } else if (strmatch(argv[i],"-headmargin")) {
00333 head_margin_msec = atoi(NEXTARG);
00334 continue;
00335 } else if (strmatch(argv[i],"-tailmargin")) {
00336 tail_margin_msec = atoi(NEXTARG);
00337 continue;
00338 } else if (strmatch(argv[i],"-hipass")||strmatch(argv[i],"-hifreq")) {
00339 para.hipass = atoi(NEXTARG);
00340 continue;
00341 } else if (strmatch(argv[i],"-lopass")||strmatch(argv[i],"-lofreq")) {
00342 para.lopass = atoi(NEXTARG);
00343 continue;
00344 } else if (strmatch(argv[i],"-smpPeriod")) {
00345 para.smp_period = atoi(NEXTARG);
00346 para.smp_freq = period2freq(para.smp_period);
00347 continue;
00348 } else if (strmatch(argv[i],"-smpFreq")) {
00349 para.smp_freq = atoi(NEXTARG);
00350 para.smp_period = freq2period(para.smp_freq);
00351 continue;
00352 } else if (strmatch(argv[i],"-fsize")) {
00353 para.framesize = atoi(NEXTARG);
00354 continue;
00355 } else if (strmatch(argv[i],"-fshift")) {
00356 para.frameshift = atoi(NEXTARG);
00357 continue;
00358 } else if (strmatch(argv[i],"-preemph")) {
00359 para.preEmph = atof(NEXTARG);
00360 continue;
00361 } else if (strmatch(argv[i],"-fbank")) {
00362 para.fbank_num = atoi(NEXTARG);
00363 continue;
00364 } else if (strmatch(argv[i],"-ceplif")) {
00365 para.lifter = atoi(NEXTARG);
00366 continue;
00367 } else if (strmatch(argv[i],"-rawe")) {
00368 para.raw_e = TRUE;
00369 continue;
00370 } else if (strmatch(argv[i],"-norawe")) {
00371 para.raw_e = FALSE;
00372 continue;
00373 } else if (strmatch(argv[i],"-enormal")) {
00374 para.enormal = TRUE;
00375 continue;
00376 } else if (strmatch(argv[i],"-noenormal")) {
00377 para.enormal = FALSE;
00378 continue;
00379 } else if (strmatch(argv[i],"-escale")) {
00380 para.escale = atof(NEXTARG);
00381 continue;
00382 } else if (strmatch(argv[i],"-silfloor")) {
00383 para.silFloor = atof(NEXTARG);
00384 continue;
00385 } else if (strmatch(argv[i],"-delwin")) {
00386 para.delWin = atoi(NEXTARG);
00387 continue;
00388 } else if (strmatch(argv[i],"-accwin")) {
00389 para.accWin = atoi(NEXTARG);
00390 continue;
00391 } else if (strmatch(argv[i],"-ssalpha")) {
00392 para.ss_alpha = atof(NEXTARG);
00393 continue;
00394 } else if (strmatch(argv[i],"-ssfloor")) {
00395 para.ss_floor = atof(NEXTARG);
00396 continue;
00397 } else if (strmatch(argv[i],"-version") || strmatch(argv[i], "--version") || strmatch(argv[i], "-setting") || strmatch(argv[i], "--setting")) {
00398 put_header(stderr);
00399 put_compile_defs(stderr);
00400 j_printerr("\n");
00401 put_library_defs(stderr);
00402 j_exit();
00403 } else if (strmatch(argv[i],"-quiet")) {
00404 debug2_flag = verbose_flag = FALSE;
00405 continue;
00406 } else if (strmatch(argv[i],"-debug")) {
00407 debug2_flag = verbose_flag = TRUE;
00408 continue;
00409 } else if (strmatch(argv[i],"-progout")) {
00410 progout_flag = TRUE;
00411 continue;
00412 } else if (strmatch(argv[i],"-proginterval")) {
00413 progout_interval = atoi(NEXTARG);
00414 continue;
00415 } else if (strmatch(argv[i],"-nocharconv")) {
00416 #ifdef CHARACTER_CONVERSION
00417 if (from_code) free(from_code);
00418 if (to_code) free(to_code);
00419 from_code = NULL;
00420 to_code = NULL;
00421 #else
00422 j_printerr("Warning: character set conversion disabled, option \"-nocharconv\" ignored\n");
00423 #endif
00424 continue;
00425 } else if (strmatch(argv[i],"-charconv")) {
00426 #ifdef CHARACTER_CONVERSION
00427 if (from_code) free(from_code);
00428 if (to_code) free(to_code);
00429 tmparg = NEXTARG;
00430 from_code = strcpy((char*)mymalloc(strlen(tmparg)+1),tmparg);
00431 tmparg = NEXTARG;
00432 to_code = strcpy((char*)mymalloc(strlen(tmparg)+1),tmparg);
00433 #else
00434 j_printerr("Warning: character set conversion disabled, option \"-charconv\" ignored\n");
00435 i+=2;
00436 #endif
00437 continue;
00438 } else if (strmatch(argv[i],"-kanji")) {
00439 #ifdef CHARACTER_CONVERSION
00440 if (from_code) free(from_code);
00441 if (to_code) free(to_code);
00442 from_code = NULL;
00443 tmparg = NEXTARG;
00444 if (strmatch(tmparg, "noconv")) {
00445 to_code = NULL;
00446 } else {
00447 to_code = strcpy((char*)mymalloc(strlen(tmparg)+1),tmparg);
00448 }
00449 #else
00450 j_printerr("Warning: character set conversion disabled, option \"-kanji\" ignored\n");
00451 i++;
00452 #endif
00453 continue;
00454 } else if (strmatch(argv[i],"-demo")) {
00455 debug2_flag = verbose_flag = FALSE;
00456 progout_flag = TRUE;
00457 continue;
00458 } else if (strmatch(argv[i],"-walign")) {
00459 align_result_word_flag = TRUE;
00460 continue;
00461 } else if (strmatch(argv[i],"-palign")) {
00462 align_result_phoneme_flag = TRUE;
00463 continue;
00464 } else if (strmatch(argv[i],"-salign")) {
00465 align_result_state_flag = TRUE;
00466 continue;
00467 } else if (strmatch(argv[i],"-output")) {
00468 output_hypo_maxnum = atoi(NEXTARG);
00469 continue;
00470 } else if (strmatch(argv[i],"-1pass")) {
00471 compute_only_1pass = TRUE;
00472 continue;
00473 } else if (strmatch(argv[i],"-hlist")) {
00474 if (mapfilename) free(mapfilename);
00475 mapfilename = filepath(NEXTARG, cwd);
00476 continue;
00477 #ifdef USE_NGRAM
00478 } else if (strmatch(argv[i],"-nlr")) {
00479 if (ngram_filename_lr_arpa) free(ngram_filename_lr_arpa);
00480 ngram_filename_lr_arpa = filepath(NEXTARG, cwd);
00481 if (ngram_filename) free(ngram_filename);
00482 ngram_filename = NULL;
00483 continue;
00484 } else if (strmatch(argv[i],"-nrl")) {
00485 if (ngram_filename_rl_arpa) free(ngram_filename_rl_arpa);
00486 ngram_filename_rl_arpa = filepath(NEXTARG, cwd);
00487 if (ngram_filename) free(ngram_filename);
00488 ngram_filename = NULL;
00489 continue;
00490 } else if (strmatch(argv[i],"-lmp")) {
00491 lm_weight = (LOGPROB)atof(NEXTARG);
00492 lm_penalty = (LOGPROB)atof(NEXTARG);
00493 lmp_specified = TRUE;
00494 continue;
00495 } else if (strmatch(argv[i],"-lmp2")) {
00496 lm_weight2 = (LOGPROB)atof(NEXTARG);
00497 lm_penalty2 = (LOGPROB)atof(NEXTARG);
00498 lmp2_specified = TRUE;
00499 continue;
00500 } else if (strmatch(argv[i],"-transp")) {
00501 lm_penalty_trans = (LOGPROB)atof(NEXTARG);
00502 continue;
00503 #else
00504 } else if (strmatch(argv[i],"-gram")) {
00505 multigram_add_prefix_list(NEXTARG, cwd);
00506 continue;
00507 } else if (strmatch(argv[i],"-gramlist")) {
00508 tmparg = filepath(NEXTARG, cwd);
00509 multigram_add_prefix_filelist(tmparg);
00510 free(tmparg);
00511 continue;
00512 } else if (strmatch(argv[i],"-nogram")) {
00513 multigram_remove_gramlist();
00514 if (dfa_filename) {
00515 free(dfa_filename);
00516 dfa_filename = NULL;
00517 }
00518 if (dictfilename) {
00519 free(dictfilename);
00520 dictfilename = NULL;
00521 }
00522 continue;
00523 } else if (strmatch(argv[i],"-dfa")) {
00524 if (dfa_filename) free(dfa_filename);
00525 dfa_filename = filepath(NEXTARG, cwd);
00526 continue;
00527 } else if (strmatch(argv[i],"-penalty1")) {
00528 penalty1 = (LOGPROB)atof(NEXTARG);
00529 continue;
00530 } else if (strmatch(argv[i],"-penalty2")) {
00531 penalty2 = (LOGPROB)atof(NEXTARG);
00532 continue;
00533 #endif
00534 } else if (strmatch(argv[i],"-spmodel") || strmatch(argv[i], "-sp")) {
00535 if (spmodel_name) free(spmodel_name);
00536 tmparg = NEXTARG;
00537 spmodel_name = strcpy((char*)mymalloc(strlen(tmparg)+1),tmparg);
00538 continue;
00539 #ifdef MULTIPATH_VERSION
00540 } else if (strmatch(argv[i],"-iwsp")) {
00541 enable_iwsp = TRUE;
00542 continue;
00543 } else if (strmatch(argv[i],"-iwsppenalty")) {
00544 iwsp_penalty = atof(NEXTARG);
00545 continue;
00546 #endif
00547 #ifdef USE_NGRAM
00548 } else if (strmatch(argv[i],"-silhead")) {
00549 if (head_silname) free(head_silname);
00550 tmparg = NEXTARG;
00551 head_silname = strcpy((char*)mymalloc(strlen(tmparg)+1),tmparg);
00552 continue;
00553 } else if (strmatch(argv[i],"-siltail")) {
00554 if (tail_silname) free(tail_silname);
00555 tmparg = NEXTARG;
00556 tail_silname = strcpy((char*)mymalloc(strlen(tmparg)+1),tmparg);
00557 continue;
00558 } else if (strmatch(argv[i],"-iwspword")) {
00559 enable_iwspword = TRUE;
00560 continue;
00561 } else if (strmatch(argv[i],"-iwspentry")) {
00562 if (iwspentry) free(iwspentry);
00563 tmparg = NEXTARG;
00564 iwspentry = strcpy((char*)mymalloc(strlen(tmparg)+1),tmparg);
00565 continue;
00566 } else if (strmatch(argv[i],"-iwcache")) {
00567 #ifdef HASH_CACHE_IW
00568 iw_cache_rate = atof(NEXTARG);
00569 if (iw_cache_rate > 100) iw_cache_rate = 100;
00570 if (iw_cache_rate < 1) iw_cache_rate = 1;
00571 #else
00572 j_printerr("Warning: option \"-iwcache\" ignored\n");
00573 #endif
00574 continue;
00575 } else if (strmatch(argv[i],"-sepnum")) {
00576 #ifdef SEPARATE_BY_UNIGRAM
00577 separate_wnum = atoi(NEXTARG);
00578 #else
00579 j_printerr("Warning: option \"-sepnum\" ignored\n");
00580 i++;
00581 #endif
00582 continue;
00583 #endif
00584 #ifdef USE_NETAUDIO
00585 } else if (strmatch(argv[i],"-NA")) {
00586 if (netaudio_devname) free(netaudio_devname);
00587 tmparg = NEXTARG;
00588 netaudio_devname = strcpy((char*)mymalloc(strlen(tmparg)+1),tmparg);
00589 continue;
00590 #endif
00591 } else if (strmatch(argv[i],"-adport")) {
00592 adinnet_port = atoi(NEXTARG);
00593 continue;
00594 } else if (strmatch(argv[i],"-nostrip")) {
00595 strip_zero_sample = FALSE;
00596 continue;
00597 } else if (strmatch(argv[i],"-zmean")) {
00598 use_zmean = TRUE;
00599 continue;
00600 } else if (strmatch(argv[i],"-nozmean")) {
00601 use_zmean = FALSE;
00602 continue;
00603 } else if (strmatch(argv[i],"-zmeanframe")) {
00604 para.zmeanframe = TRUE;
00605 continue;
00606 } else if (strmatch(argv[i],"-nozmeanframe")) {
00607 para.zmeanframe = FALSE;
00608 continue;
00609 #ifdef SP_BREAK_CURRENT_FRAME
00610 } else if (strmatch(argv[i],"-spdur")) {
00611 sp_frame_duration = atoi(NEXTARG);
00612 continue;
00613 #endif
00614 } else if (strmatch(argv[i],"-gprune")) {
00615 tmparg = NEXTARG;
00616 if (strmatch(tmparg,"safe")) {
00617 gprune_method = GPRUNE_SEL_SAFE;
00618 } else if (strmatch(tmparg,"heuristic")) {
00619 gprune_method = GPRUNE_SEL_HEURISTIC;
00620 } else if (strmatch(tmparg,"beam")) {
00621 gprune_method = GPRUNE_SEL_BEAM;
00622 } else if (strmatch(tmparg,"none")) {
00623 gprune_method = GPRUNE_SEL_NONE;
00624 } else if (strmatch(tmparg,"default")) {
00625 gprune_method = GPRUNE_SEL_UNDEF;
00626 } else {
00627 j_printerr("%s: no such pruning method \"%s\"\n", argv[0], tmparg);
00628 opt_terminate();
00629 }
00630 continue;
00631
00632
00633
00634
00635
00636 } else if (strmatch(argv[i],"-no_ccd")) {
00637 ccd_flag = FALSE;
00638 ccd_flag_force = TRUE;
00639 continue;
00640 } else if (strmatch(argv[i],"-force_ccd")) {
00641 ccd_flag = TRUE;
00642 ccd_flag_force = TRUE;
00643 continue;
00644 } else if (strmatch(argv[i],"-iwcd1")) {
00645 tmparg = NEXTARG;
00646 if (strmatch(tmparg, "max")) {
00647 iwcdmethod = IWCD_MAX;
00648 } else if (strmatch(tmparg, "avg")) {
00649 iwcdmethod = IWCD_AVG;
00650 } else if (strmatch(tmparg, "best")) {
00651 iwcdmethod = IWCD_NBEST;
00652 tmparg = NEXTARG;
00653 iwcdmaxn = atoi(tmparg);
00654 } else {
00655 j_printerr("%s: -iwcd1: wrong argument (max|avg|best N): %s\n", argv[0], tmparg);
00656 opt_terminate();
00657 }
00658 continue;
00659 } else if (strmatch(argv[i],"-tmix")) {
00660 if (i + 1 < argc && isdigit(argv[i+1][0])) {
00661 mixnum_thres = atoi(argv[++i]);
00662 }
00663 continue;
00664 } else if (strmatch(argv[i],"-b2") || strmatch(argv[i],"-bw") || strmatch(argv[i],"-wb")) {
00665 enveloped_bestfirst_width = atoi(NEXTARG);
00666 continue;
00667 } else if (strmatch(argv[i],"-hgs")) {
00668 if (hmm_gs_filename) free(hmm_gs_filename);
00669 hmm_gs_filename = filepath(NEXTARG, cwd);
00670 continue;
00671 } else if (strmatch(argv[i],"-booknum")) {
00672 gs_statenum = atoi(NEXTARG);
00673 continue;
00674 } else if (strmatch(argv[i],"-gshmm")) {
00675 if (hmm_gs_filename) free(hmm_gs_filename);
00676 hmm_gs_filename = filepath(NEXTARG, cwd);
00677 continue;
00678 } else if (strmatch(argv[i],"-gsnum")) {
00679 gs_statenum = atoi(NEXTARG);
00680 continue;
00681 } else if (strmatch(argv[i],"-cmnload")) {
00682 if (cmnload_filename) free(cmnload_filename);
00683 cmnload_filename = filepath(NEXTARG, cwd);
00684 continue;
00685 } else if (strmatch(argv[i],"-cmnsave")) {
00686 if (cmnsave_filename) free(cmnsave_filename);
00687 cmnsave_filename = filepath(NEXTARG, cwd);
00688 continue;
00689 } else if (strmatch(argv[i],"-cmnupdate")) {
00690 cmn_update = TRUE;
00691 continue;
00692 } else if (strmatch(argv[i],"-cmnnoupdate")) {
00693 cmn_update = FALSE;
00694 continue;
00695 } else if (strmatch(argv[i],"-cmnmapweight")) {
00696 cmn_map_weight = (float)atof(NEXTARG);
00697 continue;
00698 } else if (strmatch(argv[i],"-sscalc")) {
00699 sscalc = TRUE;
00700 if (ssload_filename) free(ssload_filename);
00701 ssload_filename = NULL;
00702 continue;
00703 } else if (strmatch(argv[i],"-sscalclen")) {
00704 sscalc_len = atoi(NEXTARG);
00705 continue;
00706 } else if (strmatch(argv[i],"-ssload")) {
00707 if (ssload_filename) free(ssload_filename);
00708 ssload_filename = filepath(NEXTARG, cwd);
00709 sscalc = FALSE;
00710 continue;
00711 #ifdef CONFIDENCE_MEASURE
00712 } else if (strmatch(argv[i],"-cmalpha")) {
00713 #ifdef CM_MULTIPLE_ALPHA
00714 cm_alpha_bgn = (LOGPROB)atof(NEXTARG);
00715 cm_alpha_end = (LOGPROB)atof(NEXTARG);
00716 cm_alpha_step = (LOGPROB)atof(NEXTARG);
00717 cm_alpha_num = (int)((cm_alpha_end - cm_alpha_bgn) / cm_alpha_step) + 1;
00718 if (cm_alpha_num > 100) j_error("too small step or wide range! outputnum > 100\n");
00719 #else
00720 cm_alpha = (LOGPROB)atof(NEXTARG);
00721 #endif
00722 continue;
00723 #ifdef CM_SEARCH_LIMIT
00724 } else if (strmatch(argv[i],"-cmthres")) {
00725 cm_cut_thres = (LOGPROB)atof(NEXTARG);
00726 continue;
00727 #endif
00728 #ifdef CM_SEARCH_LIMIT_POP
00729 } else if (strmatch(argv[i],"-cmthres2")) {
00730 cm_cut_thres_pop = (LOGPROB)atof(NEXTARG);
00731 continue;
00732 #endif
00733 #endif
00734 } else if (strmatch(argv[i],"-gmm")) {
00735 if (gmm_filename) free(gmm_filename);
00736 gmm_filename = filepath(NEXTARG, cwd);
00737 continue;
00738 } else if (strmatch(argv[i],"-gmmnum")) {
00739 gmm_gprune_num = atoi(NEXTARG);
00740 continue;
00741 } else if (strmatch(argv[i],"-gmmreject")) {
00742 tmparg = NEXTARG;
00743 gmm_reject_cmn_string = strcpy((char *)mymalloc(strlen(tmparg)+1), tmparg);
00744 continue;
00745 } else if (strmatch(argv[i],"-htkconf")) {
00746 tmparg = NEXTARG;
00747 if (htk_config_file_parse(tmparg, ¶_htk) == FALSE) {
00748 j_error("Error: failed to read %s\n", tmparg);
00749 }
00750 continue;
00751 } else if (strmatch(argv[i],"-help")) {
00752 detailed_help();
00753 } else if (strmatch(argv[i],"--help")) {
00754 detailed_help();
00755 }
00756 if (argv[i][0] == '-' && strlen(argv[i]) == 2) {
00757
00758 switch(argv[i][1]) {
00759 case 'h':
00760 if (hmmfilename) free(hmmfilename);
00761 hmmfilename = filepath(NEXTARG, cwd);
00762 break;
00763 case 'v':
00764 if (dictfilename) free(dictfilename);
00765 dictfilename = filepath(NEXTARG, cwd);
00766 break;
00767 #ifdef USE_NGRAM
00768 case 'd':
00769 if (ngram_filename) free(ngram_filename);
00770 if (ngram_filename_lr_arpa) free(ngram_filename_lr_arpa);
00771 if (ngram_filename_rl_arpa) free(ngram_filename_rl_arpa);
00772 ngram_filename = filepath(NEXTARG, cwd);
00773 ngram_filename_lr_arpa = NULL;
00774 ngram_filename_rl_arpa = NULL;
00775 break;
00776 #endif
00777 case 'b':
00778 specified_trellis_beam_width = atoi(NEXTARG);
00779 break;
00780 case 's':
00781 stack_size = atoi(NEXTARG);
00782 break;
00783 case 'n':
00784 nbest = atoi(NEXTARG);
00785 break;
00786 case 'm':
00787 hypo_overflow = atoi(NEXTARG);
00788 break;
00789 default:
00790 j_printerr("%s: wrong argument: %s\n", argv[0], argv[i]);
00791 opt_terminate();
00792 }
00793 } else {
00794 j_printerr("%s: wrong argument: %s\n", argv[0], argv[i]);
00795 opt_terminate();
00796 }
00797 }
00798
00799
00800 if (!spmodel_name) {
00801 spmodel_name = strcpy((char*)mymalloc(strlen(SPMODEL_NAME_DEFAULT)+1),
00802 SPMODEL_NAME_DEFAULT);
00803 }
00804 #ifdef USE_NGRAM
00805 if (!head_silname) {
00806 head_silname = strcpy((char*)mymalloc(strlen(BEGIN_WORD_DEFAULT)+1),
00807 BEGIN_WORD_DEFAULT);
00808 }
00809 if (!tail_silname) {
00810 tail_silname = strcpy((char*)mymalloc(strlen(END_WORD_DEFAULT)+1),
00811 END_WORD_DEFAULT);
00812 }
00813 if (!iwspentry) {
00814 iwspentry = strcpy((char*)mymalloc(strlen(IWSPENTRY_DEFAULT)+1),
00815 IWSPENTRY_DEFAULT);
00816 }
00817 #endif
00818 #ifdef USE_NETAUDIO
00819 if (!netaudio_devname) {
00820 netaudio_devname = strcpy((char*)mymalloc(strlen(NETAUDIO_DEVNAME)+1),
00821 NETAUDIO_DEVNAME);
00822 }
00823 #endif
00824 }
00825
00834 void
00835 opt_release()
00836 {
00837 if (inputlist_filename) {
00838 free(inputlist_filename);
00839 inputlist_filename = NULL;
00840 }
00841 if (record_dirname) {
00842 free(record_dirname);
00843 record_dirname = NULL;
00844 }
00845 #ifdef CHARACTER_CONVERSION
00846 if (from_code) {
00847 free(from_code);
00848 from_code = NULL;
00849 }
00850 if (to_code) {
00851 free(to_code);
00852 to_code = NULL;
00853 }
00854 #endif
00855 if (mapfilename) {
00856 free(mapfilename);
00857 mapfilename = NULL;
00858 }
00859 #ifdef USE_NGRAM
00860 if (ngram_filename) {
00861 free(ngram_filename);
00862 ngram_filename = NULL;
00863 }
00864 if (ngram_filename_lr_arpa) {
00865 free(ngram_filename_lr_arpa);
00866 ngram_filename_lr_arpa = NULL;
00867 }
00868 if (ngram_filename_rl_arpa) {
00869 free(ngram_filename_rl_arpa);
00870 ngram_filename_rl_arpa = NULL;
00871 }
00872 #endif
00873 #ifdef USE_DFA
00874 if (dfa_filename) {
00875 free(dfa_filename);
00876 dfa_filename = NULL;
00877 }
00878 #endif
00879 if (spmodel_name) {
00880 free(spmodel_name);
00881 spmodel_name = NULL;
00882 }
00883 #ifdef USE_NGRAM
00884 if (head_silname) {
00885 free(head_silname);
00886 head_silname = NULL;
00887 }
00888 if (tail_silname) {
00889 free(tail_silname);
00890 tail_silname = NULL;
00891 }
00892 if (iwspentry) {
00893 free(iwspentry);
00894 iwspentry = NULL;
00895 }
00896 #endif
00897 #ifdef USE_NETAUDIO
00898 if (netaudio_devname) {
00899 free(netaudio_devname);
00900 netaudio_devname = NULL;
00901 }
00902 #endif
00903 if (hmm_gs_filename) {
00904 free(hmm_gs_filename);
00905 hmm_gs_filename = NULL;
00906 }
00907 if (cmnload_filename) {
00908 free(cmnload_filename);
00909 cmnload_filename = NULL;
00910 }
00911 if (cmnsave_filename) {
00912 free(cmnsave_filename);
00913 cmnsave_filename = NULL;
00914 }
00915 if (ssload_filename) {
00916 free(ssload_filename);
00917 ssload_filename = NULL;
00918 }
00919 if (gmm_filename) {
00920 free(gmm_filename);
00921 gmm_filename = NULL;
00922 }
00923 if (gmm_reject_cmn_string) {
00924 free(gmm_reject_cmn_string);
00925 gmm_reject_cmn_string = NULL;
00926 }
00927 if (hmmfilename) {
00928 free(hmmfilename);
00929 hmmfilename = NULL;
00930 }
00931 if (dictfilename) {
00932 free(dictfilename);
00933 dictfilename = NULL;
00934 }
00935 }