7

I'm searching for how to use CMU Sphinx with Ruby (Rails) application. I need very simple task - I have an mp3 file and I want get it transcribed into text.

How can I implement this easiest way? I dont' know C/C++ and my task isn't so big to learn C/C++ for it :)

Thanks for help!

Nikolay Shmyrev
  • 24,897
  • 5
  • 43
  • 87
Alve
  • 1,315
  • 2
  • 17
  • 16

3 Answers3

10

CMUSphinx provides several interfaces you can use to leverage speech recognition features. Some of them might be more suitable for you, some less:

  1. Use command-line tools and execute them as an external binaries from Rails application to obtain the required results. The tool to execute is pocketsphinx_continuous. For more information on how to invoke binaries from Rails see the question: how to execute binary on heroku?

  2. You can invoke Sphinx4 framework from JRuby using JVM, see for example on how to use Sphinx4 from JRuby: http://cmusphinx.sourceforge.net/wiki/tutorialsphinx4#writing_scripts

  3. You can implement the pocketsphinx bindings using SWIG. The easy part is that the swig wrappers for Python already exist as a part of the pocketsphinx, you just need to use SWIG to generate Ruby wrappers: https://sourceforge.net/p/cmusphinx/code/11643/tree/trunk/pocketsphinx/swig/

  4. Finally, you can implement a REST web using Java REST frameworks to convert audio to text using CMUSphinx tools and invoke the sevice from your Ruby code. For more information see information how to use REST from Rails This way your can make your system really scalable.

Community
  • 1
  • 1
Nikolay Shmyrev
  • 24,897
  • 5
  • 43
  • 87
3

I've recently created a gem for doing just this:

https://github.com/watsonbox/pocketsphinx-ruby

It uses the Ruby Foreign Function Interface (FFI) to interact directly with libpocketsphinx.

Dónal
  • 185,044
  • 174
  • 569
  • 824
Howard Wilson
  • 143
  • 1
  • 6
  • Hey Howard, I'm very interested in using your gem, but I fount it really hard to set up. I compiled both pocketsphinx and sphinx but I don't know what to do next... How do I tell ruby where these files are? Do I need to put them in a specific location? – SlySherZ Nov 26 '14 at 16:52
  • Hey I found many words are not recognising correctly using that gem... but thanks that's a nice gem – vamsi Sep 22 '17 at 11:36
1

Maybe look into this Ruby-based speech recognition web service that uses PocketSphinx:

https://github.com/alumae/ruby-pocketsphinx-server

Kaarel
  • 10,554
  • 4
  • 56
  • 78