# Energy and SpectralFlatnessMeasure taken for PCM audio VoiceActitivyDetection

I'm trying to implement the VAD algorithm in this paper:

I'm polling a microphone on an Android phone, and getting short[]'s which I want to perform operations on. The audio data is 16bit PCM data.

I've gotten the basics of the algorithm done, but there are two issues I don't really understand yet.

1) Step 3-1- of the above algorithm says to

"compute frame energy".

I'm not entirely sure what this means. Should I take the PCM data and convert it to Db's? Should I generate this off of the magnitude values derived from an FFT?

2) In section 2 (1) of the paper, There is an equation for Spectral Flatness given:

SPM = 10log10(Gm/Am)  or Spectral Flatness Measure = 10*Log10(GeometricMean/ArithmeticMean)


There is a brief description underneath which reads:

"Where Am and Gm are the geometric means of speech spectrum respectively".

I understand what the general terms of this equation are, however I don't understand what I should be summing to generate the Gm and Am terms. At first I thought it was the energy values computed in part 1) of my question, however rereading it seems to instead relate to the energy present only in the speech spectrum portion of a given frame. If thats the case what range should I use and how do I generate the value to sum/multiply?

The frame energy can be computed in the time domain as well as in the frequency domain. For a frame of $N$ samples, due to Parseval's theorem, you get for the frame energy

$$\sum_{n=0}^{N-1}|x[n]|^2=\frac{1}{N}\sum_{k=0}^{N-1}|X[k]|^2$$

where $x[n]$ are the time domain samples, and $X[k]$ are the complex DFT coefficients.

The spectral flatness is commonly computed from the power spectrum, or from the squared magnitudes of the DFT coefficients. I can't open the link to the paper, but unless otherwise stated, I would compute the means using all values $|X[k]|^2$ in the current frame.