Use The Beep Detector

⌘K
  1. Home
  2. Programmable Voice
  3. How do I
  4. Use The Beep Detector

Use The Beep Detector

If you’re worried about improving your call progress, the Voice Elements Beep Detector is the answer.

Traditional Call Progress detection is limited because it relies on the first couple of seconds of audio to determine if what picked up the phone was a human or an answering machine.

The Voice Elements Beep Detector analyzes much longer amounts of audio listening for a beep. If a beep is “heard”, you can be certain that it was a machine. Alternatively, you can be relatively certain that if no beep was detected that it was a human that answered the call.

In our testing, we found that the Voice Elements Beep Detector was 98.5% accurate in detecting beeps. By comparison, the most finely tuned Call Progress engines reach only about 90% accuracy.

The Problems with Traditional Call Progress

When someone answers their phone while driving, the system will hear the background noise and think that it was a machine that picked up. Or perhaps someone will pick up the phone and say “Thank you for calling Inventive Labs, this is Matt, how may I help you?” — and because the introduction is so long, a traditional call progress engine will determine that it was a machine that picked up the phone.

Also, traditional systems find it difficult to determine when it’s appropriate to begin playing the message to a machine. When the message begins at the beginning of a call that is going to voicemail, the first half of the message is played during their outbound voicemail message.  By the time the voicemail plays the beep and begins recording, much of your message has been lost. When the recipient listens to their voicemail, they hear a message fragment that is completely ineffective.

Our Beep Detector resolves this by allowing you to restart your message as soon as you hear a beep — effectively allowing you to get the entirety of your message on a voicemail system on a consistent basis.

Our Beep Detection Works!

Once you start the Beep Detector in Voice Elements, it will analyze all of the audio listening for anything that might be considered a beep. When a beep is detected, Voice Elements will return a Termination Code of Beep back to the client application and you can then determine how to handle the situation.

When you make calls, you begin playing a message as though a human picked up the phone. Then once a beep is detected, you can begin playing the machine message. This means that people who pick up the phone will always hear the message that is meant for them, and voicemails will always contain the entirety of the message.

Using the Beep Detector

Below is some sample code that shows how to use the Beep Detector:

public class BeepDetector
{
    public ChannelResource ChannelResource
    {
        get;
        set;
    }
 
    public VoiceResource VoiceResource
    {
        get;
        set;
    }
 
    public TelephonyServer TelephonyServer
    {
        get;
        set;
    }
 
    public Log Log
    {
        get;
        set;
    }
 
    public string DeviceName
    {
        get;
        set;
    }
 
    public string PhoneNumber
    {
        get;
        set;
    }
 
    public BeepDetector(TelephonyServer telephonyServer, Log log)
    {
        TelephonyServer = telephonyServer;
        Log = log;
    }
 
    public bool IsBeepDetected
    {
        get;
        set;
    }
 
    public void RunScript()
    {
        try
        {
            TerminationCode tc = TerminationCode.Normal;
            try
            {
                ChannelResource = TelephonyServer.GetChannel();
                VoiceResource = ChannelResource.VoiceResource;
                DeviceName = ChannelResource.DeviceName;
            }
            catch (Exception ex)
            {
                Log.WriteException(ex, "Could not get a channel resource!");
                return;
            }
 
            // We will set the CallProgress mode to WaitForConnect
            // This means that we will return as soon as we get a connect message back from the carrier
            ChannelResource.CallProgress = CallProgress.WaitForConnect;
 
            // Place the call
            DialResult dr = ChannelResource.Dial(PhoneNumber);
            Log.WriteWithId(DeviceName, "Returned from Dial: {0}", dr);
 
            // Now we begin our Beep Detector. Once started, it's possible for us to receive Termination Codes of Beep
            VoiceResource.BeepDetectionStart();
 
            // Now we play a message to a human
            tc = VoiceResource.PlayTTS("Hello Human! Please press any digit if you would like to speak to a live operator");
 
            // Check to see if we detected a beep
            if (tc == TerminationCode.Beep)
            {
                IsBeepDetected = true;
                // Stop the Beep Detector. Make sure you do so before doing your next play!
                VoiceResource.BeepDetectionStop(); 
                VoiceResource.PlayTTS("Hello Machine! This is a message meant for you");
 
                // Return from this message -- we don't need to get digits if we know that it's a machine.
                return;
            }
 
            // The beep detector also works when detecting digits
            tc = VoiceResource.GetDigits(1, 15, "@");
 
            Log.WriteWithId(DeviceName, "TerminationCode was: {0}", tc);
 
            if (tc == TerminationCode.Beep)
            {
                IsBeepDetected = true;
                // Stop the Beep Detector. Make sure you do so before doing your next play!
                VoiceResource.BeepDetectionStop(); 
                VoiceResource.PlayTTS("Hello Machine! This is a message meant for you");
 
            }
            else if (tc == TerminationCode.MaximumDTMF || tc == TerminationCode.Digit)
            {
                // The person entered a digit...Transfer to an operator
            }
            else
            {
                // The person did not enter a digit.
            }
        }
        catch (HangupException hex)
        {
            Log.WriteWithId(DeviceName, "Caller Hungup!");
        }
        catch (Exception ex)
        {
            Log.WriteException(ex, "Unexpected exception: {0}", DeviceName);
        }
        finally
        {
            if (!IsBeepDetected)
            {
                // Make sure you always stop the Beep Detector
                VoiceResource.BeepDetectionStop();
            }
            try
            {
                ChannelResource.Disconnect();
            }
            catch { }
 
            try
            {
                ChannelResource.Dispose();
            }
            catch { }
        }
    }
}

 

‘BeepDetectionStart’ and ‘BeepDetectionStop’

The Beep Detector must be active for a termination code of Beep to be met. This means that you must always call BeepDetectionStart, before you do anything where you may want to detect a beep.

Make sure that that you always stop the beep detector with BeepDetectionStop before doing a subsequent play. Otherwise, the next play will end immediately with a return code of beep. This allows your code to fall through multiple plays (i.e. you play message 1, 2, and 3 in quick succession).

You can see this in action in the code sample above.

Using the Beep Detector with Short Messages

One potential issue with the beep detector is that if you play short messages, you may never hear a beep. To remedy this situation, we recommend the following:

  1. Determine how long you should typically wait (between 30 and 45 seconds is typically long enough). Perhaps, you should make this a configuration setting.
  2. Get the time when your call first connects.
  3. Get the time when your message is finished playing.
  4. If it’s been more time than you defined in item 1, then determine how many more seconds you need to wait by subtracting the duration of the call from the desired wait time for the beep.
  5. Wait for digits as in this setting:
VoiceResource.GetDigits(1, secondsToWait, "");

As long as the beep detector is still on, the GetDigits will return with a return code of BeepDetected.

Using the method above, you would ensure that you wait the necessary time for the message to return.

Conclusion

As you can see, it’s a straightforward process to take advantage of the Beep Detector in your existing code. Implementing the Beep Detector is a powerful way to improve the accuracy of your call results.

Please see our article Beep Detection Default Settings for more detailed information.

Developers will appreciate this full list of VoiceResource Properties.

If you have any questions about using the Beep Detector, please contact us at support@inventivelabs.com.

Was this article helpful to you? No 1 Yes 16

How can we help?