• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ ps_args函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: main

int
main(int argc, char *argv[])
{
	logmath_t *lmath;
	cmd_ln_t *config;
	acmod_t *acmod;
	ps_mgau_t *ps;
	ptm_mgau_t *s;
	int i, lastcb;

	lmath = logmath_init(1.0001, 0, 0);
	config = cmd_ln_init(NULL, ps_args(), TRUE,
	     "-compallsen", "yes",
	     "-input_endian", "little",
	     NULL);
	cmd_ln_parse_file_r(config, ps_args(), MODELDIR "/en-us/en-us/feat.params", FALSE);

	cmd_ln_set_str_extra_r(config, "_mdef", MODELDIR "/en-us/en-us/mdef");
	cmd_ln_set_str_extra_r(config, "_mean", MODELDIR "/en-us/en-us/means");
	cmd_ln_set_str_extra_r(config, "_var", MODELDIR "/en-us/en-us/variances");
	cmd_ln_set_str_extra_r(config, "_tmat", MODELDIR "/en-us/en-us/transition_matrices");
	cmd_ln_set_str_extra_r(config, "_sendump", MODELDIR "/en-us/en-us/sendump");
	cmd_ln_set_str_extra_r(config, "_mixw", NULL);
	cmd_ln_set_str_extra_r(config, "_lda", NULL);
	cmd_ln_set_str_extra_r(config, "_senmgau", NULL);	
	
	err_set_debug_level(3);
	TEST_ASSERT(config);
	TEST_ASSERT((acmod = acmod_init(config, lmath, NULL, NULL)));
	TEST_ASSERT((ps = acmod->mgau));
	TEST_EQUAL(0, strcmp(ps->vt->name, "ptm"));
	s = (ptm_mgau_t *)ps;
	E_DEBUG(2,("PTM model loaded: %d codebooks, %d senones, %d frames of history\n",
		   s->g->n_mgau, s->n_sen, s->n_fast_hist));
	E_DEBUG(2,("Senone to codebook mappings:\n"));
	lastcb = s->sen2cb[0];
	E_DEBUG(2,("\t%d: 0", lastcb));
	for (i = 0; i < s->n_sen; ++i) {
		if (s->sen2cb[i] != lastcb) {
			lastcb = s->sen2cb[i];
			E_DEBUGCONT(2,("-%d\n", i-1));
			E_DEBUGCONT(2,("\t%d: %d", lastcb, i));
		}
	}
	E_INFOCONT("-%d\n", i-1);
	run_acmod_test(acmod);

#if 0
	/* Replace it with ms_mgau. */
	ptm_mgau_free(ps);
	cmd_ln_set_str_r(config,
			 "-mixw",
			 MODELDIR "/en-us/en-us/mixture_weights");
	TEST_ASSERT((acmod->mgau = ms_mgau_init(acmod, lmath, acmod->mdef)));
	run_acmod_test(acmod);
	cmd_ln_free_r(config);
#endif

	return 0;
}
开发者ID:DanielSWolf,项目名称:rhubarb-lip-sync,代码行数:60,代码来源:test_ptm_mgau.c


示例2: main

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

    TEST_ASSERT(config =
                    cmd_ln_init(NULL, ps_args(), TRUE,
                                "-hmm", MODELDIR "/hmm/en_US/hub4wsj_sc_8k",
                                "-lm", MODELDIR "/lm/en_US/wsj0vp.5000.DMP",
                                "-dict", MODELDIR "/lm/en_US/cmu07a.dic",
                                "-fwdtree", "yes",
                                "-fwdflat", "yes",
                                "-bestpath", "yes",
                                "-input_endian", "little",
                                "-samprate", "16000", NULL));
    TEST_ASSERT(ps = ps_init(config));

    TEST_ASSERT(config =
                    cmd_ln_init(NULL, ps_args(), TRUE,
                                "-hmm", MODELDIR "/hmm/en/tidigits",
                                "-lm", MODELDIR "/lm/en/tidigits.DMP",
                                "-dict", MODELDIR "/lm/en/tidigits.dic",
                                "-fwdtree", "yes",
                                "-fwdflat", "yes",
                                "-bestpath", "yes",
                                "-input_endian", "little",
                                "-samprate", "16000", NULL));
    TEST_EQUAL(0, ps_reinit(ps, config));

    ps_free(ps);

    return 0;
}
开发者ID:zaqzaq,项目名称:cmusphinx,代码行数:34,代码来源:test_ps_reinit.c


