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


C++ E_FATAL函数代码示例

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


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

示例1: main

/*
 * Wait for the user to type a <CR> then capture input audio for approx. 2 sec
 * and compute a measure of its power.
 */
int
main (int32 argc, char *argv[])
{
    char line[1024];
    ad_rec_t *ad;
    int16 buf[1000];
    int32 sps;
    
    sps = DEFAULT_SAMPLES_PER_SEC;

    if ((ad = ad_open_sps (sps)) == NULL)
	E_FATAL("ad_open_sps failed\n");
    
    for (;;) {
	printf ("Hit <CR> to measure A/D power; Q<CR> to quit: ");
	
	fgets (line, sizeof(line), stdin);
	if ((line[0] == 'q') || (line[0] == 'Q'))
	    break;
	
	ad_start_rec (ad);

	adpow(ad);
	
	ad_stop_rec (ad);
	while (ad_read (ad, buf, 1000) >= 0);	/* Flush any buffered, unread data */
    }

    ad_close (ad);
    return 0;
}
开发者ID:Rambonuaa,项目名称:BoundCheck4,代码行数:35,代码来源:adpow.c

示例2: read_ngrams

/**
 * Reads all the N-grams in the given N-gram file into the array of strings.
 *
 * args:
 * ngrams_file - the N-gram file to read N-grams from
 * ngrams - the array of string to read N-grams into
 *
 * returns: the number of ngrams read
 */
int
read_ngrams(char *ngrams_file,
            char **ngrams,
            s3lmwid32_t * wid[], int32 nwords[], int max_lines, lm_t * lm)
{
    FILE *fp;
    char line_read[MAX_STRLEN];
    int n, length;

    if ((fp = fopen(ngrams_file, "r")) == NULL) {
        E_FATAL("Unable to open N-gram file %s\n", ngrams_file);
    }

    n = 0;

    /* read each line in the file into the ngrams array */
    while (fgets(line_read, MAX_STRLEN, fp) != NULL) {
        if (n < max_lines) {
            length = strlen(line_read);
            line_read[length - 1] = '\0';
            ngrams[n] = (char *) ckd_calloc(length, sizeof(char));
            strncpy(ngrams[n], line_read, length - 1);
            wid[n] = (s3lmwid32_t *) ckd_calloc(3, sizeof(s3lmwid32_t));
            nwords[n] = ngram2wid(line_read, length, wid[n], lm);
            n++;
        }
        else {
            break;
        }
    }

    return n;
}
开发者ID:channainfo,项目名称:sphinx3-verboice,代码行数:42,代码来源:lm_test.c

示例3: read_seno_cluster

