1

我想,如果用户说“帮助”以下字段没有被填写,并且用户可以获得所有可能的选项。

<form id="test">    
    <field name="var1">


<prompt bargein="true" bargeintype="hotword" >say xy </prompt>

<grammar src = "grammar.grxml" type="application/srgs+xml"  />



    <filled>
    <assign name="myProdukt" expr="var1" />
    you said <value expr="myProdukt"/>
    </filled>

</field>

(假设在外部语法中是“p1”,“p2”和“p3”,用户说“帮助”,系统说“p1”,“p2”,“p3”,用户可以再次选择 - 因此“帮助”这个词也必须在外部语法中,不是吗?)

提前致谢

4

1 回答 1

2

是的,活动语法必须包含返回值“帮助”的“帮助”话语。help然后,您使用标签捕获事件:

<?xml version="1.0" encoding="UTF-8"?>
<vxml xmlns="http://www.w3.org/2001/vxml" version="2.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://www.w3.org/2001/vxml http://www.w3.org/TR/voicexml20/vxml.xsd">
    <form id="test">    
        <field name="var1">
            <prompt bargein="true" bargeintype="hotword" >say xy </prompt>
            <grammar src = "grammar.grxml" type="application/srgs+xml"  />
            <filled>
                <assign name="myProdukt" expr="var1" />
                you said <value expr="myProdukt"/>
            </filled>
            <help>
                To choose a product, say, 
                <!-- whatever the product choices are -->
                frobinator, submarine, curling iron, .. 
                <reprompt/>
            </help>
        </field>
    </form>
</vxml>

或者,遵循DRY 原则,可以使用 包含元素的应用程序根文档为您的应用程序全局完成此效果。在下面的示例文档中,将全局语法“帮助”话语绑定到事件:linkapp-root.vxmllinkhelp

<?xml version="1.0"?>
<vxml version="2.1" xmlns="http://www.w3.org/2001/vxml">
   <link event="help">
      <grammar mode="voice" root="root_rule" tag-format="semantics/1.0"
               type="application/srgs+xml" version="1.0" xml:lang="en-US">
            <rule id="root_rule" scope="public">
                  <one-of>
                        <item weight="1.0">
                              help
                        </item>
                  </one-of>
            </rule>
      </grammar>
   </link>
</vxml>

该语法将在任何地方都有效——有效地与每个有效字段语法合并。如果您需要有关应用程序根文档的更多信息,VoiceXML 规范执行多文档应用程序部分会解释。另请参阅Tellme Studio文档中的处理事件

然后,在应用程序的页面中,通过元素的application属性引用应用程序根文档,并在catch 块中适当地说:vxmlhelp

<?xml version="1.0" encoding="UTF-8"?>
<vxml xmlns="http://www.w3.org/2001/vxml" version="2.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://www.w3.org/2001/vxml http://www.w3.org/TR/voicexml20/vxml.xsd"
    application="app-root.vxml">
    <form id="test">    
        <field name="var1">
            <prompt bargein="true" bargeintype="hotword" >say xy </prompt>
            <grammar src = "grammar.grxml" type="application/srgs+xml"  />
            <filled>
                <assign name="myProdukt" expr="var1" />
                you said <value expr="myProdukt"/>
            </filled>
            <help>
                To choose a product, say, 
                <!-- whatever the product choices are -->
                frobinator, submarine, curling iron, .. 
                <reprompt/>
            </help>
        </field>
    </form>
</vxml>

当然,您可以将link代码与表单放在同一页面中,但您可能希望help应用程序的每个字段都处于活动状态,除非与特定字段的语法中的某些内容发生冲突。

于 2011-01-19T15:57:29.377 回答