Skip to content

Instantly share code, notes, and snippets.

@hackintoshrao
Created September 19, 2015 01:18
Show Gist options
  • Save hackintoshrao/ec14c9d88147e62ff3ba to your computer and use it in GitHub Desktop.
Save hackintoshrao/ec14c9d88147e62ff3ba to your computer and use it in GitHub Desktop.
from scipy.io.wavfile import read #import wav audio related functions
import matplotlib.pyplot as plt #for plotting
fs , x = read('/home/karthic/Downloads/kalimba.wav') #x is an array of integers containing all the samples of the wav file
print "sample rate = " ,fs #sample rate of the wav file
print "Total samples in the wav audio: ",x.size #total number of samples in the wav audio
print "Length of wav file in seconds: ",x.size/float(fs)
#number of samples / sampling rate gives the length of the wav file in seconds
plt.plot(x) #plot the wav sampling
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment