2 hopefully minor questions: I'm running continuous inside a block of
objective-c code (not as a compiled application in a terminal) and I have two
goals. 1) I'd like to be able to stop utterance_loop() as cleanly as possible,
so that it could be restarted later, and 2) I'd like to suppress all of the
text that is output into the debugger when utterance_loop() is running (all of
the logging stuff that is going to stdio even in non-verbose mode such as the
options, the scores, words recognized, etc).
For question 1, is there a simple and clean way to stop and shut continuous
off (basically meaning main() and utterance_loop()) inside of the same piece
of code, making sure that everything in use gets stopped and freed in the
correct order? Or do I need to just go through and write a new function to do
it? I tried using sighandler() but I wasn't sure what to pass through it and I
got some crashes. I've also just tried stopping the ad and then freeing the ps
with very mixed results depending on what was going on when I did it. My
second question is just whether it's possible to run utterance_loop() in
silent mode, and if so, how. Thanks very much.
Here is how I run continuous inside my code, starting by calling
start_up_continuous():
static const arg_t cont_args_def = {
POCKETSPHINX_OPTIONS,
/ Argument file. /
{ "-argfile",
ARG_STRING,
NULL,
"Argument file giving extra arguments." },
{ "-adcdev", ARG_STRING, NULL, "Name of audio device to use for input." },
CMDLN_EMPTY_OPTION
};
static void
utterance_loop()
{
the entirety of utterance_loop() as found in continuous.c
}
int continuous_main(int argc, char *argv)
{
the entirety of main() as found in continuous.c
}
OK, this seems to be do-able as long as I first check if the ad is recording,
stop recording if it is recording, and then have the various fatal results in
utterance_loop() return "break;" instead. This returns to the main function
and allows the pointers to be cleanly freed as far as I can tell.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
To solve my second question, in the event that anyone else has a similar need
to run pocketsphinx silently, I did the following. I added a #define to my
class:
define QUIETPOCKETSPHINX
and in the blocks of code responsible for the bulk of the logging, I have
these preprocessor conditionals, this at the start of the block:
ifdef QUIETPOCKETSPHINX
fclose(stderr);
endif
and this at the end:
ifdef QUIETPOCKETSPHINX
stderr = fdopen(dup(fileno(stdout)), "w");
endif
This has cleared out my debug console, but of course this isn't a good
approach until you have the impression things are working well, since
suppressing stderr will...suppress errors. But, since it's very easy to toggle
back and forth it can be left on unless there is an issue.
I put the first conditional at the very start of my function that initializes
pocketsphinx and then starts utterance_loop(), and then the second block goes
right before utterance_loop() starts so that I don't get the initialization
text but I get the text for the hypotheses etc. Hope this is helpful to
someone.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This has cleared out my debug console, but of course this isn't a good
approach until you have the impression things are working well, since
suppressing stderr will...suppress errors. But, since it's very easy to toggle
back and forth it can be left on unless there is an issue.
Heh, we need more flexible logging system indeed. I hope we'll fix it one day
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I don't know if this is useful at all, but back when I was using pocketsphinx
and sphinxbase as static libraries with cross-project references in Xcode
(before I switched to using the build script that is included with the current
version, so I can no longer make changes to those libraries at build time), I
controlled logging by putting this file in my sphinxbase static library with
whatever logging I needed or didn't need defined or undefined, and then
including it in my actual project code that also included pocketsphinx.h:
/ loggingcontrol.h control pocketsphinx logging level
*/
define PRINT_E__pr_info_header_wofn // ??
//#undef PRINT_E__pr_info_header_wofn
define PRINT_E__pr_header // show the headers that are sending
warnings/errors
//#undef PRINT_E__pr_header
define PRINT_E__pr_info_header // show the headers that are sending info
//#undef PRINT_E__pr_info_header
define PRINT_E__pr_warn // show recognition/config warnings or errors like
"Skipping duplicate definition of <sil> or No \data\ mark in LM file"
//#undef PRINT_E__pr_warn </sil>
define PRINT_E__pr_info // information about the recognition results
//#undef PRINT_E__pr_info
define PRINT_E__die_error // For serious errors, probably should be left on
//#undef PRINT_E__die_error
define PRINT_E__fatal_sys_error // For serious errors, probably should be
left on
//#undef PRINT_E__fatal_sys_error
define PRINT_E__sys_error // For serious errors, probably should be left on
//#undef PRINT_E__sys_error
define PRINT_E__abort_error // For serious errors, probably should be left on
//#undef PRINT_E__abort_error
define PRINT_arg_dump_r // show the config arguments and their
Hello,
2 hopefully minor questions: I'm running continuous inside a block of
objective-c code (not as a compiled application in a terminal) and I have two
goals. 1) I'd like to be able to stop utterance_loop() as cleanly as possible,
so that it could be restarted later, and 2) I'd like to suppress all of the
text that is output into the debugger when utterance_loop() is running (all of
the logging stuff that is going to stdio even in non-verbose mode such as the
options, the scores, words recognized, etc).
For question 1, is there a simple and clean way to stop and shut continuous
off (basically meaning main() and utterance_loop()) inside of the same piece
of code, making sure that everything in use gets stopped and freed in the
correct order? Or do I need to just go through and write a new function to do
it? I tried using sighandler() but I wasn't sure what to pass through it and I
got some crashes. I've also just tried stopping the ad and then freeing the ps
with very mixed results depending on what was going on when I did it. My
second question is just whether it's possible to run utterance_loop() in
silent mode, and if so, how. Thanks very much.
Here is how I run continuous inside my code, starting by calling
start_up_continuous():
static const arg_t cont_args_def = {
POCKETSPHINX_OPTIONS,
/ Argument file. /
{ "-argfile",
ARG_STRING,
NULL,
"Argument file giving extra arguments." },
{ "-adcdev", ARG_STRING, NULL, "Name of audio device to use for input." },
CMDLN_EMPTY_OPTION
};
static void
utterance_loop()
{
the entirety of utterance_loop() as found in continuous.c
}
int continuous_main(int argc, char *argv)
{
the entirety of main() as found in continuous.c
}
int start_up_continuous() {
const char hmmCString = ;
const char lmCString = ;
const char dictCString = ;
const char deviceCString = ;
char argv;
argv = (char )"-hmm";
argv = (char )hmmCString;
argv = (char )"-lm";
argv = (char )lmCString;
argv = (char )"-dict";
argv = (char )dictCString;
argv = (char )"-adcdev";
argv = (char *)deviceCString;
return continuous_main( 8, argv );
}
OK, this seems to be do-able as long as I first check if the ad is recording,
stop recording if it is recording, and then have the various fatal results in
utterance_loop() return "break;" instead. This returns to the main function
and allows the pointers to be cleanly freed as far as I can tell.
To solve my second question, in the event that anyone else has a similar need
to run pocketsphinx silently, I did the following. I added a #define to my
class:
define QUIETPOCKETSPHINX
and in the blocks of code responsible for the bulk of the logging, I have
these preprocessor conditionals, this at the start of the block:
ifdef QUIETPOCKETSPHINX
fclose(stderr);
endif
and this at the end:
ifdef QUIETPOCKETSPHINX
stderr = fdopen(dup(fileno(stdout)), "w");
endif
This has cleared out my debug console, but of course this isn't a good
approach until you have the impression things are working well, since
suppressing stderr will...suppress errors. But, since it's very easy to toggle
back and forth it can be left on unless there is an issue.
I put the first conditional at the very start of my function that initializes
pocketsphinx and then starts utterance_loop(), and then the second block goes
right before utterance_loop() starts so that I don't get the initialization
text but I get the text for the hypotheses etc. Hope this is helpful to
someone.
Thanks, looks interesting
Heh, we need more flexible logging system indeed. I hope we'll fix it one day
Hi Nickolay,
I don't know if this is useful at all, but back when I was using pocketsphinx
and sphinxbase as static libraries with cross-project references in Xcode
(before I switched to using the build script that is included with the current
version, so I can no longer make changes to those libraries at build time), I
controlled logging by putting this file in my sphinxbase static library with
whatever logging I needed or didn't need defined or undefined, and then
including it in my actual project code that also included pocketsphinx.h:
/
loggingcontrol.h
control pocketsphinx logging level
*/
define PRINT_E__pr_info_header_wofn // ??
//#undef PRINT_E__pr_info_header_wofn
define PRINT_E__pr_header // show the headers that are sending
warnings/errors
//#undef PRINT_E__pr_header
define PRINT_E__pr_info_header // show the headers that are sending info
//#undef PRINT_E__pr_info_header
define PRINT_E__pr_warn // show recognition/config warnings or errors like
"Skipping duplicate definition of <sil> or No \data\ mark in LM file"
//#undef PRINT_E__pr_warn </sil>
define PRINT_E__pr_info // information about the recognition results
//#undef PRINT_E__pr_info
define PRINT_E__die_error // For serious errors, probably should be left on
//#undef PRINT_E__die_error
define PRINT_E__fatal_sys_error // For serious errors, probably should be
left on
//#undef PRINT_E__fatal_sys_error
define PRINT_E__sys_error // For serious errors, probably should be left on
//#undef PRINT_E__sys_error
define PRINT_E__abort_error // For serious errors, probably should be left on
//#undef PRINT_E__abort_error
define PRINT_arg_dump_r // show the config arguments and their
default/configured settings.
//#undef PRINT_arg_dump_r
Hey all
Actually my bad, there is simple way to disble logging in sphinxbase, see
err.h doxygen documentation:
Just call err_set_logfp(NULL) to disable log output.