We've Moved! Please visit our new and improved forum over at our new portal: https://portal.plumvoice.com/hc/en-us/community/topics

Validated grammar fails

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
moshe
Posts: 66
Joined: Wed Aug 15, 2007 5:36 pm
Location: Chicago
Contact:

Validated grammar fails

Post by moshe »

Perhaps I'm overlooking something obvious, but the grammar validator says this is valid code, while the grammar fails at runtime:

Code: Select all

<grammar version="1.0" root="mainmenu">

	<!-- does user want main menu? -->
	
	<rule id="mainmenu" scope="public">
		<item>main menu</item>
	</rule>

</grammar>
I don't think it gets much simpler than this. Although this validates, I get an error at runtime:

Code: Select all

Attempting to fetch http://(removed for privacy)
Error creating grammar
received event: error.grammar
comments welcome

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

IVR fix for Validated grammar fails

Post by support »

Hi,

You have to specify the IVR grammar type to be SRGS+XML inside of your <grammar> tag. Otherwise, it defaults to JSGF.

Basically, you have to change this line of IVR code:

Code: Select all

<grammar version="1.0" root="mainmenu"> 
to this:

Code: Select all

<grammar type="application/srgs+xml" version="1.0" root="mainmenu">
Hope this helps.

Regards,
Plum Support
Last edited by support on Fri Feb 19, 2010 4:27 pm, edited 3 times in total.

moshe
Posts: 66
Joined: Wed Aug 15, 2007 5:36 pm
Location: Chicago
Contact:

Post by moshe »

Unfortunately, that doesn't work... and why would it validate if it's not valid?

In any case, the grammar is online here; suggestions welcome. I'm modifying it as we speak, but nothing seems to work at the moment; not adding "mode", not taking off "version," etc.

moshe
Posts: 66
Joined: Wed Aug 15, 2007 5:36 pm
Location: Chicago
Contact:

Test Script

Post by moshe »

I've placed a test script here.

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

Test Script for IVR application

Post by support »

Hi,

In your .grxml file, you are missing the following:

Code: Select all

<?xml version="1.0"?>
This line has to be placed at the beginning of your .grxml file because the file has to return XML.

Also, in your .grxml file, you specify the attribute "version" twice in your .grxml application, as shown here:

Code: Select all

<grammar version="1.0" root="mainmenu" type="application/srgs+xml" mode="voice"  version="1.0" >
This IVR code should be changed to:

Code: Select all

<grammar version="1.0" root="mainmenu" type="application/srgs+xml" mode="voice">
This explains why the IVR application is having problems creating the IVR grammar.

Regards,
Plum Support
Last edited by support on Fri Feb 19, 2010 4:28 pm, edited 3 times in total.

moshe
Posts: 66
Joined: Wed Aug 15, 2007 5:36 pm
Location: Chicago
Contact:

Post by moshe »

When I put the <?xml> into the script, it failed, complaining that <?xml> wasn't acceptable. That's why it's not in there now.

moshe
Posts: 66
Joined: Wed Aug 15, 2007 5:36 pm
Location: Chicago
Contact:

Post by moshe »

I should be more specific: when I had both the <?xml> construct and the DOCTYPE, I had error messages complaining about the <?xml> construct.

I've placed the <?xml> back into the script, and fixed the duplicate version that crept into it when I was fiddling around, and it still fails to run.

moshe
Posts: 66
Joined: Wed Aug 15, 2007 5:36 pm
Location: Chicago
Contact:

Validator explicitly rejects xml element

Post by moshe »

I thought I might be even more explicit, since I still can't get this grammar to work. If I use your recommendation and put the xml element back into the top of the document,

Code: Select all

<?xml version="1.0"?> 
<grammar root="mainmenu" type="application/srgs+xml" mode="voice" version="1.0" >

	<!-- does user want main menu? -->
	
	<rule id="mainmenu" scope="public">
		<token>main menu</token>
	</rule>

</grammar>
I've also tried the item element and no element whatsoever to delineate the spoken text. All fail.

I get the following output from your XML validator with the xml element in place:

Code: Select all

ERROR: 
Fatal Error at  line 0, char 6
  Message: No processing instruction starts with 'xml'
Using the full xml and DOCTYPE, as is my normal practice, gives the same error message. In other words, these lines at the top are also rejected by the validator:

Code: Select all

<?xml version="1.0" encoding ="UTF-8"?>
<!DOCTYPE grammar PUBLIC "-//W3C//DTD GRAMMAR 1.0//EN" "http://www.w3.org/TR/speech-grammar/grammar.dtd">
If I disregard the validator's assessment and attempt to use this grammar anyway, it still doesn't work. I call this grammar using

Code: Select all

		<grammar src="http://assassin.homeip.net:15338/~moshe/devel/freewill/trunk/vxml/grammars/dailyupdate.grxml" type="application/srgs+xml" mode="voice" root="mainmenu"/>
[/code]

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

Validator explicity rejects xml element in IVR system

Post by support »

Hi,

As for the validator rejecting the xml prologue in your remote IVR grammar, the validator was meant for inline IVR grammars within your vxml document. This is why the validator rejects the xml prologue.

However, have you tried calling into your IVR application to see if it works? We have been able to test this remote IVR grammar just fine on our side:

Code: Select all

<?xml version="1.0"?>
<grammar root="mainmenu" type="application/srgs+xml" mode="voice" version="1.0" >

	<!-- does user want main menu? -->
	
	<rule id="mainmenu" scope="public">
		<item>main menu</item>
	</rule>

</grammar>
You should leave out the DOCTYPE and the encoding though since this will cause an IVR error.

Regards,
Plum Support
Last edited by support on Fri Feb 19, 2010 4:29 pm, edited 2 times in total.

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

include global property "grammarmaxage" in IVR scr

Post by support »

Hi,

In your IVR script, you also might want to include the IVR global property, "grammarmaxage" to ensure that a fresh copy of the IVR grammar file will always be fetched by the IVR server.

To do this, you would type:

Code: Select all

<property name="grammarmaxage" value="0s"/>
Regards,
Plum Support
Last edited by support on Wed Feb 24, 2010 4:38 pm, edited 4 times in total.

moshe
Posts: 66
Joined: Wed Aug 15, 2007 5:36 pm
Location: Chicago
Contact:

Post by moshe »

Ah. The validator explicitly invites me to input a URL, so I of course assumed it meant the URL of a grammar file.

I tried the grammar multiple times in live calls. I have just re-vamped (again) the grammar file again, as seen in this grammar.

At present this works, to my great surprise. I sincerely have no idea why it failed in the past, under essentially the same circumstances and with the same grammar element attributes. I am fairly certain it's not a caching issue; I went so far as to test the order in which the different attributes appear in the element.

Thank you for your assistance.

Post Reply