Usually this can be done by following the following steps :
1- segmentation of the incoming data Stream into blocks of N samples
2- compute the squared absolute value of the N points-FFT of each input block,
3 - for each input block, compute the SFM (spectral flatness Measure) as the ratio between the geometric mean of the power spectrum by the arithmetic mean of the power Spectrum (see wikipedia - Spectral Flatness)