示例3: main

int main(int argc, char *argv[]) {
    int go = 1;
    const char *lang    = argv[1];
    const char *rawFile = argv[2];
    cmd_ln_t *config;

    // Configure recognizer for English or Spanish
    if (strcmp(lang, "engl") == 0) {
        config = cmd_ln_init(NULL, ps_args(), TRUE,
                "-hmm",    MODELDIR "/en-us/en-us",
                "-lm",     MODELDIR "/en-us/en-us.lm.bin",
                "-dict",   MODELDIR "/en-us/cmudict-en-us.dict",
                NULL);

    } else if (strcmp(lang, "span") == 0) {
        config = cmd_ln_init(NULL, ps_args(), TRUE,
                "-hmm",     "/home/pi/es_MX_broadcast_cont_2500/model_parameters/hub4_spanish_itesm.cd_cont_2500",
                "-lm",      "/home/pi/es_MX_broadcast_cont_2500/etc/H4.arpa.Z.DMP",
                "-dict",    "/home/pi/es_MX_broadcast_cont_2500/etc/h4.dict",
                NULL);
    }

    if (config == NULL) {
        fprintf(stderr, "Failed to create config object, see log for details\n");
        return -1;
    }
    
    // Initialize pocketsphinx
    ps = ps_init(config);
    if (ps == NULL) {
        fprintf(stderr, "Failed to create recognizer, see log for details\n");
        return -1;
    }

    fflush(stdout);

    // Wait for signal from stdin
    while (1) {
        // Waiting for command
        scanf("%d", &go);
        if (go) {
            processRaw(rawFile);
        } else break;
    }

    // free memory
    ps_free(ps);
    cmd_ln_free_r(config);
    
    return 0;
}
开发者ID:champagneSeth,项目名称:lopez,代码行数:51,代码来源:sonus.c


示例4: gst_pocketsphinx_init

static void
gst_pocketsphinx_init(GstPocketSphinx * ps,
                      GstPocketSphinxClass * gclass)
{
    ps->sinkpad =
        gst_pad_new_from_static_template(&sink_factory, "sink");
    ps->srcpad =
        gst_pad_new_from_static_template(&src_factory, "src");

    /* Create the hash table to store argument strings. */
    ps->arghash = g_hash_table_new(g_str_hash, g_str_equal);

    /* Parse default command-line options. */
    ps->config = cmd_ln_parse_r(NULL, ps_args(), default_argc, default_argv, FALSE);

    /* Set up pads. */
    gst_element_add_pad(GST_ELEMENT(ps), ps->sinkpad);
    gst_pad_set_chain_function(ps->sinkpad, gst_pocketsphinx_chain);
    gst_pad_set_event_function(ps->sinkpad, gst_pocketsphinx_event);
    gst_pad_use_fixed_caps(ps->sinkpad);

    gst_element_add_pad(GST_ELEMENT(ps), ps->srcpad);
    gst_pad_use_fixed_caps(ps->srcpad);

    /* Initialize time. */
    ps->last_result_time = 0;
    ps->last_result = NULL;

    /* Nbest size */
    ps->n_best_size = 10;
}
开发者ID:SibghatullahSheikh,项目名称:pocketsphinx.js,代码行数:31,代码来源:gstpocketsphinx.c


示例5: default_config

