| VoiceXML 2.1 Development Guide | Home | Frameset Home |
|
lastresult$.marktime, which will be populated with a time value (in milliseconds) showing us where the user interrupted our <prompt>. Leveraging this shadow variable, we can then assign a universal grammar ("that one," or even a dtmf key) to choose items from a list and then use some simple mathematical calculations to determine which choice the caller wants.lastresult$.marktime. To be clear, lastresult$.markname is not presently supported but will be added in future software releases of the platform.
<?xml version="1.0" encoding="UTF-8"?>
<vxml version="2.1" xmlns="http://www.w3.org/2001/vxml" xmlns:voxeo="http://community.voxeo.com/xmlns/vxml" >
<meta name="maintainer" content="your_email_address@somewhere.com"/>
<form>
<block>
<voxeo:recordcall value="100" info="marktest"/>
</block>
<field name="LenandBarrys">
<prompt bargein="false">
Welcome to Len and Barry's Ice Cream Ordering System.
You can select from the following menu your favorite ice cream of the day.
At any time you can say "that one."
</prompt>
<prompt>
<break time="1000ms"/>
Cocoa Banana Cabana
<break time="2500ms"/>
Banana Caramel Crunch
<break time="2500ms"/>
Chocolate Devotion
<break time="2500ms"/>
German Chocolate
<break time="1000ms"/>
</prompt>
<grammar mode="voice" root="LenBarry">
<rule id="LenBarry" scope="public">
<one-of>
<item>that one</item>
</one-of>
</rule>
</grammar>
<filled>
</filled>
</field>
</form>
</vxml>
<voxeo:recordcall> element in our <block>. Second, we have defined a Voxeo XML namespace within the <vxml> element. These are important for our next step in the tutorial: In order to effectively set up demarcations for our "universal choice" grammar, we will need to determine where the different choices of ice cream are output and how much time they take to render to the caller. More importantly, you'll note that we have some pauses added after each flavor of ice cream listed in our TTS. This allows our caller a "window" to declare their choice and have the system determine what choice they really wanted.<voxeo:recordcall> element.<voxeo:recordcall> element will be dumped into the "C:\Program Files\Voxeo\www\MRCP\Recordings" directory, and will look something like this.<voxeo:recordcall> and drag it into the window. This will give us a tidy representation of where the audio is output and how much time there is between the rendering of the different ice cream choices. An annotated screenshot of what this will look like is found below for reference:
<if cond="LenandBarrys$.marktime <= 6700">
<!-- USER MUST HAVE CHOSEN "Cocoa Banana Cabana" -->
<break> tag immediately following it. To find the times, we just keep adding the pause and render times to the time above. Remember, greater-than and less-than values need to be encoded, as the "<" and ">" brackets would cause us a parse error. As such, they need to be represented with ">" and "<" within the XML file:
<filled>
<log expr="'****** LenandBarrys$.marktime' + LenandBarrys$.marktime + '********'" />
<if cond="LenandBarrys$.marktime <=6700">
<prompt>You chose Cocoa Banana Cabana.</prompt>
<elseif cond="LenandBarrys$.marktime >=6700 && LenandBarrys$.marktime <=12000" />
<prompt>You chose Banana Caramel Crunch.</prompt>
<elseif cond="LenandBarrys$.marktime >=12000 && LenandBarrys$.marktime <=16000" />
<prompt>You chose Chocolate Devotion.</prompt>
<else />
<prompt>You chose German Chocolate.</prompt>
</if>
</filled>
<log> statement, as it is going to give us some external validation on our math skills and show the actual marktime value for us in the Voxeo debugger. And we always keep the debugger open when making test calls, right? Right?
<?xml version="1.0" encoding="UTF-8"?>
<vxml version="2.1" xmlns="http://www.w3.org/2001/vxml" xmlns:voxeo="http://community.voxeo.com/xmlns/vxml">
<meta name="maintainer" content="your_email_address@somewhere.com"/>
<form>
<block>
<voxeo:recordcall value="100" info="marktest"/>
</block>
<field name="LenandBarrys">
<prompt bargein="false">
Welcome to Len and Barry's Ice Cream ordering system.
You can select from the following menu your favorite ice cream of the day.
At any time you can say "that one."
</prompt>
<prompt>
<break time="1000ms"/>
Cocoa Banana Cabana
<break time="2500ms"/>
Banana Caramel Crunch
<break time="2500ms"/>
Chocolate Devotion
<break time="2500ms"/>
German Chocolate
<break time="1000ms"/>
</prompt>
<grammar mode="voice" root="LenBarry">
<rule id="LenBarry" scope="public">
<one-of>
<item>that one</item>
</one-of>
</rule>
</grammar>
<catch event="noinput nomatch">
<log expr="'***** OOGNI event caught: ' + _event"/>
<prompt>
I'm sorry, but I didn't quite catch that.
Let's try again.
</prompt>
<reprompt/>
</catch>
<filled>
<log expr="'***** LenandBarrys$.marktime' + LenandBarrys$.marktime + '********'"/>
<if cond="LenandBarrys$.marktime <=6700" >
<prompt>
You chose Cocoa Banana Cabana.
</prompt>
<elseif cond="LenandBarrys$.marktime >=6700 && LenandBarrys$.marktime <=12000"/>
<prompt>
You chose Banana Caramel Crunch.
</prompt>
<elseif cond="LenandBarrys$.marktime >=12000 && LenandBarrys$.marktime <=16000"/>
<prompt>
You chose Chocolate Devotion.
</prompt>
<else/>
<prompt>
You chose German Chocolate.
</prompt>
</if>
</filled>
</field>
</form>
</vxml>
| ANNOTATIONS: EXISTING POSTS |
ebaker
|
|
| It seems the milliseconds that the marktimes are compared to are off in the downloadable source code (and less so in the above code). Examining the recording using Audacity gives me time demarcations for the beginning of each next choice of about 6000ms, 10500ms and 14500ms. Even if you were to allow "that one" to select the last choice halfway into the prompting of the next one, it would still only be about 6700ms, 11000ms and 15000ms.
Also, there is a simplification for the <if> block in that the "greater than" portions of the <elseif> "cond=" are unnecessary as the preceding conditions have accounted for them. So, the new <if> block would be (including the updated timings): <if cond="LenandBarrys$.marktime &lt;=6000" > <prompt> You chose Cocoa Banana Cabana. </prompt> <elseif cond="LenandBarrys$.marktime &lt;=10500"/> <prompt> You chose Banana Caramel Crunch. </prompt> <elseif cond="LenandBarrys$.marktime &lt;=14500"/> <prompt> You chose Chocolate Devotion. </prompt> <else/> <prompt> You chose German Chocolate. </prompt> </if> |
|
MattHenry
|
|
|
Hiya Eric, Thanks for the heads-up on this. This tutorial was written a few years ago as you my have noticed, and it really could stand to be updated to be more in-line with the new prophecy software versions which have slightly different endpointer settings: I'll make sure that our doc writing team puts this on-deck in the interest of providing clear, accurate sample code for our developers. Cheers, ~Matthew Henry |
| login |
|