Skip to content

Instantly share code, notes, and snippets.

@kscottz
Created July 1, 2013 04:29
Show Gist options
  • Save kscottz/5898352 to your computer and use it in GitHub Desktop.
Save kscottz/5898352 to your computer and use it in GitHub Desktop.
Convert mp3 to numpy array. Ugly, but it works.
import os
import scipy.io.wavfile as wav
# install lame
# install bleeding edge scipy (needs new cython)
fname = 'XC135672-Red-winged\ Blackbird1301.mp3'
oname = 'temp.wav'
cmd = 'lame --decode {0} {1}'.format( fname,oname )
os.system(cmd)
data = wav.read(oname)
# your code goes here
print len(data[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment