I would like to get the sample-rate of a given audio file using sox. Couldn't find the commandline to do that.
SoX determines the files type by looking at its extension. To adjust the rate of the output file, add the -r option to the output files formatting options.
Audio recorder SoX includes a very handy way of recording audio using the rec command. The simplest use is to type rec filename which will start recording from the default input until you stop it by pressing ctrl-c in the terminal window.
In the General Preferences tab, click on Import Settings, located towards the bottom. Click on the menu next to Import Using > WAV Encoder. Then click to change Setting > Custom and a new window will open. In the WAV Encoder window, change the Sample Rate to 44.100 kHz and Sample Size to 16-bit.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With