In the recent article about extracting the audio from videos I detailed a method to get the audio track from a video. One use for this is extracting the audio of recorded lectures that universities or professors have placed online and are made freely available. Many of these lectures can actually be listened to at a faster speed, reducing the amount of time needed to learn the same material, and while many media players for computers can play audio at a faster speed, this ability is far less common amongst portable media players. This forces you to create a version of the file which is faster than the original.

Of course, when you do this, it is key is to ensure that the only the speed is adjusted, while keeping the pitch the same (otherwise you end up with that high-pitched chipmunk sound). To do this, we will use the command line program sox.

First you need to install two packages. To install them, run the following command:

sudo apt-get install sox libsox-fmt-all

sox is a program that manipulates, plays, converts and records audio on various computing platforms. libsox-fmt-all installs various codecs for sox, although it did not enable encoding to mp3 (although it could read from mp3) on Ubuntu, nor was I interested in trying to make it do so.

Having installed the two necessary packages, a command of the format below will speed up the file.

sox inputfile.ext outputfile.ext tempo #

In this, inputfile.ext is the music file you desire to speed up, outputfile.ext is the file name to write the new file to. tempo # tells the sox to change the speed of the music by the factor (which appears to allow any integer or decimal number).This factor, a number, goes in the place of #.

For example, if I had a file called slowfile.mp3 I could create a faster file in an ogg format called tenpercentfaster.ogg by running the command:

sox slowfile.mp3 tenpercentfaster.ogg tempo 1.1

and the resulting file would be ten percent faster than the original file.

If the original file was really slow, I might want to increase it by fifty percent by running the command

sox slowfile.mp3 fiftypercentfaster.ogg tempo 1.5

or even make it one hundred percent faster by running the command

sox slowfile.mp3 onehundredpercentfaster.ogg tempo 2.

Alternatively, if I had a file, toofast.mp3, which I wanted to have a playback that was eighty-five percent slower than the original playback, I could run the command

sox toofast.mp3 eighty-fivepercentslower.ogg tempo 0.15

which would have the desired results because any number below 1 as the factor decreases the speed.

So far, I’ve found that on the lectures I’ve changed the speed on, using a factor of about 1.75 works pretty well, but it depends on the speaker’s accent and the subject material. However, in order to get a speed which is optimal, you will most likely have to experiment with various factors.