Telephony Isn't All Talk for Java Developers (cont'd)

Closing Out the Statement

And we're done. We can close the VoiceXML document with the final </vxml> tag and close the output stream itself. We'll go back to showing the entire Java statements for this last bit remembering that we've been producing this file like this all along.

out.println( "</vxml>" );
    out.close();
  }

The only thing left to do now is to define the grammar. VoiceXML doesn't define a mandatory grammar language, although it suggests using the Java Speech Grammar Format. The Nuance VoiceXML implementation chosen for this example uses a different specialized grammar definition language called GSL. This grammar defines an utterance in mandatory lower case and then the name of a string variable together with the value to be returned for that variable. GSL is capable of great complexity which we won't go into here but you can approximate natural language voice recognition with a clever grammar description. You have to label the grammar with a name starting with a capital letter. VXMLgrammar

[
    [mail]         { < Destination "Mail" > }
    [weather]      { < Destination "Weather" > }
    ]

We're done! After compiling the code and placing it on a Java-enabled server, we can try out the application by calling (408) 907-4656 , (415) 723-8917, (510) 870-8391, or (707) 780-8962. The Java code can be seen at www.leeanne.com/javavxml.java and the resulting VoiceXML code can be seen at www.leeanne.com/javavxmlapp.vxml. If we wanted to, we could include text to speech, which would allow us to output any text data likely to found on our system. Here's a sample text-to-speech version of the last form, just to get you started on variations; but the full VoiceXML language description and DTD is the final arbiter of how to achieve any given task.

<form id="Goodbye">
    <block>
      Thank you for calling. Goodbye.
      <exit />
      </block>
    </form>

     Next: Code It Yourself

1 Introduction 2 Coding a Java Telephony Application 3 Outputting the Actual Code
4 Starting the Input Field ^ Closing Out the Statement 6 Code It Yourself
Back to Top of This Page
 

Sun Microsystems

Polyphone, Inc.

IBM's Alphaworks

Lucent Technologies

DevX Book Bonus: A Review of "Essential JTAPI--Java Telephony API," by Spencer Roberts (Prentice Hall, 1999)


 TALK BACK
What has been your experience writing telephony applications? What are the pitfalls involved? If you haven't worked on one, do you expect to do so anytime in the near future? Join the discussion.
Click here to Join


Save on Hot Java Specials
SOFTWARE:
dtSearch Web
Add power searching to your web site.
Buy Now!
BOOKS:
PointBase Mobile Edition
Enable local data access for mobile users.
Buy Now!
Advertising Info  |   Member Services  |   Contact Us  |   Help  |   Feedback  |   Site Map
Jupiterweb networks

internet.comearthweb.comDevx.comClickZ

Search Jupiterweb:

Jupitermedia Corporation has four divisions:
JupiterWeb, JupiterResearch, JupiterEvents, and JupiterImages

Copyright 2004 Jupitermedia Corporation All Rights Reserved.
Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Jupitermedia Corporate Info | Newsletters | Tech Jobs | E-mail Offers