本文整理汇总了C++中ps_args函数的典型用法代码示例。如果您正苦于以下问题:C++ ps_args函数的具体用法?C++ ps_args怎么用?C++ ps_args使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ps_args函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}