static cmd_ln_t *
default_config()
{
    return cmd_ln_init(NULL, ps_args(), TRUE,
                       "-hmm", MODELDIR "/en-us/en-us",
                       "-dict", MODELDIR "/en-us/cmudict-en-us.dict", NULL);
}
开发者ID:googolhkl,项目名称:jarvis,代码行数:7,代码来源:test_ps_set_search.c


示例6: main

int
main(int argc, char *argv[])
{
	cmd_ln_t *config;
	ps_decoder_t *ps;
	FILE *rawfh;
	char const *hyp;
	char const *uttid;
	int32 score;

	TEST_ASSERT(config =
		    cmd_ln_init(NULL, ps_args(), TRUE,
				"-hmm", DATADIR "/an4_ci_cont",
				"-lm", MODELDIR "/lm/en/turtle.DMP",
				"-dict", MODELDIR "/lm/en/turtle.dic",
				"-mllr", DATADIR "/mllr_matrices",
				"-samprate", "16000", NULL));

	TEST_ASSERT(ps = ps_init(config));
	TEST_ASSERT(rawfh = fopen(DATADIR "/goforward.raw", "rb"));
	ps_decode_raw(ps, rawfh, "goforward", -1);
	fclose(rawfh);
	hyp = ps_get_hyp(ps, &score, &uttid);
	printf("FWDFLAT (%s): %s (%d)\n", uttid, hyp, score);
	ps_free(ps);
	cmd_ln_free_r(config);
	return 0;
}
开发者ID:AaronZhangL,项目名称:pocketsphinx.js,代码行数:28,代码来源:test_mllr.c


示例7: sphinx_gui_listen_main

void*
sphinx_gui_listen_main(void *arg)
{
    int outfd = (int)arg;
    char const *cfg;
    char hmm[256];
    char lm[256];
    char dict[256];

    snprintf(hmm, 256, "%s/%s", modeldir, hmmdir);
    snprintf(lm, 256, "%s/%s", modeldir, lmdump);
    snprintf(dict, 256, "%s/%s", modeldir, lmdict);

    config = cmd_ln_init(NULL, ps_args(), TRUE,
			"-hmm", hmm, "-lm", lm, "-dict", dict,
			NULL);

    if (config == NULL)
        return NULL;

    ps = ps_init(config);
    if (ps == NULL)
        return NULL;

    recognize_from_microphone(outfd);

    ps_free(ps);

    return NULL;
}
开发者ID:echoline,项目名称:PocketSphinxLauncher,代码行数:30,代码来源:sphx.c


示例8: cmd_ln_init

bool GqAndroidSphinx::init_sphinx(IGqRecord *precord) {
	m_pconfig = cmd_ln_init(NULL, ps_args(), TRUE, "-hmm", m_shmm.c_str(),
			"-lm", m_slm.c_str(), "-dict", m_sdict.c_str(), NULL);
	if (m_pconfig == NULL) {
		return false;
	}

	if (m_pdecoder) {
		LOGD("m_pdecoder");
		ps_free(m_pdecoder);
		m_pdecoder = NULL;
	}
	m_pdecoder = ps_init(m_pconfig);
	if (m_pdecoder == 0) {
		return false;
	}
	if (m_precord) {
		LOGD("delete m_precord;");
		m_precord->stop_record();
		delete m_precord;
		m_precord = NULL;
	}
	m_precord = precord;
	m_precord->set_record_cb(this);
	m_precord->init_recorder();
	LOGD("after init_recorder");
	return true;
}
开发者ID:vinodkumarkv13,项目名称:sphinx-on-android,代码行数:28,代码来源:gqandroidsphinx.cpp


示例9: main

