DTMF and Speech

Many speech applications are best suited if the user has the option of entering DTMF input (telephone keypad presses) in addition to speech. While we don't recommend "press or say" menus that ask the user to say DTMF options, there are applications where collecting speech and DTMF is important.

For instance, if the user is being asked to enter a credit card number, it is a good idea to allow for DTMF entry as users will not want to speak sensitive data in public locations.

When you call SpeechBackground() to perform speech recognition, Asterisk listens for both speech and DTMF entry. As soon as it detects a DTMF key press, it immediately stops streaming audio to the Speech Engine and it will then collect exclusively DTMF for that interaction.

DTMF presses are stored in $(SPEECH_TEXT()) as a digit string. So if the user presses 5 1 4 then $(SPEECH_TEXT(0)) is equal to 514. This makes it simple to collect both speech and DTMF at the same time, as you simply need to check $(SPEECH_TEXT()) for the input, regardless of how the user responded.

Controlling DTMF Input

Asterisk supports a few special variables you can set using the Set command to alter how Asterisk collects DTMF input during a speech event.

SPEECH_DTMF_MAXLEN

specifies the maximum number of digits Asterisk will listen for. So Set(SPEECH_DTMF_MAXLEN=5) will cause Asterisk to immediately stop waiting for DTMF input after the user has pressed 5 keys.

SPEECH_DTMF_TERMINATOR

causes a specific key to act as a terminator. After Asterisk receives this key, it will immediately stop waiting for DTMF input. So Set(SPEECH_DTMF_TERMINATOR=#) will cause the pound key (the # key) to end the interaction.

DTMF Grammars

It is Asterisk, not the Speech Engine, that handles all DTMF collection. As soon as Asterisk "hears" DTMF, it immediately stops the Speech Engine from processing anything else for that interaction.

The SRGS grammar specification allows for DTMF grammars (using DTMF as the grammar's mode instead of voice), something the LumenVox Speech Engine supports. However, because Asterisk does not send any DTMF data to the Engine, you cannot use DTMF grammars in conjunction with Asterisk and LumenVox.

You will have to handle all DTMF interpretation within your Asterisk application and not at the grammar level.

© 2012 LumenVox LLC. All rights reserved.