Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
25 lines (18 sloc) 757 Bytes
import librosa
import matplotlib.pyplot as plt
from dtw import dtw
#Loading audio files
y1, sr1 = librosa.load('/home/user/Desktop/1.wav')
y2, sr2 = librosa.load('/home/user/Desktop/2.wav')
#Showing multiple plots using subplot
plt.subplot(1, 2, 1)
mfcc1 = librosa.feature.mfcc(y1,sr1) #Computing MFCC values
plt.subplot(1, 2, 2)
mfcc2 = librosa.feature.mfcc(y2, sr2)
dist, cost, path = dtw(mfcc1.T, mfcc2.T)
print("The normalized distance between the two : ",dist) # 0 for similar audios
plt.imshow(cost.T, origin='lower', cmap=plt.get_cmap('gray'), interpolation='nearest')
plt.plot(path[0], path[1], 'w') #creating plot for DTW #To display the plots graphically