int
main(int argc, char *argv[])
{
	cmd_ln_t *config;
	logmath_t *lmath;
	acmod_t *acmod[5];
	sbthread_t *thr[5];
	featbuf_t *fb;
	FILE *raw;
	int16 buf[2048];
	int nsamp;
	int i;

	config = cmd_ln_init(NULL, ps_args(), TRUE,
			     "-hmm", TESTDATADIR "/hub4wsj_sc_8k",
			     "-lm", TESTDATADIR "/bn10000.3g.arpa",
			     "-dict", TESTDATADIR "/bn10000.dic",
			     "-compallsen", "yes",
			     NULL);
	ps_init_defaults(config);
	fb = featbuf_init(config);
	TEST_ASSERT(fb);

	lmath = logmath_init(cmd_ln_float32_r(config, "-logbase"),
			     0, FALSE);
	acmod[0] = acmod_init(config, lmath, fb);
	TEST_ASSERT(acmod[0]);
	/* Create a couple threads to pull features out of it. */
	for (i = 0; i < 5; ++i) {
		if (i != 0)
			acmod[i] = acmod_copy(acmod[0]);
		thr[i] = sbthread_start(NULL, consumer, acmod[i]);
	}

	/* Feed them some data. */
	raw = fopen(TESTDATADIR "/chan3.raw", "rb");
	featbuf_producer_start_utt(fb, "chan3");
	while ((nsamp = fread(buf, 2, 2048, raw)) > 0) {
		int rv;
		rv = featbuf_producer_process_raw(fb, buf, nsamp, FALSE);
		printf("Producer processed %d samples\n", nsamp);
		TEST_ASSERT(rv > 0);
	}
	fclose(raw);
	printf("Waiting for consumers\n");
	featbuf_producer_end_utt(fb);
	printf("Finished waiting\n");

	/* Reap those threads. */
	for (i = 0; i < 5; ++i) {
		sbthread_wait(thr[i]);
		sbthread_free(thr[i]);
		acmod_free(acmod[i]);
		printf("Reaped consumer %p\n", acmod[i]);
	}
	featbuf_free(fb);
	logmath_free(lmath);
	cmd_ln_free_r(config);
	return 0;
}
开发者ID:Ankit77,项目名称:cmusphinx,代码行数:60,代码来源:test_acmod.c


示例10: asr_init

static av_cold int asr_init(AVFilterContext *ctx)
{
    ASRContext *s = ctx->priv;
    const float frate = s->rate;
    char *rate = av_asprintf("%f", frate);
    const char *argv[] = { "-logfn",    s->logfn,
                           "-hmm",      s->hmm,
                           "-lm",       s->lm,
                           "-lmctl",    s->lmctl,
                           "-lmname",   s->lmname,
                           "-dict",     s->dict,
                           "-samprate", rate,
                           NULL };

    s->config = cmd_ln_parse_r(NULL, ps_args(), 14, (char **)argv, 0);
    av_free(rate);
    if (!s->config)
        return AVERROR(ENOMEM);

    ps_default_search_args(s->config);
    s->ps = ps_init(s->config);
    if (!s->ps)
        return AVERROR(ENOMEM);

    return 0;
}
开发者ID:ShiftMediaProject,项目名称:FFmpeg,代码行数:26,代码来源:af_asr.c


示例11: main

int main(int argc, char* argv[])
{
    /*FILE *fh;*/
    /*int rv;*/
    /*char const *hyp, *uttid;*/
    /*int16 buf[512];*/
    if (argc < 2) {
        printf("Usage: %s <config.gram>\n", argv[0]);
        return 0;
    }

    config = cmd_ln_init(NULL, ps_args(), TRUE,
                        "-hmm", MODELDIR "/hmm/en_US/hub4wsj_sc_8k",
                        "-lm", MODELDIR "/lm/en_US/wsj0vp.5000.DMP",
                        "-dict", MODELDIR "/lm/en_US/cmu07a.dic",
                        "-jsgf", argv[1],
                        NULL);
    /*config = cmd_ln_parse_file_r(NULL, ps_args(), "config.es", FALSE);*/
    if ( config == NULL )
        return 1;
    
    ps = ps_init(config);
    if ( ps == NULL ) {
      printf("Unable to allocate decoder.\n");
      return 1;
    }

	recognize_from_microphone();

    // Cleaning up
    ps_free(ps);
    return 0;
}
开发者ID:hackliff,项目名称:domobot,代码行数:33,代码来源:voiceCommands.c


