Student Pages anni/roster.html.

85
Student Pages http://www.clsp.jhu.edu/~anni/roster.html

Transcript of Student Pages anni/roster.html.

Page 1: Student Pages anni/roster.html.

Student Pageshttp://www.clsp.jhu.edu/~anni/roster.html

Page 2: Student Pages anni/roster.html.

Last Time: HTML Forms and Javascript

If you haven’t finished the survey assignment, email us or come to office hours

Page 3: Student Pages anni/roster.html.

2/14: Programming Phones

Page 4: Student Pages anni/roster.html.

This script says “hello world”<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <block> Hello World! <exit/> </block> </form></vxml>

Page 5: Student Pages anni/roster.html.

This script says “hello world”<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <block> Hello World! <exit/> </block> </form></vxml>

Call 877-500-VXML and use my developer ID

(540460366) and pin (0123) to preview it

When you’re done, put this text into your Scratchpad and call

VXML again and use your developer ID and pin to preview

your own code

Page 6: Student Pages anni/roster.html.

Prerequisite: XML

Page 7: Student Pages anni/roster.html.

XML

Disclaimer: This is an introduction to how an XML format works in general, this is not the particular syntax of a VoiceXML program or any other specific XML format

Page 8: Student Pages anni/roster.html.

XMLOpening and closing tags

<myTellmeProgram> </myTellmeProgram>

Page 9: Student Pages anni/roster.html.

XMLNested hierarchy of tags

<myTellmeProgram> <introduction> <welcome>Hello World</welcome> <welcome>Hi, What’s up?</welcome> </introduction> <mainSection> … </mainSection></myTellmeProgram>

Page 10: Student Pages anni/roster.html.

XMLNested hierarchy of tags

<myTellmeProgram> <introduction> <welcome>Hello World</welcome> <welcome>Hi, What’s up?</welcome> </introduction> <mainSection> … </mainSection></myTellmeProgram>

Level 1 (Document Root)

Page 11: Student Pages anni/roster.html.

XMLNested hierarchy of tags

<myTellmeProgram> <introduction> <welcome>Hello World</welcome> <welcome>Hi, What’s up?</welcome> </introduction> <mainSection> … </mainSection></myTellmeProgram>

Level 1 (Document Root)

Level 2

Page 12: Student Pages anni/roster.html.

XMLNested hierarchy of tags

<myTellmeProgram> <introduction> <welcome>Hello World</welcome> <welcome>Hi, What’s up?</welcome> </introduction> <mainSection> … </mainSection></myTellmeProgram>

Level 1 (Document Root)

Level 2

Level 3

Page 13: Student Pages anni/roster.html.

XMLTag Attributes

<myTellmeProgram> <introduction> <welcome type=“veryFirst”>Hello World</welcome> <welcome type=“casual”>Hi, What’s up?</welcome> </introduction> <mainSection> … </mainSection></myTellmeProgram>

Attribute Value

Page 14: Student Pages anni/roster.html.

XMLComments

<myTellmeProgram> <!-- this is the beginning of the introduction --> <introduction> <welcome type=“veryFirst”>Hello World</welcome> <welcome type=“casual”>Hi, What’s up?</welcome> </introduction> <mainSection> … </mainSection></myTellmeProgram>

Page 15: Student Pages anni/roster.html.

VoiceXML (Programming Phones)

Page 16: Student Pages anni/roster.html.

This script says “hello world”<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <block> Hello World! <exit/> </block> </form></vxml>

Page 17: Student Pages anni/roster.html.

VoiceXML (Programming Phones)

<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml">

</vxml>

Page 18: Student Pages anni/roster.html.

VoiceXML (Programming Phones)

<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> </form></vxml>

Page 19: Student Pages anni/roster.html.

VoiceXML (Programming Phones)

<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field> </field> </form></vxml>

Page 20: Student Pages anni/roster.html.

VoiceXML (Programming Phones)

<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <block> </block> </form></vxml>

Page 21: Student Pages anni/roster.html.

VoiceXML: Form Blocks

<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <block> Hello World! <exit/> </block> </form></vxml>

Audio (“Text to Speech”)

Exit the application

Page 22: Student Pages anni/roster.html.

VoiceXML: Form Blocks

<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <block> Hello World! <exit/> </block> </form></vxml>

Note beginning and end tags

Page 23: Student Pages anni/roster.html.

VoiceXML: Form Blocks

<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <block> Hello World! <exit/> </block> </form></vxml>

This should be what’s in your Scratchpad now

Page 24: Student Pages anni/roster.html.

Back to Javascript

