1
$\begingroup$

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.

  1. 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
  2. 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?

$\endgroup$
3
  • $\begingroup$ Why not to try some activity detection, even based on energy envelope? It will determine boundaries of beeps and then process chunks. Of course providing that data is not very noisy. Otherwise pre-filter data with notch bandpass filter covering DTMF frequencies and perform activity detection on that. As simple as that. $\endgroup$
    – jojeck
    Nov 26, 2014 at 9:06
  • $\begingroup$ Kharo, it's the same problem that any embedded system has with button switches. you need to create a simple "state machine" in which one state is "key pressed" or "key held" and the other state is "no key pressed" only when there is a transition from "no key pressed" to "key pressed" do you enter a digit in the telephone number. (some might do that when a key is released, the opposite transition, but i would not recommend that.) $\endgroup$ Nov 26, 2014 at 17:13
  • $\begingroup$ Anyway please refer for example to this article: Detection of Multi-tone Signals Based on Energy Operators $\endgroup$
    – jojeck
    Nov 28, 2014 at 12:08

1 Answer 1

2
$\begingroup$

If you interested in computational efficiency then performing FFTs is not the best solution. Here's something you might try: apply the samples of your .wav file to a parallel bank of 8 Goertzel filters. (One filter for each of the 8 possible tone frequencies.) For example, below is the Goertzel filter for detecting the 770 Hz tone.

Monitor (measure) the output powers of the 8 filters every, say, 25 milliseconds. If the sample rate is 8000 Hz, then 25 msec means measure the 8 filter output power values every 200 input samples. So, in the figure below, apply the first 200 input samples to the filter and compute a single v(n) value. Then, and only then, compute a single complex-valued y(m) sample and single real-valued P770(m) sample. For the first 200 input samples do the same for the other 7 filters. At the end of the first 200 input samples see if two the eight Pxxx(m) power sample values exceeded some threshold value. If so, then you know a phone button key was pressed. Using some sort of logic, decode the two high-level Pxxx(m) power values to determine which key was pressed and store that single 'key number'. If no key was pushed during those first 200 input samples set the stored 'key number' value to Nan in Matlab.

Repeat the above processing for every block of 200 samples in your .wav file. If your .wav file had 16,000 samples then you should end up with a sequence of 80 'key number' values. Plot those 'key number' values versus the time index m.

770 Hz filter

$\endgroup$

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.