0

I am trying to stream the recorded audio from my raspberry pis to my desktop computer which handles pocketsphinx phenomenally. I can pipe the audio using

arecord -D plughw:1,0 -r 16000 -f S16_LE | ssh -C user@192.168.86.101 sox - test.wav

And then run it using pocketsphinx_continuous -dict ~/4568.dic -lm ~/4568.lm -infile ~/test.wav

But once it reaches the end of the file, it stops, even though the file is still writing. Is there a way to keep it open?

Mitchell Ingram
  • 686
  • 2
  • 11
  • 23

2 Answers2

2

Use named pipe instead of a regular file. Also you can file an issue at github.com/cmusphinx/pocketsphinx requesting that pocketsphinx_continious should be able to read from stdin. And of course you're welcome to submit such a patch.

Alexander Solovets
  • 2,447
  • 15
  • 22
  • I will try this tomorrow, but that looks like a very promising solution. – Mitchell Ingram Jan 14 '16 at 01:11
  • I am not sure that works, or I am using it wrong. I tried, mkfifo /tmp/pipe then arecord -D plughw:1,0 -r 16000 -f S16_LE /tmp/pipe and finally in another term ssh -C mingram@192.168.86.101 pocketsphinx_continuous -infile /tmp/pipe but it can't find the pipe. – Mitchell Ingram Jan 14 '16 at 13:10
  • Also, arecord -D plughw:1,0 -r 16000 -f S16_LE | ssh -C mingram@192.168.86.101 sox - /tmp/pipe throws sox FAIL formats: can't determine type of `/tmp/pipe' – Mitchell Ingram Jan 14 '16 at 13:17
  • The second variant is the right one, but as you didn't provide the suffix sox couldn't decide about the format. Either give the pipe a suffix, e.g. `/tmp/pipe.wav` or specify the desired format as the sox argument. – Alexander Solovets Jan 14 '16 at 18:15
  • yeah, I got it all running. It still just ends at the end of the file, though. arecord -D plughw:1,0 -f S16_LE -r 16000 | ssh -C mingram@192.168.86.101 sox - /tmp/pipe.wav then ssh -C mingram@192.168.86.101 pocketsphinx_continuous -infile /tmp/pipe.wav – Mitchell Ingram Jan 14 '16 at 18:20
  • Can you elaborate on "ends at the end of the file"? I'm now not sure about what you expect to get eventually. – Alexander Solovets Jan 14 '16 at 19:05
  • The anwser was arecord -D plughw:1,0 -r 16000 -f S16_LE | ssh -C user@192.168.86.101 pocketsphinx_continuous -infile /dev/stdin and end of file meaning that it races to meet where it is recording and ends. – Mitchell Ingram Jan 14 '16 at 19:26
1

To anyone else finding this,

arecord -D plughw:1,0 -r 16000 -f S16_LE | ssh -C user@192.168.86.101 pocketsphinx_continuous -infile /dev/stdin

is how to do it

Mitchell Ingram
  • 686
  • 2
  • 11
  • 23