当前位置: 首页>>代码示例>>C++>>正文


C++ cmd_ln_int32_r函数代码示例

本文整理汇总了C++中cmd_ln_int32_r函数的典型用法代码示例。如果您正苦于以下问题:C++ cmd_ln_int32_r函数的具体用法?C++ cmd_ln_int32_r怎么用?C++ cmd_ln_int32_r使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了cmd_ln_int32_r函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: fe_parse_melfb_params

static int
fe_parse_melfb_params(cmd_ln_t *config, fe_t *fe, melfb_t * mel)
{
    mel->sampling_rate = fe->sampling_rate;
    mel->fft_size = fe->fft_size;
    mel->num_cepstra = fe->num_cepstra;
    mel->num_filters = cmd_ln_int32_r(config, "-nfilt");

    if (fe->log_spec)
        fe->feature_dimension = mel->num_filters;
    else
        fe->feature_dimension = fe->num_cepstra;

    mel->upper_filt_freq = cmd_ln_float32_r(config, "-upperf");
    mel->lower_filt_freq = cmd_ln_float32_r(config, "-lowerf");

    mel->doublewide = cmd_ln_boolean_r(config, "-doublebw");

    mel->warp_type = cmd_ln_str_r(config, "-warp_type");
    mel->warp_params = cmd_ln_str_r(config, "-warp_params");
    mel->lifter_val = cmd_ln_int32_r(config, "-lifter");

    mel->unit_area = cmd_ln_boolean_r(config, "-unit_area");
    mel->round_filters = cmd_ln_boolean_r(config, "-round_filters");

    if (fe_warp_set(mel, mel->warp_type) != FE_SUCCESS) {
        E_ERROR("Failed to initialize the warping function.\n");
        return -1;
    }
    fe_warp_set_parameters(mel, mel->warp_params, mel->sampling_rate);
    return 0;
}
开发者ID:Bangybug,项目名称:sphinxbase,代码行数:32,代码来源:fe_interface.c

示例2: main

int32
main(int32 argc, char *argv[])
{
    kb_t kb;
    stat_t *st;
    cmd_ln_t *config;

    print_appl_info(argv[0]);
    cmd_ln_appl_enter(argc, argv, "default.arg", arg);

    unlimit();

    config = cmd_ln_get();
    kb_init(&kb, config);
    st = kb.stat;
    fprintf(stdout, "\n");

    if (cmd_ln_str_r(config, "-ctl")) {
        /* 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(cmd_ln_str_r(config, "-ctl"),
                             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_decode, &kb);
    }
    else if (cmd_ln_str_r(config, "-utt")) {
        /* When -utt is specified, corpus.c will wait for the utterance to
           change */
        st->tm = ctl_process_utt(cmd_ln_str_r(config, "-utt"),
                                 cmd_ln_int32_r(config, "-ctlcount"),
                                 utt_decode, &kb);

    }
    else {
        /* Is error checking good enough?" */
        E_FATAL("Both -utt and -ctl are not specified.\n");

    }

    if (kb.matchsegfp)
        fclose(kb.matchsegfp);
    if (kb.matchfp)
        fclose(kb.matchfp);

    stat_report_corpus(kb.stat);

    kb_free(&kb);

#if (! WIN32)
#if defined(_SUN4)
    system("ps -el | grep sphinx3_decode");
#else
    system("ps aguxwww | grep sphinx3_decode");
#endif
#endif

    cmd_ln_free_r(config);
    exit(0);
}
开发者ID:aniket134,项目名称:XBMC-video-plugins,代码行数:60,代码来源:main_decode.c

示例3: acmod_init_feat

