代码之家  ›  专栏  ›  技术社区  ›  mtmurdock

vxml:用等价输入定义语法

  •  0
  • mtmurdock  · 技术社区  · 14 年前

    我用的是基于TellMe的引擎。我见过一些语法的例子,在这些例子中,用户可以说出几个被认为是相同的不同事物中的一个。然而,我看到的所有例子都是针对内联语法的(我使用的vxml引擎不适用)。我想知道如何更改.grxml文件来实现这一点。这是文件:

    <?xml version="1.0"?>
    <!-- created by Matthew Murdock. Grammars for speech rec menus -->
    <grammar xmlns="http://www.w3.org/2001/06/grammar" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2001/06/grammar      http://www.w3.org/TR/speech-grammar/grammar.xsd" xml:lang="en" version="1.0" mode="voice" scope="dialog" tag-format="semantics/1.0.2006">
       <rule id="keep">
          <one-of>
             <item>exit</item>
             <item>exit the system</item>
             <item>another</item>
             <item>another mailbox</item>
             <item>play</item>
             <item>play back</item>                      
          </one-of>
       </rule>
    </grammar>
    

    我希望有3个条目,每个条目有两个可能的语句,而不是6个条目。有什么办法吗?

    3 回复  |  直到 14 年前
        1
  •  2
  •   gawi    14 年前

    更紧凑的形式:

      <rule id="exit">
        exit <item repeat="0-1">the system</item>
        <tag>out.result = "exit"</tag>
      </rule>
      <rule id="play">
        play <item repeat="0-1">back</item>
        <tag>out.result = "play"</tag>
      </rule>
    
        2
  •  0
  •   Jim Rush    14 年前

    SISR 提供一种将意义附加到输入路径的机制的规范。改写你的例子:

    <?xml version="1.0"?>
    <grammar xmlns="http://www.w3.org/2001/06/grammar" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2001/06/grammar      http://www.w3.org/TR/speech-grammar/grammar.xsd" xml:lang="en" version="1.0" mode="voice" scope="dialog" tag-format="semantics/1.0-literals">
       <rule id="keep">
          <one-of>
           <item>
            <one-of>
             <item>exit</item>
             <item>exit the system</item>
            </one-of>
            <tag>exit</tag>
            </item>
    
           <item>
            <one-of>
             <item>another</item>
             <item>another mailbox</item>
            </one-of>
            <tag>another</tag>
           </item>
    
           <item>
            <one-of>
             <item>play</item>
             <item>play back</item>                      
            </one-of>
            <tag>play</tag>
           </item>
          </one-of>
       </rule>
    </grammar>
    

    要知道的几件事:

    • TellMe标记格式值可能需要不同,但是 development guide 意味着他们遵循标准。
          </one-of>
          <item repeat="0-1"><ruleref uri="#trailing"/></item>
       </rule>
    
       <rule id="trailing>
          <one-of>
             <item>please</item>
             <item>thank you</item>
    
          </one-of>
       </rule>
    
    </grammar>
    

    这将支持更自然的反应类型。这可能很重要,也可能不重要,这取决于你的电话基础。填充语法可以非常大,但往往是高度可重用的。也可以在输入的开头添加填充符。在丰富的语音应用程序中,调优过程中最大的好处是更新语法以包含调用者所说的实际短语,而不是开发人员或VUI设计者所认为的短语。

        3
  •  0
  •   mtmurdock    14 年前

    我想出来了。我把语法改成这样:

    <?xml version="1.0"?>
    <grammar xmlns="http://www.w3.org/2001/06/grammar" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2001/06/grammar      http://www.w3.org/TR/speech-grammar/grammar.xsd" xml:lang="en" version="1.0" mode="voice" scope="dialog" tag-format="semantics/1.0-literals">
       <rule id="keep">
          <one-of>
             <item><ruleref id="#exit"/></item>
             <item><ruleref id="#play"/></item>
          </one-of>
       </rule>
       <rule id="exit">
          <one-of>
             <item>exit</item>
             <item>exit the system</item>
          </one-of>
          <tag>out.result = "exit"</tag>
       </rule>
       <rule id="play">
          <one-of>
             <item>play</item>
             <item>play back</item>
          </one-of>
          <tag>out.result = "play"</tag>
       </rule>
    </grammar>
    

    然后,回到我的脚本中,而不是基于callerInput(在 <field> <tag>

    注意:因为我们正在使用我们自己的vxml引擎,所以我们能够创建一个从xml中提取解释值的方法。