|
In
this monthly column, an industry expert will answer
common questions about VoiceXML and related technologies.
Readers are encouraged to submit questions about VoiceXML,
including development, voice-user interface design,
and speech technology in general, or how VoiceXML is
being used commercially in the marketplace. If you have
a question about VoiceXML, e-mail it to speak.and.listen@voicexmlreview.org
and be sure to read future issues of VoiceXML Review
for the answer.
Continued
from page 1...
Designing
the dialer
Before jumping into our stylesheet, let's briefly discuss
the design of our voice application. We'll keep it simple:
We'll prompt our user for the name of the employee they
want to reach. If she says the name of an employee,
we'll attempt to connect to that employee.
We'll also allow her to hear a list of departments.
While I could provide a list of employees, in the interest
of privacy, I don't want to freely distribute employee
names to random callers.
To
allow the user to say the name of the employee, we'll
need to generate a grammar containing the employee names.
If the user says the name of the employee, it would be
nice to acknowledge the employee name by playing it back
to the caller just before we connect them. This will allow
her to cancel the transfer in case the recognizer misunderstood.
While we could embed all of the data in our grammar, we'll
take another approach: we'll have our grammar simply return
the employee's id, and we'll use a JavaScript associative
array (object) to map the employee's id to their name
and phone number.
We'll
source in this object from an external JavaScript file
(.js) generated from the same XML source document but
using a different stylesheet.
To
provide the user with a list of departments, we'll generate
a JavaScript file containing two data structures:
- An associative array containing the department
data keyed by department id,
- An array of the department ids ordered by department
name. Our VoiceXML will maintain an index and
iterate through the array.
The value at each array index maps directly into our associative
array where the interesting data about the department
is stored.
To allow the user to say the name of a department, we'll
also generate a grammar containing the department names.
Our first two stylesheets will produce the employee and
department grammars in SRGS format. SRGS is the de facto
grammar format that all VoiceXML interpreters must support
in order to claim compliance with the VoiceXML 2.0 specification.
If your VoiceXML interpreter vendor doesn't support SRGS,
find out which grammar format it does support, and author
a stylesheet accordingly.
Here's the stylesheet that produces the employee grammar:
http://www.voicexmlreview.org/Mar2003/columns/speak_files/emps_srgs.xslt
When you transform the exported employee data through
this stylesheet using an XSLT processor, here's the output:
http://www.voicexmlreview.org/Mar2003/columns/speak_files/emps.srgs
Here's the stylesheet that produces the department grammar:
http://www.voicexmlreview.org/Mar2003/columns/speak_files/depts_srgs.xslt
When you transform the exported department data through
this stylesheet, here's the output:
http://www.voicexmlreview.org/Mar2003/columns/speak_files/depts.srgs
Our next set of stylesheets will produce the employee
and department JavaScript files.
Here's the stylesheet that produces the employee .js file:
http://www.voicexmlreview.org/Mar2003/columns/speak_files/emps.srgs
When you transform the exported employee data through
this stylesheet, here's the output:
http://www.voicexmlreview.org/Mar2003/columns/speak_files/emps.js
Here's the stylesheet that produces the department .js file:
http://www.voicexmlreview.org/Mar2003/columns/speak_files/depts.js
When you transform the exported department data through this stylesheet, here's the output:
http://www.voicexmlreview.org/Mar2003/columns/speak_files/depts.js
A Simple tool for XSL Transformations
Now that we've provided you with several
XSL templates, here's some code that
allows you to transform the employee and department data
through its corresponding XSL templates:
http://www.voicexmlreview.org/Mar2003/columns/speak_files/xform.js
The code is written in JScript, Microsoft's implementation of ECMAScript
262 (aka JavaScript), and it leverages the Windows Script Host (WSH).
If you've never played with WSH, just think of it as MS-DOS batch files (.bat) on steroids.
Using WSH you can use any COM-compatible scripting language (e.g. JScript or VBScript) to automate just about any task.
WSH is pre-installed with all reasonably current versions of the Microsoft Windows Operating System.
For more information on WSH, see
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/wsconwshbasics.asp.
To use the script, create a text file using your favorite programming
editor (e.g. Notepad), and save it to a file with a .js extension, for
example, "xform.js".
Identify the following:
- The location of your exported XML data (e.g. employee.xml)
- The location of your XSL template (e.g. emps_srgs.xslt)
- The location where you'd like to save transformation.
(e.g. c:\inetpub\dialer\emps.srgs)
Type the following at the command line, adjusting the paths as appropriate:
cscript c:\bin\xform.js c:\exports\employee.xml c:\xslt\emps_srgs.xslt c:\inetpub\dialer\emps.srgs
Upon executing this command, the exported employee data is transformed through the employee SRGS XSL template to produce the employee grammar.
I'll leave it to you as an exercise to perform the remaining three transformations to produce the employee .js, the department grammar, and the department .js.
Continued...
back
to the top
Copyright
© 2001-2003 VoiceXML Forum. All rights reserved.
The VoiceXML Forum is a program of the
IEEE
Industry Standards and Technology Organization (IEEE-ISTO).
|