Just like you can embed Javascript into HTML, you can embed Javascript into VoiceXML

https://studio.tellme.com/vxml2/ovw/javascript.html

Page 25: Student Pages anni/roster.html.

Back to Javascript

Just like you can embed Javascript into HTML, you can embed Javascript into VoiceXML

https://studio.tellme.com/vxml2/ovw/javascript.html

But we won’t do that in this class…

Page 26: Student Pages anni/roster.html.

VoiceXML: <goto> tag<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <block> Hello World! <goto next=“#secondGreeting”/> </block> </form> </vxml>

Page 27: Student Pages anni/roster.html.

VoiceXML: <goto> tag<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <block> Hello World! <goto next=“#secondGreeting”/> </block> </form> </vxml>

Tag

Page 28: Student Pages anni/roster.html.

VoiceXML: <goto> tag<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <block> Hello World! <goto next=“#secondGreeting”/> </block> </form> </vxml>

Tag

Attribute

Page 29: Student Pages anni/roster.html.

VoiceXML: <goto> tag<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <block> Hello World! <goto next=“#secondGreeting”/> </block> </form> </vxml>

Tag

Attribute Value: Name of another form

Page 30: Student Pages anni/roster.html.

VoiceXML: <goto> tag<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <block> Hello World! <goto next=“#secondGreeting”/> </block> </form> <form id=“secondGreeting”> <block> I found my second form. <exit/> </block> </form></vxml>

Page 31: Student Pages anni/roster.html.

VoiceXML: <goto> tag<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <block> Hello World! <goto next=“#secondGreeting”/> </block> </form> <form id=“secondGreeting”> <block> I found my second form. <exit/> </block> </form></vxml>

Attribute

Page 32: Student Pages anni/roster.html.

VoiceXML: <goto> tag<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <block> Hello World! <goto next=“#secondGreeting”/> </block> </form> <form id=“secondGreeting”> <block> I found my second form. <exit/> </block> </form></vxml>

Attribute

Value

Page 33: Student Pages anni/roster.html.

VoiceXML: <goto> tag<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <block> Hello World! <goto next=“#secondGreeting”/> </block> </form> <form id=“secondGreeting”> <block> I found my second form. <exit/> </block> </form></vxml>

Sounds like…:“Hello WorldI found my second form.”

Page 34: Student Pages anni/roster.html.

Try this in your Scratchpad<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <block> Hello World! This dialogue goes on <goto next=“#secondGreeting”/> </block> </form> <form id=“secondGreeting”> <block> and on <goto next=“#secondGreeting”/> </block> </form></vxml>

1. Guess what this script will do.2. Edit Scratchpad3. Call 1-877-500-8965

Page 35: Student Pages anni/roster.html.

VoiceXML: Form Blocks

<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field> </field> </form></vxml>

Page 36: Student Pages anni/roster.html.

VoiceXML: Form Blocks

<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> </field> </form></vxml>

Page 37: Student Pages anni/roster.html.

VoiceXML: Form Blocks

<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> </field> </form></vxml>

Attribute

Page 38: Student Pages anni/roster.html.

VoiceXML: Form Blocks

<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> </field> </form></vxml>

AttributeValue

Page 39: Student Pages anni/roster.html.

VoiceXML: Form Blocks

<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers” type=“boolean”> </field> </form></vxml>

Attribute Value

Page 40: Student Pages anni/roster.html.

VoiceXML: Form Blocks<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers” type=“boolean”> <prompt> Do you like computers? </prompt> </field> </form></vxml>

New “prompt” tag: child of “field”

Page 41: Student Pages anni/roster.html.

VoiceXML: Form Blocks<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers” type=“boolean”> <prompt> Do you like computers? </prompt> </field> </form></vxml>

Text to Speech:“Do you like computers?”

Page 42: Student Pages anni/roster.html.

VoiceXML: Form Blocks<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers” type=“boolean”> <prompt> Do you like computers? </prompt> <filled> </filled> </field> </form></vxml>

New “filled” tag: child of “field”

Page 43: Student Pages anni/roster.html.

VoiceXML: Form Blocks<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers” type=“boolean”> <prompt> Do you like computers? </prompt> <filled> Great, I got your answer.

</filled> </field> </form></vxml>

Text to Speech:“Great, I got

your answer”

Page 44: Student Pages anni/roster.html.

VoiceXML: Form Blocks<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers” type=“boolean”> <prompt> Do you like computers? </prompt> <filled> Great, I got your answer.

</filled> </field> </form></vxml>

Broken!

Page 45: Student Pages anni/roster.html.