示例12: run

int run(CallbackType callback, char* kpath) {
	//string path ="C:/Users/Reza/Documents/GitHub/speech_agent/speech/Release/";
	listenCallback = callback;
	config = cmd_ln_init(NULL, ps_args(), TRUE,
			"-hmm", "C:/Users/Reza/Documents/GitHub/speech_agent/speech/Release/model/en-us/en-us",
			//"-lm","C:/Users/Reza/Documents/GitHub/speech_agent/speech/Release/model/en-us/en-us.lm.dmp",
			//"-lm","C:/Users/Reza/Documents/GitHub/speech_agent/speech/Release/cristina.lm",
			//"-jsgf", "grammar.gram",
			"-vad_threshold","3",
			"-kws", kpath,
			"-dict", "C:/Users/Reza/Documents/GitHub/speech_agent/speech/Release/model/en-us/cmudict-en-us2.dict",
			//"-beam", "1e-20", "-pbeam", "1e-20", "-lw", "2.0",
			//"-logfn","model",
			NULL);
	if (config == NULL)
		return -1;
	ps = ps_init(config);
	if (ps == NULL)
		return -1;
	recognize_from_mic();
	//recognize_from_file();
	ps_free(ps);
	cmd_ln_free_r(config);
	return 0;
}
开发者ID:emreza,项目名称:speech_agent,代码行数:25,代码来源:kw_spotter.cpp


示例13: main

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

	TEST_ASSERT(config =
		    cmd_ln_init(NULL, ps_args(), TRUE,
				"-hmm", MODELDIR "/en-us/en-us",
				"-lm", MODELDIR "/en-us/en-us.lm.dmp",
				"-dict", MODELDIR "/en-us/cmudict-en-us.dict",
				"-fwdtree", "yes",
				"-fwdflat", "no",
				"-bestpath", "yes",
				"-input_endian", "little",
				"-cmninit", "37",
				"-samprate", "16000", NULL));
	TEST_ASSERT(ps = ps_init(config));
	rv = test_decode(ps);
	ps_free(ps);
	cmd_ln_free_r(config);

	return rv;
}
开发者ID:IncBin94,项目名称:pocketsphinx,代码行数:25,代码来源:test_posterior.c


示例14: gst_pocketsphinx_init

static void
gst_pocketsphinx_init(GstPocketSphinx * ps)
{
    ps->sinkpad =
        gst_pad_new_from_static_template(&sink_factory, "sink");
    ps->srcpad =
        gst_pad_new_from_static_template(&src_factory, "src");

    /* Parse default command-line options. */
    ps->config = cmd_ln_parse_r(NULL, ps_args(), default_argc, default_argv, FALSE);
    ps_default_search_args(ps->config);
    ps->ps = ps_init(ps->config);
    if (ps->ps == NULL) {
        GST_ELEMENT_ERROR(GST_ELEMENT(ps), LIBRARY, INIT,
                          ("Failed to initialize PocketSphinx"),
                          ("Failed to initialize PocketSphinx"));
    }

    /* Set up pads. */
    gst_element_add_pad(GST_ELEMENT(ps), ps->sinkpad);
    gst_pad_set_chain_function(ps->sinkpad, gst_pocketsphinx_chain);
    gst_pad_set_event_function(ps->sinkpad, gst_pocketsphinx_event);
    gst_pad_use_fixed_caps(ps->sinkpad);

    gst_element_add_pad(GST_ELEMENT(ps), ps->srcpad);
    gst_pad_use_fixed_caps(ps->srcpad);

    /* Initialize time. */
    ps->last_result_time = 0;
    ps->last_result = NULL;
}
开发者ID:HomeBankCode,项目名称:lena-its-tools,代码行数:31,代码来源:gstpocketsphinx.c


示例15: file

