5

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.

Solution

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);
}
Community
  • 1
  • 1
sjw
  • 228
  • 1
  • 4
  • 8
  • Where do you put `continuous.c`? Also when I try to use the `-backtrace`, `-logfn`, and `-hyp` arguments it gives me an arg not found error. – Patrick Cook Jan 04 '16 at 03:12
  • @PatrickCook Are you able to build pocketsphinx_continuous from source? Check [http://cmusphinx.sourceforge.net/wiki/tutorialpocketsphinx](http://cmusphinx.sourceforge.net/wiki/tutorialpocketsphinx) for help. – sjw Jan 05 '16 at 11:31

2 Answers2

4

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.

Alexander Solovets
  • 2,447
  • 15
  • 22
1

Since revision 13156 pocketsphinx should flush stdout on every message thus interactive applications should work.

You can update your version.

Nikolay Shmyrev
  • 24,897
  • 5
  • 43
  • 87
  • How does one find the version of pocketsphinx? I downloaded it awhile ago. It seems like it dumps EVERYTHING to the log, I need to dig through it and see if there is a way to turn off the debugging stuff. – nomadic_squirrel May 14 '16 at 07:47
  • In case you checked out pocketsphinx from subversion you can run "svn info" to figure out the version. Logging in configured with -logfn option, you check http://stackoverflow.com/questions/17825820/how-do-i-turn-off-e-info-in-pocketsphinx – Nikolay Shmyrev May 15 '16 at 08:40