|
Developing
Multimodal Applications using XHTML+Voice
Continued from previous page...
size.jsgf
grammar pizza_size;
public <size> = small|medium|large ; |
5
-- Voice part of a multimodal applicationFigure
<vxml:form id="voice_toppings_vegetable">
<vxml:field
name="vtoppingsvegetable">
<vxml:prompt>
What
vegetable toppings would you like?
</vxml:prompt>
<vxml:grammar
src="vegtoppings.jsgf"/>
<vxml:catch
event="help nomatch noinput">
For
example, say mushrooms and peppers.
</vxml:catch>
<vxml:filled>
<vxml:assign
name="varVegetableToppings"
expr="vtoppingsvegetable"/>
</vxml:filled>
</vxml:field>
</vxml:form> |
Figure
6 -- How to specify an external grammer
External Speech Grammar Files
External speech grammar files are used to define specific
selections. For example, the vegetable toppings for the
form are in the vegtoppings.jsgf file and the meat toppings
are in the meattoppings.jsgf file. These grammar files
are shown in Figures 7, 8 and 9.
vegtoppings.jsgf
grammar
vegitable_toppings;
<veggies>
= olives | mushrooms | onions | peppers;
public
<toppings> =
<NULL>
{
this.$value="";
}
(<veggies>
[and]{
this.$value
= this.$value + " " + $veggies;
})+; |
Figure
7 -- Grammars for vegetable toppings
onetotwenty.jsgf
grammar one_twenty;
public <onetotwenty> = 1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20
; |
Figure
8 -- Grammars for number choice of 1-20
meattoppings.jsgf
grammar meat_toppings;
<meats> = bacon | chicken | ham | meatball
| sausage | pepperoni;
public <toppings> =
<NULL>
{
this.$value="";
}
(<meats>
[and]{
this.$value
= this.$value + " " + $meats;
})+; |
Figure
9 -- Grammars for meat toppings
Phonetic Representations
The application also needs the phonetic pronunciations
for the words in the grammar. The pizza.pbs file contains
the words and their phonetic representations.
pizza.pbs
small
medium
large
yes
no
and
olives
mushrooms
onions
peppers
bacon
chicken
ham
meatball
sausage
sausage
pepperoni |
S M AO L
M IY D IY AH M
L AA R JH
Y EH S
N OW
AX N DD
AA L IH V Z
M AH SH R UW M Z
AH N Y AH N Z
P EH P ER Z
B EY K AH N
CH IH K AH N
HH AE M
M IY T B AO L
S AO S AH JH
S AO S IH JH
P EH P ER OW N IY |
Figure
10 -- pizza.pbs phonetic representations file
Processing Part
The Processing Part of the application contains the code
that is used to perform the needed instructions for each
of the various events. This section also contains the
event handlers. For example, the quantity of pizzas ordered
requires the event handlers shown in Figure 11.
<b>Quantity:</b><br/>
<input type="text" id="pizzaQuantity"
ev:event="focus" ev:handler="#voice_quantity"/>
<ev:listener ev:event="vxmldone" ev:handler="#handleVoiceQuantityDone"
ev:observer="pizzaQuantity" ev:propagate="stop"/> |
Figure
11 --Processing part
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).
|