Student Pages
Last Time: HTML Forms and Javascript If you haven’t finished the survey assignment, us or come to office hours
2/14: Programming Phones
This script says “hello world” Hello World!
This script says “hello world” Hello World! Call VXML and use my developer ID ( ) 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
Prerequisite: XML
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
XML Opening and closing tags
XML Nested hierarchy of tags Hello World Hi, What’s up? …
XML Nested hierarchy of tags Hello World Hi, What’s up? … Level 1 (Document Root)
XML Nested hierarchy of tags Hello World Hi, What’s up? … Level 1 (Document Root) Level 1 (Document Root) Level 2
XML Nested hierarchy of tags Hello World Hi, What’s up? … Level 1 (Document Root) Level 2 Level 3
XML Tag Attributes Hello World Hi, What’s up? … Attribute Value
XML Comments Hello World Hi, What’s up? …
VoiceXML (Programming Phones)
This script says “hello world” Hello World!
VoiceXML (Programming Phones)
VoiceXML (Programming Phones)
VoiceXML (Programming Phones)
VoiceXML (Programming Phones)
VoiceXML: Form Blocks Hello World! Audio (“Text to Speech”) Exit the application
VoiceXML: Form Blocks Hello World! Note beginning and end tags
VoiceXML: Form Blocks Hello World! This should be what’s in your Scratchpad now
Back to Javascript Just like you can embed Javascript into HTML, you can embed Javascript into VoiceXML
Back to Javascript Just like you can embed Javascript into HTML, you can embed Javascript into VoiceXML But we won’t do that in this class…
VoiceXML: tag Hello World!
VoiceXML: tag Hello World! Tag
VoiceXML: tag Hello World! Tag Attribute
VoiceXML: tag Hello World! Tag Attribute Value: Name of another form
VoiceXML: tag Hello World! I found my second form.
VoiceXML: tag Hello World! I found my second form. Attribute
VoiceXML: tag Hello World! I found my second form. Attribute Value
VoiceXML: tag Hello World! I found my second form. Sounds like…: “Hello World I found my second form.” Sounds like…: “Hello World I found my second form.”
Try this in your Scratchpad Hello World! This dialogue goes on and on 1. Guess what this script will do. 2. Edit Scratchpad 3. Call Guess what this script will do. 2. Edit Scratchpad 3. Call
VoiceXML: Form Blocks
VoiceXML: Form Blocks
VoiceXML: Form Blocks Attribute
VoiceXML: Form Blocks Attribute Value
VoiceXML: Form Blocks Attribute Value
VoiceXML: Form Blocks Do you like computers? New “prompt” tag: child of “field”
VoiceXML: Form Blocks Do you like computers? Text to Speech: “Do you like computers?” Text to Speech: “Do you like computers?”
VoiceXML: Form Blocks Do you like computers? New “filled” tag: child of “field”
VoiceXML: Form Blocks Do you like computers? Great, I got your answer. Text to Speech: “Great, I got your answer” Text to Speech: “Great, I got your answer”
VoiceXML: Form Blocks Do you like computers? Great, I got your answer. Broken!
VoiceXML: Form Blocks Do you like computers? Great, I heard your answer. Broken!
VoiceXML: Form Blocks Do you like computers? Great, I got your answer. Broken!
VoiceXML: Form Blocks Do you like computers? Great, I got your answer. Since the predefined boolean grammar isn’t working, we’ll add one ourselves
VoiceXML: Form Blocks Do you like computers? 1 2 Great, I got your answer. Press 1 or 2, record the answer Copy and paste this to receive any “1 or 2” input
VoiceXML: Form Blocks Do you like computers? 1 2 Great, I got your answer.
VoiceXML: Form Blocks Input type will be a touch tone keyboard
VoiceXML: Form Blocks Reference some touch tone input gathering code
VoiceXML: Form Blocks A grammar can have many rules In this example, when this grammar is used, it should start with the rule named “top” A grammar can have many rules In this example, when this grammar is used, it should start with the rule named “top”
VoiceXML: Form Blocks “one-of” tag: user specifies one of the following items
VoiceXML: Form Blocks The allowable items are “1” and “2”
VoiceXML: Form Blocks Text to Speech: “Great, I got your answer” Text to Speech: “Great, I got your answer”
VoiceXML: Form Blocks Try this!
Do you like computers? 1 2 Great, I got your answer. VoiceXML: Form Blocks Now let’s do something with the input after it’s identified
Do you like computers? 1 2 Great, I got your answer. VoiceXML: Form Blocks
Do you like computers? 1 2 Great, I got your answer. I'm glad you like computers. Too bad that you don't like computers. VoiceXML: Form Blocks
Do you like computers? 1 2 Great, I got your answer. I'm glad you like computers. Too bad that you don't like computers. VoiceXML: Form Blocks “if-else” tag: Special two-part tag: 1.The if part 2. The else part “if-else” tag: Special two-part tag: 1.The if part 2. The else part
Do you like computers? 1 2 Great, I got your answer. I'm glad you like computers. Too bad that you don't like computers. VoiceXML: Form Blocks If some condition is met, do what follows here Otherwise, do what follows here
Do you like computers? 1 2 Great, I got your answer. I'm glad you like computers. Too bad that you don't like computers. 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”
Do you like computers? 1 2 Great, I got your answer. I'm glad you like computers. Too bad that you don't like computers. VoiceXML: Form Blocks Notice the double “==“
Do you like computers? 1 2 Great, I got your answer. I'm glad you like computers. Too bad that you don't like computers. VoiceXML: Form Blocks If the condition is true, say this.
Do you like computers? 1 2 Great, I got your answer. I'm glad you like computers. Too bad that you don't like computers. VoiceXML: Form Blocks If the condition is not true, say this
Do you like computers? 1 2 Great, I got your answer. I'm glad you like computers. Too bad that you don't like computers. 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) [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)
VoiceXML Homework In 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 and me an with the contents of your Scratchpad. Due Tuesday, February 22 nd before sunrise.
Hint for Option #1 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 I'm glad you like computers. Too bad that you don't like computers. I'm glad you like computers. Too bad that you don't like computers. =
Hint for Option #2 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. I hope you’ll like computers forever Too bad that you don't like computers. and ever + +
Another Hint for Option #2 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. … … Note that your single code can include multiple forms
More Advanced Phone Programming
Welcome to the fruit picker. apple out.fruit = "apple"; orange out.fruit = "orange"; pear out.fruit = "pear"; Pick a fruit. Please pick a fruit. You picked
Welcome to the fruit picker. apple out.fruit = "apple"; orange out.fruit = "orange"; pear out.fruit = "pear"; Pick a fruit. Please pick a fruit. You picked
Welcome to the fruit picker. apple out.fruit = "apple"; orange out.fruit = "orange"; pear out.fruit = "pear"; Pick a fruit. Please pick a fruit. You picked
Welcome to the fruit picker. apple out.fruit = "apple"; orange out.fruit = "orange"; pear out.fruit = "pear"; Pick a fruit. Please pick a fruit. You picked
Welcome to the fruit picker. apple out.fruit = "apple"; orange out.fruit = "orange"; pear out.fruit = "pear"; Pick a fruit. Please pick a fruit. You picked
Welcome to the fruit picker. apple out.fruit = "apple"; orange out.fruit = "orange"; pear out.fruit = "pear"; Pick a fruit. Please pick a fruit. You picked
Welcome to the fruit picker. apple out.fruit = "apple"; orange out.fruit = "orange"; pear out.fruit = "pear"; Pick a fruit. Please pick a fruit. You picked
Welcome to the fruit picker. apple out.fruit = "apple"; orange out.fruit = "orange"; pear out.fruit = "pear"; Pick a fruit. Please pick a fruit. You picked Major Components: 1.Block introduction 2.Field for user input 3.Grammar 4.Prompt 5.Filled (6. catch) Major Components: 1.Block introduction 2.Field for user input 3.Grammar 4.Prompt 5.Filled (6. catch)
Welcome to the fruit picker. apple out.fruit = "apple"; orange out.fruit = "orange"; pear out.fruit = "pear"; Pick a fruit. Please pick a fruit. You picked Grammar: Speech Recognition, not Touch Tone like before Grammar: Speech Recognition, not Touch Tone like before
Welcome to the fruit picker. apple out.fruit = "apple"; orange out.fruit = "orange"; pear out.fruit = "pear"; Pick a fruit. Please pick a fruit. You picked Grammar: Three possible answers: Apple, Orange, Pear Grammar: Three possible answers: Apple, Orange, Pear
Welcome to the fruit picker. apple red out.fruit = "apple"; orange out.fruit = "orange"; pear out.fruit = "pear"; Pick a fruit. Please pick a fruit. You picked Grammar: For Apple can say “apple” or “red” Grammar: For Apple can say “apple” or “red”
Welcome to the fruit picker. apple red out.fruit = "apple"; orange out.fruit = "orange"; pear out.fruit = "pear"; Pick a fruit. Please pick a fruit. You picked Filled: Repeats the input that is heard Filled: Repeats the input that is heard
Welcome to the fruit picker. apple red out.fruit = "apple"; orange out.fruit = "orange"; pear out.fruit = "pear"; Pick a fruit. Please pick a fruit. You picked No match with Grammar or No input at all: “Please pick a fruit” No match with Grammar or No input at all: “Please pick a fruit”
More Advanced Phone Programming: Full example with even more bells and whistles here: