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


C++ E_ERROR_SYSTEM函数代码示例

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


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

示例1: detect_riff

/**
 * Detect RIFF file and parse its header if detected.
 *
 * @return TRUE if it's a RIFF file, FALSE if not, -1 if an error occurred.
 */
static int
detect_riff(sphinx_wave2feat_t *wtf)
{
    FILE *fh;
    MSWAV_hdr hdr;

    if ((fh = fopen(wtf->infile, "rb")) == NULL) {
        E_ERROR_SYSTEM("Failed to open %s", wtf->infile);
        return -1;
    }
    if (fread(&hdr, sizeof(hdr), 1, fh) != 1) {
        E_ERROR_SYSTEM("Failed to read RIFF header");
        fclose(fh);
        return -1;
    }
    /* Make sure it is actually a RIFF file. */
    if (0 != memcmp(hdr.rifftag, "RIFF", 4)) {
        fclose(fh);
        return FALSE;
    }

    /* Get relevant information. */
    cmd_ln_set_int32_r(wtf->config, "-nchans", hdr.numchannels);
    cmd_ln_set_float32_r(wtf->config, "-samprate", hdr.SamplingFreq);
    wtf->infh = fh;

    return TRUE;
}
开发者ID:kirpen,项目名称:pocketsphinx.js,代码行数:33,代码来源:sphinx_fe.c

示例2: mmio_file_read

mmio_file_t *
mmio_file_read(const char *filename)
{
    mmio_file_t *mf;
    struct stat buf;
    void *ptr;
    int fd;
    size_t pagesize;

    if ((fd = open(filename, O_RDONLY)) == -1) {
        E_ERROR_SYSTEM("Failed to open %s", filename);
        return NULL;
    }
    if (fstat(fd, &buf) == -1) {
        E_ERROR_SYSTEM("Failed to stat %s", filename);
        close(fd);
        return NULL;
    }
    ptr = mmap(NULL, buf.st_size, PROT_READ, MAP_SHARED, fd, 0);
    if (ptr == (void *)-1) {
        E_ERROR_SYSTEM("Failed to mmap %lld bytes", (unsigned long long)buf.st_size);
        close(fd);
        return NULL;
    }
    close(fd);
    mf = ckd_calloc(1, sizeof(*mf));
    mf->ptr = ptr;
    /* Align map size to next page. */
    pagesize = sysconf(_SC_PAGESIZE);
    mf->mapsize = (buf.st_size + pagesize - 1) / pagesize * pagesize;

    return mf;
}
开发者ID:Toine-db,项目名称:pocketsphinx-wp-demo,代码行数:33,代码来源:mmio.c

示例3: sphinx_wave2feat_free

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;
}
开发者ID:kirpen,项目名称:pocketsphinx.js,代码行数:30,代码来源:sphinx_fe.c

示例4: open_nist_file

static int
open_nist_file(sphinx_wave2feat_t *wtf, char const *infile, FILE **out_fh, int detect_endian)
{
    char nist[7];
    lineiter_t *li;
    FILE *fh;

    if ((fh = fopen(infile, "rb")) == NULL) {
        E_ERROR_SYSTEM("Failed to open %s", infile);
        return -1;
    }
    if (fread(&nist, 1, 7, fh) != 7) {
        E_ERROR_SYSTEM("Failed to read NIST header");
        fclose(fh);
        return -1;
    }
    /* Is this actually a NIST file? */
    if (0 != strncmp(nist, "NIST_1A", 7)) {
        fclose(fh);
        return FALSE;
    }
    /* Rewind, parse lines. */
    fseek(fh, 0, SEEK_SET);
    for (li = lineiter_start(fh); li; li = lineiter_next(li)) {
        char **words;
        int nword;

        string_trim(li->buf, STRING_BOTH);
        if (strlen(li->buf) == 0) {
            lineiter_free(li);
            break;
        }
        nword = str2words(li->buf, NULL, 0);
        if (nword != 3)
            continue;
        words = (char **)ckd_calloc(nword, sizeof(*words));
        str2words(li->buf, words, nword);
        if (0 == strcmp(words[0], "sample_rate")) {
            cmd_ln_set_float32_r(wtf->config, "-samprate", atof_c(words[2]));
        }
        if (0 == strcmp(words[0], "channel_count")) {
            cmd_ln_set_int32_r(wtf->config, "-nchans", atoi(words[2]));
        }
        if (detect_endian && 0 == strcmp(words[0], "sample_byte_format")) {
            cmd_ln_set_str_r(wtf->config, "-input_endian",
                             (0 == strcmp(words[2], "10")) ? "big" : "little");
        }
        ckd_free(words);
    }

    fseek(fh, 1024, SEEK_SET);
    if (out_fh)
        *out_fh = fh;
    else
        fclose(fh);
    return TRUE;
}
开发者ID:kirpen,项目名称:pocketsphinx.js,代码行数:57,代码来源:sphinx_fe.c

