void ld_finish(live_decoder_t * _decoder) { assert(_decoder != NULL); if (_decoder->fe != NULL) { fe_close(_decoder->fe); } if (_decoder->features != NULL) { /* consult the implementation of feat_array_alloc() for how to free our * internal feature vector buffer */ ckd_free((void *) **_decoder->features); ckd_free_2d((void **) _decoder->features); } if (_decoder->internal_cmdln == TRUE) { cmd_ln_free(); } kb_free(&_decoder->kb); ld_free_hyps(_decoder); if (_decoder->uttid != NULL) { ckd_free(_decoder->uttid); _decoder->uttid = NULL; } _decoder->ld_state = LD_STATE_FINISHED; }
int main(int argc, char *argv[]) { cmd_ln_parse(defn, argc, argv, TRUE); /* Run a control file if requested. */ if (cmd_ln_str("-c")) { if (run_control_file(cmd_ln_str("-c")) < 0) return 1; } else { if (extract_pitch(cmd_ln_str("-i"), cmd_ln_str("-o")) < 0) return 1; } cmd_ln_free(); return 0; }
int ld_finish(live_decoder_t *decoder) { cmd_ln_free(); /* lgalescu@ihmc -- this is not right! the string is allocated with decoder! ckd_free(decoder->kb.uttid); */ kb_free(&decoder->kb); /* consult the implementation of feat_array_alloc() for the following two * lines */ /* lgalescu@ihmc -- what's going on here? ckd_free((void *)decoder->features); ckd_free_2d((void **)decoder->features); */ /* lgalescu@ihmc -- replaced the two calls above with the following: */ ckd_free_3d((void ***)decoder->features); decoder->ld_state = LD_STATE_IDLE; return 0; }
void cmd_ln_appl_exit() { cmd_ln_free(); }
static int ld_init_impl(live_decoder_t * _decoder, int32 _internal_cmdln) { param_t fe_param; int rv = LD_SUCCESS; assert(_decoder != NULL); unlimit(); /* ARCHAN 20050708: This part should be factored with fe_parse_option */ /* allocate and initialize front-end */ fe_init_params(&fe_param); fe_param.SAMPLING_RATE = cmd_ln_float32("-samprate"); fe_param.FRAME_RATE = cmd_ln_int32("-frate"); fe_param.WINDOW_LENGTH = cmd_ln_float32("-wlen"); fe_param.FB_TYPE = strcmp("mel_scale", cmd_ln_str("-fbtype")) == 0 ? MEL_SCALE : LOG_LINEAR; fe_param.NUM_CEPSTRA = cmd_ln_int32("-ncep"); fe_param.NUM_FILTERS = cmd_ln_int32("-nfilt"); fe_param.FFT_SIZE = cmd_ln_int32("-nfft"); fe_param.LOWER_FILT_FREQ = cmd_ln_float32("-lowerf"); fe_param.UPPER_FILT_FREQ = cmd_ln_float32("-upperf"); fe_param.PRE_EMPHASIS_ALPHA = cmd_ln_float32("-alpha"); fe_param.dither = strcmp("no", cmd_ln_str("-dither")); fe_param.warp_type = cmd_ln_str("-warp_type"); fe_param.warp_params = cmd_ln_str("-warp_params"); if ((_decoder->fe = fe_init(&fe_param)) == NULL) { E_WARN("Failed to initialize front-end.\n"); rv = LD_ERROR_OUT_OF_MEMORY; goto ld_init_impl_cleanup; } /* capture decoder parameters */ kb_init(&_decoder->kb); /* initialize decoder variables */ _decoder->kbcore = _decoder->kb.kbcore; _decoder->hyp_frame_num = -1; _decoder->uttid = NULL; _decoder->ld_state = LD_STATE_IDLE; _decoder->hyp_str = NULL; _decoder->hyp_segs = NULL; /* _decoder->swap= (cmd_ln_int32("-machine_endian") != cmd_ln_int32("-input_endian")); */ _decoder->swap = (strcmp(cmd_ln_str("-machine_endian"), cmd_ln_str("-input_endian")) != 0); _decoder->phypdump = (cmd_ln_int32("-phypdump")); _decoder->rawext = (cmd_ln_str("-rawext")); if (_decoder->phypdump) E_INFO("Partial hypothesis WILL be dumped\n"); else E_INFO("Partial hypothesis will NOT be dumped\n"); if (_decoder->swap) E_INFO("Input data WILL be byte swapped\n"); else E_INFO("Input data will NOT be byte swapped\n"); _decoder->internal_cmdln = _internal_cmdln; _decoder->features = feat_array_alloc(kbcore_fcb(_decoder->kbcore), LIVEBUFBLOCKSIZE); if (_decoder->features == NULL) { E_WARN("Failed to allocate internal feature buffer.\n"); rv = LD_ERROR_OUT_OF_MEMORY; goto ld_init_impl_cleanup; } return LD_SUCCESS; ld_init_impl_cleanup: if (_decoder->fe != NULL) { fe_close(_decoder->fe); } if (_decoder->features != NULL) { /* consult the implementation of feat_array_alloc() for how to free our * internal feature vector buffer */ ckd_free((void *) **_decoder->features); ckd_free_2d((void **) _decoder->features); } if (_internal_cmdln == TRUE) { cmd_ln_free(); } _decoder->ld_state = LD_STATE_FINISHED; return rv; }