Nick Argall
Nick Argall

Reputation:

How to disable a VoiceXML grammar?

I'm writing a VoiceXML application where we have a speech grammar and a DTMF grammar. If the caller is calling from a particularly noisy environment, we need to disable the speech grammar. Is there a way to do this which doesn't involve copying the entire form into another form and deleting the speech grammar?

Upvotes: 2

Views: 760

Answers (3)

Neel
Neel

Reputation: 854

Using inputmodes can work but you'll still need two forms. There is, however, a work around if you are using voicexml 2.1 and make sure you do not provide the input mod in the grammar tag and make sure it's specified in the grammar itself then you can use a srcexpr to "turn off" your speech grammar.

Say you specify your grammars thus:

<grammar type="application/srgs+xml" src="/grammars/menu.grxml" />
<grammar type="application/srgs+xml" src="/grammars/menu-dtmf.grxml" />

You can disable the speech grammar by repeating the use of the dtmf version:

<grammar type="application/srgs+xml" srcexpr="'/grammars/menu' + (dtmfMode?'-dtmf':'') + '.grxml'" />
<grammar type="application/srgs+xml" src="/grammars/menu-dtmf.grxml" />

So all you need to do is set a boolean variable called dtmfMode that is true when you only want DTMF.

Upvotes: 0

Willigar
Willigar

Reputation:

You don't mention which platform(s) you're using, but it's important because this is one of those areas where you have variation between platforms.

Section [3.1.4][1] of the VoiceXMl 2.0 spec says that inputmodes="dtmf" does not de-activate speech grammars, but merely makes it impossible for them to be matched. So, if you turn off the speech recognition grammars, you would hope that the end pointer wouldn't allow speech bargein, but it isn't necessarily forbidden by the spec.

Barring any platform-specific extensions you can use, you might also consider the sensitivity property. Setting that to 0 should make the ASR stop listening for speech.

You could also try setting the bargeintype property to "hotword", if your platform supports it. This won't disable the speech grammars, but it will make it less likely that users won't hear the prompts due to noise-related bargein which is sometimes enough to make the application work.

Upvotes: 2

Ateş G&#246;ral
Ateş G&#246;ral

Reputation: 140050

What you're looking for is probably the inputmodes property:

<property name="inputmodes" value="dtmf"/>

This will enable the DTMF grammar while the voice grammar is disabled.

Upvotes: 6

Related Questions