I would like to write a program to compare two '.wav' files, one of which is the original played file with human speech and the other is a recorded '.wav' file. The program I wish to write in python should be able to do the following:
- Read the '.wav' files, compare them and say if speech exists or not. If yes, what is the match % and gain or loss if any.
- Detect if there's any noise that's present in the recorded '.wav' file.
- Calculate the delay between the original played file and the recorded file (playing and recording done using threads, so
t=0is the same for either files).
As far as requirement 3 is concerned, I was fairly successful in calculating the delay using correlation function that's offered by numpy as:
corr_files = numpy.correlate(orig_pitch, rec_pitch, 'full') delay = int(len(corr_files) / 2) - numpy.argmax(corr_files)
For requirements 1 and 2, I happened to play around with an RMS based approach, but it didn't go well. What is the best way to achieve all the above requirements? Which algorithm suits the above requirements?