Esempio n. 1
0
main (int32 argc, char *argv[])
{
    int32 i;
    
    if (argc < 3) {
	E_INFO("Usage: %s outhypfile inhypfile1 inhypfile2 ... < ctlfile\n", argv[0]);
	exit(0);
    }
    
    n_inhyp = argc - 2;
    inhyp = (corpus_t **) ckd_calloc (n_inhyp, sizeof(corpus_t *));
    
    for (i = 2; i < argc; i++)
	inhyp[i-2] = corpus_load_headid (argv[i], validate, dup_resolve);
    
    E_INFO("Extracting\n");
    
    if ((outfp = fopen(argv[1], "w")) == NULL)
	E_FATAL_SYSTEM("fopen(%s,w) failed\n", argv[1]);
    
    infilename = &(argv[2]);
    ctl_process (NULL, 0, 1000000000, process_utt);
    
    fclose (outfp);
    
    E_INFO("Done\n");
    
    exit(0);
}
Esempio n. 2
0
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);
}
Esempio n. 3
0
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;

}
Esempio n. 4
0
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;
}
Esempio n. 5
0
int
main(int32 argc, char *argv[])
{
    /*  kb_t kb;
       ptmr_t tm; */

    cmd_ln_appl_enter(argc, argv, "default.arg", defn);
    config = cmd_ln_get();

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

    /* Read in input databases */
    models_init();

    ptmr_init(&tm_utt);

    nbestdir = cmd_ln_str_r(config, "-nbestdir");

    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_astar, NULL);

    }
    else {
        E_FATAL("-ctl is not specified\n");
    }

    models_free();

    logmath_free(logmath);

#if (! WIN32)
    system("ps aguxwww | grep s3astar");
