2

I wonder if there any example showing how to detect silence in audio file.

Would I would like to achieve is to record a audio with a format such as WAV, and check if there is real sound is recorded or just silence.

any clue is appreciated.

user836026
  • 10,608
  • 15
  • 73
  • 129
  • You could either listen to it, or open it in a sound editor like Audacity to check the waveform. If it's a perfectly straight line, it's silence. http://audacity.sourceforge.net/ – Felix Guo Nov 20 '12 at 16:44
  • I need to do it progrmatically. – user836026 Nov 20 '12 at 16:47
  • "Silence" is kind of poorly defined. You can have a recording that most would regard as "silence" with higher signal levels than one with a clear voice speaking, due to hiss, hum, fan noise, etc. The way to really tell the difference is to run an FFT on the audio and look for spectral variations over time. – Hot Licks Nov 23 '12 at 02:58

1 Answers1

3

If you read the samples in from the WAV, you can sum their absolute value to get an idea of the total amplitude represented in the file. Lower values will indicate lower amplitude. You will likely have to calibrate this calculation to your specific problem.

In OS X or iOS, you can use Extended Audio File Services to obtain the samples. I have some example code posted at https://gist.github.com/d108/1ea9c833b10e714defef29824362821a to get you going.

Daniel Zhang
  • 5,778
  • 2
  • 23
  • 28