static int
acmod_init_feat(acmod_t *acmod)
{
    acmod->fcb =
        feat_init(cmd_ln_str_r(acmod->config, "-feat"),
                  cmn_type_from_str(cmd_ln_str_r(acmod->config,"-cmn")),
                  cmd_ln_boolean_r(acmod->config, "-varnorm"),
                  agc_type_from_str(cmd_ln_str_r(acmod->config, "-agc")),
                  1, cmd_ln_int32_r(acmod->config, "-ceplen"));
    if (acmod->fcb == NULL)
        return -1;

    if (cmd_ln_str_r(acmod->config, "-lda")) {
        E_INFO("Reading linear feature transformation from %s\n",
               cmd_ln_str_r(acmod->config, "-lda"));
        if (feat_read_lda(acmod->fcb,
                          cmd_ln_str_r(acmod->config, "-lda"),
                          cmd_ln_int32_r(acmod->config, "-ldadim")) < 0)
            return -1;
    }

    if (cmd_ln_str_r(acmod->config, "-svspec")) {
        int32 **subvecs;
        E_INFO("Using subvector specification %s\n",
               cmd_ln_str_r(acmod->config, "-svspec"));
        if ((subvecs = parse_subvecs(cmd_ln_str_r(acmod->config, "-svspec"))) == NULL)
            return -1;
        if ((feat_set_subvecs(acmod->fcb, subvecs)) < 0)
            return -1;
    }

    if (cmd_ln_exists_r(acmod->config, "-agcthresh")
        && 0 != strcmp(cmd_ln_str_r(acmod->config, "-agc"), "none")) {
        agc_set_threshold(acmod->fcb->agc_struct,
                          cmd_ln_float32_r(acmod->config, "-agcthresh"));
    }

    if (acmod->fcb->cmn_struct
        && cmd_ln_exists_r(acmod->config, "-cmninit")) {
        char *c, *cc, *vallist;
        int32 nvals;

        vallist = ckd_salloc(cmd_ln_str_r(acmod->config, "-cmninit"));
        c = vallist;
        nvals = 0;
        while (nvals < acmod->fcb->cmn_struct->veclen
               && (cc = strchr(c, ',')) != NULL) {
            *cc = '\0';
            acmod->fcb->cmn_struct->cmn_mean[nvals] = FLOAT2MFCC(atof_c(c));
            c = cc + 1;
            ++nvals;
        }
        if (nvals < acmod->fcb->cmn_struct->veclen && *c != '\0') {
            acmod->fcb->cmn_struct->cmn_mean[nvals] = FLOAT2MFCC(atof_c(c));
        }
        ckd_free(vallist);
    }
    return 0;
}
开发者ID:JonGBowen,项目名称:GoodVibes,代码行数:59,代码来源:acmod.c

示例4: fe_parse_general_params

int
fe_parse_general_params(cmd_ln_t *config, fe_t * fe)
{
    int j;

    fe->config = config;
    fe->sampling_rate = cmd_ln_float32_r(config, "-samprate");
    fe->frame_rate = (int16)cmd_ln_int32_r(config, "-frate");
    if (cmd_ln_boolean_r(config, "-dither")) {
        fe->dither = 1;
        fe->seed = cmd_ln_int32_r(config, "-seed");
    }
#ifdef WORDS_BIGENDIAN
    fe->swap = strcmp("big", cmd_ln_str_r(config, "-input_endian")) == 0 ? 0 : 1;
#else        
    fe->swap = strcmp("little", cmd_ln_str_r(config, "-input_endian")) == 0 ? 0 : 1;
#endif
    fe->window_length = cmd_ln_float32_r(config, "-wlen");
    fe->pre_emphasis_alpha = cmd_ln_float32_r(config, "-alpha");

    fe->num_cepstra = (uint8)cmd_ln_int32_r(config, "-ncep");
    fe->fft_size = (int16)cmd_ln_int32_r(config, "-nfft");

    /* Check FFT size, compute FFT order (log_2(n)) */
    for (j = fe->fft_size, fe->fft_order = 0; j > 1; j >>= 1, fe->fft_order++) {
        if (((j % 2) != 0) || (fe->fft_size <= 0)) {
            E_ERROR("fft: number of points must be a power of 2 (is %d)\n",
                    fe->fft_size);
            return -1;
        }
    }
    /* Verify that FFT size is greater or equal to window length. */
    if (fe->fft_size < (int)(fe->window_length * fe->sampling_rate)) {
        E_ERROR("FFT: Number of points must be greater or equal to frame size (%d samples)\n",
                (int)(fe->window_length * fe->sampling_rate));
        return -1;
    }

    fe->remove_dc = cmd_ln_boolean_r(config, "-remove_dc");

    if (0 == strcmp(cmd_ln_str_r(config, "-transform"), "dct"))
        fe->transform = DCT_II;
    else if (0 == strcmp(cmd_ln_str_r(config, "-transform"), "legacy"))
        fe->transform = LEGACY_DCT;
    else if (0 == strcmp(cmd_ln_str_r(config, "-transform"), "htk"))
        fe->transform = DCT_HTK;
    else {
        E_ERROR("Invalid transform type (values are 'dct', 'legacy', 'htk')\n");
        return -1;
    }

    if (cmd_ln_boolean_r(config, "-logspec"))
        fe->log_spec = RAW_LOG_SPEC;
    if (cmd_ln_boolean_r(config, "-smoothspec"))
        fe->log_spec = SMOOTH_LOG_SPEC;

    return 0;
}
开发者ID:Ankit77,项目名称:cmusphinx,代码行数:58,代码来源:fe_interface.c