#endif

    cmd_ln_free_r(config);
    return 0;
}
Esempio n. 6
0
int
main(int32 argc, char *argv[])
{
    char sent[16384];
    cmd_ln_t *config;

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

    unlimit();
    config = cmd_ln_get();

    ctloffset = cmd_ln_int32_r(config, "-ctloffset");
    sentfile = cmd_ln_str_r(config, "-insent");

    if ((sentfp = fopen(sentfile, "r")) == NULL)
        E_FATAL_SYSTEM("Failed to open file %s for reading", sentfile);

    /* Note various output directories */
    if (cmd_ln_str_r(config, "-s2stsegdir") != NULL)
        s2stsegdir = (char *) ckd_salloc(cmd_ln_str_r(config, "-s2stsegdir"));
    if (cmd_ln_str_r(config, "-stsegdir") != NULL)
        stsegdir = (char *) ckd_salloc(cmd_ln_str_r(config, "-stsegdir"));
    if (cmd_ln_str_r(config, "-phsegdir") != NULL)
        phsegdir = (char *) ckd_salloc(cmd_ln_str_r(config, "-phsegdir"));
    if (cmd_ln_str_r(config, "-phlabdir") != NULL)
        phlabdir = (char *) ckd_salloc(cmd_ln_str_r(config, "-phlabdir"));
    if (cmd_ln_str_r(config, "-wdsegdir") != NULL)
        wdsegdir = (char *) ckd_salloc(cmd_ln_str_r(config, "-wdsegdir"));

    /* HACK! Pre-read insent without checking whether ctl could also 
       be read.  In general, this is caused by the fact that we used
       multiple files to specify resource in sphinx III.  This is easy
       to solve but currently I just to remove process_ctl because it
       duplicates badly with ctl_process.  

       The call back function will take care of matching the uttfile
       names. We don't need to worry too much about inconsistency. 
     */

    while (ctloffset > 0) {
        if (fgets(sent, sizeof(sent), sentfp) == NULL) {
            E_ERROR("EOF(%s)\n", sentfile);
            break;
        }
        --ctloffset;
    }

    if ((outsentfile = cmd_ln_str_r(config, "-outsent")) != NULL) {
        if ((outsentfp = fopen(outsentfile, "w")) == NULL)
            E_FATAL_SYSTEM("Failed to open file %s for writing", outsentfile);
    }

    if ((outctlfile = cmd_ln_str_r(config, "-outctl")) != NULL) {
        if ((outctlfp = fopen(outctlfile, "w")) == NULL)
            E_FATAL_SYSTEM("Failed top open file %s for writing", outctlfile);
    }

    if ((cmd_ln_str_r(config, "-s2stsegdir") == NULL) &&
        (cmd_ln_str_r(config, "-stsegdir") == NULL) &&
        (cmd_ln_str_r(config, "-phlabdir") == NULL) &&
        (cmd_ln_str_r(config, "-phsegdir") == NULL) &&
        (cmd_ln_str_r(config, "-wdsegdir") == NULL) &&
        (cmd_ln_str_r(config, "-outsent") == NULL))
        E_FATAL("Missing output file/directory argument(s)\n");

    /* Read in input databases */
    models_init(config);

    if (!feat)
        feat = feat_array_alloc(kbcore_fcb(kbc), S3_MAX_FRAMES);

    timers[tmr_utt].name = "U";
    timers[tmr_gauden].name = "G";
    timers[tmr_senone].name = "S";
    timers[tmr_align].name = "A";

    /* Initialize align module */
    align_init(kbc->mdef, kbc->tmat, dict, config, kbc->logmath);
    printf("\n");

    if (cmd_ln_str_r(config, "-mllr") != NULL) {
        if (kbc->mgau)
            adapt_set_mllr(adapt_am, kbc->mgau, cmd_ln_str_r(config, "-mllr"), NULL,
                           kbc->mdef, config);
        else if (kbc->ms_mgau)
            model_set_mllr(kbc->ms_mgau, cmd_ln_str_r(config, "-mllr"), NULL, kbcore_fcb(kbc),
                           kbc->mdef, config);
        else
            E_WARN("Can't use MLLR matrices with .s2semi. yet\n");
    }

    tot_nfr = 0;

    /*  process_ctlfile (); */

    if (cmd_ln_str_r(config, "-ctl")) {
        /* When -ctlfile is speicified, corpus.c will look at -ctl_mllr to get
           the corresponding  MLLR for the utterance */
        ctl_process(cmd_ln_str_r(config, "-ctl"),
                    NULL,
                    cmd_ln_str_r(config, "-ctl_mllr"),
                    cmd_ln_int32_r(config, "-ctloffset"),
                    cmd_ln_int32_r(config, "-ctlcount"),
                    utt_align, config);
    }
    else {
        E_FATAL(" -ctl are not specified.\n");
    }

    if (tot_nfr > 0) {
        printf("\n");
        printf("TOTAL FRAMES:       %8d\n", tot_nfr);
        printf("TOTAL CPU TIME:     %11.2f sec, %7.2f xRT\n",
               tm_utt.t_tot_cpu, tm_utt.t_tot_cpu / (tot_nfr * 0.01));
        printf("TOTAL ELAPSED TIME: %11.2f sec, %7.2f xRT\n",
               tm_utt.t_tot_elapsed,
               tm_utt.t_tot_elapsed / (tot_nfr * 0.01));
    }

    if (outsentfp)
        fclose(outsentfp);
    if (outctlfp)
        fclose(outctlfp);
    if (sentfp)
        fclose(sentfp);

    ckd_free(s2stsegdir);
    ckd_free(stsegdir);
    ckd_free(phsegdir);
    ckd_free(wdsegdir);

    feat_array_free(feat);
    align_free();
    models_free();

#if (! WIN32)
    system("ps aguxwww | grep s3align");
#endif

    cmd_ln_free_r(config);
    return 0;
}
Esempio n. 7
0
File: main.c Progetto: 10v/cmusphinx
main (int32 argc, char *argv[])
{
    kb_t kb;
    kbcore_t *kbcore;
    bitvec_t active;
    int32 w;
    
    cmd_ln_parse (arglist, argc, argv);
    unlimit();
    
    kbcore = kbcore_init (cmd_ln_float32("-logbase"),
			  cmd_ln_str("-feat"),
			  cmd_ln_str("-mdef"),
			  cmd_ln_str("-dict"),
			  cmd_ln_str("-fdict"),
			  cmd_ln_str("-compsep"),
			  cmd_ln_str("-lm"),
			  cmd_ln_str("-fillpen"),
			  cmd_ln_float32("-silprob"),
			  cmd_ln_float32("-fillprob"),
			  cmd_ln_float32("-lw"),
			  cmd_ln_float32("-wip"),
			  cmd_ln_str("-mean"),
			  cmd_ln_str("-var"),
			  cmd_ln_float32("-varfloor"),
			  cmd_ln_str("-senmgau"),
			  cmd_ln_str("-mixw"),
			  cmd_ln_float32("-mixwfloor"),
			  cmd_ln_str("-tmat"),
			  cmd_ln_float32("-tmatfloor"));
    
    /* Here's the perfect candidate for inheritance */
    kb.mdef = kbcore->mdef;
    kb.dict = kbcore->dict;
    kb.lm = kbcore->lm;
    kb.fillpen = kbcore->fillpen;
    kb.tmat = kbcore->tmat;
    kb.dict2lmwid = kbcore->dict2lmwid;
    
    if ((kb.am = acoustic_init (kbcore->fcb, kbcore->gau, kbcore->sen, cmd_ln_float32("-mgaubeam"),
				S3_MAX_FRAMES)) == NULL) {
	E_FATAL("Acoustic models initialization failed\n");
    }
    kb.beam = logs3 (cmd_ln_float64("-beam"));
    kb.wordbeam = logs3 (cmd_ln_float64("-wordbeam"));
    kb.wordmax = cmd_ln_int32("-wordmax");
    
    /* Mark the active words and build lextree */
    active = bitvec_alloc (dict_size (kb.dict));
    bitvec_clear_all (active, dict_size(kb.dict));
    for (w = 0; w < dict_size(kb.dict); w++) {
	if (IS_LMWID(kb.dict2lmwid[w]) || dict_filler_word (kb.dict, w))
	    bitvec_set (active, w);
    }
    kb.lextree_root = lextree_build (kb.dict, kb.mdef, active, cmd_ln_int32("-flatdepth"));
    
    kb.vithist = (glist_t *) ckd_calloc (S3_MAX_FRAMES+2, sizeof(glist_t));
    kb.vithist++;	/* Allow for dummy frame -1 for start word */
    kb.lextree_active = NULL;
    kb.wd_last_sf = (int32 *) ckd_calloc (dict_size(kb.dict), sizeof(int32));
    
    kb.tm = (ptmr_t *) ckd_calloc (1, sizeof(ptmr_t));
    kb.tm_search = (ptmr_t *) ckd_calloc (1, sizeof(ptmr_t));
    
    ctl_process (cmd_ln_str("-ctl"), cmd_ln_int32("-ctloffset"), cmd_ln_int32("-ctlcount"),
		 decode_utt, &kb);
    
    exit(0);
}