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

Spell a word

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

goochalba
Posts: 18
Joined: Wed Jun 13, 2012 9:01 pm

Spell a word

Post by goochalba »

Hi,

It looks like this is not possible but I wanted to double check. So if I want a user to spell their last
name and capture that this is not possible at this point correct? If I knew their last name up front
could I ask them to spell it and capture at least if it was accurate or not?

Thanks in advance!
Mike

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

Re: Spell a word

Post by support »

Hi Mike,

Yes, this is possible. There is a built in last name grammar, though it only covers about 90% of the US population's last names. For more information, please take a look at the VXML documentation: http://www.plumvoice.com/docs/dev/devel ... ce:grammar

Regards,
Plum Support

goochalba
Posts: 18
Joined: Wed Jun 13, 2012 9:01 pm

Re: Spell a word

Post by goochalba »

Great thanks so much for the quick reply! So lets say I wanted the user to spell a random word
but I will know what the word is and ask them to spell it. Would I create a dynamic grammar
to achieve this?

Thanks again!

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

Re: Spell a word

Post by support »

Hi Mike,

Yes, you would have to create your own grammar. We think it would be best if you used the alphanum builtin grammar, which is currently undocumented. To limit the amount of mistakes that may occur while using it, you should modify your confidence and sensitivity properties. Here is a code example:

Code: Select all

<form>
  <field>
    <property name="sensitivity" value="0.2"/>
    <property name="confidencelevel" value="0.75"/>
    <grammar src="spelling_grammar.php" type="application/srgs+xml"/>
    <prompt>Spell the word example.</prompt>
    <filled>You spelled example correctly.</filled>
  </field>
</form>
spelling_grammar.php would be the grammar you write using the builtin alphanum:

Code: Select all

<?php
header('Content-type: text/xml');
echo '<?xml version="1.0"?>'; 
?>

<grammar root="spelling" mode="voice">
  <rule id="spelling">
    <ruleref uri="builtin:grammar/alphanum?entries=word_list.txt"/>
  </rule>
</grammar>
word_list.txt is simply a text file with the word(s) you want your users to spell:

Code: Select all

example
Regards,
Plum Support

goochalba
Posts: 18
Joined: Wed Jun 13, 2012 9:01 pm

Re: Spell a word

Post by goochalba »

Awesome thanks so much!

goochalba
Posts: 18
Joined: Wed Jun 13, 2012 9:01 pm

Re: Spell a word

Post by goochalba »

Hi,

I have tried exactly what you have suggested and am getting the following

Code: Select all