示例5: srch_FLAT_FWD_bestpath_impl

glist_t
srch_FLAT_FWD_bestpath_impl(void *srch,           /**< A void pointer to a search structure */
                            dag_t * dag)
{
    srch_t *s;
    srch_FLAT_FWD_graph_t *fwg;

    float32 bestpathlw;
    float64 lwf;
    srch_hyp_t *tmph, *bph;
    glist_t ghyp, rhyp;

    s = (srch_t *) srch;
    fwg = (srch_FLAT_FWD_graph_t *) s->grh->graph_struct;

    assert(fwg->lathist);

    bestpathlw = cmd_ln_float32_r(kbcore_config(fwg->kbcore), "-bestpathlw");
    lwf = bestpathlw ? (bestpathlw / cmd_ln_float32_r(kbcore_config(fwg->kbcore), "-lw")) : 1.0;

    flat_fwd_dag_add_fudge_edges(fwg,
				 dag,
				 cmd_ln_int32_r(kbcore_config(fwg->kbcore), "-dagfudge"),
				 cmd_ln_int32_r(kbcore_config(fwg->kbcore), "-min_endfr"),
				 (void *) fwg->lathist, s->kbc->dict);


    /* Bypass filler nodes */
    if (!dag->filler_removed) {
        /* If Viterbi search terminated in filler word coerce final DAG node to FINISH_WORD */
        if (dict_filler_word(s->kbc->dict, dag->end->wid))
            dag->end->wid = s->kbc->dict->finishwid;

        if (dag_bypass_filler_nodes(dag, lwf, s->kbc->dict, s->kbc->fillpen) < 0)
            E_ERROR("maxedge limit (%d) exceeded\n", dag->maxedge);
        else
            dag->filler_removed = 1;
    }

    bph =
        dag_search(dag, s->uttid, lwf, dag->end,
                   s->kbc->dict, s->kbc->lmset->cur_lm, s->kbc->fillpen);

    if (bph != NULL) {
        ghyp = NULL;
        for (tmph = bph; tmph; tmph = tmph->next)
            ghyp = glist_add_ptr(ghyp, (void *) tmph);

        rhyp = glist_reverse(ghyp);
        return rhyp;
    }
    else {
        return NULL;
    }

}
开发者ID:4auka,项目名称:cmusphinx,代码行数:56,代码来源:srch_flat_fwd.c

示例6: detect_sphinx_mfc

/**
 * "Detect" Sphinx MFCC files, meaning verify their lousy headers, and
 * set up some parameters from the config object.
 *
 * @return TRUE, or -1 on error.
 */
