user2533493
user2533493

Reputation: 81

How to pass audio data directly to Sphinx4

I would like to use Sphinx4 for a part of my system. And, I have already tried the HelloWorld demo which uses the microphone directly. Also, I have seen examples about using audio files.

So, my question is that is whether there is any other way to recognize voice? For example, recognize short type data (e.g. a short[] buffer).

I cannot find ways other than using the microphone or wav files (audio files).

For example, PocketSphinx has the processRaw function which is described in this question (Input for Pocketsphinx on Android).

Is there no corresponding function in Sphinx4?

Upvotes: 2

Views: 779

Answers (1)

Nikolay Shmyrev
Nikolay Shmyrev

Reputation: 25220

To feed data from a byte array you need to do the following:

  1. Configure frontend to use StreamDataSource instead of Microphone or AudioFileDataSource. You can see LatticeDemo or TranscriberDemo for example how to do that.

  2. Create ByteArrayInputStream from byte[] array with data

  3. Set input stream to use ByteArrayInputStream with setInputStream method of StreamDataSource

  4. Run recognize() to recognize data from byte array

You can succesfully use any data through InputStream, for example input data from a Socket or from a File.

Upvotes: 1

Related Questions