Speech SNR estimation
Here is the C++ code of the answer. 



#include &lt;algorithm&gt;
#include &lt;queue&gt;
#include &lt;numeric&gt;
#include &lt;vector&gt;
#include &lt;cmath&gt;
const float N = 4;
float noise_th= 0.35;    //noise threshold
float calculate_SNR(queue&lt;float&gt; &amp;signal_fifo)
{
    vector&lt;float&gt; noise_vect;
    vector&lt;float&gt; speech_vect;
    float SNR;
    float noise_std;
    float speech_std;
    auto fast_std = [](vector&lt;float&gt; input) //https://stackoverflow.com/questions/7616511/calculate-mean-and-standard-deviation-from-a-vector-of-samples-in-c-using-boos/12405793#12405793
    {
        float mean, acc;
        mean = accumulate(begin(input), end(input), 0.0)/input.size();
        acc = 0.0;
        for_each(begin(input), end(input), [&amp;](const float d)
        {
            acc += (d - mean)*(d - mean);
        });
        return sqrt(acc/(input.size()-1));
    };

    while(!signal_fifo.empty()) //Seprate speech and noise samples(fifo has the ABS of input signal)
    {
        if(signal_fifo.front() &lt; noise_th)
        {
            noise_vect.push_back(signal_fifo.front());
            signal_fifo.pop();
        }
        else
        {
            speech_vect.push_back(signal_fifo.front());
            signal_fifo.pop();
        }
    }

    noise_std = fast_std(noise_vect);
    speech_std = fast_std(speech_vect);
    SNR = 20*log10(speech_std/noise_std);
    noise_th = N*noise_std;     //Update threshold value
    return SNR;
}