这篇教程C++ E_ERROR_SYSTEM函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中E_ERROR_SYSTEM函数的典型用法代码示例。如果您正苦于以下问题:C++ E_ERROR_SYSTEM函数的具体用法?C++ E_ERROR_SYSTEM怎么用?C++ E_ERROR_SYSTEM使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了E_ERROR_SYSTEM函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 intdetect_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,
示例2: mmio_file_readmmio_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,
示例3: sphinx_wave2feat_freeintsphinx_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,
示例4: open_nist_filestatic intopen_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,
示例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 intdetect_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,
示例6: mk_bkpstatic int32mk_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,
示例7: write_nbeststatic intwrite_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,
示例8: write_kd_treesint32write_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,
示例9: jsgf_parse_filejsgf_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,
示例10: output_frames_htk/** * Output frames in HTK format. */static intoutput_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,
示例11: dict_writeintdict_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,
示例12: acmod_log_mfcstatic intacmod_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,
示例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: * *********************************************************************/intcorpus_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,
示例14: guess_file_typestatic intguess_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,
示例15: put_dhmmstatic intput_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,
示例16: stat_retryint32stat_retry(const char *file, struct stat * statbuf){ int32 i; for (i = 0; i < STAT_RETRY_COUNT; i++) {#ifndef HAVE_SYS_STAT_H FILE *fp; if ((fp=(FILE *)fopen(file, "r"))!= 0) { fseek( fp, 0, SEEK_END); statbuf->st_size = ftell( fp ); fclose(fp); return 0; } #else /* HAVE_SYS_STAT_H */ if (stat(file, statbuf) == 0) return 0;#endif if (i == 0) { E_ERROR_SYSTEM("Failed to stat file '%s'; retrying...", file); }#ifdef HAVE_UNISTD_H sleep(1);#endif } return -1;}
开发者ID:andrenatal,项目名称:pocketsphinx-gecko,代码行数:34,
示例17: uttfile_openuttfile_t *uttfile_open(const char *fn){ uttfile_t *uf; char tmp[32000]; uint32 i; uf = (uttfile_t *)ckd_calloc(1, sizeof(uttfile_t)); uf->fp = fopen(fn, "r"); if (uf->fp == NULL) { E_ERROR_SYSTEM("Can't open file %s", fn); ckd_free(uf); return NULL; } for (i = 0; read_line(tmp, 32000, &i, uf->fp) != NULL;); uf->len = i; rewind(uf->fp); /* uf->off == 0 by virtue of calloc */ return uf;}
开发者ID:Amos-zq,项目名称:speechcontrol-sphinxtrain,代码行数:28,
示例18: strlenFILE *fopen_compchk (char *file, int32 *ispipe){ char tmpfile[16384]; FILE *fp; int32 k, isgz; struct stat statbuf; k = strlen (file); #if (WIN32) *ispipe = (k > 3) && ((strcmp (file+k-3, ".gz") == 0) || (strcmp (file+k-3, ".GZ") == 0)); isgz = *ispipe;#else *ispipe = 0; isgz = 0; if ((k > 2) && ((strcmp (file+k-2, ".Z") == 0) || (strcmp (file+k-2, ".z") == 0))) { *ispipe = 1; } else { if ((k > 3) && ((strcmp (file+k-3, ".gz") == 0) || (strcmp (file+k-3, ".GZ") == 0))) { *ispipe = 1; isgz = 1; } }#endif strcpy (tmpfile, file); if (stat (tmpfile, &statbuf) != 0) { /* File doesn't exist; try other compressed/uncompressed form, as appropriate */ E_ERROR_SYSTEM("stat(%s) failed/n", tmpfile); if (*ispipe) { if (isgz) tmpfile[k-3] = '/0'; else tmpfile[k-2] = '/0'; if (stat (tmpfile, &statbuf) != 0) return NULL; } else { strcpy (tmpfile+k, ".gz"); if (stat (tmpfile, &statbuf) != 0) {#if (! WIN32) strcpy (tmpfile+k, ".Z"); if (stat (tmpfile, &statbuf) != 0) return NULL;#else return NULL;#endif } } E_WARN("Using %s instead of %s/n", tmpfile, file); } return (fopen_comp (tmpfile, "r", ispipe));}
开发者ID:phillipstanleymarbell,项目名称:sunflower-simulator,代码行数:58,
示例19: output_header_sphinx/** * Output sphinx format "header" * * @return 0 for success, <0 for error. */static intoutput_header_sphinx(sphinx_wave2feat_t *wtf, int32 nfloat){ if (fwrite(&nfloat, 4, 1, wtf->outfh) != 1) { E_ERROR_SYSTEM("Failed to write to %s", wtf->outfile); return -1; } return 0;}
开发者ID:kirpen,项目名称:pocketsphinx.js,代码行数:14,
示例20: acmod_read_scores_internal/** * Internal version, used for reading previous frames in acmod_score() */static intacmod_read_scores_internal(acmod_t *acmod){ FILE *senfh = acmod->insenfh; int16 n_active; size_t rv; if (acmod->n_feat_frame == acmod->n_feat_alloc) { if (acmod->grow_feat) acmod_grow_feat_buf(acmod, acmod->n_feat_alloc * 2); else return 0; } if (senfh == NULL) return -1; if ((rv = fread(&n_active, 2, 1, senfh)) != 1) goto error_out; acmod->n_senone_active = n_active; if (acmod->n_senone_active == bin_mdef_n_sen(acmod->mdef)) { if ((rv = fread(acmod->senone_scores, 2, acmod->n_senone_active, senfh)) != acmod->n_senone_active) goto error_out; } else { int i, n; if ((rv = fread(acmod->senone_active, 1, acmod->n_senone_active, senfh)) != acmod->n_senone_active) goto error_out; for (i = 0, n = 0; i < acmod->n_senone_active; ++i) { int j, sen = n + acmod->senone_active[i]; for (j = n + 1; j < sen; ++j) acmod->senone_scores[j] = SENSCR_DUMMY; if ((rv = fread(acmod->senone_scores + sen, 2, 1, senfh)) != 1) goto error_out; n = sen; } n++; while (n < bin_mdef_n_sen(acmod->mdef)) acmod->senone_scores[n++] = SENSCR_DUMMY; } return 1;error_out: if (ferror(senfh)) { E_ERROR_SYSTEM("Failed to read frame from senone file"); return -1; } return 0;}
开发者ID:JonGBowen,项目名称:GoodVibes,代码行数:60,
示例21: mmio_file_unmapvoidmmio_file_unmap(mmio_file_t *mf){ if (mf == NULL) return; if (munmap(mf->ptr, mf->mapsize) < 0) { E_ERROR_SYSTEM("Failed to unmap %ld bytes at %p", mf->mapsize, mf->ptr); } ckd_free(mf);}
开发者ID:Toine-db,项目名称:pocketsphinx-wp-demo,代码行数:10,
示例22: revert_bkpstatic int32revert_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]; if (mixw_reest) { sprintf(fn, "%s/mixw_counts", out_dir); sprintf(fn_bkp, "%s/mixw_counts.bkp", out_dir); if (rename(fn_bkp, fn) < 0) { E_ERROR_SYSTEM("Couldn't revert to backup of %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); if (rename(fn_bkp, fn) < 0) { E_ERROR_SYSTEM("Couldn't revert to backup of %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); if (rename(fn_bkp, fn) < 0) { E_ERROR_SYSTEM("Couldn't revert to backup of %s/n", fn); return S3_ERROR; } } return S3_SUCCESS;}
开发者ID:10v,项目名称:cmusphinx,代码行数:41,
示例23: write_wdseg/* Write word segmentation output file */static voidwrite_wdseg(char *dir, align_wdseg_t * wdseg, char *uttid, char *ctlspec){ char str[1024]; FILE *fp; int32 uttscr; /* Attempt to write segmentation for this utt to a separate file */ build_output_uttfile(str, dir, uttid, ctlspec); strcat(str, ".wdseg"); E_INFO("Writing word segmentation to: %s/n", str); if ((fp = fopen(str, "w")) == NULL) { E_ERROR_SYSTEM("Failed to open file %s for writing", str); fp = stdout; /* Segmentations can be directed to stdout this way */ E_INFO("Word segmentation (%s):/n", uttid); dir = NULL; /* Flag to indicate fp shouldn't be closed at the end */ } if (!dir) { fprintf(fp, "WD:%s>", uttid); fflush(fp); } fprintf(fp, "/t%5s %5s %10s %s/n", "SFrm", "EFrm", "SegAScr", "Word"); fflush(fp); uttscr = 0; for (; wdseg; wdseg = wdseg->next) { if (!dir) { fprintf(fp, "wd:%s>", uttid); fflush(fp); } fprintf(fp, "/t%5d %5d %10d %s/n", wdseg->sf, wdseg->ef, wdseg->score, dict_wordstr(dict, wdseg->wid)); fflush(fp); uttscr += wdseg->score; } if (!dir) { fprintf(fp, "WD:%s>", uttid); fflush(fp); } fprintf(fp, " Total score: %11d/n", uttscr); fflush(fp); if (dir) fclose(fp); else { fprintf(fp, "/n"); fflush(fp); }}
开发者ID:Ankit77,项目名称:cmusphinx,代码行数:54,
示例24: detect_raw/** * Default "detection" function, just opens the file and keeps the * default configuration parameters. * * @return TRUE, or -1 on error. */static intdetect_raw(sphinx_wave2feat_t *wtf){ FILE *fh; if ((fh = fopen(wtf->infile, "rb")) == NULL) { E_ERROR_SYSTEM("Failed to open %s", wtf->infile); return -1; } wtf->infh = fh; return TRUE;}
开发者ID:kirpen,项目名称:pocketsphinx.js,代码行数:18,
示例25: batch_decoder_decodeint batch_decoder_decode(batch_decoder_t *bd, char *file, char *uttid, int32 sf, int32 ef, alignment_t *al){ featbuf_t *fb; FILE *infh; char const *cepdir, *cepext; char *infile; int rv; if (ef != -1 && ef < sf) { E_ERROR("End frame %d is < start frame %d/n", ef, sf); return -1; } cepdir = cmd_ln_str_r(bd->config, "-cepdir"); cepext = cmd_ln_str_r(bd->config, "-cepext"); /* Build input filename. */ infile = string_join(cepdir ? cepdir : "", "/", file, cepext ? cepext : "", NULL); if (uttid == NULL) uttid = file; if ((infh = fopen(infile, "rb")) == NULL) { E_ERROR_SYSTEM("Failed to open %s", infile); return -1; } fb = search_factory_featbuf(bd->sf); gettimeofday(&bd->utt_start, NULL); featbuf_producer_start_utt(fb, uttid); if (cmd_ln_boolean_r(bd->config, "-adcin")) rv = batch_decoder_decode_adc(bd, infh, sf, ef, al); else rv = batch_decoder_decode_mfc(bd, infh, sf, ef, al); featbuf_producer_end_utt(fb); if (bd->hypfh) { char const *hyp; int32 score; hyp = search_hyp(bd->fwdflat, &score); fprintf(bd->hypfh, "%s (%s %d)/n", hyp, uttid, score); } fclose(infh); ckd_free(infile); return rv;}
开发者ID:Ankit77,项目名称:cmusphinx,代码行数:52,
示例26: write_phseg/* Write phone segmentation output file */static voidwrite_phseg(char *dir, align_phseg_t * phseg, char *uttid, char *ctlspec){ char str[1024]; FILE *fp; int32 uttscr; /* Attempt to write segmentation for this utt to a separate file */ build_output_uttfile(str, dir, uttid, ctlspec); strcat(str, ".phseg"); E_INFO("Writing phone segmentation to: %s/n", str); if ((fp = fopen(str, "w")) == NULL) { E_ERROR_SYSTEM("Failed to open file %s for writing", str); fp = stdout; /* Segmentations can be directed to stdout this way */ E_INFO("Phone segmentation (%s):/n", uttid); dir = NULL; /* Flag to indicate fp shouldn't be closed at the end */ } if (!dir) { fprintf(fp, "PH:%s>", uttid); fflush(fp); } fprintf(fp, "/t%5s %5s %9s %s/n", "SFrm", "EFrm", "SegAScr", "Phone"); fflush(fp); uttscr = 0; for (; phseg; phseg = phseg->next) { mdef_phone_str(kbc->mdef, phseg->pid, str); if (!dir) { fprintf(fp, "ph:%s>", uttid); fflush(fp); } fprintf(fp, "/t%5d %5d %9d %s/n", phseg->sf, phseg->ef, phseg->score, str); fflush(fp); uttscr += (phseg->score); } if (!dir) { fprintf(fp, "PH:%s>", uttid); fflush(fp); } fprintf(fp, " Total score: %11d/n", uttscr); fflush(fp); if (dir) fclose(fp); else { fprintf(fp, "/n"); fflush(fp); }}
开发者ID:Ankit77,项目名称:cmusphinx,代码行数:53,
示例27: decode_pcm/** * Process PCM audio from a filehandle. Assume that wtf->infh is * positioned just after the file header. */static intdecode_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,
示例28: open_dmpstatic FILE *open_dmp(const char *fn){ FILE *fp; s3clr_fattr(); fp = s3open(fn, "wb", NULL); if (fp == NULL) { E_ERROR_SYSTEM("Unable to open %s for writing.", fn); } return fp;}
开发者ID:Amos-zq,项目名称:speechcontrol-sphinxtrain,代码行数:13,
示例29: fsg_model_readfilefsg_model_t *fsg_model_readfile(const char *file, logmath_t * lmath, float32 lw){ FILE *fp; fsg_model_t *fsg; if ((fp = fopen(file, "r")) == NULL) { E_ERROR_SYSTEM("Failed to open FSG file '%s' for reading", file); return NULL; } fsg = fsg_model_read(fp, lmath, lw); fclose(fp); return fsg;}
开发者ID:AaronZhangL,项目名称:pocketsphinx.js,代码行数:14,
示例30: corpus_ckpt/* * This must be done after the processing of the utterance */intcorpus_ckpt(const char *fn){ FILE *fp; char tmp[256]; fp = fopen(fn, "w"); if (fp == NULL) { E_ERROR_SYSTEM("Unable to open chkpt file %s/n", fn); return S3_ERROR; } sprintf(tmp,"%u %u/n", begin + n_proc, n_run); printf("|%s|/n", tmp); if (fprintf(fp, "%u %u/n", begin + n_proc, n_run) != strlen(tmp)) { E_ERROR_SYSTEM("Unable to write %s successfully/n", fn); } fclose(fp); return S3_SUCCESS;}
开发者ID:lliuguangbo,项目名称:sphinxtrain,代码行数:27,
注:本文中的E_ERROR_SYSTEM函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ E_FATAL函数代码示例 C++ E_ERROR函数代码示例 |