Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

audio

sox

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

like image 519
Guy Avatar asked Dec 21 '10 08:12

Guy


People also ask

How do I change the sample rate of a WAV file in SoX?

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.

How do I use SoX audio?

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.

How do I convert a WAV file to sample rate?

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.


1 Answers

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.

like image 123
Guy Avatar answered Oct 17 '22 17:10

Guy