static int
detect_sphinx_mfc(sphinx_wave2feat_t *wtf)
{
    FILE *fh;
    int32 len;
    long flen;

    if ((fh = fopen(wtf->infile, "rb")) == NULL) {
        E_ERROR_SYSTEM("Failed to open %s", wtf->infile);
        return -1;
    }
    if (fread(&len, 4, 1, fh) != 1) {
        E_ERROR_SYSTEM("Failed to read header from %s\n", wtf->infile);
        fclose(fh);
        return -1;
    }
    fseek(fh, 0, SEEK_END);
    flen = ftell(fh);

    /* figure out whether to byteswap */
    flen = (flen / 4) - 1;
    if (flen != len) {
        /* First make sure this is an endianness problem, otherwise fail. */
        SWAP_INT32(&len);
        if (flen != len) {
            SWAP_INT32(&len);
            E_ERROR("Mismatch in header/file lengths: 0x%08x vs 0x%08x\n",
                    len, flen);
            return -1;
        }
        /* Set the input endianness to the opposite of the machine endianness... */
        cmd_ln_set_str_r(wtf->config, "-input_endian",
                         (0 == strcmp("big", cmd_ln_str_r(wtf->config, "-mach_endian"))
                          ? "little" : "big"));
    }
    
    fseek(fh, 4, SEEK_SET);
    wtf->infh = fh;
    if (cmd_ln_boolean_r(wtf->config, "-spec2cep")) {
        wtf->in_veclen = cmd_ln_int32_r(wtf->config, "-nfilt");
    }
    else if (cmd_ln_boolean_r(wtf->config, "-cep2spec")) {
        wtf->in_veclen = cmd_ln_int32_r(wtf->config, "-ncep");
        wtf->veclen = cmd_ln_int32_r(wtf->config, "-nfilt");
    }
    else {
        /* Should not happen. */
        E_ERROR("Sphinx MFCC file reading requested but -spec2cep/-cep2spec not given\n");
        assert(FALSE);
    }
            
    return TRUE;
}
开发者ID:kirpen,项目名称:pocketsphinx.js,代码行数:59,代码来源:sphinx_fe.c

示例7: decode_pcm

/**
 * Process PCM audio from a filehandle.  Assume that wtf->infh is
 * positioned just after the file header.
 */
static int
decode_pcm(sphinx_wave2feat_t *wtf)
{
    size_t nsamp;
    int32 n, nfr, nchans, whichchan;
    uint32 nfloat;

    nchans = cmd_ln_int32_r(wtf->config, "-nchans");
    whichchan = cmd_ln_int32_r(wtf->config, "-whichchan");
    fe_start_utt(wtf->fe);
    nfloat = 0;
    while ((nsamp = fread(wtf->audio, 2, wtf->blocksize, wtf->infh)) != 0) {
        size_t nvec;
        int16 const *inspeech;

        /* Byteswap stuff here if necessary. */
        if (wtf->byteswap) {
            for (n = 0; n < nsamp; ++n)
                SWAP_INT16(wtf->audio + n);
        }

        /* Mix or pick channels. */
        if (nchans > 1)
            nsamp = mixnpick_channels(wtf->audio, nsamp, nchans, whichchan);
            
        inspeech = wtf->audio;
        nvec = wtf->featsize;
        /* Consume all samples. */
        while (nsamp) {
            nfr = nvec;
            fe_process_frames(wtf->fe, &inspeech, &nsamp, wtf->feat, &nfr, NULL);
            if (nfr) {
                if ((n = (*wtf->ot->output_frames)(wtf, wtf->feat, nfr)) < 0)
                    return -1;
                nfloat += n;
            }
        }
        inspeech = wtf->audio;
    }
    /* Now process any leftover audio frames. */
    fe_end_utt(wtf->fe, wtf->feat[0], &nfr);
    if (nfr) {
        if ((n = (*wtf->ot->output_frames)(wtf, wtf->feat, nfr)) < 0)
            return -1;
        nfloat += n;
    }

    if (fclose(wtf->infh) == EOF)
        E_ERROR_SYSTEM("Failed to close input file");
    wtf->infh = NULL;
    return nfloat;
}
开发者ID:kirpen,项目名称:pocketsphinx.js,代码行数:56,代码来源:sphinx_fe.c