bool FSpeechRecognitionWorker::Init() {

	std::string modelPath = contentPath_str + "model/" + langStr + "/" + langStr;
	std::string languageModel = contentPath_str + "model/" + langStr + "/" + langStr + ".lm.bin";
	std::string dictionaryPath = contentPath_str + "model/" + langStr + "/" + langStr + ".dict";

	// load dictionary
	dictionaryMap.clear();

	std::ifstream file(dictionaryPath);
	std::vector<std::string> words;
	std::string currentLine;

	while (file.good())
	{
		std::getline(file, currentLine);
		std::string word = currentLine.substr(0, currentLine.find(" "));
		std::string phrase = currentLine.substr(currentLine.find(" ") + 1, currentLine.size());
		dictionaryMap.insert(make_pair(word, phrase));
	}

	// Start Sphinx
	config = cmd_ln_init(NULL, ps_args(), 1,
		"-hmm", modelPath.c_str(),
		"-lm", languageModel.c_str(),
		NULL);
	
	ps = ps_init(config);

	if (!Manager | !ps) {
		ClientMessage(FString(TEXT("Speech Recognition Thread failed to start")));
		initSuccess = false;
		return false;
	}

	// only include the words/phrases that have been added
	for (auto It = dictionaryList.CreateConstIterator(); It; ++It)
	{
		FString word = *It;
		std::string wordStr = std::string(TCHAR_TO_UTF8(*word));
		if (dictionaryMap.find(wordStr) != dictionaryMap.end())
		{
			std::string phraseStr = dictionaryMap.at(wordStr);
			ps_add_word(ps, wordStr.c_str(), phraseStr.c_str(), TRUE);
		}
	}

	// attempt to open the default recording device
	if ((ad = ad_open_dev(cmd_ln_str_r(config, "-adcdev"),
		(int)cmd_ln_float32_r(config,
		"-samprate"))) == NULL) {
			ClientMessage(FString(TEXT("Failed to open audio device")));
			initSuccess = false;
			return initSuccess;
	}

	utt_started = 0;
	return true;
}
开发者ID:dbadrian,项目名称:sphinx-ue4,代码行数:59,代码来源:SpeechRecognitionWorker.cpp


示例16: main

int
main(int argc, char *argv[])
{
	ps_decoder_t *ps;
	cmd_ln_t *config;
	FILE *fh;
	char const *hyp, *uttid;
	int16 buf[512];
	int rv;
	int32 score;
	//int i;

	config = cmd_ln_init(NULL, ps_args(), TRUE,
		"-hmm", MODELDIR "/hmm/en_US/hub4wsj_sc_8k",
		"-lm", MODELDIR "/lm/en/turtle.DMP",
		"-dict", MODELDIR "/lm/en/turtle.dic",
		NULL);
	if (config == NULL)
		return 1;
	ps = ps_init(config);
	if (ps == NULL)
		return 1;

	fh = fopen("goforward.raw", "rb");
	if (fh == NULL) {
		perror("Failed to open goforward.raw");
		return 1;
	}

	rv = ps_decode_raw(ps, fh, "goforward", -1);
	if (rv < 0)
		return 1;
	hyp = ps_get_hyp(ps, &score, &uttid);
	if (hyp == NULL)
		return 1;
	printf("Recognized: %s\n", hyp);

	fseek(fh, 0, SEEK_SET);
	rv = ps_start_utt(ps, "goforward");
	if (rv < 0)
		return 1;
	while (!feof(fh)) {
		size_t nsamp;
		nsamp = fread(buf, 2, 512, fh);
		rv = ps_process_raw(ps, buf, nsamp, FALSE, FALSE);
	}
	rv = ps_end_utt(ps);
	if (rv < 0)
		return 1;
	hyp = ps_get_hyp(ps, &score, &uttid);
	if (hyp == NULL)
		return 1;
	printf("Recognized: %s\n", hyp);

	fclose(fh);
	ps_free(ps);
	return 0;
}
开发者ID:roboanil,项目名称:Opencv-CMUSphinx,代码行数:58,代码来源:Source.cpp


示例17: main