Sun 08 Jul 2012 08:20:24.0687 PM EDT (000001;024;1341791797) [inet] EVENT: Attempting to fetch http://us.popproxy.plumgroup.com/plumvp/demo.php
Sun 08 Jul 2012 08:20:24.0716 PM EDT (000001;024;1341791797) [vxi] EVENT: DocumentParser::FetchDocument(http://ec2-user@174.129.240.84:8999/spell.vxml)
Sun 08 Jul 2012 08:20:24.0716 PM EDT (000001;024;1341791797) [vxi] EVENT: Cache Miss: http://ec2-user@174.129.240.84:8999/spell.vxml
Sun 08 Jul 2012 08:20:24.0716 PM EDT (000001;024;1341791797) [inet] EVENT: Attempting to fetch http://ec2-user@174.129.240.84:8999/spell.vxml
Sun 08 Jul 2012 08:20:24.0749 PM EDT (000001;024;1341791797) [rec] EVENT: Cache Hit: http://ec2-user@174.129.240.84:8999/spelling_grammar.php
Sun 08 Jul 2012 08:20:24.0754 PM EDT (000001;024;1341791797) [rec] ERROR: Error creating grammar
Any suggestions?

Thanks

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

Re: Spell a word

Post by support »

Hi,

Just a bit of clarification on the earlier example we posted.

Within spelling_grammar.php, you will want to reference the full URL of where word_list.txt exists. For example:

Code: Select all

<?php
header('Content-type: text/xml');
echo '<?xml version="1.0"?>';
?>

<grammar root="spelling" mode="voice">
  <rule id="spelling">
    <item>
      <ruleref uri="builtin:grammar/alphanum?entries=http://myserver.com/code_examples/word_list.txt"/>
    </item>
  </rule>
</grammar>
Hope this helps.

Regards,
Plum Support

goochalba
Posts: 18
Joined: Wed Jun 13, 2012 9:01 pm

Re: Spell a word

Post by goochalba »

thanks I will try this out

goochalba
Posts: 18
Joined: Wed Jun 13, 2012 9:01 pm

Re: Spell a word

Post by goochalba »

Hi,

I am still getting the same error when I try this...

Code: Select all

ed 11 Jul 2012 07:59:59.0454 PM EDT (000001;043;1342050844) [vxi] EVENT: DocumentParser::FetchDocument(http://ec2-user@174.129.240.84:8999/spell.vxml)
Wed 11 Jul 2012 07:59:59.0454 PM EDT (000001;043;1342050844) [vxi] EVENT: Cache Hit: http://ec2-user@174.129.240.84:8999/spell.vxml
Wed 11 Jul 2012 07:59:59.0456 PM EDT (000001;043;1342050844) [rec] EVENT: Cache Hit: http://ec2-user@174.129.240.84:8999/spelling_grammar.php
Wed 11 Jul 2012 07:59:59.0458 PM EDT (000001;043;1342050844) [rec] ERROR: Error creating grammar
here is my code

Code: Select all

<?php
header('Content-type: text/xml');
echo '<?xml version="1.0"?>';
?>

<grammar root="spelling" mode="voice">
  <rule id="spelling">
    <ruleref uri="builtin:grammar/alphanum?entries=http://<server:port>/word_list.txt"/>
  </rule>
</grammar>
Thanks
Mike

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

Re: Spell a word

Post by support »

Hi,

Would you be able to provide us with the code snippet you are using to generate this error? The following code that we are using works for us:

spelling_example.php:

Code: Select all

<?php
header("Content-type: text/xml");
echo("<?xml version=\"1.0\"?>\n");
?>
<vxml version="2.0">
<form>
  <field>
    <property name="sensitivity" value="0.2"/>
    <property name="confidencelevel" value="0.75"/>
    <grammar src="spelling_grammar.php" type="application/srgs+xml"/>
    <prompt>Spell the word example.</prompt>
    <filled>You spelled example correctly.</filled>
  </field>
</form>
</vxml>
spelling_grammar.php:

Code: Select all

<?php
header('Content-type: text/xml');
echo '<?xml version="1.0"?>';
?>

<grammar root="spelling" mode="voice">
  <rule id="spelling">
    <item>
      <ruleref uri="builtin:grammar/alphanum?entries=http://myserver.com/code_examples/word_list.txt"/>
    </item>
  </rule>
</grammar>
word_list.txt:

Code: Select all

example
Hope this helps.

Regards,
Plum Support

goochalba
Posts: 18
Joined: Wed Jun 13, 2012 9:01 pm

Re: Spell a word

Post by goochalba »

Hi,

Sorry I finally realized what was wrong. I am using Tomcat and JSPs to serve up my vxml.
So I switched the php page to a JSP and everything is great.

Thanks so much for your help and sorry for the confusion
Mike

goochalba
Posts: 18
Joined: Wed Jun 13, 2012 9:01 pm

Re: Spell a word

Post by goochalba »

Hi,

One last question you don't mind. I am trying to give a prompt if they spell the word incorrectly. So I have been trying

Code: Select all

<vxml version="2.0">
<form>
  <field name="word" type="alphanum">
    <property name="sensitivity" value="0.2"/>
    <property name="confidencelevel" value="0.75"/>
    <grammar src="spelling_grammar.jsp" type="application/srgs+xml"/>
    <prompt>Spell the word example.</prompt>
    <filled>
      <if conf="word===example">
        <prompt>
          You spelled example correctly.
        </prompt>
      <else/>
        <prompt>
          You have spelled example incorrectly
        </prompt>
      </if>
    </filled>
  </field>
</form>
</vxml>
But doesnt seem to work correctly is there a way to do this?

Thanks!

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

Re: Spell a word

Post by support »

Hi Mike,

Your spelling_grammar.jsp will determine if the user has spelled the word correctly. There's no need to use another <if> tag to check. If the user spells incorrectly, a nomatch event will be thrown, and you can play your error message then. Here is an example:

Code: Select all

<vxml version="2.0">
<form>
  <field name="word" type="alphanum">
    <property name="sensitivity" value="0.2"/>
    <property name="confidencelevel" value="0.75"/>
    <grammar src="spelling_grammar.jsp" type="application/srgs+xml"/>
    <prompt>Spell the word example.</prompt>
    <filled>
        <prompt>
          You spelled example correctly.
        </prompt>
    </filled>
    <nomatch>
	  You have spelled example incorrectly
    </nomatch>
  </field>
</form>
</vxml>
For more information on error handling, please take a look at the VXML documentation: http://www.plumvoice.com/docs/dev/voicexml:tags:nomatch

Regards,
Plum Support

goochalba
Posts: 18
Joined: Wed Jun 13, 2012 9:01 pm

Re: Spell a word

Post by goochalba »

Perfect! Thanks so much for all of your help!

goochalba
Posts: 18
Joined: Wed Jun 13, 2012 9:01 pm

Re: Spell a word

Post by goochalba »

Hi,

Okay so if I spell example incorrectly it just keeps saying

"Sorry I didn't understand you"

Thanks
Mike

Post Reply