VoiceXML: Form Blocks<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers” type=“boolean”> <prompt> Do you like computers? </prompt> <filled> Great, I heard your answer.

</filled> </field> </form></vxml>

Broken!

Page 46: Student Pages anni/roster.html.

VoiceXML: Form Blocks<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers” type=“boolean”> <prompt> Do you like computers? </prompt> <filled> Great, I got your answer.

</filled> </field> </form></vxml>

Broken!

Page 47: Student Pages anni/roster.html.

VoiceXML: Form Blocks<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> <prompt> Do you like computers? </prompt>

<filled> Great, I got your answer. </filled> </field> </form></vxml>

Since the predefined boolean grammar isn’t working, we’ll add one ourselves

Page 48: Student Pages anni/roster.html.

VoiceXML: Form Blocks<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> <prompt> Do you like computers? </prompt> <grammar mode="dtmf" root="top” version="1.0" tag-format="semantics/1.0" type="application/srgs+xml">

<rule id="top"> <one-of> <item>1</item> <item>2</item> </one-of> </rule> </grammar> <filled> Great, I got your answer. </filled> </field> </form></vxml>

Press 1 or 2, record the

answer

Copy and paste this to receive any “1 or

2” input

Page 49: Student Pages anni/roster.html.

VoiceXML: Form Blocks<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> <prompt> Do you like computers? </prompt> <grammar mode="dtmf" root="top” version="1.0" tag-format="semantics/1.0" type="application/srgs+xml">

<rule id="top"> <one-of> <item>1</item> <item>2</item> </one-of> </rule> </grammar> <filled> Great, I got your answer. </filled> </field> </form></vxml>

Page 50: Student Pages anni/roster.html.

<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> <prompt> Do you like computers? </prompt> <grammar mode="dtmf" root="top” version="1.0" tag-format="semantics/1.0" type="application/srgs+xml">

<rule id="top"> <one-of> <item>1</item> <item>2</item> </one-of> </rule> </grammar> <filled> Great, I got your answer. </filled> </field> </form></vxml>

VoiceXML: Form Blocks

Input type will be a touch tone keyboard

Page 51: Student Pages anni/roster.html.

<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> <prompt> Do you like computers? </prompt> <grammar mode="dtmf" root="top” version="1.0" tag-format="semantics/1.0" type="application/srgs+xml">

<rule id="top"> <one-of> <item>1</item> <item>2</item> </one-of> </rule> </grammar> <filled> Great, I got your answer. </filled> </field> </form></vxml>

VoiceXML: Form Blocks

Reference some touch tone input gathering code

Page 52: Student Pages anni/roster.html.

<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> <prompt> Do you like computers? </prompt> <grammar mode="dtmf" root="top” version="1.0" tag-format="semantics/1.0" type="application/srgs+xml">

<rule id="top"> <one-of> <item>1</item> <item>2</item> </one-of> </rule> </grammar> <filled> Great, I got your answer. </filled> </field> </form></vxml>

VoiceXML: Form Blocks

A grammar can have many rulesIn this example, when this

grammar is used, it should start with the rule named “top”

Page 53: Student Pages anni/roster.html.

<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> <prompt> Do you like computers? </prompt> <grammar mode="dtmf" root="top” version="1.0" tag-format="semantics/1.0" type="application/srgs+xml">

<rule id="top"> <one-of> <item>1</item> <item>2</item> </one-of> </rule> </grammar> <filled> Great, I got your answer. </filled> </field> </form></vxml>

VoiceXML: Form Blocks

“one-of” tag: user specifies one of the

following items

Page 54: Student Pages anni/roster.html.

<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> <prompt> Do you like computers? </prompt> <grammar mode="dtmf" root="top” version="1.0" tag-format="semantics/1.0" type="application/srgs+xml">

<rule id="top"> <one-of> <item>1</item> <item>2</item> </one-of> </rule> </grammar> <filled> Great, I got your answer. </filled> </field> </form></vxml>

VoiceXML: Form Blocks

The allowable items are “1” and “2”

Page 55: Student Pages anni/roster.html.

<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> <prompt> Do you like computers? </prompt> <grammar mode="dtmf" root="top” version="1.0" tag-format="semantics/1.0" type="application/srgs+xml">

<rule id="top"> <one-of> <item>1</item> <item>2</item> </one-of> </rule> </grammar> <filled> Great, I got your answer. </filled> </field> </form></vxml>

VoiceXML: Form Blocks

Text to Speech:“Great, I got

your answer”

Page 56: Student Pages anni/roster.html.