int main(int argc, char *argv[]) {
    ps_decoder_t *ps;
    cmd_ln_t *config;
    FILE *fh;
    char const *hyp, *uttid;
    int16 buf[512];
    int rv;
    int32 score;

    config = cmd_ln_init(NULL, ps_args(), TRUE,
            "-hmm",    MODELDIR "/en-us/en-us",
            "-lm",     MODELDIR "/en-us/en-us.lm.bin",
            "-dict",   MODELDIR "/en-us/cmudict-en-us.dict",
            NULL);

    if (config == NULL) {
        fprintf(stderr, "Failed to create config object, see log for details\n");
        return -1;
    }
    
    // Initialize pocketsphinx
    ps = ps_init(config);
    if (ps == NULL) {
        fprintf(stderr, "Failed to create recognizer, see log for details\n");
        return -1;
    }

    // Open the wav file passed from argument
    printf("file: %s\n", argv[1]);
    fh = fopen(argv[1], "rb");
    if (fh == NULL) {
        fprintf(stderr, "Unable to open input file %s\n", argv[1]);
        return -1;
    }

    // Start utterance
    rv = ps_start_utt(ps);
    
    // Process buffer, 512 samples at a time
    while (!feof(fh)) {
        size_t nsamp;
        nsamp = fread(buf, 2, 512, fh);
        rv = ps_process_raw(ps, buf, nsamp, FALSE, FALSE);
    }
    
    // Recieve the recognized string
    rv = ps_end_utt(ps);
    hyp = ps_get_hyp(ps, &score);
    printf("Recognized: |%s|\n", hyp);

    // free memory
    fclose(fh);
    ps_free(ps);
    cmd_ln_free_r(config);
    
    return 0;
}
开发者ID:atreayou,项目名称:WeslyWebService,代码行数:57,代码来源:sonus.c


示例18: ps_load_dict

int
ps_load_dict(ps_decoder_t *ps, char const *dictfile,
             char const *fdictfile, char const *format)
{
    cmd_ln_t *newconfig;
    dict2pid_t *d2p;
    dict_t *dict;
    hash_iter_t *search_it;

    /* Create a new scratch config to load this dict (so existing one
     * won't be affected if it fails) */
    newconfig = cmd_ln_init(NULL, ps_args(), TRUE, NULL);
    cmd_ln_set_boolean_r(newconfig, "-dictcase",
                         cmd_ln_boolean_r(ps->config, "-dictcase"));
    cmd_ln_set_str_r(newconfig, "-dict", dictfile);
    if (fdictfile)
        cmd_ln_set_str_r(newconfig, "-fdict", fdictfile);
    else
        cmd_ln_set_str_r(newconfig, "-fdict",
                         cmd_ln_str_r(ps->config, "-fdict"));

    /* Try to load it. */
    if ((dict = dict_init(newconfig, ps->acmod->mdef, ps->acmod->lmath)) == NULL) {
        cmd_ln_free_r(newconfig);
        return -1;
    }

    /* Reinit the dict2pid. */
    if ((d2p = dict2pid_build(ps->acmod->mdef, dict)) == NULL) {
        cmd_ln_free_r(newconfig);
        return -1;
    }

    /* Success!  Update the existing config to reflect new dicts and
     * drop everything into place. */
    cmd_ln_free_r(newconfig);
    cmd_ln_set_str_r(ps->config, "-dict", dictfile);
    if (fdictfile)
        cmd_ln_set_str_r(ps->config, "-fdict", fdictfile);
    dict_free(ps->dict);
    ps->dict = dict;
    dict2pid_free(ps->d2p);
    ps->d2p = d2p;

    /* And tell all searches to reconfigure themselves. */
    for (search_it = hash_table_iter(ps->searches); search_it;
       search_it = hash_table_iter_next(search_it)) {
        if (ps_search_reinit(hash_entry_val(search_it->ent), dict, d2p) < 0) {
            hash_table_iter_free(search_it);
            return -1;
        }
    }

    return 0;
}
开发者ID:jhector,项目名称:sphinxfuzz,代码行数:55,代码来源:pocketsphinx.c