示例5: 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

示例6: mk_bkp

static int32
mk_bkp(int32 mixw_reest,
       int32 tmat_reest,
       int32 mean_reest,
       int32 var_reest,
       const char *out_dir)
{
    char fn[MAXPATHLEN+1];
    char fn_bkp[MAXPATHLEN+1];
    FILE *fp;

    if (mixw_reest) {
	sprintf(fn, "%s/mixw_counts", out_dir);
	sprintf(fn_bkp, "%s/mixw_counts.bkp", out_dir);

	fp = fopen(fn, "rb");
	if (fp != NULL) {
	    fclose(fp);
	    if (rename(fn, fn_bkp) < 0) {
		E_ERROR_SYSTEM("Couldn't backup %s\n", fn);
		return S3_ERROR;
	    }
	}
    }
    if (tmat_reest) {
	sprintf(fn, "%s/tmat_counts", out_dir);
	sprintf(fn_bkp, "%s/tmat_counts.bkp", out_dir);

	fp = fopen(fn, "rb");
	if (fp != NULL) {
	    fclose(fp);
	    if (rename(fn, fn_bkp) < 0) {
		E_ERROR_SYSTEM("Couldn't backup %s\n", fn);
		return S3_ERROR;
	    }
	}
    }
    if (mean_reest || var_reest) {
	sprintf(fn, "%s/gauden_counts", out_dir);
	sprintf(fn_bkp, "%s/gauden_counts.bkp", out_dir);

	fp = fopen(fn, "rb");
	if (fp != NULL) {
	    fclose(fp);
	    if (rename(fn, fn_bkp) < 0) {
		E_ERROR_SYSTEM("Couldn't backup %s\n", fn);
		return S3_ERROR;
	    }
	}
    }

    return S3_SUCCESS;
}
开发者ID:10v,项目名称:cmusphinx,代码行数:53,代码来源:accum.c

示例7: 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

示例8: write_kd_trees

int32
write_kd_trees(const char *outfile, kd_tree_node_t **trees, uint32 n_trees)
{
	FILE *fp;
	uint32 i;

	if ((fp = fopen(outfile, "w"))  == NULL) {
		E_ERROR_SYSTEM("Failed to open %s", outfile);
		return -1;
	}
	fprintf(fp, "KD-TREES\n");
	fprintf(fp, "version %d\n", KDTREE_VERSION);
	fprintf(fp, "n_trees %d\n", n_trees);
	for (i = 0; i < n_trees; ++i) {
		fprintf(fp, "TREE %d\n", i);
		fprintf(fp, "n_density %d\n", trees[i]->n_density);
		fprintf(fp, "n_comp %d\n", trees[i]->n_comp);
		fprintf(fp, "n_level %d\n", trees[i]->n_level);
		fprintf(fp, "threshold %f\n", trees[i]->threshold);
		/* Output the nodes in depth-first ordering */
		write_kd_nodes(fp, trees[i], trees[i]->n_level);
		fprintf(fp, "\n");
	}
	fclose(fp);
	return 0;
}
开发者ID:Ankit77,项目名称:cmusphinx,代码行数:26,代码来源:kdtree.c

示例9: jsgf_parse_file

