Professional Documents
Culture Documents
Acknowledgements
Prof. Mctear, Natural Language Processing, http://www.infj.ulst.ac.uk/nlp/index.html, University of Ulster. Bevocal documentation
Overview
Types of grammar Grammar design and use Optional items in a grammar Semantic tags DTMF grammars Grammar rules Built-in grammars Grammar scope
What is a grammar
A grammar defines the words and patterns of words that a user can say at any particular point in a dialogue Uses: speech recognition: to constrain the speech recognition process by specifying permissible sequences of words language understanding: to determine the structure and/or meaning of a sequence of words e.g. Transfer one hundred dollars from my checking to my savings account might be parsed and transformed into the structure:
<transfer> <command> transfer </command> <destination> savings </destination> <source> checking </source> <amount> 100 </amount> </transfer>
Types of grammar
Finite-state and phrase structure
take the form of rules with a left-hand and right-hand side
e.g. noun_phrase -> determiner adjective noun flight -> <destination> <date> <time> used in language understanding and speech recognition
Grammar in VoiceXML
May be specified
Inline i.e. embedded into a VoiceXML page
Grammar formats
XML, ABNF (Augmented BNF syntax), Java Speech
Grammar format (JSGF), GSL (Nuances Grammar Specification language) W3C specification embodies XML and ABNF IBM Voice Toolkit supports the XML and ABNF grammar formats Bevocal Caf, Voxpilot and Tellme support the XML and GSL grammar formats
For further details on the W3C Speech Recognition Grammar Specification, see http://www.w3.org/TR/speech-grammar/
An external grammar is defined in an external file and referenced in the VoiceXML document
In an external grammar document, all rules must be named In external GSL grammar file, the contents of that file should not be inside a CDATA section and should not contain a <grammar> element. : ;GSL2.0 ...grammar rule definitions...
GSL grammars use special characters: wrap your inline grammar as a section of CDATA:
<grammar ...usage attributes...> <![CDATA[ ...grammar header... ...grammar rule definitions... ]]> </grammar>
<option> element
Specifies a set of possible responses for a field If the number of possible responses is small, then a set of <option> elements can be used instead of a <grammar> element <form> <field name=choice"> <prompt> Say students, courses, or reports </prompt> <option> can also <option>students</option> be used for <option>courses</option> alternative DTMF <option>reports</option> input e.g. </field> <option dtmf = 1 </form> value = balance >
balance </option>
Grammar Design
A grammar should cover all the ways that a user might say something 1. 2. Alternative choices within a category e.g. studentname [john rosemary etc] Alternative words for the same concept e.g. [comms communications] Alternative sentences that have the same meaning e.g. [(student john scott taking databases) (databases john scott) (john scott taking the course databases)]
3.
Note: careful wording of prompts can constrain the user to saying what has been predicted by the grammar designer
These examples use the GSL grammar format, which is more suitable than the XML format for the presentation of examples
</grammar>
XML <rule id = choice" > <one-of> <item> students <item> <item> courses <item> <item> reports </item> </one-of> </rule>
Repeating items
XML: repeat = "0-1" means the item is optional i.e. zero or one time repeat = "n- means the item is repeated n or more times e.g. 0- = zero or more times repeat = "m-n" means the item re repeated between m and n times (inclusive) e.g. 1-3 = between one and three times repeat = "n" means the item is repeated exactly n times
GSL: +(item) - the item is repeated 1 or more times *(item) - the item is repeated 0 or more times ?(item) the item is optional
<filled>
<assign name=selected" expr=MainMenu.selection"/>
;GSL 2.0; ColoredOjbect:public (Color Object) Color [ [red pink] { <color red> } Colored Object [yellow canary] { <color yellow> } [green khaki] { <color green> } Object Color ] Object [ [truck car] { <object vehicle> } [ball block] { <object toy> } [shirt blouse] { <object clothing> } ] "yellow shirt" "canary blouse"=> { color: yellow; object: clothing; }
To mark a rule as public, the format is: RuleName:public ruleExpansion If no rules in the grammar are explicitly marked with :public, then all rules in the grammar are public. If any rule in the grammar is marked with :public, then all public rules must be so marked. The root rule in a GSL grammar is always the first public rule.
For example, the following set of definitions creates one public rule named Snapper and two private rules named SnapperType and FishColors: SnapperType [mutton FishColors] FishColors [black gray red] Snapper:public (SnapperType snapper)
<one-of> referenced by a rule in same grammar <item> john </item> <item> rosemary </item> </one-of>
</rule>
External:
;GSL2.0 ...grammar rule definitions...
No definition of top-level rule Referencing an external grammar or a top level rule in a
grammar:
<grammar src="foo.gsl"> <grammar src="foo.gsl#Month">
Grammar Scope
Grammar elements can be included within any VoiceXML element that receives user input
field link: for transitions to other documents e.g. operator.vxml menu: grammar implicitly specified by the <choice>
by default the scope of a grammar is limited to the elements in which it is defined scope can be set using the scope attribute e.g. grammars defined within forms or menus can be given document scope grammars defined in the root document scope to the entire application
DTMF
DTMF (touch-tone) can be used as an alternative to speech input, particularly when speech recognition is unreliable or problematic. In VoiceXML 2.0 dtmf is included as a value of the mode attribute in the <grammar> element
<grammar mode="dtmf" type="application/srgs+xml" version= "1.0" root="digit"> <rule id = "digit" scope = "public"> <one-of> <item> 1 <tag>$= students" </tag> </item> <item> 2 <tag>$= courses" </tag></item> <item> 3 <tag>$= reports" </tag> </item> </one-of> </rule> </grammar>
Built-In Grammars
Built-in grammars are provided in VoiceXML
boolean (true or false: in DTMF 1 is true, 2 is false) date digits (e.g. three four seven) currency number (e.g. three hundred and forty seven) phone time
IBM Voice Toolkit UK English: yes, true, positive, right, ok, sure, affirmative, check, yep, correct, no, false, negative, wrong,not, nope, incorrect The return value sent is a boolean true or false. If the field name is subsequently used in a value element within a prompt, the TTS engine will speak either yes or no. Users can also provide DTMF input: 1 is yes, and 2 is no.
<field name=pin" type="digits?length=4" modal="false"> <prompt version="1.0"> what is your pin? </prompt> </field>
<field name="confirm" type="boolean" modal="false"> <prompt version="1.0"> Please confirm your pin is <say-as interpretas=vxml:digits"><value expr=pin"/></say-as> </prompt> </field>
</form>
date
phone
digits time