I'm using pocketsphinx_continuous on Windows. Redirecting output to a text file works with the "-infile" argument, but fails with "-inmic yes".
As noted in the question Does pocketsphinx flush stdout? pocketsphinx ignores stdout (at least when using -inmic).
Is there any way I can save the words recognized by pocketsphinx_continuous with "-inmic yes" to a text file?
Specifically, I want my Java program to run pocketsphinx_continuous.exe and get the words recognized from microphone input.
Using -backtrace
with -logfn
as suggested by Alexander Solovets indeed saves the results along with the log in the specified file. However, the log is not saved as frequently as the results are sent to the terminal. I wanted the results output to a file as fast as possible, so I built pocketsphinx_continuous.exe from source with the following changes to continous.c
.
In continuous.c:
hyp = ps_get_hyp(ps, NULL );
if (hyp != NULL)
{
printf("%s\n", hyp);
FILE * fp;
fp = fopen("file.txt", "a+");
fprintf(fp, hyp);
fprintf(fp, "\r\n");
fclose(fp);
}
There is no dedicated option to save only results to a file. However, you can use -backtrace
to tell pocketsphinx to save results and backtraces to the log file, which you can specify with -logfn
.
Since revision 13156 pocketsphinx should flush stdout on every message thus interactive applications should work.
You can update your version.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With