Published on 2007-05-18 00:37:51

Let's see SpeakRight in action. This example is part of a hotel application, where the user is asked for the number of rooms to be reserved.

SRApp app = new SRApp();
//add other callflow elements...

//ask # of rooms
SRONumber question = new SRONumber("rooms", 1, 10);
question.setConfirmer(new SROConfirmYesNo("rooms"));
question.setModelVar("numRooms");
app.add(question);
app.add(new PromptFlow("Got it. ${M.numRooms} rooms"));

//etc..


A question object is created using one of the built-in SpeakRight classes. SRONumber asks for a number and and does range validation. We attach a confirmation object as well, that will execute if the recognition score is below a configurable threshold. We use a simply yes/no confirmation in this example.

When executed, the question object might interact with the user like this:

Computer: How many rooms would you like?
Human: two, please.
Computer: Got it. Two rooms.


Or if the user has more trouble due to background noise, the same question object would add error prompts and confirmation:

C: How many rooms would you like?
H: (garbled)
C: I didn't get that. Please say the number of rooms you would like.
H: one (recognized "nine" but with a low confidence score)
C: I heard 'nine'. Is that correct?
H: no
C: Let's try again. How many rooms would you like?
H: one
C: Got it. one room.



Speakright provides default prompts and grammars. This lets you build a bare-bones application quickly. Then you can customize prompts (in external XML files) and grammars. You can also change the retry, validation, and confirmation logic. Since it's all Java code, you have the full power of an object-oriented framework to customize, override, and extend. Even the final rendering into VoiceXML is an extension point.

Architecture

A SpeakRight application generally lives in a servlet, serving up VoiceXML to a speech platform such as those offered by Voxeo, Nuance, and Microsoft. The platform renders the VoiceXML into audio. Upon completion of a page, it sends back user input and call events. SpeakRight uses this information to traverse to the next element in the callflow. Dialog state during a session is stored by SpeakRight, usually in a servlet session variable.

GUI frameworks are based around objects called controls (or widgets). A form is built out of a set of controls that manage presentation and take user input. SpeakRight takes a similar approach to VUIs (voice user interfaces). It is based around flow objects. A flow object manages presentation (prompts, grammars, and retry logic), and control flow. In Model-View-Controller terms, a flow object is both the view and the controller. Flow objects can be customized (by setting properties), or extended using sub-classing. SpeakRight provides built-in objects for standard data types (time, date, alphanum), and for standard flow algorithms (forms, menus, list traversal, confirmation).

Features




On your next VoiceXML project, give SpeakRight a try.

Previous Page


Related Entries

Member of the PHP Magazine Network, Copyright (C) 2005-2008 phpmagazine.net All Rights Reserved