示例8: main

int
main(int argc, char *argv[])
{
    print_appl_info(argv[0]);
    cmd_ln_appl_enter(argc, argv, "default.arg", defn);

    unlimit();

    config = cmd_ln_get();

    logmath = logs3_init(cmd_ln_float64_r(config, "-logbase"), 1,
                         cmd_ln_int32_r(config, "-log3table"));

    E_INFO("Value of base %f \n", cmd_ln_float32_r(config, "-logbase"));
    models_init();
    ptmr_init(&tm_utt);

    if ((inmatchsegfp = fopen(cmd_ln_str_r(config, "-inhypseg"), "r")) == NULL)
        E_ERROR("fopen(%s,r) failed\n", cmd_ln_str_r(config, "-inhypseg"));


    if ((outconfmatchsegfp = fopen(cmd_ln_str_r(config, "-output"), "w")) == NULL)
        E_ERROR("fopen(%s,w) failed\n", cmd_ln_str_r(config, "-output"));

    if (cmd_ln_str_r(config, "-ctl")) {
        ctl_process(cmd_ln_str_r(config, "-ctl"),
                    cmd_ln_str_r(config, "-ctl_lm"),
                    NULL,
                    cmd_ln_int32_r(config, "-ctloffset"),
                    cmd_ln_int32_r(config, "-ctlcount"), utt_confidence, NULL);
    }
    else {
        E_FATAL("-ctl is not specified\n");
    }

#if (! WIN32)
    system("ps auxwww | grep s3dag");
#endif

    fclose(outconfmatchsegfp);
    fclose(inmatchsegfp);

    models_free();

    logmath_free(logmath);

    cmd_ln_free_r(config);

    return 0;

}
开发者ID:4auka,项目名称:cmusphinx,代码行数:51,代码来源:main_conf.c

示例9: srch_FLAT_FWD_nbest_impl

glist_t
srch_FLAT_FWD_nbest_impl(void *srch,           /**< A void pointer to a search structure */
                         dag_t * dag)
{
    srch_t *s;
    srch_FLAT_FWD_graph_t *fwg;
    float32 bestpathlw;
    float64 lwf;
    char str[2000];

    s = (srch_t *) srch;
    fwg = (srch_FLAT_FWD_graph_t *) s->grh->graph_struct;
    assert(fwg->lathist);

    if (!(cmd_ln_exists_r(kbcore_config(fwg->kbcore), "-nbestdir")
          && cmd_ln_str_r(kbcore_config(fwg->kbcore), "-nbestdir")))
        return NULL;
    ctl_outfile(str, cmd_ln_str_r(kbcore_config(fwg->kbcore), "-nbestdir"),
                cmd_ln_str_r(kbcore_config(fwg->kbcore), "-nbestext"),
                (s->uttfile ? s->uttfile : s->uttid), s->uttid,
                cmd_ln_boolean_r(kbcore_config(fwg->kbcore), "-build_outdirs"));

    bestpathlw = cmd_ln_float32_r(kbcore_config(fwg->kbcore), "-bestpathlw");
    lwf = bestpathlw ? (bestpathlw / cmd_ln_float32_r(kbcore_config(fwg->kbcore), "-lw")) : 1.0;

    flat_fwd_dag_add_fudge_edges(fwg,
				 dag,
				 cmd_ln_int32_r(kbcore_config(fwg->kbcore), "-dagfudge"),
				 cmd_ln_int32_r(kbcore_config(fwg->kbcore), "-min_endfr"),
				 (void *) fwg->lathist, s->kbc->dict);

    /* Bypass filler nodes */
    if (!dag->filler_removed) {
        /* If Viterbi search terminated in filler word coerce final DAG node to FINISH_WORD */
        if (dict_filler_word(s->kbc->dict, dag->end->wid))
            dag->end->wid = s->kbc->dict->finishwid;
        dag_remove_unreachable(dag);
        if (dag_bypass_filler_nodes(dag, lwf, s->kbc->dict, s->kbc->fillpen) < 0)
            E_ERROR("maxedge limit (%d) exceeded\n", dag->maxedge);
    }

    dag_compute_hscr(dag, kbcore_dict(s->kbc), kbcore_lm(s->kbc), lwf);
    dag_remove_bypass_links(dag);
    dag->filler_removed = 0;

    nbest_search(dag, str, s->uttid, lwf,
                 kbcore_dict(s->kbc),
                 kbcore_lm(s->kbc), kbcore_fillpen(s->kbc)
        );
    return NULL;
}
开发者ID:4auka,项目名称:cmusphinx,代码行数:51,代码来源:srch_flat_fwd.c

