本文整理汇总了C++中ps_free函数的典型用法代码示例。如果您正苦于以下问题:C++ ps_free函数的具体用法?C++ ps_free怎么用?C++ ps_free使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ps_free函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:gitpan,项目名称:PHP-Serialization-XS,代码行数:29,代码来源:ps_parser.c
示例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;
}
开发者ID:hackliff,项目名称:domobot,代码行数:33,代码来源:voiceCommands.c
示例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;
}
开发者ID:YanyangChen,项目名称:KVPJ,代码行数:35,代码来源:continuous.c
示例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;
}
开发者ID:dgkae,项目名称:unicallasr,代码行数:28,代码来源:mod_pocketsphinx.c
示例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;
}
开发者ID:agesmundo,项目名称:IDParser,代码行数:26,代码来源:idp_search.c
示例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;
}
开发者ID:agesmundo,项目名称:IDParser,代码行数:29,代码来源:idp_search.c
示例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;
}
开发者ID:bedahr,项目名称:LiveTranscriber,代码行数:32,代码来源:modified_continous.c
示例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;
}
开发者ID:echoline,项目名称:PocketSphinxLauncher,代码行数:30,代码来源:sphx.c
示例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;
}
开发者ID:sergei,项目名称:ottopi,代码行数:34,代码来源:voice2nmea.c
示例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;
}
开发者ID:IncBin94,项目名称:pocketsphinx,代码行数:25,代码来源:test_posterior.c
示例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;
}
开发者ID:vinodkumarkv13,项目名称:sphinx-on-android,代码行数:28,代码来源:gqandroidsphinx.cpp
示例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;
}
开发者ID:zaqzaq,项目名称:cmusphinx,代码行数:34,代码来源:test_ps_reinit.c
示例13: cleanup
void Recognizer::cleanup() {
if (decoder) ps_free(decoder);
if (logmath) logmath_free(logmath);
decoder = NULL;
grammar_set = NULL;
logmath = NULL;
}
开发者ID:keirantai,项目名称:pocketsphinx.js,代码行数:7,代码来源:psRecognizer.cpp
示例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;
}
开发者ID:emreza,项目名称:speech_agent,代码行数:25,代码来源:kw_spotter.cpp
示例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);
}
}
开发者ID:dps123,项目名称:nitrogenS100,代码行数:35,代码来源:sbr_dec.c
示例16: 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
示例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;
//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
示例18: test_no_search
static void
test_no_search()
{
cmd_ln_t *config = default_config();
ps_decoder_t *ps = ps_init(config);
TEST_ASSERT(ps_start_utt(ps) < 0);
ps_free(ps);
cmd_ln_free_r(config);
}
开发者ID:googolhkl,项目名称:jarvis,代码行数:9,代码来源:test_ps_set_search.c
示例19: sphinxClose
int sphinxClose()
{
if (ps_free(ps) != 0) {
printf("Error freeing pocketsphinx.\n");
return 0;
}
return 1;
}
开发者ID:RealzeitsystemeSS14,项目名称:SpeechRecognition,代码行数:9,代码来源:onButtonSphinx.c
示例20: 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
注:本文中的ps_free函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论