0
$\begingroup$

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:

  1. 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.
  2. Detect if there's any noise that's present in the recorded '.wav' file.
  3. Calculate the delay between the original played file and the recorded file (playing and recording done using threads, so t=0 is 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?

$\endgroup$

1 Answer 1

2
$\begingroup$

wav files generally have uncompressed data. That means you can get the exact waveform of the speech signal in digital form. You can tell whether the signal has some speech or not by calculating energy and using threshold to make the decision.

Again, the above technique may not work if there is noise along with speech.

Speech signal is quasi stationary signal and same speech will have different waveforms based on who is speaking, his pitch, his slang, his emotion and many more factors. So, it is very difficult to match two speech files.

The two problems that you wanted to solve

  1. % of match between two files.
  2. Detect noise.

are special fields in signal processing by itself. First one can be achieved by doing speech recognition on both the files and get the exact text for both files and then decide some rules to get % of match. For example, even though waveform of both speech are different but content is same, only with speech recognition you can 100% match.

coming to noise in the speech signal, there is again separate field in signal processing called as noise reduction. even though the process of noise reduction is used to reduce noise, one of the steps in noise reduction is to detect noise. You can use that step to detect noise.

But, both these topics are pure signal processing topics and i don't think you can achieve these with some simple function call or some simple python code.

$\endgroup$
1
  • $\begingroup$ Of course I know a simple function won't suffice. I'm looking for developing mathematical models for this. Have tried out the simpler way - FFT. Doesn't help much. I can get the frequency components and verify. Also, pitch match is feasible with this. I would also like to dig in and identify good algorithms/techniques for calculating the gain. Speech to text seems like a good idea, but I need to see the overhead on the resources. Any further details? $\endgroup$ May 14, 2019 at 5:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.