How do I get an audio file sample rate using sox?

Guy picture Guy · Dec 21, 2010 · Viewed 37.7k times · Source

I would like to get the sample-rate of a given audio file using sox. Couldn't find the commandline to do that.

Answer

Guy picture Guy · Dec 21, 2010

just use:

soxi <filename>

or

sox --i <filename>

to produce output such as:

Input File     : 'final.flac'
Channels       : 4
Sample Rate    : 44100
Precision      : 16-bit
Duration       : 00:00:11.48 = 506179 samples = 860.849 CDDA sectors
File Size      : 2.44M
Bit Rate       : 1.70M
Sample Encoding: 16-bit FLAC
Comment        : 'Comment=Processed by SoX'

The latter one is in case you're using the win32 version that doesn't include soxi, by default. To grab the sample rate only, just use:

soxi -r <filename>

or

sox --i -r <filename>

which will return the sample rate alone.