<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> <prompt> Do you like computers? </prompt> <grammar mode="dtmf" root="top” version="1.0" tag-format="semantics/1.0" type="application/srgs+xml">

<rule id="top"> <one-of> <item>1</item> <item>2</item> </one-of> </rule> </grammar> <filled> Great, I got your answer. </filled> </field> </form></vxml>

VoiceXML: Form Blocks

Try this!

Page 57: Student Pages anni/roster.html.

<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> <prompt> Do you like computers? </prompt> <grammar mode="dtmf" root="top” version="1.0" tag-format="semantics/1.0" type="application/srgs+xml">

<rule id="top"> <one-of> <item>1</item> <item>2</item> </one-of> </rule> </grammar> <filled> Great, I got your answer. </filled> </field> </form></vxml>

VoiceXML: Form Blocks

Now let’s do something with the input after it’s identified

Page 58: Student Pages anni/roster.html.

<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> <prompt> Do you like computers? </prompt> <grammar mode="dtmf" root="top” version="1.0" tag-format="semantics/1.0" type="application/srgs+xml"> <rule id="top"> <one-of> <item>1</item> <item>2</item> </one-of> </rule> </grammar> <filled> Great, I got your answer. </filled> </field> </form></vxml>

VoiceXML: Form Blocks

Page 59: Student Pages anni/roster.html.

<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> <prompt> Do you like computers? </prompt> <grammar mode="dtmf" root="top” version="1.0" tag-format="semantics/1.0" type="application/srgs+xml"> <rule id="top"> <one-of> <item>1</item> <item>2</item> </one-of> </rule> </grammar> <filled> Great, I got your answer. <if cond="likeComputers==1"> I'm glad you like computers. <else /> Too bad that you don't like computers. </if> <exit/> </filled> </field> </form></vxml>

VoiceXML: Form Blocks

Page 60: Student Pages anni/roster.html.

<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> <prompt> Do you like computers? </prompt> <grammar mode="dtmf" root="top” version="1.0" tag-format="semantics/1.0" type="application/srgs+xml"> <rule id="top"> <one-of> <item>1</item> <item>2</item> </one-of> </rule> </grammar> <filled> Great, I got your answer. <if cond="likeComputers==1"> I'm glad you like computers. <else /> Too bad that you don't like computers. </if> <exit/> </filled> </field> </form></vxml>

VoiceXML: Form Blocks

“if-else” tag:Special two-part tag:

1. The if part2. The else part

Page 61: Student Pages anni/roster.html.

<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> <prompt> Do you like computers? </prompt> <grammar mode="dtmf" root="top” version="1.0" tag-format="semantics/1.0" type="application/srgs+xml"> <rule id="top"> <one-of> <item>1</item> <item>2</item> </one-of> </rule> </grammar> <filled> Great, I got your answer. <if cond="likeComputers==1"> I'm glad you like computers. <else /> Too bad that you don't like computers. </if> <exit/> </filled> </field> </form></vxml>

VoiceXML: Form Blocks

If some condition is met, do what follows here

Otherwise, do what follows here

Page 62: Student Pages anni/roster.html.

<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> <prompt> Do you like computers? </prompt> <grammar mode="dtmf" root="top” version="1.0" tag-format="semantics/1.0" type="application/srgs+xml"> <rule id="top"> <one-of> <item>1</item> <item>2</item> </one-of> </rule> </grammar> <filled> Great, I got your answer. <if cond="likeComputers==1"> I'm glad you like computers. <else /> Too bad that you don't like computers. </if> <exit/> </filled> </field> </form></vxml>

VoiceXML: Form Blocks

The “if” tag has a “cond” condition

attribute

The condition here is that the “likeComputers” field is filled with the value “1”

Page 63: Student Pages anni/roster.html.

<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> <prompt> Do you like computers? </prompt> <grammar mode="dtmf" root="top” version="1.0" tag-format="semantics/1.0" type="application/srgs+xml"> <rule id="top"> <one-of> <item>1</item> <item>2</item> </one-of> </rule> </grammar> <filled> Great, I got your answer. <if cond="likeComputers==1"> I'm glad you like computers. <else /> Too bad that you don't like computers. </if> <exit/> </filled> </field> </form></vxml>

VoiceXML: Form Blocks

Notice the double “==“

Page 64: Student Pages anni/roster.html.

<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> <prompt> Do you like computers? </prompt> <grammar mode="dtmf" root="top” version="1.0" tag-format="semantics/1.0" type="application/srgs+xml"> <rule id="top"> <one-of> <item>1</item> <item>2</item> </one-of> </rule> </grammar> <filled> Great, I got your answer. <if cond="likeComputers==1"> I'm glad you like computers. <else /> Too bad that you don't like computers. </if> <exit/> </filled> </field> </form></vxml>

