int sphinx_wave2feat_free(sphinx_wave2feat_t *wtf) { if (wtf == NULL) return 0; if (--wtf->refcount > 0) return wtf->refcount; if (wtf->audio) ckd_free(wtf->audio); if (wtf->feat) ckd_free_2d(wtf->feat); if (wtf->infile) ckd_free(wtf->infile); if (wtf->outfile) ckd_free(wtf->outfile); if (wtf->infh) { if (fclose(wtf->infh) == EOF) E_ERROR_SYSTEM("Failed to close input file"); } if (wtf->outfh) { if (fclose(wtf->outfh) == EOF) E_ERROR_SYSTEM("Failed to close output file"); } cmd_ln_free_r(wtf->config); fe_free(wtf->fe); ckd_free(wtf); return 0; }
int ofxSphinxASR::engineExit() { s3_decode_close(decoder); if (decoder != NULL) { delete decoder; decoder = NULL; } if (fe != NULL) { fe_free(fe); fe = NULL; } return OFXASR_SUCCESS; }
int main(int _argc, char **_argv) { char *ctrlfn; char *cfgfn; cmd_ln_t *config = NULL; print_appl_info(_argv[0]); if (_argc != 4) { printf("\nUSAGE: %s <ctrlfile> <rawdir> <cfgfile>\n", _argv[0]); return -1; } ctrlfn = _argv[1]; rawdirfn = _argv[2]; cfgfn = _argv[3]; if ((config = cmd_ln_parse_file_r(config, S3_DECODE_ARG_DEFS, cfgfn, TRUE)) == NULL) E_FATAL("Bad configuration file %s.\n", cfgfn); if (s3_decode_init(&decoder, config) != S3_DECODE_SUCCESS) E_FATAL("Failed to initialize live-decoder.\n"); fe = fe_init_auto_r(config); st = decoder.kb.stat; ptmr_init(&(st->tm)); if (ctrlfn) { /* When -ctlfile is speicified, corpus.c will look at -ctl_lm and -ctl_mllr to get the corresponding LM and MLLR for the utterance */ st->tm = ctl_process(ctrlfn, cmd_ln_str_r(config, "-ctl_lm"), cmd_ln_str_r(config, "-ctl_mllr"), cmd_ln_int32_r(config, "-ctloffset"), cmd_ln_int32_r(config, "-ctlcount"), utt_livepretend, &(decoder.kb)); } else { E_FATAL("control file is not specified.\n"); } stat_report_corpus(decoder.kb.stat); s3_decode_close(&decoder); fe_free(fe); return 0; }
static int process(sbthread_t *th) { FILE *raw; int16 *buf; mfcc_t **cepbuf; size_t nsamps; fe_t *fe; long fsize; int32 nfr; char outfile[16]; FILE *logfile; sprintf(outfile, "%03ld.log", (long) sbthread_arg(th)); logfile = fopen(outfile, "w"); pthread_setspecific(logfp_index, (void *)logfile); if ((fe = fe_init_auto_r(sbthread_config(th))) == NULL) return -1; if ((raw = fopen(TESTDATADIR "/chan3.raw", "rb")) == NULL) return -1; fseek(raw, 0, SEEK_END); fsize = ftell(raw); fseek(raw, 0, SEEK_SET); buf = ckd_malloc(fsize); fread(buf, 1, fsize, raw); nsamps = fsize / 2; fe_process_utt(fe, buf, nsamps, &cepbuf, &nfr); E_INFO("nfr = %d\n", nfr); fe_free_2d(cepbuf); ckd_free(buf); fclose(raw); fe_free(fe); fclose(logfile); return 0; }
void acmod_free(acmod_t *acmod) { if (acmod == NULL) return; feat_free(acmod->fcb); fe_free(acmod->fe); cmd_ln_free_r(acmod->config); if (acmod->mfc_buf) ckd_free_2d((void **)acmod->mfc_buf); if (acmod->feat_buf) feat_array_free(acmod->feat_buf); if (acmod->mfcfh) fclose(acmod->mfcfh); if (acmod->rawfh) fclose(acmod->rawfh); if (acmod->senfh) fclose(acmod->senfh); ckd_free(acmod->framepos); ckd_free(acmod->senone_scores); ckd_free(acmod->senone_active_vec); ckd_free(acmod->senone_active); ckd_free(acmod->rawdata); if (acmod->mdef) bin_mdef_free(acmod->mdef); if (acmod->tmat) tmat_free(acmod->tmat); if (acmod->mgau) ps_mgau_free(acmod->mgau); if (acmod->mllr) ps_mllr_free(acmod->mllr); ckd_free(acmod); }
int main(int argc, char *argv[]) { char const *cfg; int i; int16 buf[2048]; if (argc == 2) { config = cmd_ln_parse_file_r(NULL, cont_args_def, argv[1], TRUE); } else { config = cmd_ln_parse_r(NULL, cont_args_def, argc, argv, FALSE); } /* Handle argument file as -argfile. */ if (config && (cfg = cmd_ln_str_r(config, "-argfile")) != NULL) { config = cmd_ln_parse_file_r(config, cont_args_def, cfg, FALSE); } if (config == NULL) return 1; singlefile = cmd_ln_boolean_r(config, "-singlefile"); if ((infile_path = cmd_ln_str_r(config, "-infile")) != NULL) { if ((infile = fopen(infile_path, "rb")) == NULL) { E_FATAL_SYSTEM("Failed to read audio from '%s'", infile_path); return 1; } read_audio = &read_audio_file; /* skip wav header */ read_audio(buf, 44); } else { if ((ad = ad_open_dev(cmd_ln_str_r(config, "-adcdev"), (int) cmd_ln_float32_r(config, "-samprate"))) == NULL) { E_FATAL("Failed to open audio device\n"); return 1; } read_audio = &read_audio_adev; printf("Start recording ...\n"); fflush(stdout); if (ad_start_rec(ad) < 0) E_FATAL("Failed to start recording\n"); /* TODO remove this thing */ for (i = 0; i < 5; i++) { sleep_msec(200); read_audio(buf, 2048); } printf("You may speak now\n"); fflush(stdout); } fe = fe_init_auto_r(config); if (fe == NULL) return 1; segment_audio(); if (ad) ad_close(ad); if (infile) fclose(infile); fe_free(fe); cmd_ln_free_r(config); return 0; }
int main(int argc, char *argv[]) { static const arg_t fe_args[] = { waveform_to_cepstral_command_line_macro(), { NULL, 0, NULL, NULL } }; FILE *raw; cmd_ln_t *config; fe_t *fe; int16 buf[1024]; int16 const *inptr; int32 frame_shift, frame_size; mfcc_t **cepbuf1, **cepbuf2, **cptr; int32 nfr, i; size_t nsamp; TEST_ASSERT(config = cmd_ln_parse_r(NULL, fe_args, argc, argv, FALSE)); TEST_ASSERT(fe = fe_init_auto_r(config)); TEST_EQUAL(fe_get_output_size(fe), DEFAULT_NUM_CEPSTRA); fe_get_input_size(fe, &frame_shift, &frame_size); TEST_EQUAL(frame_shift, DEFAULT_FRAME_SHIFT); TEST_EQUAL(frame_size, (int)(DEFAULT_WINDOW_LENGTH*DEFAULT_SAMPLING_RATE)); TEST_ASSERT(raw = fopen(TESTDATADIR "/chan3.raw", "rb")); TEST_EQUAL(0, fe_start_utt(fe)); TEST_EQUAL(1024, fread(buf, sizeof(int16), 1024, raw)); nsamp = 1024; TEST_ASSERT(fe_process_frames(fe, NULL, &nsamp, NULL, &nfr) >= 0); TEST_EQUAL(1024, nsamp); TEST_EQUAL(4, nfr); cepbuf1 = ckd_calloc_2d(5, DEFAULT_NUM_CEPSTRA, sizeof(**cepbuf1)); inptr = &buf[0]; nfr = 1; printf("frame_size %d frame_shift %d\n", frame_size, frame_shift); /* Process the first frame. */ TEST_ASSERT(fe_process_frames(fe, &inptr, &nsamp, &cepbuf1[0], &nfr) >= 0); printf("inptr %d nsamp %d nfr %d\n", inptr - buf, nsamp, nfr); TEST_EQUAL(nfr, 1); /* Note that this next one won't actually consume any frames * of input, because it already got sufficient overflow * samples last time around. This is implementation-dependent * so we shouldn't actually test for it. */ TEST_ASSERT(fe_process_frames(fe, &inptr, &nsamp, &cepbuf1[1], &nfr) >= 0); printf("inptr %d nsamp %d nfr %d\n", inptr - buf, nsamp, nfr); TEST_EQUAL(nfr, 1); TEST_ASSERT(fe_process_frames(fe, &inptr, &nsamp, &cepbuf1[2], &nfr) >= 0); printf("inptr %d nsamp %d nfr %d\n", inptr - buf, nsamp, nfr); TEST_EQUAL(nfr, 1); TEST_ASSERT(fe_process_frames(fe, &inptr, &nsamp, &cepbuf1[3], &nfr) >= 0); printf("inptr %d nsamp %d nfr %d\n", inptr - buf, nsamp, nfr); TEST_EQUAL(nfr, 1); TEST_ASSERT(fe_end_utt(fe, cepbuf1[4], &nfr) >= 0); printf("nfr %d\n", nfr); TEST_EQUAL(nfr, 1); /* What we *should* test is that the output we get by * processing one frame at a time is exactly the same as what * we get from doing them all at once. So let's do that */ cepbuf2 = ckd_calloc_2d(5, DEFAULT_NUM_CEPSTRA, sizeof(**cepbuf2)); inptr = &buf[0]; nfr = 5; nsamp = 1024; TEST_EQUAL(0, fe_start_utt(fe)); TEST_ASSERT(fe_process_frames(fe, &inptr, &nsamp, cepbuf2, &nfr) >= 0); printf("nfr %d\n", nfr); TEST_EQUAL(nfr, 4); nfr = 1; TEST_ASSERT(fe_end_utt(fe, cepbuf2[4], &nfr) >= 0); printf("nfr %d\n", nfr); TEST_EQUAL(nfr, 1); for (i = 0; i < 5; ++i) { int j; printf("%d: ", i); for (j = 0; j < DEFAULT_NUM_CEPSTRA; ++j) { printf("%.2f,%.2f ", MFCC2FLOAT(cepbuf1[i][j]), MFCC2FLOAT(cepbuf2[i][j])); TEST_EQUAL_FLOAT(cepbuf1[i][j], cepbuf2[i][j]); } printf("\n"); } /* Now, also test to make sure that even if we feed data in * little tiny bits we can still make things work. */ memset(cepbuf2[0], 0, 5 * DEFAULT_NUM_CEPSTRA * sizeof(**cepbuf2)); inptr = &buf[0]; cptr = &cepbuf2[0]; nfr = 5; i = 5; nsamp = 256; TEST_EQUAL(0, fe_start_utt(fe)); TEST_ASSERT(fe_process_frames(fe, &inptr, &nsamp, cptr, &i) >= 0); printf("inptr %d nsamp %d nfr %d\n", inptr - buf, nsamp, i); cptr += i; nfr -= i; i = nfr; nsamp = 256; TEST_ASSERT(fe_process_frames(fe, &inptr, &nsamp, cptr, &i) >= 0); printf("inptr %d nsamp %d nfr %d\n", inptr - buf, nsamp, i); cptr += i; nfr -= i; i = nfr; nsamp = 256; TEST_ASSERT(fe_process_frames(fe, &inptr, &nsamp, cptr, &i) >= 0); printf("inptr %d nsamp %d nfr %d\n", inptr - buf, nsamp, i); cptr += i; nfr -= i; i = nfr; nsamp = 256; TEST_ASSERT(fe_process_frames(fe, &inptr, &nsamp, cptr, &i) >= 0); printf("inptr %d nsamp %d nfr %d\n", inptr - buf, nsamp, i); cptr += i; nfr -= i; TEST_ASSERT(fe_end_utt(fe, *cptr, &nfr) >= 0); printf("nfr %d\n", nfr); TEST_EQUAL(nfr, 1); for (i = 0; i < 5; ++i) { int j; printf("%d: ", i); for (j = 0; j < DEFAULT_NUM_CEPSTRA; ++j) { printf("%.2f,%.2f ", MFCC2FLOAT(cepbuf1[i][j]), MFCC2FLOAT(cepbuf2[i][j])); TEST_EQUAL_FLOAT(cepbuf1[i][j], cepbuf2[i][j]); } printf("\n"); } /* And now, finally, test fe_process_utt() */ inptr = &buf[0]; i = 0; TEST_EQUAL(0, fe_start_utt(fe)); TEST_ASSERT(fe_process_utt(fe, inptr, 256, &cptr, &nfr) >= 0); printf("i %d nfr %d\n", i, nfr); if (nfr) memcpy(cepbuf2[i], cptr[0], nfr * DEFAULT_NUM_CEPSTRA * sizeof(**cptr)); ckd_free_2d(cptr); i += nfr; inptr += 256; TEST_ASSERT(fe_process_utt(fe, inptr, 256, &cptr, &nfr) >= 0); printf("i %d nfr %d\n", i, nfr); if (nfr) memcpy(cepbuf2[i], cptr[0], nfr * DEFAULT_NUM_CEPSTRA * sizeof(**cptr)); ckd_free_2d(cptr); i += nfr; inptr += 256; TEST_ASSERT(fe_process_utt(fe, inptr, 256, &cptr, &nfr) >= 0); printf("i %d nfr %d\n", i, nfr); if (nfr) memcpy(cepbuf2[i], cptr[0], nfr * DEFAULT_NUM_CEPSTRA * sizeof(**cptr)); ckd_free_2d(cptr); i += nfr; inptr += 256; TEST_ASSERT(fe_process_utt(fe, inptr, 256, &cptr, &nfr) >= 0); printf("i %d nfr %d\n", i, nfr); if (nfr) memcpy(cepbuf2[i], cptr[0], nfr * DEFAULT_NUM_CEPSTRA * sizeof(**cptr)); ckd_free_2d(cptr); i += nfr; inptr += 256; TEST_ASSERT(fe_end_utt(fe, cepbuf2[i], &nfr) >= 0); printf("i %d nfr %d\n", i, nfr); TEST_EQUAL(nfr, 1); for (i = 0; i < 5; ++i) { int j; printf("%d: ", i); for (j = 0; j < DEFAULT_NUM_CEPSTRA; ++j) { printf("%.2f,%.2f ", MFCC2FLOAT(cepbuf1[i][j]), MFCC2FLOAT(cepbuf2[i][j])); TEST_EQUAL_FLOAT(cepbuf1[i][j], cepbuf2[i][j]); } printf("\n"); } ckd_free_2d(cepbuf1); ckd_free_2d(cepbuf2); fclose(raw); fe_free(fe); return 0; }
fe_t * fe_init_auto_r(cmd_ln_t *config) { fe_t *fe; int prespch_frame_len; fe = (fe_t*)ckd_calloc(1, sizeof(*fe)); fe->refcount = 1; /* transfer params to front end */ if (fe_parse_general_params(cmd_ln_retain(config), fe) < 0) { fe_free(fe); return NULL; } /* compute remaining fe parameters */ /* We add 0.5 so approximate the float with the closest * integer. E.g., 2.3 is truncate to 2, whereas 3.7 becomes 4 */ fe->frame_shift = (int32) (fe->sampling_rate / fe->frame_rate + 0.5); fe->frame_size = (int32) (fe->window_length * fe->sampling_rate + 0.5); fe->prior = 0; fe_start_stream(fe); assert (fe->frame_shift > 1); if (fe->frame_size < fe->frame_shift) { E_ERROR ("Frame size %d (-wlen) must be greater than frame shift %d (-frate)\n", fe->frame_size, fe->frame_shift); fe_free(fe); return NULL; } if (fe->frame_size > (fe->fft_size)) { E_ERROR ("Number of FFT points has to be a power of 2 higher than %d, it is %d\n", fe->frame_size, fe->fft_size); fe_free(fe); return NULL; } if (fe->dither) fe_init_dither(fe->seed); /* establish buffers for overflow samps and hamming window */ fe->overflow_samps = ckd_calloc(fe->frame_size, sizeof(int16)); fe->hamming_window = ckd_calloc(fe->frame_size/2, sizeof(window_t)); /* create hamming window */ fe_create_hamming(fe->hamming_window, fe->frame_size); /* init and fill appropriate filter structure */ fe->mel_fb = ckd_calloc(1, sizeof(*fe->mel_fb)); /* transfer params to mel fb */ fe_parse_melfb_params(config, fe, fe->mel_fb); if (fe->mel_fb->upper_filt_freq > fe->sampling_rate / 2 + 1.0) { E_ERROR("Upper frequency %.1f is higher than samprate/2 (%.1f)\n", fe->mel_fb->upper_filt_freq, fe->sampling_rate / 2); fe_free(fe); return NULL; } fe_build_melfilters(fe->mel_fb); fe_compute_melcosine(fe->mel_fb); if (fe->remove_noise || fe->remove_silence) fe->noise_stats = fe_init_noisestats(fe->mel_fb->num_filters); fe->vad_data = (vad_data_t*)ckd_calloc(1, sizeof(*fe->vad_data)); prespch_frame_len = fe->log_spec != RAW_LOG_SPEC ? fe->num_cepstra : fe->mel_fb->num_filters; fe->vad_data->prespch_buf = fe_prespch_init(fe->pre_speech + 1, prespch_frame_len, fe->frame_shift); /* Create temporary FFT, spectrum and mel-spectrum buffers. */ /* FIXME: Gosh there are a lot of these. */ fe->spch = ckd_calloc(fe->frame_size, sizeof(*fe->spch)); fe->frame = ckd_calloc(fe->fft_size, sizeof(*fe->frame)); fe->spec = ckd_calloc(fe->fft_size, sizeof(*fe->spec)); fe->mfspec = ckd_calloc(fe->mel_fb->num_filters, sizeof(*fe->mfspec)); /* create twiddle factors */ fe->ccc = ckd_calloc(fe->fft_size / 4, sizeof(*fe->ccc)); fe->sss = ckd_calloc(fe->fft_size / 4, sizeof(*fe->sss)); fe_create_twiddle(fe); if (cmd_ln_boolean_r(config, "-verbose")) { fe_print_current(fe); } /*** Initialize the overflow buffers ***/ fe_start_utt(fe); return fe; }
fe_t * fe_init_auto_r(cmd_ln_t *config) { fe_t *fe; fe = ckd_calloc(1, sizeof(*fe)); fe->refcount = 1; /* transfer params to front end */ if (fe_parse_general_params(cmd_ln_retain(config), fe) < 0) { fe_free(fe); return NULL; } /* compute remaining fe parameters */ /* We add 0.5 so approximate the float with the closest * integer. E.g., 2.3 is truncate to 2, whereas 3.7 becomes 4 */ fe->frame_shift = (int32) (fe->sampling_rate / fe->frame_rate + 0.5); fe->frame_size = (int32) (fe->window_length * fe->sampling_rate + 0.5); fe->prior = 0; fe->frame_counter = 0; assert (fe->frame_shift > 1); if (fe->frame_size > (fe->fft_size)) { E_WARN ("Number of FFT points has to be a power of 2 higher than %d\n", (fe->frame_size)); fe_free(fe); return (NULL); } if (fe->dither) fe_init_dither(fe->seed); /* establish buffers for overflow samps and hamming window */ fe->overflow_samps = ckd_calloc(fe->frame_size, sizeof(int16)); fe->hamming_window = ckd_calloc(fe->frame_size/2, sizeof(window_t)); /* create hamming window */ fe_create_hamming(fe->hamming_window, fe->frame_size); /* init and fill appropriate filter structure */ fe->mel_fb = ckd_calloc(1, sizeof(*fe->mel_fb)); /* transfer params to mel fb */ fe_parse_melfb_params(config, fe, fe->mel_fb); fe_build_melfilters(fe->mel_fb); fe_compute_melcosine(fe->mel_fb); /* Create temporary FFT, spectrum and mel-spectrum buffers. */ /* FIXME: Gosh there are a lot of these. */ fe->spch = ckd_calloc(fe->frame_size, sizeof(*fe->spch)); fe->frame = ckd_calloc(fe->fft_size, sizeof(*fe->frame)); fe->spec = ckd_calloc(fe->fft_size, sizeof(*fe->spec)); fe->mfspec = ckd_calloc(fe->mel_fb->num_filters, sizeof(*fe->mfspec)); /* create twiddle factors */ fe->ccc = ckd_calloc(fe->fft_size / 4, sizeof(*fe->ccc)); fe->sss = ckd_calloc(fe->fft_size / 4, sizeof(*fe->sss)); fe_create_twiddle(fe); if (cmd_ln_boolean_r(config, "-verbose")) { fe_print_current(fe); } /*** Z.A.B. ***/ /*** Initialize the overflow buffers ***/ fe_start_utt(fe); return fe; }
int sphinx_wave2feat_convert_file(sphinx_wave2feat_t *wtf, char const *infile, char const *outfile) { int nchans, minfft, nfft, nfloat, veclen; audio_type_t const *atype; int fshift, fsize; if (cmd_ln_boolean_r(wtf->config, "-verbose")) E_INFO("Converting %s to %s\n", infile, outfile); wtf->infile = ckd_salloc(infile); /* Detect input file type. */ if ((atype = detect_audio_type(wtf)) == NULL) return -1; /* Determine whether to byteswap input. */ wtf->byteswap = strcmp(cmd_ln_str_r(wtf->config, "-mach_endian"), cmd_ln_str_r(wtf->config, "-input_endian")); /* Make sure the FFT size is sufficiently large. */ minfft = (int)(cmd_ln_float32_r(wtf->config, "-samprate") * cmd_ln_float32_r(wtf->config, "-wlen") + 0.5); for (nfft = 1; nfft < minfft; nfft <<= 1) ; if (nfft > cmd_ln_int32_r(wtf->config, "-nfft")) { E_WARN("Value of -nfft = %d is too small, increasing to %d\n", cmd_ln_int32_r(wtf->config, "-nfft"), nfft); cmd_ln_set_int32_r(wtf->config, "-nfft", nfft); fe_free(wtf->fe); wtf->fe = fe_init_auto_r(wtf->config); } /* Get the output frame size (if not already set). */ if (wtf->veclen == 0) wtf->veclen = fe_get_output_size(wtf->fe); /* Set up the input and output buffers. */ fe_get_input_size(wtf->fe, &fshift, &fsize); /* Want to get at least a whole frame plus shift in here. Also we will either pick or mix multiple channels so we need to read them all at once. */ nchans = cmd_ln_int32_r(wtf->config, "-nchans"); wtf->blocksize = cmd_ln_int32_r(wtf->config, "-blocksize") * nchans; if (wtf->blocksize < (fsize + fshift) * nchans) { E_INFO("Block size of %d too small, increasing to %d\n", wtf->blocksize, (fsize + fshift) * nchans); wtf->blocksize = (fsize + fshift) * nchans; } wtf->audio = (short *)ckd_calloc(wtf->blocksize, sizeof(*wtf->audio)); wtf->featsize = (wtf->blocksize / nchans - fsize) / fshift; /* Use the maximum of the input and output frame sizes to allocate this. */ veclen = wtf->veclen; if (wtf->in_veclen > veclen) veclen = wtf->in_veclen; wtf->feat = (mfcc_t**)ckd_calloc_2d(wtf->featsize, veclen, sizeof(**wtf->feat)); /* Let's go! */ if ((wtf->outfh = fopen(outfile, "wb")) == NULL) { E_ERROR_SYSTEM("Failed to open %s for writing", outfile); return -1; } /* Write an empty header, which we'll fill in later. */ if (wtf->ot->output_header && (*wtf->ot->output_header)(wtf, 0) < 0) { E_ERROR_SYSTEM("Failed to write empty header to %s\n", outfile); goto error_out; } wtf->outfile = ckd_salloc(outfile); if ((nfloat = (*atype->decode)(wtf)) < 0) { E_ERROR("Failed to convert"); goto error_out; } if (wtf->ot->output_header) { if (fseek(wtf->outfh, 0, SEEK_SET) < 0) { E_ERROR_SYSTEM("Failed to seek to beginning of %s\n", outfile); goto error_out; } if ((*wtf->ot->output_header)(wtf, nfloat) < 0) { E_ERROR_SYSTEM("Failed to write header to %s\n", outfile); goto error_out; } } if (wtf->audio) ckd_free(wtf->audio); if (wtf->feat) ckd_free_2d(wtf->feat); if (wtf->infile) ckd_free(wtf->infile); if (wtf->outfile) ckd_free(wtf->outfile); wtf->audio = NULL; wtf->infile = NULL; wtf->feat = NULL; wtf->outfile = NULL; if (wtf->outfh) if (fclose(wtf->outfh) == EOF) E_ERROR_SYSTEM("Failed to close output file"); wtf->outfh = NULL; return 0; error_out: if (wtf->audio) ckd_free(wtf->audio); if (wtf->feat) ckd_free_2d(wtf->feat); if (wtf->infile) ckd_free(wtf->infile); if (wtf->outfile) ckd_free(wtf->outfile); wtf->audio = NULL; wtf->infile = NULL; wtf->feat = NULL; wtf->outfile = NULL; if (wtf->outfh) if (fclose(wtf->outfh) == EOF) E_ERROR_SYSTEM("Failed to close output file"); wtf->outfh = NULL; return -1; }