示例19: main

int
main(int argc, char *argv[]) {
	ps_decoder_t *ps;
	cmd_ln_t *config;
	FILE *fh;
	const char *filename = "goforward.raw";
	const char *word = "goforward";
	char const *hyp, *uttid;
	int rv;
	int32 score;

	/* setup the sphinx config */
	config = cmd_ln_init(NULL, ps_args(), TRUE,
			"-hmm", MODELDIR "/hmm/en_US/hub4wsj_sc_8k", 
			"-lm", MODELDIR "/lm/en/turtle.DMP",
			"-dict", MODELDIR "/lm/en/turtle.dic",
			NULL);
	if(config == NULL) {
		EXIT_ERROR;
	}

	/* initialize the config */
	ps = ps_init(config);
	if(ps == NULL) {
		EXIT_ERROR;
	}

	/* open the audio file (stream?) */
	fh = fopen(filename, "rb");
	if(fh == NULL) {
		perror(filename);
		exit(1);
	}

	/* decode the file */
	rv = ps_decode_raw(ps, fh, word, -1);
	if(rv < 0) {
		EXIT_ERROR;
	}

	/* get hypothesis */
	hyp = ps_get_hyp(ps, &score, &uttid);
	if(hyp == NULL) {
		EXIT_ERROR;
	}
	printf("Recognized: %s; score: %d; uttid: %s\n", 
			hyp, score, uttid);

	/* clean up */
	fclose(fh);
	ps_free(ps);

	return 0;
}
开发者ID:capdevc,项目名称:guggug,代码行数:54,代码来源:moveforward.c


示例20: ps_load_dict

int
ps_load_dict(ps_decoder_t *ps, char const *dictfile,
             char const *fdictfile, char const *format)
{
    cmd_ln_t *newconfig;
    dict2pid_t *d2p;
    dict_t *dict;
    gnode_t *gn;
    int rv;

    /* Create a new scratch config to load this dict (so existing one
     * won't be affected if it fails) */
    newconfig = cmd_ln_init(NULL, ps_args(), TRUE, NULL);
    cmd_ln_set_boolean_r(newconfig, "-dictcase",
                         cmd_ln_boolean_r(ps->config, "-dictcase"));
    cmd_ln_set_str_r(newconfig, "-dict", dictfile);
    if (fdictfile)
        cmd_ln_set_str_r(newconfig, "-fdict", fdictfile);
    else
        cmd_ln_set_str_r(newconfig, "-fdict",
                         cmd_ln_str_r(ps->config, "-fdict"));

    /* Try to load it. */
    if ((dict = dict_init(newconfig, ps->acmod->mdef)) == NULL) {
        cmd_ln_free_r(newconfig);
        return -1;
    }

    /* Reinit the dict2pid. */
    if ((d2p = dict2pid_build(ps->acmod->mdef, dict)) == NULL) {
        cmd_ln_free_r(newconfig);
        return -1;
    }

    /* Success!  Update the existing config to reflect new dicts and
     * drop everything into place. */
    cmd_ln_free_r(newconfig);
    cmd_ln_set_str_r(ps->config, "-dict", dictfile);
    if (fdictfile)
        cmd_ln_set_str_r(ps->config, "-fdict", fdictfile);
    dict_free(ps->dict);
    ps->dict = dict;
    dict2pid_free(ps->d2p);
    ps->d2p = d2p;

    /* And tell all searches to reconfigure themselves. */
    for (gn = ps->searches; gn; gn = gnode_next(gn)) {
        ps_search_t *search = gnode_ptr(gn);
        if ((rv = ps_search_reinit(search, dict, d2p)) < 0)
            return rv;
    }

    return 0;
}
开发者ID:006,项目名称:ios_lab,代码行数:54,代码来源:pocketsphinx.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ps_end_utt函数代码示例发布时间:2022-05-30
下一篇:
C++ psMalloc函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap