Home > Articles

  • Print
  • + Share This

The VoiceXML Language

I've talked a bit about the standard and the architecture of a VoiceXML application. Now I'll introduce you to the basics of the VoiceXML language and step through a simple app. If you're interested in viewing the VoiceXML Document Type Definition (DTD), visit http://www.voicexml.org/voicexml1-0.dtd. This DTD defines the grammar of a valid VoiceXML application and was developed by the VoiceXML Forum.

All VoiceXML documents begin and end with the <vxml> tag. Two types of "dialogs" are used to interface to the user: forms and menus. A form presents information to a user or retrieves information from a user. A menu is a specialized form that forces the user to choose a specific option and then branches based on the selected option. A simple form is shown in the following example:

<?xml version="1.0"?>
<vxml version="1.0">
  <form>
    <block>Welcome To VoiceXML!</block>
  </form>
</vxml>

Using this example, a user dialing into a VoiceXML service would simply hear "Welcome to VoiceXML!" spoken into his/her earpiece. (An interesting aside: Server speech-processing tools are very advanced. Inclusion of the exclamation point will result in most engines saying the above sentence in an exclamatory fashion.) The VoiceXML menu allows several options to be presented using the <choice> tag within a <menu> construct. The following example presents several options to the user and branches to a corresponding VoiceXML document based on the user selection. Note the use of the VoiceXML <help> tag. This is used to handle unexpected selections—it acts as a sort of default.

<?xml version="1.0"?>
<vxml version="1.0">
  <menu>
    <prompt>
       <audio>
          Which service would you like to access?
       </audio>
    </prompt>

    <choice next="stocks.vxml">Quotes</choice>
    <choice next="traffic.vxml">Traffic</choice>
    <choice next="news.vxml">News</choice>

    <help>
      Please say either quotes, traffic, or news to select an option.
    </help>
  </menu>
</vxml>

If you wanted to access an Active Server Pages script to retrieve the news (as opposed to the news.vxml document specified in the above example), you would build a standard VoiceXML document with VBScript code embedded throughout. A news.asp file might look like this:

<vxml>
<form>
<block>
<audio>

<%
   Response.Write("Welcome To Today's News!")
%>

</audio>
</block>
</form>
</vxml>

Other tags of interest include <assign> (for assigning a value to a variable), <goto> (for transitioning to another form item, dialog, or document), <script> (for specifying a block of client-side scripting language code, if supported), and <throw> (for throwing an event).

One interesting note about VoiceXML: Because it's entirely XML-based and applications that use it have no graphical user interface, it's possible to build a Web-based development tool that simply "hooks" your VoiceXML documents into an application service provider's (ASP) telephony infrastructure. In fact, two leading voice portals, TellMe Networks and BeVocal, have done just that! If you want to start using the technology but aren't interested in buying the hardware and very expensive server speech software, check out TellMe Studio and BeVocal Café. You can tell them InformIT sent you!

  • + Share This
  • 🔖 Save To Your Account

Related Resources

There are currently no related titles. Please check back later.