示例10: main

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;
}
开发者ID:4auka,项目名称:cmusphinx,代码行数:51,代码来源:main_livepretend.c

示例11: acmod_fe_mismatch

int
acmod_fe_mismatch(acmod_t *acmod, fe_t *fe)
{
    /* Output vector dimension needs to be the same. */
    if (cmd_ln_int32_r(acmod->config, "-ceplen") != fe_get_output_size(fe)) {
	E_ERROR("Configured feature length %d doesn't match feature extraction output size %d\n", 
		cmd_ln_int32_r(acmod->config, "-ceplen"), 
		fe_get_output_size(fe));
        return TRUE;
    }
    /* Feature parameters need to be the same. */
    /* ... */
    return FALSE;
}
开发者ID:OmkarKirpan,项目名称:CMUSphinx,代码行数:14,代码来源:acmod.c

示例12: write_nbest

static int
write_nbest(ps_decoder_t *ps, char const *nbestdir, char const *uttid)
{
    cmd_ln_t *config;
    char *outfile;
    FILE *fh;
    ps_nbest_t *nbest;
    int32 i, n, score;
    const char* hyp;

    config = ps_get_config(ps);
    outfile = string_join(nbestdir, "/", uttid,
                          cmd_ln_str_r(config, "-nbestext"), NULL);
    n = cmd_ln_int32_r(config, "-nbest");
    fh = fopen(outfile, "w");
    if (fh == NULL) {
        E_ERROR_SYSTEM("Failed to write a lattice to file %s\n", outfile);
        return -1;
    }
    nbest = ps_nbest(ps, 0, -1, NULL, NULL);
    for (i = 0; i < n && nbest && (nbest = ps_nbest_next(nbest)); i++) {
        hyp = ps_nbest_hyp(nbest, &score);
        fprintf(fh, "%s %d\n", hyp, score);        
    }
    if (nbest)
	ps_nbest_free(nbest);
    fclose(fh);

    return 0;
}
开发者ID:joicemjoseph,项目名称:pocketsphinx.js,代码行数:30,代码来源:batch.c

示例13: filter_buffer_create

int filter_buffer_create(context_t *ctx)
{
    options_t *opts;
    decoder_set_t *decset;
    decoder_t *dec;
    cmd_ln_t *cfg;
    uint32_t rate;
    int32 fps;
    int32_t frlen;
    filter_buf_t *filtbuf;

    if (!ctx || !(opts = ctx->opts) ||
        !(decset = ctx->decset) || !(dec = decset->decs) ||
        !(cfg = dec->cfg) || !(filtbuf = mrp_allocz(sizeof(filter_buf_t))))
        return -1;

    rate = opts->rate;
    fps =  cmd_ln_int32_r(cfg, "-frate");
    frlen = rate / (double)fps;

    filtbuf->len = 0;
    filtbuf->frlen = frlen;
    filtbuf->fdrec = open_file_for_recording(opts->audio);

    ctx->filtbuf = filtbuf;

    return 0;
}
开发者ID:avalluri,项目名称:winthorpe,代码行数:28,代码来源:filter-buffer.c

