Phase difference between two wave files I am doing comparison between two wave files, How to calculate phase difference between those files?
Second wave is generated by making some changes in the first one .I have tried calculating phase like this:-

y, sr = librosa.load('first.wav') 
D = librosa.stft(y) 
magnitude, phase1 = librosa.magphase(D)

y1, sr1 = librosa.load('second.wav')
D1 = librosa.stft(y1)
magnitude1, phase2 = librosa.magphase(D1)


then calculated the difference as (phase1-phase2)

Is this the correct way??
You need to cross-correlate those two wavfiles : from wikipedia "cross-correlation is a measure of similarity of two series as a function of the displacement of one relative to the other" 

The result obtained will give you a measure of the similarity between those two audio signals depending on the time. 

Therefore you will need to find the time for which the cross-correlation is at its maximum (ie : maximum similarity), it will indicates you the time delay, phase between those two signals. 

A couple of advices : 

1/ If your signals are periodic, you only need to compute cross-correlation over one period (or more if you want to average the noise). 

2/ Don't forget to take the absolute value of the cross-correlation while searching for the maximum.