Beispiel #1
0
int
rd_gau_full(const char *fn, uint32 n_o)
{
    if (s3gau_read_full(fn,
			&igau_full,
			&n_cb_i,
			&n_stream,
			&n_density,
			&veclen) != S3_SUCCESS)
	return S3_ERROR;

    n_cb_o = n_o;
    
    ogau_full = (vector_t ****)gauden_alloc_param_full(n_cb_o,
						       n_stream,
						       n_density,
						       veclen);
    return S3_SUCCESS;
}
Beispiel #2
0
static int
init_state(const char *obsdmp,
	   const char *obsidx,
	   uint32 n_density,
	   uint32 n_stream,
	   const uint32 *veclen,
	   int reest,
	   const char *mixwfn,
	   const char *meanfn,
	   const char *varfn,
	   uint32 ts_off,
	   uint32 ts_cnt,
	   uint32 n_ts,
	   uint32 n_d_ts)
{
    uint32 blksz;
    vector_t ***mean;
    vector_t ***var = NULL;
    vector_t ****fullvar = NULL;
    float32  ***mixw = NULL;
    uint32 n_frame;
    uint32 ignore = 0;
    codew_t *label;
    uint32 n_corpus = 0;
    float64 sqerr;
    float64 tot_sqerr;
    segdmp_type_t t;
    uint32 i, j, ts, n;
    timing_t *km_timer;
    timing_t *var_timer;
    timing_t *em_timer;
    int32 full_covar;

    km_timer = timing_get("km");
    var_timer = timing_get("var");
    em_timer = timing_get("em");
    
    blksz = feat_blksize();

    full_covar = cmd_ln_int32("-fullvar");
    /* fully-continuous for now */
    mean = gauden_alloc_param(ts_cnt, n_stream, n_density, veclen);
    if (full_covar)
	    fullvar  = gauden_alloc_param_full(ts_cnt, n_stream, n_density, veclen);
    else
	    var  = gauden_alloc_param(ts_cnt, n_stream, n_density, veclen);
    if (mixwfn)
	mixw = (float32 ***)ckd_calloc_3d(ts_cnt,
					  n_stream,
					  n_density,
					  sizeof(float32));

    if ((const char *)cmd_ln_access("-segidxfn")) {
	E_INFO("Multi-class dump\n");
	if (segdmp_open_read((const char **)cmd_ln_access("-segdmpdirs"),
			     (const char *)cmd_ln_access("-segdmpfn"),
			     (const char *)cmd_ln_access("-segidxfn"),
			     &n,
			     &t) != S3_SUCCESS) {
	    E_FATAL("Unable to open dumps\n");
	}

	if (n != n_d_ts) {
	    E_FATAL("Expected %u tied-states in dump, but apparently %u\n",
		    n_d_ts, n);
	}
	if (t != SEGDMP_TYPE_FEAT) {
	    E_FATAL("Expected feature dump, but instead saw %u\n", t);
	}
	
	multiclass = TRUE;
    }
    else {
	E_INFO("1-class dump file\n");
	
	multiclass = FALSE;
	
	dmp_fp = s3open((const char *)cmd_ln_access("-segdmpfn"), "rb",
			&dmp_swp);
	if (dmp_fp == NULL) {
	    E_ERROR_SYSTEM("Unable to open dump file %s for reading\n",
			   (const char *)cmd_ln_access("-segdmpfn"));

	    return S3_ERROR;
	}

	if (s3read(&n_frame, sizeof(uint32), 1, dmp_fp, dmp_swp, &ignore) != 1) {
	    E_ERROR_SYSTEM("Unable to open dump file %s for reading\n",
			   (const char *)cmd_ln_access("-segdmpfn"));

	    return S3_ERROR;
	}

	data_offset = ftell(dmp_fp);
    }

    tot_sqerr = 0;
    for (i = 0; i < ts_cnt; i++) {
	ts = ts_off + i;

	/* stride not accounted for yet */
	if (o2d == NULL) {
	    if (multiclass)
		n_frame = segdmp_n_seg(ts);
	}
	else {
	    for (j = 0, n_frame = 0; j < n_o2d[ts]; j++) {
		n_frame += segdmp_n_seg(o2d[ts][j]);
	    }
	}
    
	E_INFO("Corpus %u: sz==%u frames%s\n",
	       ts, n_frame,
	       (n_frame > *(uint32 *)cmd_ln_access("-vartiethr") ? "" : " tied var"));

	if (n_frame == 0) {
	    continue;
	}


	E_INFO("Convergence ratios are abs(cur - prior) / abs(prior)\n");
	/* Do some variety of k-means clustering */
	if (km_timer)
	    timing_start(km_timer);
	sqerr = cluster(ts, n_stream, n_frame, veclen, mean[i], n_density, &label);
	if (km_timer)
	    timing_stop(km_timer);

	if (sqerr < 0) {
	    E_ERROR("Unable to do k-means for state %u; skipping...\n", ts);

	    continue;
	}

	/* Given the k-means and assuming equal prior liklihoods
	 * compute the variances */
	if (var_timer)
	    timing_start(var_timer);
	if (full_covar)
		full_variances(ts, mean[i], fullvar[i], n_density, veclen,
			       n_frame, n_stream, label);
	else
		variances(ts, mean[i], var[i], n_density, veclen, n_frame, n_stream, label);
	if (var_timer)
	    timing_stop(var_timer);

	if (mixwfn) {
	    /* initialize the mixing weights by counting # of occurrances
	     * of the top codeword over the corpus and normalizing */
	    init_mixw(mixw[i], mean[i], n_density, veclen, n_frame, n_stream, label);

	    ckd_free(label);

	    if (reest == TRUE && full_covar)
		E_ERROR("EM re-estimation is not yet supported for full covariances\n");
	    else if (reest == TRUE) {
		if (em_timer)
		    timing_start(em_timer);
		/* Do iterations of EM to estimate the mixture densities */
		reest_sum(ts, mean[i], var[i], mixw[i], n_density, n_stream,
			  n_frame, veclen,
			  *(uint32 *)cmd_ln_access("-niter"),
			  FALSE,
			  *(uint32 *)cmd_ln_access("-vartiethr"));
		if (em_timer)
		    timing_stop(em_timer);
	    }
	}
	
	++n_corpus;
	tot_sqerr += sqerr;
	    
	E_INFO("sqerr [%u] == %e\n", ts, sqerr);
    }

    if (n_corpus > 0) {
	E_INFO("sqerr = %e tot %e rms\n", tot_sqerr, sqrt(tot_sqerr/n_corpus));
    }

    if (!multiclass)
	s3close(dmp_fp);
    
    if (meanfn) {
	if (s3gau_write(meanfn,
			(const vector_t ***)mean,
			ts_cnt,
			n_stream,
			n_density,
			veclen) != S3_SUCCESS) {
	    return S3_ERROR;
	}
    }
    else {
	E_INFO("No mean file given; none written\n");
    }
		    
    if (varfn) {
	if (full_covar) {
	    if (s3gau_write_full(varfn,
				 (const vector_t ****)fullvar,
				 ts_cnt,
				 n_stream,
				 n_density,
				 veclen) != S3_SUCCESS)
		return S3_ERROR;
	}
	else {
	    if (s3gau_write(varfn,
				 (const vector_t ***)var,
				 ts_cnt,
				 n_stream,
				 n_density,
				 veclen) != S3_SUCCESS)
		return S3_ERROR;
	}
    }
    else {
	E_INFO("No variance file given; none written\n");
    }

    if (mixwfn) {
	if (s3mixw_write(mixwfn,
			 mixw,
			 ts_cnt,
			 n_stream,
			 n_density) != S3_SUCCESS) {
	    return S3_ERROR;
	}
    }
    else {
	E_INFO("No mixing weight file given; none written\n");
    }

    return S3_SUCCESS;
}
Beispiel #3
0
int
main(int argc, char *argv[])
{
    vector_t ***mean;
    vector_t ***var = NULL;
    vector_t ****fullvar = NULL;
    vector_t ***new_mean;
    vector_t ***new_var = NULL;
    vector_t ****new_fullvar = NULL;
    float32  ***dnom;
    float32 ***mixw;
    float32 ***new_mixw;
    uint32 n_mixw;
    uint32 n_mgau;
    uint32 n_dnom;
    uint32 n_feat;
    uint32 n_density;
    uint32 n_inc;
    uint32 *veclen;
    int32 var_is_full;

    parse_cmd_ln(argc, argv);

    E_INFO("Reading mixing weight file %s.\n",
	   cmd_ln_str("-inmixwfn"));

    if (s3mixw_read(cmd_ln_str("-inmixwfn"),
		    &mixw,
		    &n_mixw,
		    &n_feat,
		    &n_density) != S3_SUCCESS) {
	return 1;
    }

    n_inc = cmd_ln_int32("-ninc");

    if (n_inc > n_density) {
	E_WARN("# of densities to split (== %u) > total # of densities/mixture (== %u); # split <- %u # den/mix\n",
	       n_inc, n_density, n_density);
	n_inc = n_density;
    }
    
    if (s3gau_read(cmd_ln_str("-inmeanfn"),
		   &mean,
		   &n_mgau,
		   &n_feat,
		   &n_density,
		   &veclen) != S3_SUCCESS) {
	return 1;
    }

    var_is_full = cmd_ln_int32("-fullvar");
    if (var_is_full) {
	if (s3gau_read_full(cmd_ln_str("-invarfn"),
			    &fullvar,
			    &n_mgau,
			    &n_feat,
			    &n_density,
			    &veclen) != S3_SUCCESS) {
	    return 1;
	}
    }
    else {
	if (s3gau_read(cmd_ln_str("-invarfn"),
		       &var,
		       &n_mgau,
		       &n_feat,
		       &n_density,
		       &veclen) != S3_SUCCESS) {
	    return 1;
	}
    }

    if (s3gaudnom_read(cmd_ln_str("-dcountfn"),
		       &dnom,
		       &n_dnom,
		       &n_feat,
		       &n_density) != S3_SUCCESS) {
	return 1;
    }
	
    new_mean = gauden_alloc_param(n_mgau, n_feat, n_density+n_inc, veclen);
    if (var_is_full)
	    new_fullvar  = gauden_alloc_param_full(n_mgau, n_feat, n_density+n_inc, veclen);
    else
	    new_var  = gauden_alloc_param(n_mgau, n_feat, n_density+n_inc, veclen);
    new_mixw = (float32 ***)ckd_calloc_3d(n_mixw, n_feat, n_density+n_inc,
					  sizeof(float32));
    
    E_INFO("output n_density == %u\n", n_density+n_inc);

    inc_densities(new_mixw,
		  new_mean,
		  new_var,
		  new_fullvar,

		  mixw,
		  mean,
		  var,
		  fullvar,
		  dnom,

		  n_mixw,
		  n_mgau,
		  n_dnom,
		  n_feat,
		  n_density,
		  veclen,

		  n_inc);

    if (cmd_ln_str("-outmixwfn") != NULL) {
	if (s3mixw_write(cmd_ln_str("-outmixwfn"),
			 new_mixw,
			 n_mixw,
			 n_feat,
			 n_density+n_inc) != S3_SUCCESS) {
	    return 1;
	}
    }
    else {
	E_FATAL("You must use the -outmixwfn argument\n");
    }

    if (cmd_ln_str("-outmeanfn") != NULL) {
	if (s3gau_write(cmd_ln_str("-outmeanfn"),
			(const vector_t ***)new_mean,
			n_mgau,
			n_feat,
			n_density+n_inc,
			veclen) != S3_SUCCESS) {
	    return 1;
	}
    }
    else {
	E_FATAL("You must use the -outmeanfn argument\n");
    }

    if (cmd_ln_str("-outvarfn") != NULL) {
	if (var_is_full) {
	    if (s3gau_write_full(cmd_ln_str("-outvarfn"),
				 (const vector_t ****)new_fullvar,
				 n_mgau,
				 n_feat,
				 n_density+n_inc,
				 veclen) != S3_SUCCESS) {
		return 1;
	    }
	}
	else {
	    if (s3gau_write(cmd_ln_str("-outvarfn"),
			    (const vector_t ***)new_var,
			    n_mgau,
			    n_feat,
			    n_density+n_inc,
			    veclen) != S3_SUCCESS) {
		return 1;
	    }
	}
    }
    else {
	E_FATAL("You must use the -outvarfn argument\n");
    }

    return 0;
}
Beispiel #4
0
static int
init_mixw()
{
    model_def_t *src_mdef;
    float32 ***src_mixw;
    vector_t ***src_mean;
    vector_t ***src_var = NULL;
    vector_t ****src_fullvar = NULL;
    float32 ***src_tmat;

    model_def_t *dest_mdef;
    float32 ***dest_mixw;
    vector_t ***dest_mean;
    vector_t ***dest_var = NULL;
    vector_t ****dest_fullvar = NULL;
    float32 ***dest_tmat;

    uint32 n_mixw_src;
    uint32 n_mixw_dest;
    uint32 n_feat;
    uint32 tmp_n_feat;
    uint32 n_gau;
    uint32 tmp_n_gau;
    uint32 n_cb_src;
    uint32 n_cb_dest;
    uint32 n_state_pm;
    uint32 n_tmat_src;
    uint32 n_tmat_dest;
    uint32 *veclen;
    uint32 *tmp_veclen;

    uint32 m;
    uint32 dest_m;
    uint32 dest_m_base;
    uint32 src_m;
    acmod_id_t src_m_base;
    const char *dest_m_name;
    const char *dest_m_base_name;

    uint32 i;
    uint32 n_ts;
    uint32 n_cb;

    const char *ts2cbfn;

    E_INFO("Reading src %s\n", cmd_ln_str("-src_moddeffn"));

    /* read in the source model definition file */
    if (model_def_read(&src_mdef,
                       cmd_ln_str("-src_moddeffn")) != S3_SUCCESS) {
        return S3_ERROR;
    }


    ts2cbfn = cmd_ln_str("-src_ts2cbfn");
    if (strcmp(SEMI_LABEL, ts2cbfn) == 0) {
        E_INFO("Generating semi-continous ts2cb mapping\n");
        src_mdef->cb = semi_ts2cb(src_mdef->n_tied_state);
        n_ts = src_mdef->n_tied_state;
        n_cb = 1;
    }
    else if (strcmp(CONT_LABEL, ts2cbfn) == 0) {
        E_INFO("Generating continous ts2cb mapping\n");
        src_mdef->cb = cont_ts2cb(src_mdef->n_tied_state);
        n_ts = src_mdef->n_tied_state;
        n_cb = src_mdef->n_tied_state;
    }
    else if (strcmp(PTM_LABEL, ts2cbfn) == 0) {
        E_INFO("Generating phonetically tied ts2cb mapping\n");
        src_mdef->cb = ptm_ts2cb(src_mdef);
        n_ts = src_mdef->n_tied_state;
        n_cb = src_mdef->acmod_set->n_ci;
    }
    else {
        E_INFO("Reading src %s\n", cmd_ln_str("-src_ts2cbfn"));
        if (s3ts2cb_read(ts2cbfn,
                         &src_mdef->cb,
                         &n_ts,
                         &n_cb) != S3_SUCCESS) {
            return S3_ERROR;
        }
    }

    E_INFO("Reading src %s\n", cmd_ln_str("-src_mixwfn"));

    /* read in the source mixing weight parameter file */
    if (s3mixw_read(cmd_ln_str("-src_mixwfn"),
                    &src_mixw, &n_mixw_src, &n_feat, &n_gau) != S3_SUCCESS) {

        return S3_ERROR;
    }

    E_INFO("Reading src %s\n",
           cmd_ln_str("-src_tmatfn"));

    if (s3tmat_read(cmd_ln_str("-src_tmatfn"),
                    &src_tmat,
                    &n_tmat_src,
                    &n_state_pm) != S3_SUCCESS) {
        return S3_ERROR;
    }

    E_INFO("Reading src %s\n", cmd_ln_str("-src_meanfn"));

    if (s3gau_read(cmd_ln_str("-src_meanfn"),
                   &src_mean,
                   &n_cb_src,
                   &tmp_n_feat,
                   &tmp_n_gau,
                   &veclen) != S3_SUCCESS) {
        return S3_ERROR;
    }

    if (tmp_n_feat != n_feat) {
        E_FATAL("src mean n_feat (== %u) != prior value (== %u)\n",
                tmp_n_feat, n_feat);
    }
    if (tmp_n_gau != n_gau) {
        E_FATAL("src mean n_gau (== %u) != prior value (== %u)\n",
                tmp_n_gau, n_gau);
    }
    if (n_cb_src != n_cb) {
        E_FATAL("src mean n_cb (== %u) is inconsistent with ts2cb mapping %u. Most probably phoneset has duplicated phones\n",
                n_cb_src, n_cb);
    }

    E_INFO("Reading src %s\n", cmd_ln_str("-src_varfn"));
    if (cmd_ln_int32("-fullvar")) {
        if (s3gau_read_full(cmd_ln_str("-src_varfn"),
                            &src_fullvar,
                            &n_cb_src,
                            &tmp_n_feat,
                            &tmp_n_gau,
                            &tmp_veclen) != S3_SUCCESS) {
            return S3_ERROR;
        }
    }
    else {
        if (s3gau_read(cmd_ln_str("-src_varfn"),
                       &src_var,
                       &n_cb_src,
                       &tmp_n_feat,
                       &tmp_n_gau,
                       &tmp_veclen) != S3_SUCCESS) {
            return S3_ERROR;
        }
    }

    if (tmp_n_feat != n_feat) {
        E_FATAL("src var n_feat (== %u) != prior value (== %u)\n",
                tmp_n_feat, n_feat);
    }
    if (tmp_n_gau != n_gau) {
        E_FATAL("src var n_gau (== %u) != prior value (== %u)\n",
                tmp_n_gau, n_gau);
    }
    if (n_cb_src != n_cb) {
        E_FATAL("src var n_cb (== %u) inconsistent w/ ts2cb mapping %u\n",
                n_cb_src, n_cb);
    }

    if (n_mixw_src < src_mdef->n_tied_state) {
        E_FATAL("Too few source mixing weights, %u, for the # of tied states, %u\n",
                n_mixw_src, src_mdef->n_tied_state);
    }

    for (i = 0; i < n_feat; i++) {
        if (veclen[i] != tmp_veclen[i]) {
            E_FATAL("src var veclen[%u] (== %u) != prior value (== %u)\n",
                    i, tmp_veclen[i], veclen[i]);
        }
    }
    ckd_free(tmp_veclen);

    E_INFO("Reading dest %s\n",
           cmd_ln_str("-dest_moddeffn"));

    /* read in the destination model definition file */
    if (model_def_read(&dest_mdef,
                       cmd_ln_str("-dest_moddeffn")) < S3_SUCCESS) {
        return S3_ERROR;
    }

    ts2cbfn = cmd_ln_str("-dest_ts2cbfn");
    if (strcmp(SEMI_LABEL, ts2cbfn) == 0) {
        E_INFO("Generating semi-continous ts2cb mapping\n");
        dest_mdef->cb = semi_ts2cb(dest_mdef->n_tied_state);
        n_ts = dest_mdef->n_tied_state;
        n_cb = 1;
    }
    else if (strcmp(CONT_LABEL, ts2cbfn) == 0) {
        E_INFO("Generating continous ts2cb mapping\n");
        dest_mdef->cb = cont_ts2cb(dest_mdef->n_tied_state);
        n_ts = dest_mdef->n_tied_state;
        n_cb = dest_mdef->n_tied_state;
    }
    else if (strcmp(PTM_LABEL, ts2cbfn) == 0) {
        E_INFO("Generating phonetically tied ts2cb mapping\n");
        dest_mdef->cb = ptm_ts2cb(dest_mdef);
        n_ts = dest_mdef->n_tied_state;
        n_cb = dest_mdef->acmod_set->n_ci;
    }
    else {
        E_INFO("Reading dest %s\n",
               cmd_ln_str("-dest_ts2cbfn"));


        if (s3ts2cb_read(ts2cbfn,
                         &dest_mdef->cb,
                         &n_ts,
                         &n_cb) != S3_SUCCESS) {
            return S3_ERROR;
        }
    }

    E_INFO("Calculating initial model parameters\n");

    n_tmat_dest = dest_mdef->n_tied_tmat;
    tmat_dest_list = init_was_added(n_tmat_dest);

    E_INFO("Alloc %ux%ux%u dest tmat\n",
           n_tmat_dest,
           n_state_pm-1,
           n_state_pm);

    dest_tmat = (float32 ***)ckd_calloc_3d(n_tmat_dest,
                                           n_state_pm-1,
                                           n_state_pm,
                                           sizeof(float32));

    n_mixw_dest = dest_mdef->n_tied_state;
    mixw_dest_list = init_was_added(n_mixw_dest);

    E_INFO("Alloc %ux%ux%u dest mixw\n",
           n_mixw_dest, n_feat, n_gau);
    dest_mixw = (float32 ***)ckd_calloc_3d(n_mixw_dest, n_feat, n_gau, sizeof(float32));

    for (i = 0, n_cb_dest = 0; i < n_mixw_dest; i++) {
        if (dest_mdef->cb[i] > n_cb_dest) {
            n_cb_dest = dest_mdef->cb[i];
        }
    }
    ++n_cb_dest;

    cb_dest_list = init_was_added(n_cb_dest);

    E_INFO("Alloc %ux%ux%u dest mean and var\n",
           n_cb_dest, n_feat, n_gau);
    dest_mean = gauden_alloc_param(n_cb_dest, n_feat, n_gau, veclen);
    if (src_var)
        dest_var = gauden_alloc_param(n_cb_dest, n_feat, n_gau, veclen);
    else if (src_fullvar)
        dest_fullvar = gauden_alloc_param_full(n_cb_dest, n_feat, n_gau, veclen);

    for (dest_m = 0; dest_m < dest_mdef->n_defn; dest_m++) {
        dest_m_name = acmod_set_id2name(dest_mdef->acmod_set, dest_m);
        src_m = acmod_set_name2id(src_mdef->acmod_set, dest_m_name);
        if (src_m == NO_ACMOD) {
            /* No corresponding phone model in the source set */

            /* See if there is a source base phone corresponding to this destination model
               base phone */
            dest_m_base = acmod_set_base_phone(dest_mdef->acmod_set, dest_m);
            dest_m_base_name = acmod_set_id2name(dest_mdef->acmod_set, dest_m_base);

            src_m_base = acmod_set_name2id(src_mdef->acmod_set, dest_m_base_name);
            if (src_m_base == NO_ACMOD) {
                /* No corresponding model or base model found.  Use uniform distribution */

                E_INFO("No source base phone %s found.  Initializing %s using uniform distribution\n",
                       dest_m_base_name, dest_m_name);

                if (src_tmat) {
                    E_INFO("Uniform initialization of tmat not supported\n");
                }
                init_uniform(dest_mixw, &dest_mdef->defn[dest_m], n_feat, n_gau);
            }
            else {
                /* No corresponding model, but a base model was found.  Use base distribution. */
                init_model(dest_mixw, dest_mean, dest_var, dest_fullvar, dest_tmat,
                           &dest_mdef->defn[dest_m], dest_mdef->cb, dest_mdef->acmod_set,
                           src_mixw, src_mean, src_var, src_fullvar, src_tmat,
                           &src_mdef->defn[src_m_base], src_mdef->cb, src_mdef->acmod_set,
                           n_feat, n_gau, n_state_pm, veclen);
            }
        }
        else {
            /* Found a corresponding model in the source set, so use source distributions to init
               the destination */
            init_model(dest_mixw, dest_mean, dest_var, dest_fullvar, dest_tmat,
                       &dest_mdef->defn[dest_m], dest_mdef->cb, dest_mdef->acmod_set,
                       src_mixw, src_mean, src_var, src_fullvar, src_tmat,
                       &src_mdef->defn[src_m], src_mdef->cb, src_mdef->acmod_set,
                       n_feat, n_gau, n_state_pm, veclen);
        }
    }

    for (m = 0; m < n_mixw_dest; m++) {
        if (mixw_dest_list[m] == NULL) {
            E_WARN("Destination state %u has not been initialized!\n", m);
        }
    }

    for (m = 0; m < n_cb_dest; m++) {
        if (cb_dest_list[m] == NULL) {
            E_WARN("Destination cb %u has not been initialized!\n", m);
        }
        else if (cb_dest_list[m]->next != NULL) {
            E_WARN("dest cb %u has > 1 corresponding source cb\n", m);
        }
    }

    E_INFO("Writing dest %s\n",
           cmd_ln_str("-dest_tmatfn"));

    if (s3tmat_write(cmd_ln_str("-dest_tmatfn"),
                     dest_tmat,
                     n_tmat_dest,
                     n_state_pm) != S3_SUCCESS) {
        return S3_ERROR;
    }


    E_INFO("Writing dest %s\n",
           cmd_ln_str("-dest_mixwfn"));

    if (s3mixw_write(cmd_ln_str("-dest_mixwfn"),
                     dest_mixw,
                     dest_mdef->n_tied_state, n_feat, n_gau) < S3_SUCCESS) {
        return S3_ERROR;
    }

    E_INFO("Writing dest %s\n",
           cmd_ln_str("-dest_meanfn"));

    if (s3gau_write(cmd_ln_str("-dest_meanfn"),
                    (const vector_t ***)dest_mean,
                    n_cb_dest,
                    n_feat,
                    n_gau,
                    veclen) != S3_SUCCESS) {
        return S3_ERROR;
    }

    E_INFO("Writing dest %s\n",
           cmd_ln_str("-dest_varfn"));
    if (cmd_ln_int32("-fullvar")) {
        if (s3gau_write_full(cmd_ln_str("-dest_varfn"),
                             (const vector_t ****)dest_fullvar,
                             n_cb_dest,
                             n_feat,
                             n_gau,
                             veclen) != S3_SUCCESS) {
            return S3_ERROR;
        }
    }
    else {
        if (s3gau_write(cmd_ln_str("-dest_varfn"),
                        (const vector_t ***)dest_var,
                        n_cb_dest,
                        n_feat,
                        n_gau,
                        veclen) != S3_SUCCESS) {
            return S3_ERROR;
        }
    }
    ckd_free(veclen);
    return S3_SUCCESS;
}