0

I am trying to run PocketSphinx from Ruby. What I did is run a terminal command from Ruby. Like this:

cmd = "pocketsphinx_continuous \
        -lm /usr/local/share/pocketsphinx/model/lm/en_US/hub4.5000.DMP \
        -dict /usr/local/share/pocketsphinx/model/lm/en_US/cmu07a.dic\
        -infile ~/Path/FileName.wav"
output = `#{cmd}`
puts output

This works well if there is a file input. However, when I tried to process streaming audio, like speaking from microphone, I just delete the line of "-infile". In this case it does not work anymore. PocketSphinx processes, but it never shows "Ready" like usually.

FYI, I am using Ubuntu 14.04 and Ruby 2.0.

Do you have any ideas about what's going on?

eddie_cat
  • 2,527
  • 4
  • 25
  • 43

1 Answers1

1

That's because reading the micrphone input assumes that you should end the process manually. There are two options: to send SIGINT to the process upon a timeout or to compile a Ruby library from the SWIG interface. You can learn more about the latter reading about Python interface for pocketsphinx and looking at the sources.

Also, see this comprehensive answer regarding the use of CMU Sphinx in Ruby.

Community
  • 1
  • 1
Alexander Solovets
  • 2,447
  • 15
  • 22
  • Thank you Alexander! I solved this problem by use exec(cmd) instead of #{} and it worked. But I still want to know what do you mean by "send SIGINT" to process upon a timeout. Is there any more specific guide? Thanx! – coral chen Oct 01 '14 at 21:46