I am developing a grammar for Speech recognition and have hit a brick wall.
If a customer does not know the answer to a prompt and says "don't Know" and other customers do know the answer, I am looking at separating these out.
For Example, if an insurance number is being requested: AB112233C and the user either knows this or does not.
I want to take a particular action in the application if the user doesn't know.
I am using NUANCE as the ASR.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<grammar xmlns="http://www.w3.org/2001/06/grammar"
xml:lang="en-GB" root="_alpha" version="1.0"
mode="voice" tag-format="swi-semantics/1.0">
<rule id="_alpha" scope="public">
<ruleref uri="#alpha"/>
<tag>
/* Only some letters allowed in prefix and suffix */
var alpharegex = /^([A-CEGHJ-PR-TW-Z]){1}([A-CEGHJ-NPR-TW-Z]){1}([0-9]){2}([0-9]){2}([0-9]){2}([A-D ]){1}?$/;
if ( !alpharegex.test(nino.out) ) SWI_disallow = 1;
SWI_meaning = alpha.out;
</tag>
</rule>
<rule id="alpha">
<ruleref special="GARBAGE"/>
<ruleref uri="#prefix"/><tag>out = prefix.out</tag>
<ruleref uri="#digits"/><tag>out += digits.out</tag>
<ruleref uri="#suffix"/><tag>out += suffix.out</tag>
</rule>
<rule id="prefix">
<tag>out = '';</tag>
<item repeat="2">
<one-of>
<item><tag>out += 'A'</tag>a</item>
<item><tag>out += 'B'</tag>b</item>
<item><tag>out += 'C'</tag>c</item>
<item><tag>out += 'E'</tag>e</item>
<item><tag>out += 'G'</tag>g</item>
<item><tag>out += 'H'</tag>h</item>
<item><tag>out += 'J'</tag>j</item>
<item><tag>out += 'K'</tag>k</item>
<item><tag>out += 'L'</tag>l</item>
<item><tag>out += 'M'</tag>m</item>
<item><tag>out += 'N'</tag>n</item>
<item><tag>out += 'O'</tag>o</item>
<item><tag>out += 'P'</tag>p</item>
<item><tag>out += 'R'</tag>r</item>
<item><tag>out += 'S'</tag>s</item>
<item><tag>out += 'T'</tag>t</item>
<item><tag>out += 'W'</tag>w</item>
<item><tag>out += 'X'</tag>x</item>
<item><tag>out += 'Y'</tag>y</item>
<item><tag>out += 'Z'</tag>z</item>
</one-of>
</item>
<tag>
/* alpha can't start with any of these */
var badPrefixes = /^(BG|GB|KN|NK|NT|TN|ZZ)/;
if ( badPrefixes.test(out) ) SWI_disallow = 1;
</tag>
</rule>
<rule id="digits">
<tag>out = '';</tag>
<item repeat="6">
<one-of>
<item><tag>out += '0'</tag>oh</item>
<item><tag>out += '0'</tag>zero</item>
<item><tag>out += '1'</tag>one</item>
<item><tag>out += '2'</tag>two</item>
<item><tag>out += '3'</tag>three</item>
<item><tag>out += '4'</tag>four</item>
<item><tag>out += '5'</tag>five</item>
<item><tag>out += '6'</tag>six</item>
<item><tag>out += '7'</tag>seven</item>
<item><tag>out += '8'</tag>eight</item>
<item><tag>out += '9'</tag>nine</item>
</one-of>
</item>
</rule>
<rule id="suffix">
<item repeat="0-1">
<one-of>
<item><tag>out = 'A'</tag>a</item>
<item><tag>out = 'B'</tag>b</item>
<item><tag>out = 'C'</tag>c</item>
<item><tag>out = 'D'</tag>d</item>
</one-of>
</item>
</rule>
</grammar>
Add a separate branch for "i don't know". You can use rulerefs inside one-of:
<rule id="alpha">
<one-of>
<item>
<ruleref special="GARBAGE"/>
<ruleref uri="#prefix"/><tag>out = prefix.out</tag>
<ruleref uri="#digits"/><tag>out += digits.out</tag>
<ruleref uri="#suffix"/><tag>out += suffix.out</tag>
</item>
<item>i don't know</item>
</one-of>
</rule>
Overall, it is better to avoid complex grammars and rules. This is 2018, time to ditch Nuance. Try Google's Dialogflow or open source speech recognizer, you'll be surprised how good is it.