static int
read_seno_cluster(int32 **seno_cluster,
                  const char *seno_dir,
                  const char *base_name,
                  const char **ext,
                  uint32 n_weights)
{
    unsigned int f;
    int n_read;
    char seno_filename[MAXPATHLEN];

    E_INFO("reading mixing weights for %s\n",
           base_name);

    for (f = 0; f < S2_N_FEATURE; f++) {
        sprintf(seno_filename,
                "%s/%s.%s",
                seno_dir, base_name, ext[f]);

        areadint(seno_filename, &seno_cluster[f], &n_read);
        if (n_read != n_weights) {
            E_FATAL("expected %d weights in %s but got %d\n",
                    n_weights, seno_filename, n_read);
        }
    }

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

示例4: agc

void
agc(float32 *mfcc,
    uint32 n_frame)
{
    const char *agc_type = cmd_ln_access("-agc");
    uint32 i;

    if (strcmp(agc_type, "noise") == 0) {
	real_agc_noise(mfcc, n_frame, veclen);
    }
    else if (strcmp(agc_type, "max") == 0) {
	agc_max(mfcc, n_frame, veclen);
    }
    else if (strcmp(agc_type, "emax") == 0) {
	for (i = 0; i < n_frame; i++) {
	    agc_emax_proc(&mfcc[i*veclen], &mfcc[i*veclen],
			  veclen);
	}
    }
    else if (strcmp(agc_type, "none") == 0) {
	/* do nothing */
    }
    else if (agc_type == NULL) {
	E_WARN("no agc set\n");
	return ;
    }
    else {
	E_FATAL("unsupported agc type %s\n", agc_type);
    }
}
开发者ID:10v,项目名称:cmusphinx,代码行数:30,代码来源:agc.c

示例5: listelem_free

void
listelem_free(void *elem, int32 elemsize)
{
    char **cpp;
    list_t *prev, *list;

    /* Find list for elemsize */
    prev = NULL;
    for (list = head; list && (list->elemsize != elemsize);
         list = list->next)
        prev = list;

    if (!list) {
        E_FATAL("Unknown list item size: %d\n", elemsize);
    }
    else if (prev) {
        /* List found; move entry to head of list */
        prev->next = list->next;
        list->next = head;
        head = list;
    }

    /*
     * Insert freed item at head of list.
     * NOTE: skipping check for size being multiple of (void *).
     */
    cpp = (char **) elem;
    *cpp = (char *) list->freelist;
    list->freelist = cpp;
    (list->n_freed)++;
}
开发者ID:hschwenk,项目名称:cslm-toolkit,代码行数:31,代码来源:linklist.c

示例6: recognize_from_microphone

static void
recognize_from_microphone()
{
    ad_rec_t *ad;
    int16 adbuf[2048];
    uint8 utt_started, in_speech;
    int32 k;
    char const *hyp;

    if ((ad = ad_open_dev(AUDIO_DEVICE_NAME,
                          (int) SAMPLE_RATE )) == NULL) {
        E_FATAL("Failed to open audio device\n");
	}
    if (ad_start_rec(ad) < 0) {
        E_FATAL("Failed to start recording\n");
    }
    if (ps_start_utt(ps) < 0) {
        E_FATAL("Failed to start utterance\n");
    }
    utt_started = FALSE;
    printf("READY....\n");

    for (;;) {
        if ((k = ad_read(ad, adbuf, 2048)) < 0)
            E_FATAL("Failed to read audio\n");
        ps_process_raw(ps, adbuf, k, FALSE, FALSE);
        in_speech = ps_get_in_speech(ps);
        if (in_speech && !utt_started) {
            utt_started = TRUE;
            printf("Listening...\n");
        }
        if (!in_speech && utt_started) {
            /* speech -> silence transition, time to start new utterance  */
            ps_end_utt(ps);
            hyp = ps_get_hyp(ps, NULL );
            if (hyp != NULL)
                printf("%s\n", hyp);

            if (ps_start_utt(ps) < 0)
                E_FATAL("Failed to start utterance\n");
            utt_started = FALSE;
            printf("READY....\n");
        }
        sleep_msec(100);
    }
    ad_close(ad);
}
开发者ID:YetAnotherMinion,项目名称:SpeechTest,代码行数:47,代码来源:hello_ps.c

示例7: main

/*
 * Record A/D data for approximately specified number of seconds into specified file.
 */
int
main (int32 argc, char *argv[])
{
    char line[1024];
    ad_rec_t *ad;
    int16 buf[1000];
    int32 len, k, sps;
    FILE *fp;
    
    if ((argc != 4) ||
	(sscanf (argv[1], "%d", &sps) != 1) ||
	(sscanf (argv[2], "%d", &len) != 1)) {
	E_FATAL("Usage: %s <sampling-rate> <#sec-to-record> <output-file>\n", argv[0]);
    }
    if ((fp = fopen (argv[3], "wb")) == NULL)
	E_FATAL("fopen(%s,wb) failed\n", argv[3]);
    
    len *= sps;		/* Convert to min. #samples to record */
    
    if ((ad = ad_open_sps (sps)) == NULL)
	E_FATAL("ad_open_sps(%d) failed\n", sps);
    
    printf ("Hit <CR> to start recording\n");
    fgets (line, sizeof(line), stdin);
    
    ad_start_rec (ad);
    
    /* Record desired no. of samples */
    while (len > 0) {
	/* Read A/D */
	if ((k = ad_read (ad, buf, 1000)) < 0)
	    E_FATAL("ad_read returned %d\n", k);

	/* Write data read, if any, to file (ad_read may return 0 samples) */
	if (k > 0) {
	    fwrite (buf, sizeof(int16), k, fp);
	    fflush (fp);
	    len -= k;
	}
    }
    
    ad_stop_rec (ad);
    ad_close (ad);

    fclose (fp);
    return 0;
}
开发者ID:Rambonuaa,项目名称:BoundCheck4,代码行数:50,代码来源:adrec.c

示例8: subvq_map_compact

static void subvq_map_compact (subvq_t *vq, mgau_model_t *g)
{
    int32 r, c, c2, s;
    
    if (g) {
	if ((g->n_mgau != vq->origsize.r) || (g->max_comp != vq->origsize.c))
	    E_FATAL("Model size conflict: %d x %d (SubVQ) vs %d x %d (Original)\n",
		    vq->origsize.r, vq->origsize.c, g->n_mgau, g->max_comp);
    }
    
    /*
     * Compress map entries by removing invalid ones.  NOTE: There's not much of a consistency
     * check to ensure that the entries remaining do map correctly on to the valid entries in
     * the original (parent) mixture Gaussian model g.  The only check we have is to verify
     * the NUMBER of valid entries (components) in each mixture.
     */
    for (r = 0; r < vq->origsize.r; r++) {
	for (c = 0, c2 = 0; c < vq->origsize.c; c++) {
	    if (vq->map[r][c][0] < 0) {
		/* All ought to be < 0 */
		for (s = 1; s < vq->n_sv; s++) {
		    if (vq->map[r][c][s] >= 0)
			E_FATAL("Partially undefined map[%d][%d]\n", r, c);
		}
	    } else {
		if (c2 != c) {
		    for (s = 0; s < vq->n_sv; s++) {
			if (vq->map[r][c][s] < 0)
			    E_FATAL("Partially undefined map[%d][%d]\n", r, c);
			vq->map[r][c2][s] = vq->map[r][c][s];
		    }
		}
		c2++;
	    }
	}
	
	if (g && (c2 != mgau_n_comp (g, r)))
	    E_FATAL("Mixture %d: #Valid components conflict: %d (SubVQ) vs %d (Original)\n",
		    r, c2, mgau_n_comp(g,r));
	
	/* Invalidate the remaining map entries, for good measure */
	for (; c2 < vq->origsize.c; c2++) {
	    for (s = 0; s < vq->n_sv; s++)
		vq->map[r][c2][s] = -1;
	}
    }
}
开发者ID:10v,项目名称:cmusphinx,代码行数:47,代码来源:subvq.c

示例9: parse_base_line

static void
parse_base_line(mdef_t * m, char *line, int p)
{
    int32 wlen, n;
    __BIGSTACKVARIABLE__ char word[1024], *lp;
    int ci;

    lp = line;

    /* Read base phone name */
    if (sscanf(lp, "%s%n", word, &wlen) != 1)
        E_FATAL("Missing base phone name: %s\n", line);
    lp += wlen;

    /* Make sure it's not a duplicate */
    ci = mdef_ciphone_id(m, word);
    if (ci >= 0)
        E_FATAL("Duplicate base phone: %s\n", line);

    /* Add ciphone to ciphone table with id p */
    ciphone_add(m, word, p);
    ci = (int) p;

    /* Read and skip "-" for lc, rc, wpos */
    for (n = 0; n < 3; n++) {
        if ((sscanf(lp, "%s%n", word, &wlen) != 1)
            || (strcmp(word, "-") != 0))
            E_FATAL("Bad context info for base phone: %s\n", line);
        lp += wlen;
    }

    /* Read filler attribute, if present */
    if (sscanf(lp, "%s%n", word, &wlen) != 1)
        E_FATAL("Missing filler atribute field: %s\n", line);
    lp += wlen;
    if (strcmp(word, "filler") == 0)
        m->ciphone[(int) ci].filler = 1;
    else if (strcmp(word, "n/a") == 0)
        m->ciphone[(int) ci].filler = 0;
    else
        E_FATAL("Bad filler attribute field: %s\n", line);

    triphone_add(m, ci, -1, -1, WORD_POSN_UNDEFINED, p);

    /* Parse remainder of line: transition matrix and state->senone mappings */
    parse_tmat_senmap(m, line, lp - line, p);
}
开发者ID:KuoHugo,项目名称:pocketsphinx-wp-demo,代码行数:47,代码来源:mdef.c

示例10: phone_add_diphones

void phone_add_diphones (void)
/*------------------------*
 * DESCRIPTION - figure out what the word begin/end diphones of intrest are
 *	         and add them to the phone set.
 */
{
    int32 	phone_cnt = phone_count();
    int32	pid;
    int32	ret;
    int32	new_phone_id = phone_cnt;
    char	tp[64];
    char 	ci[32], lc[64], rc[64], pc[64];

    for (pid = 0; pid < phone_cnt; pid++) {
	strcpy (tp, phone_from_id (pid));
	ret = parse_triphone (tp, ci, lc, rc, pc);

	if (ret == 4) {
	    switch (pc[0]) {
	    case 'b':
		sprintf (tp, "%s(%%s,%s)b", ci, rc);
		if (phone_to_id (tp, FALSE) == NO_PHONE) {
		    add_phone (tp, new_phone_id, phone_to_id(ci, TRUE),
			       PT_DIPHONE, 1);
		    new_phone_id++;
		}
		break;
	    case 'e':
		sprintf (tp, "%s(%s,%%s)e", ci, lc);
		if (phone_to_id (tp, FALSE) == NO_PHONE) {
		    add_phone (tp, new_phone_id, phone_to_id(ci, TRUE),
			       PT_DIPHONE, 1);
		    new_phone_id++;
		}
		break;
	    case 's':
		sprintf (tp, "%s(%%s,%%s)s", ci);
		if (phone_to_id (tp, FALSE) == NO_PHONE) {
		    add_phone (tp, new_phone_id, phone_to_id(ci, TRUE),
			       PT_DIPHONE_S, 1);
		    new_phone_id++;
		}
		break;
	    case '\0':
		break;
	    default:
		E_FATAL("Unknown position context in %s == '%c'\n",
			tp, pc[0]);
	    }
	}
    }
    /*
     * Remake the phone map to account for the diphones
     */
    mk_phone_map ();

    E_INFO("Added %d new begin/end word diphones\n",
	   new_phone_id - phone_cnt);
}
开发者ID:4auka,项目名称:cmusphinx,代码行数:59,代码来源:phone.c

示例11: gs_fread_float32

float32
gs_fread_float32(gs_t * gs)
{
    float32 val;
    if (fread(&val, sizeof(float32), 1, gs->fp) != 1)
        E_FATAL("fread failed\n");
    return (val);
}
开发者ID:4auka,项目名称:cmusphinx,代码行数:8,代码来源:gs.c

示例12: read_1rule

static void
read_1rule(s3_cfg_t *_cfg, FILE *_file, float32 *_score,
           s3_cfg_id_t *_src, s3_cfg_id_t *_products)
{
  char name[S3_CFG_MAX_ITEM_STR_LEN + 1];
  float32 score;
  s3_cfg_id_t src;
  s3_cfg_id_t products[S3_CFG_MAX_ITEM_COUNT + 1];
  s3_cfg_id_t item;
  char format[1024];
  int len;
  int i;

  assert(_cfg != NULL);
  assert(_file != NULL);

  sprintf(format, "%%%ds", S3_CFG_MAX_ITEM_STR_LEN);

  /* read the prior */
  if (fscanf(_file, "%f", &score) != 1 || score < 0)
    E_FATAL("Bad CFG production rule\n");

  /* read the source */
  if (fscanf(_file, format, name) != 1)
    E_FATAL("Bad CFG production rule\n");

  src = s3_cfg_str2id(_cfg, name);
  if (src == S3_CFG_INVALID_ID)
    E_FATAL("Bad CFG production rule\n");

  if (s3_cfg_is_terminal(src))
    E_FATAL("Bad CFG production rule\n");

  if (fscanf(_file, "%d", &len) != 1)
    E_FATAL("Bad CFG production rule\n");

  if (len > S3_CFG_MAX_ITEM_COUNT)
    E_FATAL("CFG Production rule too long\n");

  /* read the products */
  for (i = 0; i < len; i++) {
    if (fscanf(_file, format, name) != 1)
      E_FATAL("Bad CFG production rule\n");

    item = s3_cfg_str2id(_cfg, name);
    if (item == S3_CFG_INVALID_ID)
      E_FATAL("Bad CFG production term\n");
    products[i] = item;
  }
  products[len] = S3_CFG_EOR_ITEM;

  *_src = src;
  *_score = score;
  memcpy(_products, products, (len + 1) * sizeof(s3_cfg_id_t));

}
开发者ID:elliotfiske,项目名称:cmu-lextool,代码行数:56,代码来源:s3_cfg.c

示例13: fe_warp_unwarped_to_warped

float
fe_warp_unwarped_to_warped(melfb_t *mel,float linear)
{
    if (mel->warp_id <= FE_WARP_ID_MAX) {
        return fe_warp_conf[mel->warp_id].unwarped_to_warped(linear);
    }
    else if (mel->warp_id == FE_WARP_ID_NONE) {
        E_FATAL("fe_warp module must be configured w/ a valid ID\n");
    }
    else {
        E_FATAL
            ("fe_warp module misconfigured with invalid fe_warp_id %u\n",
             mel->warp_id);
    }

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

示例14: main

int
main(int argc, char *argv[])
{
	cmd_ln_t *config;
	ngram_model_t *lm = NULL;
	logmath_t *lmath;
	const char *lmfn, *probdefn, *lsnfn, *text;

	if ((config = cmd_ln_parse_r(NULL, defn, argc, argv, TRUE)) == NULL)
		return 1;

        verbose = cmd_ln_boolean_r(config, "-verbose");

	/* Create log math object. */
	if ((lmath = logmath_init
	     (cmd_ln_float64_r(config, "-logbase"), 0, 0)) == NULL) {
		E_FATAL("Failed to initialize log math\n");
	}

	/* Load the language model. */
	lmfn = cmd_ln_str_r(config, "-lm");
	if (lmfn == NULL
	    || (lm = ngram_model_read(config, lmfn,
				      NGRAM_AUTO, lmath)) == NULL) {
		E_FATAL("Failed to load language model from %s\n",
			cmd_ln_str_r(config, "-lm"));
	}
        if ((probdefn = cmd_ln_str_r(config, "-probdef")) != NULL)
            ngram_model_read_classdef(lm, probdefn);
        ngram_model_apply_weights(lm,
                                  cmd_ln_float32_r(config, "-lw"),
                                  cmd_ln_float32_r(config, "-wip"),
                                  cmd_ln_float32_r(config, "-uw"));

	/* Now evaluate some text. */
	lsnfn = cmd_ln_str_r(config, "-lsn");
	text = cmd_ln_str_r(config, "-text");
	if (lsnfn) {
		evaluate_file(lm, lmath, lsnfn);
	}
	else if (text) {
		evaluate_string(lm, lmath, text);
	}

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

示例15: fe_warp_doc

const char *
fe_warp_doc(melfb_t *mel)
{
    if (mel->warp_id <= FE_WARP_ID_MAX) {
        return fe_warp_conf[mel->warp_id].doc();
    }
    else if (mel->warp_id == FE_WARP_ID_NONE) {
        E_FATAL("fe_warp module must be configured w/ a valid ID\n");
    }
    else {
        E_FATAL
            ("fe_warp module misconfigured with invalid fe_warp_id %u\n",
             mel->warp_id);
    }

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


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