I am using pocketsphinx to recognize words in android application when someone speak. I want to implement functionality to return a max amplitude of a voice which pocketsphinx record. If i speak any word i need to get a sound level in return(Either word recognize or not from decoder). What i have done: I look into the code of pocketsphinx-->SpeechRecognizer currently commented in source file:
/* while (!interrupted()
&& ((timeoutSamples == NO_TIMEOUT) || (remainingSamples > 0))) {
int nread = recorder.read(buffer, 0, buffer.length);
if (-1 == nread) {
throw new RuntimeException("error reading audio buffer");
} else if (nread > 0) {
decoder.processRaw(buffer, nread, false, false);
int max = 0;
for (int i = 0; i < nread; i++) {
max = Math.max(max, Math.abs(buffer[i]));
}....
I seems to be that this max value is calculating from a buffer How i can calculate this from complete recording. Can someone give me hint?