0

I'm trying to compare between 2 audio files that contains approximately the same audio recorded (from 2 different microphones) and I'm trying to find the delay between them. Here is my program flow:

t1 = threading.Thread(target=audio_to_wav, args=(wav1, 1, _rec_time_,))
t2 = threading.Thread(target=audio_to_wav, args=(wav2, 2, _rec_time_,))
t1.start()
t2.start()
t1.join()
t2.join()

First, I'm recording the same audio from 2 different microphones, and I am saving it to a 2 wav files. (because, it's 2 different microphones and the hardware is not the same and the distance between the mics and me not the same, I am expecting for some delay from one microphone when compared to the other one.

 arr1, smp1 = wav_to_arr(wav1)
 arr2, smp2 = wav_to_arr(wav2)

 def wav_to_arr(file):
 samplerate, sound = wavfile.read(file)
 arr = numpy.array(separate_array(sound), dtype=numpy.float64)
 return arr, samplerate

then, I'm converting each wav file to an array.(sample rate is fixed : 44100)

here Is the 2 graphs of each array:

image

as you can see, the 2 samples are very similar but not the same (as expected because of hardware limits and actual distance from my voice).

so now, I need to take thees arrays, and to compare them somehow to find the delay between them. I think I know how it's done, but my first task is to find out, how to make the both graphs to be in the same scale. because the first array values jumps from -3 to 3 (axis y), and for the second one the values jumps from -1.5 to 1.5 (axis y), if they are not in the same scale how could I compare them?

so, how should I proceed?

Thank you.

jose praveen
  • 1,298
  • 2
  • 10
  • 17
igalS
  • 1
  • 2
  • You can normalize the samples - find the highest value in each file (don't forget that it can be either positive or negative), give it a value of 1 or 100 or whatever and than scale all the other values according to the new maximum. – TDG Mar 23 '20 at 17:23
  • Does this answer your question? [Time delay estimation between two audio signals](https://stackoverflow.com/questions/4967453/time-delay-estimation-between-two-audio-signals) – Roland Puntaier Feb 20 '21 at 12:51

0 Answers0