dcsimg
January 24, 2017
Hot Topics:

VoiceXML Adventure Game

  • November 30, 2002
  • By Jonathan Eisenzopf
  • Send Email »
  • More Articles »

Now that we have a simple interactive application working, we need to add the ability for users to provide voice commands in addition to DTMF input. This is done by adding additional grammar expressions.

  <grammar><![CDATA[
          [
            [dtmf-1 one] {<option "door1">}
            [dtmf-2 two] {<option "door2">}
            [dtmf-3 three] {<option "door3">}
            [(touch the monkey)] {<option "monkey">}
          ]
        ]]>
  </grammar>

If you compare the new grammar element above to the one on the previous page, you'll notice that we've added addition information for each option as well as a new line. The addition information consists of a single word for each option. For example, the first line of the grammar instructs the Tellme VoiceXML parser to match when the user presses 1 on their keypad or if they speak the word one. The last line of the grammar matches on the phrase, "touch the monkey." There will not be a match if the user says "touch" or "monkey." It will only match when the user says "touch the monkey." This is because the phrase is contained within paretheses, which require that the whole phrase be matched.

Example 2.

<?xml version="1.0"?>
<vxml version="1.0">
<form>
<field name="answer">
<grammar> <![CDATA[
[
[dtmf-1 one] {<option "door1">}
[dtmf-2 two] {<option "door2">}
[dtmf-3 three] {<option "door3">}
[(touch the monkey)] {<option "monkey">}
]
]]>
</grammar>
<prompt> <audio>You are in a small room with three doors.</audio>
<pause>300</pause> <audio>To open the first door, press or say 1.</audio>
<pause>300</pause> <audio>To open the second door, press or say 2.</audio>
<pause>300</pause> <audio>To open the third door, press or say 3.</audio>
</prompt>
</field>
<filled>
<result name="door1">
<audio>You see a large hungry monkey.</audio>
<reprompt/>
</result>
<result name="door2">
<audio>You see another room with three doors, a man, and his monkey.</audio>
<reprompt/>
</result>
<result name="door3">
<audio>You see a man scratching his monkey.</audio>
<reprompt/>
</result>
<result name="monkey">
<audio>No! Do not touch the monkey!</audio>
<reprompt/>
</result>
</filled>
</form>
</vxml>




Page 3 of 7



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

Thanks for your registration, follow us on our social networks to keep up-to-date
Rocket Fuel