Speech recognition 有没有一种方法可以在grxml中执行条件逻辑?

Speech recognition 有没有一种方法可以在grxml中执行条件逻辑?,speech-recognition,voice-recognition,ivr,nuance,grxml,Speech Recognition,Voice Recognition,Ivr,Nuance,Grxml,我正在开发语音识别语法,但遇到了困难 如果一个客户不知道提示的答案,并说“不知道”,而其他客户知道答案,我正在考虑将其分离出来 例如,如果正在请求保险号码:AB112233C,而用户知道或不知道 如果用户不知道,我想在应用程序中执行特定操作 我使用NUANCE作为ASR <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <grammar xmlns="http://www.w3.org/2001/06/grammar

我正在开发语音识别语法,但遇到了困难

如果一个客户不知道提示的答案,并说“不知道”,而其他客户知道答案,我正在考虑将其分离出来

例如,如果正在请求保险号码:AB112233C,而用户知道或不知道

如果用户不知道,我想在应用程序中执行特定操作

我使用NUANCE作为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>

/*前缀和后缀中只允许使用一些字母*/
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}$/;
如果(!alpharegex.test(nino.out))SWI_disallow=1;
SWI_的意思是=alpha.out;
out=prefix.out
out+=数字。out
out+=后缀.out
out='';
out+='A'A
out+='B'B
out+='C'C
out+='E'E
out+='G'G
out+='H'H
out+='J'J
out+='K'K
out+='L'L
out+='M
out+='N'N
out+='O'O
out+='P'P
out+='R'R
输出+='S
out+='T不能
out+='W'W
输出+='X'X
out+='Y'Y
out+='Z'Z
/*阿尔法不能从这些开始*/
变量前缀=/^(BG | GB | KN | NK | NT | TN | ZZ)/;
如果(badPrefixes.test(out))SWI_disallow=1;
out='';
out+='0'oh
输出+='0'零
out+=“1”一
out+='2'2
out+='3'3
out+='4'4
out+='5'5
out+='6'6
out+='7'7
out+='8'8
out+='9'9
out='A'A
out='B'B
out='C'C
out='D
为“我不知道”添加单独的分支。您可以在以下其中一项中使用RuleRef:

<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>

out=prefix.out
out+=数字。out
out+=后缀.out
我不知道

总的来说,最好避免复杂的语法和规则。这是2018年,是抛弃细微差别的时候了。试试谷歌的Dialogflow或开源语音识别器,你会惊讶它有多好。

你已经有了什么语法?@NikolayShmyerv我添加了代码以方便使用。