tags:

views:

189

answers:

3

Hi,

I am searching for a utility/code that could detect and let me know if my 1 minute wav file contains sound or not ? Other way, if it could detect the duration of the silence(if exists) at any position in the wav file, that would also server the purpose.

Does SOX support any command for that ? I tried with Java, but didnt found anything in JMF.

Thanks

Vivek

A: 

SoX does have the ability to trim silence, but I'm not sure whether that helps you:

silence [-l] above-periods [duration threshold[d|%] [below-periods duration threshold[d|%]]

Removes silence from the beginning, middle, or end of the audio. `Silence' is determined by a specified threshold.

bzlm
Thanks for that. But i dont have to trim the silence or the wav file. I just want to know, if the file is silent over its 1 minute duration range or there is some sound in it ? Thanks Vivek
Vivek
A: 

You could easily write your wave file processor, it's an easy header and then just simple data. You can easily find out the sample size, 8 or 16 bits, then read the file sample by sample if you find a sequence of samples with the value of 0 then you got silence. Measure how many samples are 0 and use the sampling rate (also in the header) to calculate the duration.

Francisco Soto
Does Java provide any API or binary for reading wav files?It would be of great help if Any sample code is available for this ?Thanks Vivek
Vivek
I don't do much Java, but I am sure it has binary file reading capabilities, look for the wav format specs around the web, it's a very simple format.
Francisco Soto
A: 

Audacity does this and is OpenSourced on sourceforge.net, so you should be able to gleen all the example code you need.

kent