VoiceXML: Form Blocks

If the condition is true, say this.

Page 65: Student Pages anni/roster.html.

<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> <prompt> Do you like computers? </prompt> <grammar mode="dtmf" root="top” version="1.0" tag-format="semantics/1.0" type="application/srgs+xml"> <rule id="top"> <one-of> <item>1</item> <item>2</item> </one-of> </rule> </grammar> <filled> Great, I got your answer. <if cond="likeComputers==1"> I'm glad you like computers. <else /> Too bad that you don't like computers. </if> <exit/> </filled> </field> </form></vxml>

VoiceXML: Form Blocks

If the condition is not true, say this

Page 66: Student Pages anni/roster.html.

<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> <prompt> Do you like computers? </prompt> <grammar mode="dtmf" root="top” version="1.0" tag-format="semantics/1.0" type="application/srgs+xml"> <rule id="top"> <one-of> <item>1</item> <item>2</item> </one-of> </rule> </grammar> <filled> Great, I got your answer. <if cond="likeComputers==1"> I'm glad you like computers. <else /> Too bad that you don't like computers. </if> <exit/> </filled> </field> </form></vxml>

VoiceXML: Form Blocks

[If time in class]: Try it! (might want to download the

slides and copy and paste from them, but you’ll have to fix up the quotes)

Page 67: Student Pages anni/roster.html.

VoiceXML HomeworkIn this homework you have two options (extra credit: do both!):1. Use the prompt/grammar/filled children of the field tag to ask a question.

Modify what we’ve done to accept more than “1” and “2” as input, and have the computer say something different in response to each one

2. Use the prompt/grammar/filled children of the field tag to ask a question. Then, if the user inputs a “1”, have the computer repeat a phrase forever. If the user inputs a “2”, just have the computer say one thing.

Add a tiny bit of text to your webpage with your Developer ID & pin so that we can listen. Also send Ken ([email protected]) and me ([email protected]) an email with the contents of your Scratchpad.

Due Tuesday, February 22nd before sunrise.

Page 68: Student Pages anni/roster.html.

Hint for Option #11. Use the prompt/grammar/filled children of the field tag to ask a question.

Modify what we’ve done to accept more than “1” and “2” as input, and have the computer say something different in response to each one

<if cond="likeComputers==1"> I'm glad you like computers. <else /> Too bad that you don't like computers. </if>

<if cond="likeComputers==1"> I'm glad you like computers.</if><if cond="likeComputers==2"> Too bad that you don't like computers.</if>

=

Page 69: Student Pages anni/roster.html.

Hint for Option #22. Use the prompt/grammar/filled children of the field tag to ask a question.

Then, if the user inputs a “1”, have the computer repeat a phrase forever. If the user inputs a “2”, just have the computer say one thing.

<if cond="likeComputers==1"> I hope you’ll like computers forever <else /> Too bad that you don't like computers. </if>

<form id=“secondGreeting”> <block> and ever <goto next=“#secondGreeting”/> </block> </form>

+<goto next=“#secondGreeting”/>

+

Page 70: Student Pages anni/roster.html.

Another Hint for Option #22. Use the prompt/grammar/filled children of the field tag to ask a question.

Then, if the user inputs a “1”, have the computer repeat a phrase forever. If the user inputs a “2”, just have the computer say one thing.

<vxml version="2.1" xmlns="http://www.w3.org/2001/vxml"> <form>…</form>

<form id=“second”>…</form></vxml>

Note that your single <vxml> code can

include multiple forms

Page 71: Student Pages anni/roster.html.

More Advanced Phone Programming

Page 72: Student Pages anni/roster.html.

<?xml version="1.0"?><vxml version="2.1" xmlns="http://www.w3.org/2001/vxml"><form id="pick_fruit"> <block> Welcome to the fruit picker. </block><field name="fruit"> <grammar mode="voice" root="root_rule" tag-format="semantics/1.0" type="application/srgs+xml" version="1.0" xml:lang="en-US"> <rule id="root_rule" scope="public"> <one-of> <item><one-of> <item>apple</item> </one-of><tag>out.fruit = "apple";</tag> </item> <item><one-of> <item>orange</item> </one-of><tag>out.fruit = "orange";</tag> </item> <item><one-of> <item>pear</item> </one-of><tag>out.fruit = "pear";</tag> </item> </one-of> </rule> </grammar> <prompt>Pick a fruit.<break size="medium"/></prompt> <catch event="noinput nomatch"> Please pick a fruit. </catch> <filled> You picked <value expr="fruit"/> <!-- clear the form item variable to pick another --> <clear namelist="fruit"/> </filled></field></form></vxml>

