voicexml中关于选择的实现

在voicexml中选择的实现可以用menu,也可以用form。用menu方式实现参考上一篇文章,这里主要介绍一些form实现

可以使用from的option,也可以通过grammar来实现

1、option的实现(例子:http://www.optimsys.cz/support/examples/example07.php)

<?xml version="1.0" encoding="UTF-8"?>
<vxml version="2.0" xmlns="http://www.w3.org/2001/vxml">

<meta name="description" content="options and link example"/>
<meta name="author" content="OptimSys, s.r.o., Czech Republic (http://www.optimsys.cz)"/>
<meta name="copyright" content="free for any purpose"/>

<noinput> Hey, don't sleep! </noinput>
<catch event="exit">
<prompt> Exit! </prompt>
<exit/>
</catch>


<form id="start">
<field name="lunch">
<nomatch>
<prompt> I didn't understand you. Please choose from <enumerate/> </prompt>
</nomatch>
<help> Just say what you want for lunch. </help>

<prompt> What do you want for lunch? You can choose from <enumerate/> </prompt>
<option dtmf="1" value="ch"> chicken </option>
<option dtmf="2" value="p"> pizza </option>
<option dtmf="3" value="c"> cake </option>
<option dtmf="4" value="n"> nothing </option>

<filled>
<if cond="lunch=='ch'">
<prompt> You will have chicken for lunch. </prompt>
<prompt> I like chicken too. </prompt>
<elseif cond="lunch=='p'"/>
<prompt> You will have pizza for lunch. </prompt>
<prompt> Fan of Italian kitchen? </prompt>
<elseif cond="lunch=='c'"/>
<prompt> You will have cake for lunch. </prompt>
<prompt> You will be fat! </prompt>
<else/> <!-- lunch=='n' -->
<prompt> You will have nothing for lunch. </prompt>
<prompt> Diet? </prompt>
</if>
</filled>
</field>
</form>


2、grammar的实现(http://www.w3.org/TR/voicexml20/)

<?xml version="1.0" encoding="UTF-8"?>
<vxml version="2.0" xmlns="http://www.w3.org/2001/vxml"
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="tapered">
<block>
<prompt bargein="false">
Welcome to the ice cream survey.
</prompt>
</block>
<field name="flavor">
<grammar mode="voice" version="1.0" root="root">
<rule id="root" scope="public">
<one-of>
<item>vanilla </item>
<item>chocolate</item>
<item>strawberry</item>
</one-of>
</rule>
</grammar>
<prompt count="1">What is your favorite flavor?</prompt>
<prompt count="3">Say chocolate, vanilla, or strawberry.</prompt>
<help>Sorry, no help is available.</help>
</field>
</form>
</vxml>


<?xml version="1.0" encoding="UTF-8"?>
<vxml version="2.0" xmlns="http://www.w3.org/2001/vxml"
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">

<meta name="en_inlinegrammar.vxml" content=""/>
<meta name="Author" content="HP"/>
<meta name="Date" content="September, 2005"/>
<meta name="Description"
content="This VoiceXML example is provided
as part of an HP OpenCall Media Platform
VoiceXML installation"/>
<meta name="Support" content="none"/>

<!-- Deactivate the barge in feature -->
<property name="bargein" value="false"/>

<form id="WhichDigit" scope="dialog">
<field name="digit">
<prompt>
Please say a digit.
</prompt>
<grammar mode="voice" version="1.0" root="root">
<rule id="root" scope="public">
<one-of>
<item> zero </item>
<item> one </item>
<item> two </item>
<item> three </item>
<item> four </item>
<item> five </item>
<item> six </item>
<item> seven </item>
<item> eight </item>
<item> nine </item>
</one-of>
</rule>
</grammar>
<filled>
<prompt>
Thanks, I think you said
<value expr="digit"/>.
</prompt>
</filled>
<!-- Message played if any error occured -->
<error count="1">
An error has occured.
</error>
<!-- Message played if the caller does not say anything -->
<noinput count="1">
Sorry, I did not hear anything. Try again.
<reprompt/>
</noinput>
<!-- Message played if the caller says something
that does not match -->
<nomatch count="1">
Sorry, I did not understand that. Try again.
<reprompt/>
</nomatch>
</field>
</form>
</vxml>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值