# How to detect and remove ringback-tone and ivrs voice etc from the beginning of an audio call recording

In an audio recording (say a telephone conv. b/w two people), how would I programatically detect and remove the dial-tone at the beginning of a call using python. Ex : As you can see the first 15 seconds or so is just a dial tone like tring-tring-tring-tring.

Are there any audio analysis libraries in python that could help me achieve this?

If this is not the right forum, kindly point me to the right place.

• unless your country's telephones work extremely different then my country's ones, then "tring" is not a dial tone, but a ring tone? Also, what about simply detecting the crossing of an amplitude threshold? This looks extremely much like "amplitude higher than 0.7 for more than a millisecond" is a reliable detector. – Marcus Müller Nov 17 '17 at 8:09
• Ok thank you for correcting me. ringtone/hold music/ivrs was what I meant. the tring tring part. could you please point me to any python libraries please. thank you. – kRazzy R Nov 17 '17 at 19:41
• . OK, updating my question. But you got it right, I just want to detect parts of the call which has automated IVRS, or hold music or the tring tring – kRazzy R Nov 17 '17 at 20:24
• @MarcusMüller Could you pleae tell me how to go about "amplitude higher than 0.7 for more than a millisecond detection method – kRazzy R Dec 5 '17 at 19:08
• I'm afraid I don't know where to start if you don't know what "amplitude" means in the context of a digital signal. – Marcus Müller Dec 5 '17 at 19:42

You can use librosa and scikit-learn to create a machine learning classifier. It would work roughly like this:

## Training

1. Get training signals of (A) just phone ringing, and (B) no phone ringing, e.g. ordinary conversation.
2. Segment the training signals with a frame size of ~50-500 milliseconds.
3. Extract features from each frame, e.g. MFCCs.
4. Train a scikit-learn classifier, e.g.

classifier.fit(X, y)


where X is a ndarray of feature vectors, and y are the target labels, e.g. "ring" (1) and "no ring" (0).

## Prediction

classifier.predict(X)


where X is an ndarray of feature vectors extracted in the same way from a test signal.

The latest frame which returns a positive "ring" label is where to truncate the signal.

• by Segment the training signals with a frame size of ~50-500 milliseconds` do you mean splitting the whole audio into pieces of 50milliseconds each? Or do you mean for it to be the sliding window frame size. – kRazzy R Dec 5 '17 at 22:54