Page 73: Student Pages anni/roster.html.

<?xml version="1.0"?><vxml version="2.1" xmlns="http://www.w3.org/2001/vxml"><form id="pick_fruit"> <block> Welcome to the fruit picker. </block><field name="fruit"> <grammar mode="voice" root="root_rule" tag-format="semantics/1.0" type="application/srgs+xml" version="1.0" xml:lang="en-US"> <rule id="root_rule" scope="public"> <one-of> <item><one-of> <item>apple</item> </one-of><tag>out.fruit = "apple";</tag> </item> <item><one-of> <item>orange</item> </one-of><tag>out.fruit = "orange";</tag> </item> <item><one-of> <item>pear</item> </one-of><tag>out.fruit = "pear";</tag> </item> </one-of> </rule> </grammar> <prompt>Pick a fruit.<break size="medium"/></prompt> <catch event="noinput nomatch"> Please pick a fruit. </catch> <filled> You picked <value expr="fruit"/> <!-- clear the form item variable to pick another --> <clear namelist="fruit"/> </filled></field></form></vxml>

Page 74: Student Pages anni/roster.html.

<?xml version="1.0"?><vxml version="2.1" xmlns="http://www.w3.org/2001/vxml"><form id="pick_fruit"> <block> Welcome to the fruit picker. </block><field name="fruit"> <grammar mode="voice" root="root_rule" tag-format="semantics/1.0" type="application/srgs+xml" version="1.0" xml:lang="en-US"> <rule id="root_rule" scope="public"> <one-of> <item><one-of> <item>apple</item> </one-of><tag>out.fruit = "apple";</tag> </item> <item><one-of> <item>orange</item> </one-of><tag>out.fruit = "orange";</tag> </item> <item><one-of> <item>pear</item> </one-of><tag>out.fruit = "pear";</tag> </item> </one-of> </rule> </grammar> <prompt>Pick a fruit.<break size="medium"/></prompt> <catch event="noinput nomatch"> Please pick a fruit. </catch> <filled> You picked <value expr="fruit"/> <!-- clear the form item variable to pick another --> <clear namelist="fruit"/> </filled></field></form></vxml>

Page 75: Student Pages anni/roster.html.

<?xml version="1.0"?><vxml version="2.1" xmlns="http://www.w3.org/2001/vxml"><form id="pick_fruit"> <block> Welcome to the fruit picker. </block><field name="fruit"> <grammar mode="voice" root="root_rule" tag-format="semantics/1.0" type="application/srgs+xml" version="1.0" xml:lang="en-US"> <rule id="root_rule" scope="public"> <one-of> <item><one-of> <item>apple</item> </one-of><tag>out.fruit = "apple";</tag> </item> <item><one-of> <item>orange</item> </one-of><tag>out.fruit = "orange";</tag> </item> <item><one-of> <item>pear</item> </one-of><tag>out.fruit = "pear";</tag> </item> </one-of> </rule> </grammar> <prompt>Pick a fruit.<break size="medium"/></prompt> <catch event="noinput nomatch"> Please pick a fruit. </catch> <filled> You picked <value expr="fruit"/> <!-- clear the form item variable to pick another --> <clear namelist="fruit"/> </filled></field></form></vxml>

Page 76: Student Pages anni/roster.html.

<?xml version="1.0"?><vxml version="2.1" xmlns="http://www.w3.org/2001/vxml"><form id="pick_fruit"> <block> Welcome to the fruit picker. </block><field name="fruit"> <grammar mode="voice" root="root_rule" tag-format="semantics/1.0" type="application/srgs+xml" version="1.0" xml:lang="en-US"> <rule id="root_rule" scope="public"> <one-of> <item><one-of> <item>apple</item> </one-of><tag>out.fruit = "apple";</tag> </item> <item><one-of> <item>orange</item> </one-of><tag>out.fruit = "orange";</tag> </item> <item><one-of> <item>pear</item> </one-of><tag>out.fruit = "pear";</tag> </item> </one-of> </rule> </grammar> <prompt>Pick a fruit.<break size="medium"/></prompt> <catch event="noinput nomatch"> Please pick a fruit. </catch> <filled> You picked <value expr="fruit"/> <!-- clear the form item variable to pick another --> <clear namelist="fruit"/> </filled></field></form></vxml>

Page 77: Student Pages anni/roster.html.

