python; audio; detecting silence in audio signal I have real-time audio application written in python, and I have question about detecting silence.
What's the most efficient way to distinguish silence from non-silence, in an input audio signal? By non-silence I mean any sound, even noise. I need to know when silence-period is in the process, as accurately as possible. I don't necessarily ask for some code-algorithm; theoretical tips and explanations would be also useful. I know that silence have low level of oscillations (signal is flat); in numpy.fft.fft output, silence has highest amplitude in [1] bin, and so on, there are several significant things when silence is there. 
But using any of these conditions in code,  cannot give me absolutely accurate result to  detect silence and completely split it from sound. Any advanced techniques for this task?
i'm not gonna deal with python nor numpy nor any other parochial computational platform.


first, since "silence" is a perceptual property, you need to apply a weighting filter, such as A-weighting to boost the frequency components of the audio that our ears are more sensitive to and attenuate the portions we're less sensitive to.  there are other weighting curves besides A-weighting.  i like Robert Wannamaker's E-weighting the best.
then square the filtered signal (to get power or energy).
then low-pass filter the squared and filtered signal (to get an envelope).
then compare this envelope to a threshold that will correspond to the threshold of hearing.
lastly, you may need to put in a little hysteresis in the threshold comparison so that the silence/no-silence result does not jitter as your envelope crosses the threshold.


this is similar to the "gate" function in a compressor/limiter/gate process that sometimes finds expression in audio applications.  the "gate" was to make sure that something that's perceived as silence (or sufficiently low-level that it should be perceived as silence) becomes zero during the "silent" periods of time.