I have the original record of a song, and some fragment of the same song recorded by a microphone. I need to find the time where the fragment is appearing in the original. I have tried to use cross-correlation, the results are good but sometimes it gives a completely different part of the song that is similar (same notes but not the same words). How can I solve this problem ? Could the cross-correlation value be higher than the time when the sub-signal is found ? Different approaches are welcome also. Here is my code for the correlation implementation.
#compute correlation correlation = correlate(reference,signal,mode='valid',method='direct') #get maximum index index = np.argmax(corr) #extract from the reference extract = reference[index:index + len(sec)]