<?xml version="1.0"?><vxml version="2.1" xmlns="http://www.w3.org/2001/vxml"><form id="pick_fruit"> <block> Welcome to the fruit picker. </block><field name="fruit"> <grammar mode="voice" root="root_rule" tag-format="semantics/1.0" type="application/srgs+xml" version="1.0" xml:lang="en-US"> <rule id="root_rule" scope="public"> <one-of> <item><one-of> <item>apple</item> </one-of><tag>out.fruit = "apple";</tag> </item> <item><one-of> <item>orange</item> </one-of><tag>out.fruit = "orange";</tag> </item> <item><one-of> <item>pear</item> </one-of><tag>out.fruit = "pear";</tag> </item> </one-of> </rule> </grammar> <prompt>Pick a fruit.<break size="medium"/></prompt> <catch event="noinput nomatch"> Please pick a fruit. </catch> <filled> You picked <value expr="fruit"/> <!-- clear the form item variable to pick another --> <clear namelist="fruit"/> </filled></field></form></vxml>

Page 78: Student Pages anni/roster.html.

<?xml version="1.0"?><vxml version="2.1" xmlns="http://www.w3.org/2001/vxml"><form id="pick_fruit"> <block> Welcome to the fruit picker. </block><field name="fruit"> <grammar mode="voice" root="root_rule" tag-format="semantics/1.0" type="application/srgs+xml" version="1.0" xml:lang="en-US"> <rule id="root_rule" scope="public"> <one-of> <item><one-of> <item>apple</item> </one-of><tag>out.fruit = "apple";</tag> </item> <item><one-of> <item>orange</item> </one-of><tag>out.fruit = "orange";</tag> </item> <item><one-of> <item>pear</item> </one-of><tag>out.fruit = "pear";</tag> </item> </one-of> </rule> </grammar> <prompt>Pick a fruit.<break size="medium"/></prompt> <catch event="noinput nomatch"> Please pick a fruit. </catch> <filled> You picked <value expr="fruit"/> <!-- clear the form item variable to pick another --> <clear namelist="fruit"/> </filled></field></form></vxml>

Page 79: Student Pages anni/roster.html.

<?xml version="1.0"?><vxml version="2.1" xmlns="http://www.w3.org/2001/vxml"><form id="pick_fruit"> <block> Welcome to the fruit picker. </block><field name="fruit"> <grammar mode="voice" root="root_rule" tag-format="semantics/1.0" type="application/srgs+xml" version="1.0" xml:lang="en-US"> <rule id="root_rule" scope="public"> <one-of> <item><one-of> <item>apple</item> </one-of><tag>out.fruit = "apple";</tag> </item> <item><one-of> <item>orange</item> </one-of><tag>out.fruit = "orange";</tag> </item> <item><one-of> <item>pear</item> </one-of><tag>out.fruit = "pear";</tag> </item> </one-of> </rule> </grammar> <prompt>Pick a fruit.<break size="medium"/></prompt> <catch event="noinput nomatch"> Please pick a fruit. </catch> <filled> You picked <value expr="fruit"/> <!-- clear the form item variable to pick another --> <clear namelist="fruit"/> </filled></field></form></vxml>

Major Components:1. Block introduction2. Field for user input3. Grammar4. Prompt5. Filled(6. catch)

Page 80: Student Pages anni/roster.html.

<?xml version="1.0"?><vxml version="2.1" xmlns="http://www.w3.org/2001/vxml"><form id="pick_fruit"> <block> Welcome to the fruit picker. </block><field name="fruit"> <grammar mode="voice" root="root_rule" tag-format="semantics/1.0" type="application/srgs+xml" version="1.0" xml:lang="en-US"> <rule id="root_rule" scope="public"> <one-of> <item><one-of> <item>apple</item> </one-of><tag>out.fruit = "apple";</tag> </item> <item><one-of> <item>orange</item> </one-of><tag>out.fruit = "orange";</tag> </item> <item><one-of> <item>pear</item> </one-of><tag>out.fruit = "pear";</tag> </item> </one-of> </rule> </grammar> <prompt>Pick a fruit.<break size="medium"/></prompt> <catch event="noinput nomatch"> Please pick a fruit. </catch> <filled> You picked <value expr="fruit"/> <!-- clear the form item variable to pick another --> <clear namelist="fruit"/> </filled></field></form></vxml>

Grammar:Speech Recognition, not Touch Tone like before

Page 81: Student Pages anni/roster.html.

