I am using Pocketsphinx inside an Unity Application.
To get the audio I call Microphone.GetPosition(), I get the current sample and then I call clip.GetData(audioBuffer, previousSample) where audioBuffer is the array where I store the data.
This data is a float number in range [-1...1].
Because PocketSphinx process_raw() gets an Int16 buffer, I convert each float element el into a short element multipling el * Int16.MaxValue.
And then I pass the new array of Int16 to the PocketSphinx engine and process_raw() function.
Finally, previousSample = current .
Is it this conversion process correct?
Thank you!
Last edit: Andrea Lisi 2016-07-29
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi!
I was wondering one thing:
I am using Pocketsphinx inside an Unity Application.
To get the audio I call Microphone.GetPosition(), I get the current sample and then I call clip.GetData(audioBuffer, previousSample) where audioBuffer is the array where I store the data.
This data is a float number in range [-1...1].
Because PocketSphinx process_raw() gets an Int16 buffer, I convert each float element el into a short element multipling el * Int16.MaxValue.
And then I pass the new array of Int16 to the PocketSphinx engine and process_raw() function.
Finally, previousSample = current .
Is it this conversion process correct?
Thank you!
Last edit: Andrea Lisi 2016-07-29
The conversion process is correct.
You need to be careful about position though, it might be that you have extra samples when you do not retrieve full buffer in GetData.
To debug this thing you can enable raw data logging with
-rawlogdir
parameter from pocketsphinx and check result files.Last edit: Nickolay V. Shmyrev 2016-07-29