A very common homework question. You are given an audio file(.wav) which has the recording of the keys pressed during a telephone call. You have to identify the telephone number from this audio file when you are given the sampling frequency & the duration for which one key is pressed.
From the given sampling frequency & duration of key press, I could manage to write a MATLAB code to identify the telephone number by taking (samp_freq * key_press_time) number of samples at a time, doing fft on it & finding the bin that gives me a peak. I used WAVREAD command to read the audio file.
One problem I noticed is that, if the duration of key press is different(1st key pressed for 1 sec, 2nd key for 2 sec, 3rd key for 0.5 sec & so on), my technique of separating the data & finding peak will fail.
How to get around this problem of random duration key press? I could think of 2 inefficient ways to do this.
- During 1st iteration, take entire data & plot fft. If (no. of peaks > 1), take half data at a time plot fft. Keep on doing this until there is only 1 peak in the plot. But this technique will take a lot of time
- WAVREAD the file, each key press data is separated by 0's. Thus take data between the 0's one at a time, plot fft & find peak & frequency. But this looks too simple to be used.
So is there any other effiecient method of finding the telephone number when the key press duration is random?