示例14: decode_sndfile

/**
 * Process PCM audio from a libsndfile file.  FIXME: looks a lot like
 * decode_pcm!  Also needs stereo support (as does decode_pcm).
 */
static int
decode_sndfile(sphinx_wave2feat_t *wtf)
{
    size_t nsamp;
    int32 nfr, nchans, whichchan;
    int nfloat, n;

    nchans = cmd_ln_int32_r(wtf->config, "-nchans");
    whichchan = cmd_ln_int32_r(wtf->config, "-whichchan");
    fe_start_utt(wtf->fe);
    nfloat = 0;
    while ((nsamp = sf_read_short(wtf->insfh,
                                  wtf->audio,
                                  wtf->blocksize)) != 0) {
        int16 const *inspeech;
        size_t nvec;

        /* Mix or pick channels. */
        if (nchans > 1)
            nsamp = mixnpick_channels(wtf->audio, nsamp, nchans, whichchan);

        inspeech = wtf->audio;
        nvec = wtf->featsize;
        /* Consume all samples. */
        while (nsamp) {
            nfr = nvec;
            fe_process_frames(wtf->fe, &inspeech, &nsamp, wtf->feat, &nfr, NULL);
            if (nfr) {
                if ((n = (*wtf->ot->output_frames)(wtf, wtf->feat, nfr)) < 0)
                    return -1;
                nfloat += n;
            }
        }
        inspeech = wtf->audio;
    }
    /* Now process any leftover audio frames. */
    fe_end_utt(wtf->fe, wtf->feat[0], &nfr);
    if (nfr) {
        if ((n = (*wtf->ot->output_frames)(wtf, wtf->feat, nfr)) < 0)
            return -1;
        nfloat += n;
    }

    sf_close(wtf->insfh);
    wtf->insfh = NULL;
    return nfloat;
}
开发者ID:kirpen,项目名称:pocketsphinx.js,代码行数:51,代码来源:sphinx_fe.c

示例15: main

int
main(int argc, char *argv[])
{
    cmd_ln_t *config;

    config = cmd_ln_parse_r(NULL, defs, argc, argv, TRUE);
    if (config == NULL)
        return 1;
    printf("%d %s %d %f\n",
           cmd_ln_int32_r(config, "-a"),
           cmd_ln_str_r(config, "-b") ? cmd_ln_str_r(config, "-b") : "(null)",
           cmd_ln_boolean_r(config, "-c"),
           cmd_ln_float64_r(config, "-d"));
    cmd_ln_free_r(config);

    config = cmd_ln_init(NULL, NULL, FALSE,
                         "-b", "foobie", NULL);
    if (config == NULL)
        return 1;
    cmd_ln_free_r(config);

    config = cmd_ln_init(NULL, defs, TRUE,
                         "-b", "foobie", NULL);
    if (config == NULL)
        return 1;
    printf("%d %s %d %f\n",
           cmd_ln_int32_r(config, "-a"),
           cmd_ln_str_r(config, "-b") ? cmd_ln_str_r(config, "-b") : "(null)",
           cmd_ln_boolean_r(config, "-c"),
           cmd_ln_float64_r(config, "-d"));
    cmd_ln_free_r(config);

    config = cmd_ln_init(NULL, NULL, FALSE,
                         "-b", "foobie", NULL);
    if (config == NULL)
        return 1;
    printf("%s\n",
           cmd_ln_str_r(config, "-b") ? cmd_ln_str_r(config, "-b") : "(null)");
    cmd_ln_set_str_r(config, "-b", "blatz");
    printf("%s\n",
           cmd_ln_str_r(config, "-b") ? cmd_ln_str_r(config, "-b") : "(null)");
    cmd_ln_free_r(config);
           
    return 0;
}
开发者ID:AaronZhangL,项目名称:pocketsphinx.js,代码行数:45,代码来源:cmdln_parse_r.c


注:本文中的cmd_ln_int32_r函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。