本文整理汇总了C++中ps_free函数的典型用法代码示例。如果您正苦于以下问题:C++ ps_free函数的具体用法?C++ ps_free怎么用?C++ ps_free使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ps_free函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ps_free
void ps_free(ps_node* node)
{
struct array *what = NULL;
switch (node->type) {
case NODE_BOOL :
case NODE_INT :
case NODE_FLOAT :
case NODE_NULL : break;
case NODE_STRING : free(node->val.s.val); break;
case NODE_OBJECT :
what = &node->val.o.val;
free(node->val.o.type);
goto inside_array;
case NODE_ARRAY :
what = &node->val.a;
inside_array:
for (int i = 0; i < what->len; i++) {
ps_free(what->pairs[i].key);
ps_free(what->pairs[i].val);
}
free(what->pairs);
break;
default:
_err("Invalid node type %d in %s", node->type, __func__);
};
free(node);
}
示例2: 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;
}
示例3: main
int main(int argc, char *argv[])
{
char const *cfg;
config = cmd_ln_parse_r(NULL, cont_args_def, argc, argv, TRUE);
/* Handle argument file as -argfile. */
if (config && (cfg = cmd_ln_str_r(config, "-argfile")) != NULL) {
config = cmd_ln_parse_file_r(config, cont_args_def, cfg, FALSE);
}
if (config == NULL || (cmd_ln_str_r(config, "-infile") == NULL && cmd_ln_boolean_r(config, "-inmic") == FALSE)) {
E_INFO("Specify '-infile <file.wav>' to recognize from file or '-inmic yes' to recognize from microphone.");
cmd_ln_free_r(config);
return 1;
}
ps_default_search_args(config);
ps = ps_init(config);
if (ps == NULL) {
cmd_ln_free_r(config);
return 1;
}
E_INFO("%s COMPILED ON: %s, AT: %s\n\n", argv[0], __DATE__, __TIME__);
if (cmd_ln_boolean_r(config, "-inmic")) {
recognize_from_microphone();
}
ps_free(ps);
cmd_ln_free_r(config);
return 0;
}
示例4: pocketsphinx_asr_close
/*! function to close the asr interface */
static switch_status_t pocketsphinx_asr_close(switch_asr_handle_t *ah, switch_asr_flag_t *flags)
{
pocketsphinx_t *ps = (pocketsphinx_t *) ah->private_info;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, ">>>>>>>>pocketsphinx_asr_close<<<<<<<<<\n");
switch_mutex_lock(ps->flag_mutex);
if (switch_test_flag(ps, PSFLAG_ALLOCATED)) {
if (switch_test_flag(ps, PSFLAG_READY)) {
ps_end_utt(ps->ps);
}
ps_free(ps->ps);
ps->ps = NULL;
}
switch_safe_free(ps->grammar);
switch_mutex_unlock(ps->flag_mutex);
switch_clear_flag(ps, PSFLAG_HAS_TEXT);
switch_clear_flag(ps, PSFLAG_READY);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Port Closed.\n");
switch_set_flag(ah, SWITCH_ASR_FLAG_CLOSED);
/* ifly end session */
QISRSessionEnd(ps->ifly_session_id, ps->ifly_hints);
return SWITCH_STATUS_SUCCESS;
}
示例5: add_to_best_list
void add_to_best_list(APPROX_PARAMS *ap, OPTION **new_b_options, int *new_cand_num, OPTION *to_add) {
ASSERT(*new_cand_num < ap->beam || to_add->lprob > new_b_options[ap->beam - 1]->lprob);
int i;
for (i = *new_cand_num - 1; i >= 0; i--) {
if (new_b_options[i]->lprob < to_add->lprob) {
new_b_options[i + 1] = new_b_options[i];
} else {
new_b_options[i + 1] = to_add;
break;
}
}
//should be inserted on the first position
if (i == -1) {
new_b_options[0] = to_add;
}
if (*new_cand_num == ap->beam) {
pt_free(&(new_b_options[ap->beam]->pt));
ps_free(&(new_b_options[ap->beam]->ps));
free_options(new_b_options[ap->beam]);
} else {
(*new_cand_num)++;
}
return;
}
示例6: label_sentence
double label_sentence(APPROX_PARAMS *ap, MODEL_PARAMS *mp, SENTENCE *sent) {
ASSERT(ap->beam >= 1 && ap->beam < MAX_BEAM);
ASSERT(ap->search_br_factor >= 1);
OPTION *best_options[MAX_SENT_LEN + 1][MAX_BEAM + 1];
best_options[0][0] = root_prediction(ap, mp, sent);
int cand_num = 1;
int t;
for (t = 1; t < sent->len + 1; t++) {
cand_num = search_options(ap, mp, sent, best_options[t-1], cand_num, best_options[t]);
ASSERT(cand_num <= ap->beam);
}
double best_lprob = best_options[sent->len][0]->lprob;
pt_fill_sentence(best_options[sent->len][0]->pt, mp, sent);
ps_fill_sentence(best_options[sent->len][0]->ps, mp, sent);
save_candidates(ap, mp, sent, best_options[sent->len], cand_num);
int i;
for (i = 0; i < cand_num; i++) {
pt_free(&(best_options[sent->len][i]->pt));
ps_free(&(best_options[sent->len][i]->ps));
free_options(best_options[sent->len][i]);
}
return best_lprob;
}
示例7: main
int
main(int argc, char *argv[])
{
char const *cfg;
if (argc == 2) {
config = cmd_ln_parse_file_r(NULL, cont_args_def, argv[1], TRUE);
} else {
config = cmd_ln_parse_r(NULL, cont_args_def, argc, argv, FALSE);
}
if (config && (cfg = cmd_ln_str_r(config, "-argfile")) != NULL) {
config = cmd_ln_parse_file_r(config, cont_args_def, cfg, FALSE);
}
if (config == NULL)
return 1;
ps = ps_init(config);
if (ps == NULL)
return 1;
E_INFO("%s COMPILED ON: %s, AT: %s\n\n", argv[0], __DATE__, __TIME__);
if (cmd_ln_str_r(config, "-infile") != NULL) {
recognize_from_file();
}
ps_free(ps);
return 0;
}
示例8: 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;
}
示例9: main
int
main(int argc, char *argv[])
{
char const *cfg;
if (argc == 2) {
config = cmd_ln_parse_file_r(NULL, cont_args_def, argv[1], TRUE);
}
else {
config = cmd_ln_parse_r(NULL, cont_args_def, argc, argv, FALSE);
}
/* Handle argument file as -argfile. */
if (config && (cfg = cmd_ln_str_r(config, "-argfile")) != NULL) {
config = cmd_ln_parse_file_r(config, cont_args_def, cfg, FALSE);
}
if (config == NULL)
return 1;
ps = ps_init(config);
if (ps == NULL)
return 1;
E_INFO("%s COMPILED ON: %s, AT: %s\n\n", argv[0], __DATE__, __TIME__);
/* Make sure we exit cleanly (needed for profiling among other things) */
signal(SIGINT, &sighandler);
if (setjmp(jbuf) == 0) {
recognize_from_microphone();
}
ps_free(ps);
return 0;
}
示例10: 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;
}
示例11: 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;
}
示例12: 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;
}
示例13: cleanup
void Recognizer::cleanup() {
if (decoder) ps_free(decoder);
if (logmath) logmath_free(logmath);
decoder = NULL;
grammar_set = NULL;
logmath = NULL;
}
示例14: 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;
}
示例15: sbrDecodeEnd
void sbrDecodeEnd(sbr_info *sbr)
{
uint8_t j;
if (sbr)
{
qmfa_end(sbr->qmfa[0]);
qmfs_end(sbr->qmfs[0]);
if (sbr->qmfs[1] != NULL)
{
qmfa_end(sbr->qmfa[1]);
qmfs_end(sbr->qmfs[1]);
}
for (j = 0; j < 5; j++)
{
if (sbr->G_temp_prev[0][j]) faad_free(sbr->G_temp_prev[0][j]);
if (sbr->Q_temp_prev[0][j]) faad_free(sbr->Q_temp_prev[0][j]);
if (sbr->G_temp_prev[1][j]) faad_free(sbr->G_temp_prev[1][j]);
if (sbr->Q_temp_prev[1][j]) faad_free(sbr->Q_temp_prev[1][j]);
}
#ifdef PS_DEC
if (sbr->ps != NULL)
ps_free(sbr->ps);
#endif
#ifdef DRM_PS
if (sbr->drm_ps != NULL)
drm_ps_free(sbr->drm_ps);
#endif
faad_free(sbr);
}
}