Page 1 of 1

External Grammars and the use of ruleref - Error Creating

Posted: Fri Apr 04, 2008 8:23 am
by smann
Good Morning,

For organizational purposes, I am trying to write a grammar that will understand the phonetic alphabet, Ie: "A as in Apple"

I'm going to chop down my grammar to make it easier to read, but I can't get a ruleref to an external grammar file to work.

If I write my grammar like this, it works fine:

Code: Select all

<?xml version="1.0" ?>
<grammar mode="voice" root="alphanum" xml:lang="en_us">
	<rule id="alphanum" scope="public">

		<!--	User should be able to say either Letter, or "as in" phonetic form.
			Example: Caller Speaks "A" or Caller Speaks "A as in Alpha".
			This should be allowed to occur multiple times to facilitate
			spelling of arbitrary words.-->
			
		<item repeat="1-"><!--Accept 1 or more letters,numbers or phonetic phrases.-->
		
			<one-of><!--We want to match one spoken letter, number, or phonetic at a time-->
				<item><ruleref uri="#alpha" /></item>
			</one-of>
		</item>
	</rule>


	<rule id="alpha" scope="private">
		<!-- This is the ruleset that matches a phonetic phrase or single letter.
		it is a reference to each letters individual ruleset.-->
		
		<one-of>
			<!--If one of these match it's tag is placed in the letter tag of this rule-->
			<item><ruleref uri="#a"/></item>
		</one-of>
	</rule>
	
	
	<rule id="a" scope="private">
		<!--The user can say "A" or "A as in Apple"-->
		<item>
			A
			<item repeat="0-1">
				as in
				<one-of>
					<item>Alpha</item>
					<item>Alberta</item>
				</one-of>
			</item>	
		</item>
		<!--If one of the above matches, it is returned as "a"-->
		<tag>SWI_literal="A"</tag>
	</rule>

</grammar>
However, if I break out the wordlist for a into it's own xml file, and use a ruleref tag to reference it, I'm getting Error Creating Grammar.

Here is how I'd like it to work, but can not find the write syntax (if it's even possible)

Grammar:

Code: Select all

<?xml version="1.0" ?>
<grammar mode="voice" root="alphanum" xml:lang="en_us">
	<rule id="alphanum" scope="public">

		<!--	User should be able to say either Letter, or "as in" phonetic form.
			Example: Caller Speaks "A" or Caller Speaks "A as in Alpha".
			This should be allowed to occur multiple times to facilitate
			spelling of arbitrary words.-->
			
		<item repeat="1-"><!--Accept 1 or more letters,numbers or phonetic phrases.-->
		
			<one-of><!--We want to match one spoken letter, number, or phonetic at a time-->
				<item><ruleref uri="#alpha" /></item>
			</one-of>
		</item>
	</rule>


	<rule id="alpha" scope="private">
		<!-- This is the ruleset that matches a phonetic phrase or single letter.
		it is a reference to each letters individual ruleset.-->
		
		<one-of>
			<!--If one of these match it's tag is placed in the letter tag of this rule-->
			<item><ruleref uri="#a"/></item>
		</one-of>
	</rule>
	
	
	<rule id="a" scope="private">
		<!--The user can say "A" or "A as in Apple"-->
		<item>
			A
			<item repeat="0-1">
				as in
				<one-of>
					<ruleref uri="a.xml#awords"/>
				</one-of>
			</item>	
		</item>
		<!--If one of the above matches, it is returned as "a"-->
		<tag>SWI_literal="A"</tag>
	</rule>

</grammar>
And a.xml looks like this:

Code: Select all

<?xml version="1.0" ?>
<grammar mode="voice" root="awords" xml:lang="en_us">
<rule id="awords" scope="private">
<item>Alpha</item>
<item>Alberta</item>
</rule>
</grammar>

Can you help me figure out what I've got wrong here? Also - is there a tool I can use for validatiing this? Or a way to get a more detailed error in the call log then just "Error Creating Grammar"?

Thanks

Steve

Use VXML Validator to validate IVR grammar

Posted: Fri Apr 04, 2008 9:55 am
by support
Hi Steve,

You can use our VoiceXML Validator to validate your IVR grammar. To do this, look under "Developer Tools" and click "VoiceXML Validator". There, you can enter an external URL to your IVR script and the validator will check to see if it is valid VoiceXML.

About your IVR grammar, it's giving you that IVR error because there is a <ruleref> tag placed within <one-of> tags, which is invalid VXML since <one-of> is not a parent IVR tag of <ruleref>.

Hope this helps.

Regards,
Plum Support

Posted: Fri Apr 04, 2008 2:35 pm
by smann
I tried to follow your advice, I still can not get it to work.

Here is how I changed the grammar. (I tried a few other things to, but none worked.)

Code: Select all

<?xml version="1.0" ?> 
<grammar mode="voice" root="alphanum" xml:lang="en_us"> 
   <rule id="alphanum" scope="public"> 

      <!--   User should be able to say either Letter, or "as in" phonetic form. 
         Example: Caller Speaks "A" or Caller Speaks "A as in Alpha". 
         This should be allowed to occur multiple times to facilitate 
         spelling of arbitrary words.--> 
          
      <item repeat="1-"><!--Accept 1 or more letters,numbers or phonetic phrases.--> 
       
         <one-of><!--We want to match one spoken letter, number, or phonetic at a time--> 
            <item><ruleref uri="#alpha" /></item> 
         </one-of> 
      </item> 
   </rule> 


   <rule id="alpha" scope="private"> 
      <!-- This is the ruleset that matches a phonetic phrase or single letter. 
      it is a reference to each letters individual ruleset.--> 
       
      <one-of> 
         <!--If one of these match it's tag is placed in the letter tag of this rule--> 
         <item><ruleref uri="#a"/></item> 
      </one-of> 
   </rule> 
    
    
   <rule id="a" scope="private"> 
      <!--The user can say "A" or "A as in Apple"--> 
      <item> 
         A 
         <item repeat="0-1"> 
            as in 
               <ruleref uri="a.xml#awords"/> 
         </item>    
      </item> 
      <!--If one of the above matches, it is returned as "a"--> 
      <tag>SWI_literal="A"</tag> 
   </rule> 

</grammar>
I moved the on-of tags into the referenced rule instead like so:

Code: Select all

<?xml version="1.0" ?> 
<grammar mode="voice" root="awords" xml:lang="en_us"> 
<rule id="awords" scope="private">
<one-of>
<item>Alpha</item> 
<item>Alberta</item> 
</one-of>
</rule> 
</grammar>
There must be some combination of issues I am not finding that is causing this.

Only refer to <rule>s within your IVR script

Posted: Fri Apr 04, 2008 3:50 pm
by support
Hi Steve,

You cannot use <ruleref> to reference external files (in this case, a.xml). <ruleref> specifies a local rule reference, meaning that you can only refer to <rule>s within your IVR script. This is why you are still getting the IVR error.grammar.inline error.

Regards,
Plum Support