Page 1 of 1

srgs grammar help

Posted: Wed Aug 27, 2008 4:57 pm
by jdart
I'm having trouble working with srgs+xml grammars.

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<vxml version="2.0">
<form id="form1">
    <field name="field1">
        <grammar 
            root="grammar1" 
            type="application/srgs+xml" 
            mode="voice" 
        >
            <rule id='grammar1'>
                <one-of>
                    <item>
                        One
                        <tag>
                            english='One';integer='1'
                        </tag>
                    </item>
                    <item>
                        Two
                        <tag>
                            english='Two';integer='2'
                        </tag>
                    </item>
                </one-of>
            </rule>
        </grammar>
        <prompt>
            One or two.        
        </prompt>
        <filled>
            <prompt>
                You said.
                <value expr="field1.english" />
            </prompt>
        </filled>
    </field>
</form>
</vxml>
"field1.english" is empty but doesn't cause an error when I run this script. "field1" holds a string which is the contents of the tag with the semi colons removed. That's difficult to parse. What am I missing here?

Posted: Thu Aug 28, 2008 9:03 am
by jdart
This pattern seems to be the same as the one demonstrated in the documentation just below: http://www.plumvoice.com/docs/dev/devel ... n_grammars

Posted: Thu Aug 28, 2008 9:15 am
by jdart
The contents of the tag tag should end with a one, assuming it's evaluated as ecma script. However, making that change doesn't give me a different result.

Posted: Thu Aug 28, 2008 9:16 am
by jdart
Edit above: should end with a semi colon. You guys need to enable post editing!

IVR code fix for srgs+xml grammars

Posted: Thu Aug 28, 2008 11:30 am
by support
Hi,

The IVR <tag> example gives a good demonstration on how to implement this:

We've made the following modification to your IVR code:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<vxml version="2.0">
<form id="form1">
    <field name="field1">
        <grammar root="grammar1" type="application/srgs+xml" mode="voice">
          <rule id="grammar1" scope="public">
            <item>
              <ruleref uri="#english"/>
            </item>
            <tag> english = english.SWI_literal </tag>
          </rule>

          <rule id="english">
                <one-of>
                    <item>
                        One
                    </item>
                    <item>
                        Two
                    </item>
                </one-of>
            </rule>
        </grammar>
        <prompt>
            One or two.       
        </prompt>
        <filled>
            <prompt>
                You said.
                <value expr="field1.english" />
            </prompt>
        </filled>
    </field>
</form>
</vxml>
and have tested and confirmed that this works.

Hope this helps.

Regards,
Plum Support

Posted: Thu Aug 28, 2008 12:37 pm
by jdart
Thanks for your response. I think we're getting closer.

I would like the grammar to give back several pieces of information based on the grammar match. I don't think your solution quite allows me to do that. Here's an example form:

Code: Select all

<form id="state_province">
    <field name="state_province">

        <grammar 
            src="http://pleusdev.plum.imi.ca/assets/grammars/state_province.xml"
            root="state_province" 
            type="application/srgs+xml" 
            mode="voice" 
        />
        
        <prompt>
            Say your state or province.
        </prompt>
            
        <filled>
            <prompt>
                You are in <value expr="state_province.country" />.
            </prompt>
        </filled>

    </field>
</form>
Grammar snippet:

Code: Select all

<grammar mode="voice" root="state_province" xml:lang="en_us">
    <rule id="state_province">
        <one-of>
            <item>
                Alberta
                <tag>
                    state_province='Alberta';state_province_abbr='AB';country='Canada';country_abbr='CA'
                </tag>
            </item>
            <item>
                British Columbia
                <tag>
                    state_province='British Columbia';state_province_abbr='BC';country='Canada';country_abbr='CA'
                </tag>
            </item>
        </one-of>
    </rule>
</grammar>

Further IVR code for srgs+xml grammars

Posted: Thu Aug 28, 2008 3:35 pm
by support
Hi,

We've found that the following IVR code works well on our IVR hosting site, which runs version 3.0 of the IVR platform. Again, note the use of SRGS+XML for the IVR <grammar> below:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<vxml version="2.0">
<form>
<field name="stateprovince">

<grammar type="application/srgs+xml" mode="voice" root="ROOT" xml:lang="en_us">
    <rule id="ROOT">
        <one-of>
            <item>
                Alberta
                <tag>
                    state_province='Alberta';state_province_abbr='AB';country='Canada';country_abbr='CA'
                </tag>
            </item>
            <item>
                British Columbia
                <tag>
                    state_province='British Columbia';state_province_abbr='BC';country='Canada';country_abbr='CA'
                </tag>
            </item>
        </one-of>
    </rule>
</grammar> 
       
        <prompt>
            Say your state or province.
        </prompt>
           
        <filled>
            <prompt>
                You are in <value expr="stateprovince.state_province" />.
                Your country is <value expr="stateprovince.country" />.
            </prompt>
        </filled>

    </field>
</form>
</vxml>
If you have an onsite system, you should consider upgrading to the latest version of the IVR platform.

Regards,
Plum Support