<?xml version="1.0"?><vxml version="2.1" xmlns="http://www.w3.org/2001/vxml"><form id="pick_fruit"> <block> Welcome to the fruit picker. </block><field name="fruit"> <grammar mode="voice" root="root_rule" tag-format="semantics/1.0" type="application/srgs+xml" version="1.0" xml:lang="en-US"> <rule id="root_rule" scope="public"> <one-of> <item><one-of> <item>apple</item> </one-of><tag>out.fruit = "apple";</tag> </item> <item><one-of> <item>orange</item> </one-of><tag>out.fruit = "orange";</tag> </item> <item><one-of> <item>pear</item> </one-of><tag>out.fruit = "pear";</tag> </item> </one-of> </rule> </grammar> <prompt>Pick a fruit.<break size="medium"/></prompt> <catch event="noinput nomatch"> Please pick a fruit. </catch> <filled> You picked <value expr="fruit"/> <!-- clear the form item variable to pick another --> <clear namelist="fruit"/> </filled></field></form></vxml>

Grammar:Three possible answers:

Apple, Orange, Pear

Page 82: Student Pages anni/roster.html.

<?xml version="1.0"?><vxml version="2.1" xmlns="http://www.w3.org/2001/vxml"><form id="pick_fruit"> <block> Welcome to the fruit picker. </block><field name="fruit"> <grammar mode="voice" root="root_rule" tag-format="semantics/1.0" type="application/srgs+xml" version="1.0" xml:lang="en-US"> <rule id="root_rule" scope="public"> <one-of> <item><one-of> <item>apple</item> <item>red</item> </one-of><tag>out.fruit = "apple";</tag> </item> <item><one-of> <item>orange</item> </one-of><tag>out.fruit = "orange";</tag> </item> <item><one-of> <item>pear</item> </one-of><tag>out.fruit = "pear";</tag> </item> </one-of> </rule> </grammar> <prompt>Pick a fruit.<break size="medium"/></prompt> <catch event="noinput nomatch"> Please pick a fruit. </catch> <filled> You picked <value expr="fruit"/> <!-- clear the form item variable to pick another --> <clear namelist="fruit"/> </filled></field></form></vxml>

Grammar:For Apple can say “apple” or “red”

Page 83: Student Pages anni/roster.html.

<?xml version="1.0"?><vxml version="2.1" xmlns="http://www.w3.org/2001/vxml"><form id="pick_fruit"> <block> Welcome to the fruit picker. </block><field name="fruit"> <grammar mode="voice" root="root_rule" tag-format="semantics/1.0" type="application/srgs+xml" version="1.0" xml:lang="en-US"> <rule id="root_rule" scope="public"> <one-of> <item><one-of> <item>apple</item> <item>red</item> </one-of><tag>out.fruit = "apple";</tag> </item> <item><one-of> <item>orange</item> </one-of><tag>out.fruit = "orange";</tag> </item> <item><one-of> <item>pear</item> </one-of><tag>out.fruit = "pear";</tag> </item> </one-of> </rule> </grammar> <prompt>Pick a fruit.<break size="medium"/></prompt> <catch event="noinput nomatch"> Please pick a fruit. </catch> <filled> You picked <value expr="fruit"/> <!-- clear the form item variable to pick another --> <clear namelist="fruit"/> </filled></field></form></vxml>

Filled:Repeats the input that is heard

Page 84: Student Pages anni/roster.html.

<?xml version="1.0"?><vxml version="2.1" xmlns="http://www.w3.org/2001/vxml"><form id="pick_fruit"> <block> Welcome to the fruit picker. </block><field name="fruit"> <grammar mode="voice" root="root_rule" tag-format="semantics/1.0" type="application/srgs+xml" version="1.0" xml:lang="en-US"> <rule id="root_rule" scope="public"> <one-of> <item><one-of> <item>apple</item> <item>red</item> </one-of><tag>out.fruit = "apple";</tag> </item> <item><one-of> <item>orange</item> </one-of><tag>out.fruit = "orange";</tag> </item> <item><one-of> <item>pear</item> </one-of><tag>out.fruit = "pear";</tag> </item> </one-of> </rule> </grammar> <prompt>Pick a fruit.<break size="medium"/></prompt> <catch event="noinput nomatch"> Please pick a fruit. </catch> <filled> You picked <value expr="fruit"/> <!-- clear the form item variable to pick another --> <clear namelist="fruit"/> </filled></field></form></vxml>

No match with Grammar or No input at all:“Please pick a fruit”

Page 85: Student Pages anni/roster.html.

More Advanced Phone Programming:

Full example with even more bells and whistles here:

https://studio.tellme.com/vxml2/ref/elements/prompt.html