jsgf_t *
jsgf_parse_file(const char *filename, jsgf_t *parent)
{
    yyscan_t yyscanner;
    jsgf_t *jsgf;
    int yyrv;
    FILE *in = NULL;

    yylex_init(&yyscanner);
    if (filename == NULL) {
        yyset_in(stdin, yyscanner);
    }
    else {
        in = fopen(filename, "r");
        if (in == NULL) {
            E_ERROR_SYSTEM("Failed to open %s for parsing", filename);
            return NULL;
        }
        yyset_in(in, yyscanner);
    }

    jsgf = jsgf_grammar_new(parent);
    yyrv = yyparse(yyscanner, jsgf);
    if (yyrv != 0) {
        E_ERROR("Failed to parse JSGF grammar from '%s'\n", filename ? filename : "(stdin)");
        jsgf_grammar_free(jsgf);
        yylex_destroy(yyscanner);
        return NULL;
    }
    if (in)
        fclose(in);
    yylex_destroy(yyscanner);

    return jsgf;
}
开发者ID:AaronZhangL,项目名称:pocketsphinx.js,代码行数:35,代码来源:jsgf.c

示例10: output_frames_htk

/**
 * Output frames in HTK format.
 */
static int
output_frames_htk(sphinx_wave2feat_t *wtf, mfcc_t **frames, int nfr)
{
    int i, j, swap, htk_reorder, nfloat = 0;

    fe_mfcc_to_float(wtf->fe, frames, (float32 **)frames, nfr);
    /* This is possibly inefficient, but probably not a big deal. */
    swap = (0 == strcmp("little", cmd_ln_str_r(wtf->config, "-mach_endian")));
    htk_reorder = (0 == strcmp("htk", wtf->ot->name)
                   && !(cmd_ln_boolean_r(wtf->config, "-logspec")
                        || cmd_ln_boolean_r(wtf->config, "-cep2spec")));
    for (i = 0; i < nfr; ++i) {
        if (htk_reorder) {
            mfcc_t c0 = frames[i][0];
            memmove(frames[i] + 1, frames[i], (wtf->veclen - 1) * 4);
            frames[i][wtf->veclen - 1] = c0;
        }
        if (swap)
            for (j = 0; j < wtf->veclen; ++j)
                SWAP_FLOAT32(frames[i] + j);
        if (fwrite(frames[i], sizeof(float32), wtf->veclen, wtf->outfh) != wtf->veclen) {
            E_ERROR_SYSTEM("Writing %d values to %s failed",
                           wtf->veclen, wtf->outfile);
            return -1;
        }
        nfloat += wtf->veclen;
    }
    return nfloat;
}
开发者ID:kirpen,项目名称:pocketsphinx.js,代码行数:32,代码来源:sphinx_fe.c

示例11: dict_write

int
dict_write(dict_t *dict, char const *filename, char const *format)
{
    FILE *fh;
    int i;

    if ((fh = fopen(filename, "w")) == NULL) {
        E_ERROR_SYSTEM("Failed to open %s", filename);
        return -1;
    }
    for (i = 0; i < dict->n_word; ++i) {
        char *phones;
        int j, phlen;
        if (!dict_real_word(dict, i))
            continue;
        for (phlen = j = 0; j < dict_pronlen(dict, i); ++j)
            phlen += strlen(dict_ciphone_str(dict, i, j)) + 1;
        phones = ckd_calloc(1, phlen);
        for (j = 0; j < dict_pronlen(dict, i); ++j) {
            strcat(phones, dict_ciphone_str(dict, i, j));
            if (j != dict_pronlen(dict, i) - 1)
                strcat(phones, " ");
        }
        fprintf(fh, "%-30s %s\n", dict_wordstr(dict, i), phones);
        ckd_free(phones);
    }
    fclose(fh);
    return 0;
}
开发者ID:Ankit77,项目名称:cmusphinx,代码行数:29,代码来源:dict.c

示例12: acmod_log_mfc

static int
acmod_log_mfc(acmod_t *acmod,
              mfcc_t **cep, int n_frames)
{
    int i, n;
    int32 *ptr = (int32 *)cep[0];

    n = n_frames * feat_cepsize(acmod->fcb);
    /* Swap bytes. */
    if (!WORDS_BIGENDIAN) {
        for (i = 0; i < (n * sizeof(mfcc_t)); ++i) {
            SWAP_INT32(ptr + i);
        }
    }
    /* Write features. */
    if (fwrite(cep[0], sizeof(mfcc_t), n, acmod->mfcfh) != n) {
        E_ERROR_SYSTEM("Failed to write %d values to log file", n);
    }

    /* Swap them back. */
    if (!WORDS_BIGENDIAN) {
        for (i = 0; i < (n * sizeof(mfcc_t)); ++i) {
            SWAP_INT32(ptr + i);
        }
    }
    return 0;
}
开发者ID:JonGBowen,项目名称:GoodVibes,代码行数:27,代码来源:acmod.c

