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

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.

Leave a Comment