I've got PocketSphinx up and running, and all is working great.
I'm generating a new JSGF grammar at runtime in code for each user
interaction. Is there a nice way to switch my existing ps_decoder_t to use the
newly generated JSGF grammar please?
For reference, I've got the following working, but it reloads the acoustic
model, dictionary, etc. and so is pretty slow:
Thanks for your help, that worked a treat. I did have to add another call to
pocketsphinx.h to get the acoustic model: POCKETSPHINX_EXPORT
acmod_t ps_get_acmod(ps_decoder_t ps);
Here's the code, in case anyone else wants to do this:
Hi,
I've got PocketSphinx up and running, and all is working great.
I'm generating a new JSGF grammar at runtime in code for each user
interaction. Is there a nice way to switch my existing ps_decoder_t to use the
newly generated JSGF grammar please?
For reference, I've got the following working, but it reloads the acoustic
model, dictionary, etc. and so is pretty slow:
g_argv = pNewGrammarFilename;
cmd_ln_t *config = cmd_ln_parse_r( NULL, cont_args_def, argc, g_argv, FALSE );
ps_reinit(ps, config);
Thanks for your help,
Paul
To change the grammar you need to use ps_get_fsgset/ps_update_fsgset API. To
get fsgset from jsgf you can use jsgf_parse_file/jsgf_build_fsg
And, its probably way more easier for you to build fsg instead of jsgf
directly
Thanks for your help, that worked a treat. I did have to add another call to
pocketsphinx.h to get the acoustic model: POCKETSPHINX_EXPORT
acmod_t ps_get_acmod(ps_decoder_t ps);
Here's the code, in case anyone else wants to do this:
jsgf_t pJSGF = jsgf_parse_file( pGrammarFilename, NULL );
if( pJSGF )
{
jsgf_rule_iter_t itor;
jsgf_rule_t *rule = NULL;
for (itor = jsgf_rule_iter(pJSGF); itor; itor = jsgf_rule_iter_next(itor))
{
rule = jsgf_rule_iter_rule(itor);
if (jsgf_rule_public(rule)) break;
}
fsg_model_t pNewFSGModel = jsgf_build_fsg( pJSGF, rule,
ps_get_acmod(ps)->lmath, 6.5);
if( pNewFSGModel )
{
fsg_set_t pCurrentGrammar = ps_get_fsgset( ps );
pCurrentGrammar->fsg = pNewFSGModel;
ps_update_fsgset(ps);
}
}
Cheers,
Paul
Actually to get logmath from ps, it's better to use
ps_get_logmath(ps_decoder_t *ps) instead of ps_get_acmod->lmath.
Thanks
Sorry to bring this old thread up again. But I have a problem using the code
of lemmin.
The line:
pCurrentGrammar->fsg = pNewFSGModel;
brings up a compile error:
"Building file: ../fsg_example.c
Invoking: GCC C Compiler
gcc -I/usr/include/sphinxbase -I/usr/include/pocketsphinx -O0 -g3 -Wall -c
-fmessage-length=0 -MMD -MP -MF"fsg_example.d" -MT"fsg_example.d" -o
"fsg_example.o" "../fsg_example.c"
../fsg_example.c: In function ‘main’:
../fsg_example.c:48:19: error: dereferencing pointer to incomplete type
make: *** Error 1"
I installed sphinxbase and pocketshinx using the fedora package manager. Both
are version 0.7. Same thing happens for a friend of mine on arch linux.
Has the api changed somehow?
Yes, you need to use fsg_set_add / fsg_set_select to add fsg_model_t to
fsg_set_t in runtime. You can find an example in pocketsphinx sources.