示例13: corpus_set_ctl_filename

/*********************************************************************
 *
 * Function: corpus_set_ctl_filename
 * 
 * Description: 
 *    This routine sets the control file used to define the corpus.
 *    It has a side-effect of opening the control file.
 * 
 * Function Inputs: 
 *    const char *ctl_filename -
 * 	This is the file name of the control file.
 *
 * Global Inputs: 
 *    None
 *
 * Return Values: 
 *    S3_SUCCESS -
 *	Indicates the control file could be opened for reading.
 *
 *    S3_ERROR -
 *	Indicates some error occured while opening the control file.
 *
 * Global Outputs: 
 *    None
 *
 * Pre-Conditions: 
 *    ctl_filename argument must be a pointer to a C string.
 * 
 * Post-Conditions: 
 * 
 *********************************************************************/
int
corpus_set_ctl_filename(const char *ctl_filename)
{
    lineiter_t *li;
    ctl_fp = fopen(ctl_filename, "rb");

    if (ctl_fp == NULL) {
	E_ERROR_SYSTEM("Unable to open %s for reading",  ctl_filename);
	return S3_ERROR;
    }
    
    li = lineiter_start_clean(ctl_fp);

    if (li == NULL) {
	E_ERROR("Must be at least one line in the control file\n");
	return S3_ERROR;
    }

    parse_ctl_line(li->buf,
		   &next_ctl_path,
		   &next_ctl_sf,
		   &next_ctl_ef,
		   &next_ctl_utt_id);
    lineiter_free (li);
    
    return S3_SUCCESS;
}
开发者ID:lliuguangbo,项目名称:sphinxtrain,代码行数:58,代码来源:corpus.c

示例14: guess_file_type

static int
guess_file_type(char const *file, FILE *infh)
{
    char header[4];

    fseek(infh, 0, SEEK_SET);
    if (fread(header, 1, 4, infh) != 4) {
        E_ERROR_SYSTEM("Failed to read 4 byte header");
        return -1;
    }
    if (0 == memcmp(header, "RIFF", 4)) {
        E_INFO("%s appears to be a WAV file\n", file);
        cmd_ln_set_boolean("-mswav", TRUE);
        cmd_ln_set_boolean("-nist", FALSE);
        cmd_ln_set_boolean("-raw", FALSE);
    }
    else if (0 == memcmp(header, "NIST", 4)) {
        E_INFO("%s appears to be a NIST SPHERE file\n", file);
        cmd_ln_set_boolean("-mswav", FALSE);
        cmd_ln_set_boolean("-nist", TRUE);
        cmd_ln_set_boolean("-raw", FALSE);
    }
    else {
        E_INFO("%s appears to be raw data\n", file);
        cmd_ln_set_boolean("-mswav", FALSE);
        cmd_ln_set_boolean("-nist", FALSE);
        cmd_ln_set_boolean("-raw", TRUE);
    }
    fseek(infh, 0, SEEK_SET);
    return 0;
}
开发者ID:SibghatullahSheikh,项目名称:pocketsphinx.js,代码行数:31,代码来源:sphinx_pitch.c

示例15: put_dhmm

static int
put_dhmm(float32 **tmat,
	 float32 ***mixw,
	 const char *dir,
	 const char *name)
{
    const char *hmm_ext;
    char fn[MAXPATHLEN];
    FILE *fp;

    hmm_ext = cmd_ln_access("-hmmext");

    sprintf(fn, "%s/%s.%s", dir, name, hmm_ext);
    
    fp = fopen(fn, "wb");
    if (fp == NULL) {
	E_ERROR_SYSTEM("can't open %s for writing", fn);
		       
	return S3_ERROR;
    }
    
    if (write_dhmm(tmat, mixw, fp) != S3_SUCCESS)
	return S3_ERROR;

    fclose(fp);

    return S3_SUCCESS;
}
开发者ID:10v,项目名称:cmusphinx,代码行数:28,代码来源:s2_write_hmm.c


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