VoiceXML 2.1 Development GuideHome  |  Frameset Home

  tutorial Caller ID-Called ID  |  TOC  |  tutorial JavaScript and VXML  

Tutorial: DTMF Recognition

This Lesson is based on the things you accomplished in Lessons 1, 2 and 3. If you have not completed those tutorials, you'll need to go through them first.

In this Lesson, we will:

Step 1: creating our initial VoiceXML structure

Yes, that's right. From our previous tutorials, we now recognize the following structure as a normal starting point:


<?xml version="1.0" encoding="UTF-8"?>
<vxml version = "2.1">
<meta name="maintainer" content="your_email_address@wherever.com"/>
</vxml>


Step 2: writing the prompts


The <form> and <field> tags should also be familiar by now. Giving <form> an "id" attribute will allow us to use it like an anchor tag later. The <noinput> and <nomatch> will allow us to trap, and programmatically handle, when a caller says nothing at all, or gives an answer that the does not match a defined grammar utterance.


<?xml version="1.0" encoding="UTF-8"?>
<vxml version = "2.1">
<meta name="maintainer" content="your_email_address@wherever.com"/>

  <form id="guessNumber">
    <field name="guess">
    <prompt>
      Guess what the computer is thinking! Pick a number between 0 and 9.
    </prompt>

    <noinput>
      <prompt>
        I did not hear you. Please try again.
      </prompt>
      <reprompt/>
    </noinput>

    <nomatch>
      <prompt>
        Is that a number? Please try again.
      </prompt>
      <reprompt/>
    </nomatch>

    </field>
  </form>


A few notes about the additions above: We have defined ahandler, as promised, for both the <noinput> and <nomatch> events that could occur during a voice dialog. W e also threw in the <reprompt> element for good measure. As it's name implies, this is simply a 'shortcut element' that will regurgitate the last audio file, (or in this case), TTS  <prompt> that was played to the caller.

Now that we have detailed step 1, our document is ready to recognize the caller's input. So we will need to create an inline grammar, and create an inline dtmf recognition entry.


Step 3: creating our grammar files


In order for a grammar to understand DTMF entries, as well as the spoken input of numbers, we will want to write a grammar for the spoken input, and  keypress entries. Our DTMF portion will look like this:

    <grammar type="text/gsl">
      [dtmf-1 dtmf-2 dtmf-3 dtmf-4 dtmf-5 dtmf-6 dtmf-6 dtmf-7 dtmf-8 dtmf-9 dtmf-0]
    <grammar/>

And our inline grammar will look like this:

    <grammar type="text/gsl">
      [one two three four five six seven eight nine zero]
    </grammar>


Now our file should look like this:


<?xml version="1.0" encoding="UTF-8"?>
<vxml version = "2.1">
<meta name="maintainer" content="your_email_address@wherever.com"/>

<form id="guessNumber">
    <field name="guess">

    <grammar type="text/gsl">
        [one two three four five six seven eight nine]
    </grammar>

    <grammar type="text/gsl">
      [dtmf-1 dtmf-2 dtmf-3 dtmf-4 dtmf-5 dtmf-6 dtmf-6 dtmf-7 dtmf-8 dtmf-9]
    </grammar>


    <prompt>
      Guess what the computer is thinking! Pick a number between 0 and 9.
    </prompt>

    <noinput>
      <prompt>
        I did not hear you. Please try again.
      </prompt>
      <reprompt/>
    </noinput>

    <nomatch>
      <prompt>
        Is that a number? Please try again.
      </prompt>
      <reprompt/>
    </nomatch>

    </field>
  </form>


Step 4: incorporating grammar values into our application

Should the caller successfully enter a number, what to do, what to do? We might start by repeating the number they entered. Then we could compliment them on their ability to psychically connect with a computer:


    <filled namelist="guess" mode="all">
      <prompt>
        You said <value expr="guess" />. Your brain is enormous.
      </prompt>
      <goto next="#playAgain" />
    </filled>


And that's all of the pieces we need to recognize DTMF, or voice input.


Step 5: putting it all together

That was fun, so why stop there? We're going to add another <form> to give callers the chance to guess again. This time, we're looking for a simple "yes" or "no" answer. If the caller answers "yes" we go back to the previous <form> and start over. If they answer "no" , then we can end the call.



  <form id="playAgain">
    <field name="confirm" slot="confirm">
      <prompt bargein="false">
        Do you want to play again?
      </prompt>
    </field>

    <filled namelist="confirm" mode="all">
      <if cond="confirm == 'yes'">
        <goto next="#guessNumber" />
      <elseif cond="confirm == 'no'" />
      <prompt>
        Thank you! Goodbye!
      </prompt>
      </if>
    </filled>
  </form>



All we need now is a grammar to fill in the 'confirm' slot in our document. Let's try writing a grammar for this:


  <grammar type="text/gsl">
    <![CDATA[[
        [yes]    {  <confirm  "yes"> }
        [no]    {  <confirm  "no">  }
    ]]]>
  </grammar>


Our script is now complete. The VoiceXML document, in it's entirety, should look like this:


<?xml version="1.0" encoding="UTF-8"?>
<vxml version = "2.1" >
<meta name="maintainer" content="your_email_address@wherever.com"/>

  <form id="guessNumber">
    <field name="guess">
    <grammar type="text/gsl">
        [one two three four five six seven eight nine zero] 
      </grammar>
    <grammar type="text/gsl">
      [dtmf-1 dtmf-2 dtmf-3 dtmf-4 dtmf-5 dtmf-6 dtmf-6 dtmf-7 dtmf-8 dtmf-9 dtmf-0]
    </grammar>

    <prompt>
      Guess what the computer is thinking! Pick a number between 0 and 9.
    </prompt>

    <noinput>
      <prompt>
        I did not hear you. Please try again.
      </prompt>
      <reprompt/>
    </noinput>

    <nomatch>
      <prompt>
        Is that a number? Please try again.
      </prompt>
      <reprompt/>
    </nomatch>

    </field>

    <filled namelist="guess" mode="all">
      <prompt>
        You said <value expr="guess" />. Your brain is enormous.
      </prompt>
      <goto next="#playAgain" />
    </filled>

  </form>

  <form id="playAgain">
    <field name="confirm" slot="confirm">
      <grammar type="text/gsl">
      <![CDATA[[
        [yes]    {  <confirm  "yes"> }
        [no]    {  <confirm  "no">  }
        ]]]>
      </grammar>
      <prompt bargein="false">
        Do you want to play again?
      </prompt>
    </field>
    <filled namelist="confirm" mode="all">
      <if cond="confirm == 'yes'">
        <goto next="#guessNumber" />
      <elseif cond="confirm == 'no'" />
      <prompt>
        Thank you! Goodbye!
      </prompt>
      </if>
    </filled>
  </form>
</vxml>


Step 6: upload, and try it out

All that remains now is to upload your new VoiceXML application. We might save these files as http://www.myserver.com/helloworld/dtmf.xml and http://www.myserver.com/helloworld/dtmf.grammar

Now you can provision a number to your simple voice and DTMF recognition application and call the associated number to hear the results.


Download the Code!

  Source code


What we covered:




  ANNOTATIONS: EXISTING POSTS
dodgly
1/28/2005 4:06 AM (EST)
There is a typographical error in the final example code.

On line 23 there is an open <prompt> tag but it should be a closed </prompt> tag.  This will cause the application to not parse.
MattHenry
1/28/2005 11:56 AM (EST)
Thanks for catching that typo for me; i have this corrected, (in both spots that it was present in), which will be publicly fixed upon the next document Build update.

~Matt
sonya
4/7/2005 4:09 PM (EDT)
how about several digits 'please enter your pin'
Michael.Book
4/7/2005 5:55 PM (EDT)
Hello "sonya,"

To capture multiple DTMF digits (or to capture multiple digits via voice for that matter) I would simply use the built-in field type "digits".  For more information on field types, check out: 

http://docs.voxeo.com/voicexml/2.0/field.htm
..and
http://docs.voxeo.com/voicexml/2.0/gslbuiltins.htm#start

I hope this helps...


Have Fun,

~ Michael
marmor
5/23/2005 11:35 AM (EDT)
You refer to separate grammar files here in the instructions, but then include the grammar we created inline within the main application.  So how do we reference an external grammar file?  Also there is an English mistake "ready for the to recognize".  -MM
JimMurphy
5/23/2005 11:44 AM (EDT)
Marmor-

There is an example of how to use external GSL grammars/subgrammars at:
http://www.voicexmlguide.com/gslsubg.htm

There is also an example of how to use external grXML grammars/subgrammars at: http://www.voicexmlguide.com/grxmlsubg.htm

I hope that helps. If not, please let us know.

-Jim
dwburhans
8/17/2005 2:25 PM (EDT)
Change
  our document is ready for the to recognize the caller's input.
in the last paragraph of step 2 to
  our document is ready to recognize the caller's input.
MattHenry
8/17/2005 3:16 PM (EDT)
David,

Thanks for catching that; I have this corrected in the internal build of the docs, which will be posted live sometime in the next 10 days.


~Matt
mithhilarora
10/28/2005 3:16 AM (EDT)
Shouldn't there be

<exit/>

after the

Thank you! Goodbye!
</prompt>
MattHenry
10/28/2005 12:21 PM (EDT)
Hi there,

At this particular point in the application, the FIA is at the end of it's execution, so the application will inherently exit. However, smart coders, (read: coders other than myself, ha-ha), like to explicitly terminate application execution as a general rule, as this corresponds with their coding ethics. But again, this is not entirely required.

~Matt


jagadishsuri
4/20/2006 2:11 PM (EDT)
hi
The dtmf input is fine but i need to understand how will the application which is serving the vxml file get the input the person enters on the phone with the help of numbers.i need to process that input and serve another vxml file based on the input.
MattHenry
4/20/2006 2:44 PM (EDT)


Hi there,

I'm not totally clear on what it is that you are asking here. The user input in this example is stored within the variable called "guess":

<value expr="guess" />

If we need to process based on user input, then you might do something like this:

<filled>
<if cond="guess == '1'">
  <goto next="Input_One.xml"/>
<elseif cond="guess == '2'"/>
  <goto next="Input_Two.xml"/>
<!-- etc -->
</if>
</filled>

Does this answer your question? If not, please provide us with additional details on exactly what it is that you are looking to do, and we would be glad to help.

Regards,

~Matthew Henry
jagadishsuri
4/21/2006 12:06 AM (EDT)
hi
nice to see ur response
but u havent completly got my doubt.My doubt is for suppose if we a webapplication running some where and we want to send the values entered in the phone by the person to whom we have called to that web application which is external to the IVR.Like if he enters his name in the phone and we want to send that name to the webapplication just like hmtl form submittion with the from elements and its values.how do we do that .

if iam still not clear please feel free,iam ready to explain it in more detail.

thanking you

regards
jagadish
MattHenry
4/21/2006 1:06 PM (EDT)

I think I understand what you are asking, which is easily answered. How you send these values to your webserver, is by invoking the <submit> tag, and specifying your VXML variable in the namelist attribute:

<submit next="http://myWebserver.com/postProcess.jsp" namelist="guess"/>

And how do we access this variable in in the destination page? Check the below link for details:

http://docs.voxeo.com/voicexml/2.0/qs_vars.htm

~Matthew Henry
jagadishsuri
4/23/2006 1:21 PM (EDT)
hi

I have another question,i need to take both characters and digits as input in the form of DTMF input can u help.For example i asked the caller to enter the registration number and it is like this (we234rr).How can we take both characters and numbers as DTMF input.Both characters and digits for a single input variable.ask me if iam not clear.

thanking you
regards
jagadish
jagadishsuri
4/23/2006 1:27 PM (EDT)
hi

I have another question,i need to take both characters and digits as input in the form of DTMF input can u help.For example i asked the caller to enter the registration number and it is like this (we234rr).How can we take both characters and numbers as DTMF input.Both characters and digits for a single input variable.ask me if iam not clear.

thanking you
regards
jagadish
MattHenry
4/24/2006 1:58 PM (EDT)

Hi there,

I have to caution you that arbitrary alphanumeric recognition is one of the most difficult things to accurately capture. If you do a search on our user forums for 'alpha' and 'alphanumeric', you'll doubtlessly find several instances of my 'alphanum manifesto' that explains why this is so difficult.

This being said, I do have some code that you may find useful, (originally designed to be used for Canadian zip codes), but I have to be very candid in the fact that all bets are off when it comes to accuracy. However, with some careful prompting, tuning, n-best post processing, and narrowing down of the alpha characters allowed, (if possible), you might be able to make this work for you.

Some useful bakground links/tutorials are also included, as they bear on this topic:

http://docs.voxeo.com/voicexml/2.0/t_14_mot.htm
http://docs.voxeo.com/voicexml/2.0/t_20.htm
http://docs.voxeo.com/voicexml/2.0/w3cprops.htm


Best of luck!

~Matthew Henry

jagadishsuri
4/25/2006 6:20 AM (EDT)
hi

iam happy for ur response so far.the docs here are very good but i have a small problem here a peculiar one.
I need to enter the text with the help of DTMF input with out using voice.i mean charaters.like if we ask the caller to enter his first name and we should take the name into a variable . while the caller types the characters in the key pad .can u help.

i have done a lot of googling in net and also in voxeo but in vain.
its very important for our application.

thanking you
regards
jagadishsuri
MattHenry
4/25/2006 2:19 PM (EDT)


Hi again,

If you are requiring your callers to enter in a string of digits to be converted to alpha characters, I have to be very up front: There isn't really an elegant way to do this that will be user-friendly. In short, I advise against it.

However, I suppose if you really wanted to, you could create a grammar file that corresponded to the numeral/alpha characters on a standard phone:

[(dtmf-2)] = 'a'
[(dtmf-2 dtmf-2)] = 'b'
[(dtmf-2 dtmf-2 dtmf-2)] = 'c'
(etc)

Good luck,

~Matthew Henry
jagadishsuri
4/26/2006 4:45 AM (EDT)
hi
thanks for that .This would solve the problem to a certain extent.
but always looking for a better one.
thanks for your time.
marisman
5/24/2006 11:51 AM (EDT)
How would I disable speech input if I only want a DTMF entry?
mikethompson
5/24/2006 12:00 PM (EDT)
Hello Marisman,

There is actually a handy property that you can invoke from multiple scopes in your application.  That property is known as "inputmodes" and it allows you to turn off Voice recognition (or dtmf recognition) at will.  Here is an example:

<vxml>

<property name="inputmodes" value="dtmf"/>

<form>
  <field>
    ....
  </field>
</form>


</vxml>

This will disable Voice recognition across the entire document.  If you would like to turn voice back on, simply use a value of "dtmf voice" and "voice" for simply voice.

Hope this helps,
Mike Thompson
Voxeo Extreme Support
jassy
7/13/2006 6:43 AM (EDT)
Hi,

First of all, thanks a lot for being so helpful. You guyz are really doing a great job. Thanks for your quick responses. Coming to my doubt, In our application, we need to enter text through DTMF. A few months back I saw someone came up with a similar doubt. I saw your suggession.

[(dtmf-2)] = 'a'
[(dtmf-2 dtmf-2)] = 'b'
[(dtmf-2 dtmf-2 dtmf-2)] = 'c' .

But our requirement is :
If I want to enter "Main"- I jus pres dtmf-6; dtmf-2; dtmf-4; dtmf-6
How to accomplish this? How to write specifc grammars for this?
Please clarify.

Thanks,
Jassy
mikethompson
7/13/2006 12:42 PM (EDT)
Greeting Jassy,

What you are trying to accomplish is going to be a *huge* task, as you will need to use very extensive logic to determine the correct word from the user.  If you have a pre-determined set of commands that you *know* the customer will be entering, then you could easily compare the dtmf combination to a list of results you are expecting.  For example, a user enters (dtmf-4 dtmf6 dtmf-6 dtmf-3), one possible result would be 'G O O D'.  So, if you have some idea of what the user will be entering, it won't be too difficult to tell which command they are entering.  You will need to use either client side ECMA script or server-side logic to determine the correct results.  Obviously this task will be much more difficult if the set of possible results (such as names) is enormous. 

This should give you a good idea of how to get started on building your advanced grammar.  Let us know if you have any more questions...

Regards,
Mike Thompson
Voxeo Corporation
tornblad
7/16/2006 5:09 PM (EDT)
Hi there,

thanks for a great VXML site - I wouldn't have thought it would be this easy to get started with VXML.

Using DTMF is pretty easy, but how do I allow users to enter numeric data using DTMF? For my app, I need something like this:

"Welcome! Please dial your membership number followed by the pound key."
- User dials his/her membership number

- Anders Tornblad, Sweden
mikethompson
7/16/2006 5:39 PM (EDT)
Anders,

It is actually quite simple to do this by using the <field> element with the integration of the type="number" attribute.  For more information on this, go here:

http://docs.voxeo.com/voicexml/2.0/gslbuiltins.htm
http://docs.voxeo.com/voicexml/2.0/dtmfreco.htm

Hope this helps,
Mike Thompson
Voxeo Corporation
jassy
7/17/2006 2:08 AM (EDT)
Hi Mike,

Thanks for the idea. I will start with that. If any doubt further, I wil approach you back. Thanks for your response.

Thanks,
Jassy.
tornblad
7/17/2006 7:56 AM (EDT)
Thanks Mike,

I had missed the built-in GSL grammars. That part of my app works like a charm now. The user is asked for his/her membership id and types it in. The id gets sent to my server through a php script, that checks the id for validity and outputs vxml to tell the user to enter his/her password, or that the membership id is faulty!

It just works! =)

/ Anders of Sweden
sidvoxeo
7/17/2006 11:17 AM (EDT)
Anders,
We are glad that the app works and we could assist you with all the questions.
I am closing this ticket, feel free to reopen it if you have any other questions.
Thanks
Sid
ynkrish
2/1/2007 1:12 AM (EST)
hi,

The information is provided in a very concise and neat fashion :), Thanks to Voxeo for a great site..

A few small typos :)

1) The first vxml in step 2 is missing a end tag </vxml>
2) The dtmf grammer file has dtmf-6 repeated.
3) The vxml example in step3 has the dtmf-0 missing.

Cheers
krish
rampageido
6/26/2007 10:47 AM (EDT)
Hi

This is an extremely great resource! Good effort and great job done!

I'd appreciate some help trying to attain the following:

"Please enter your 4-6 digit pin number followed by the pound key. If you have forgotten your pin, please press '1'. If you would like to change your pin, please press '2'."

So far i have the following voicexml:
<field name="Select3">
<property name="termchar" value=""/>
<!--<property name="interdigittimeout" value="0s"/>-->
<grammar mode="dtmf">
  $rule = 1 | 2;
</grammar>
<prompt>
Please enter your 4-6 digit pin number followed by the pound key. If you have forgotten your pin, please press '1'. If you would like to change your pin, please press '2'."
</prompt>
<filled>
Debug Selected value is <value expr="Select3"/>
  <if cond="Select3=='1'">
    <goto expr="paths.vxml('ManagePin')"/>
  <elseif cond="Select3=='2'"/>
    <goto next="#Get_Pin"/>
    </if>
</filled>
<catch event="repeat">
  <assign name="Select3" expr="undefined"/>
  <reprompt/>
</catch>
<catch event="noinput">
<if cond="attempt >= maxAttempts">
  <throw event="too_many_attempts"/>
<else/>
I\'m sorry this is not a valid entry.
<assign name="attempt" expr="attempt + 1"/>
</if>
<reprompt/>
</catch>
<catch event="nomatch">
<if cond="attempt >= maxAttempts">
  <throw event="too_many_attempts"/>
<else/>
  <goto next="#Get_Pin"/>
<assign name="attempt" expr="attempt + 1"/>
</if>
<reprompt/>
</catch>
</field>

My problem is that if a user has a pin starting 1 or 2 , the menu option takes precedence. How can i enhance the grammar to include 1,2 and a valid 4 to 6 digit pin. Please advice
Thanks
Ram
mjolley
7/11/2007 1:43 PM (EDT)
Step 3 seems to have a typo:

<grammar/> rather than </grammar>
equalsatty
10/10/2007 7:21 AM (EDT)
is there a way to send an dtmf response from vxml to a ccxml initiated call.
i mean ccxml app A tries to call vxml application B and plays another vxml C to B . now B shud give back a dtmf digit '3', which is handled in C.

-Satty
JOHNCL
1/10/2008 6:50 AM (EST)
Is there a way to programatically insert a 'beep tone' to indicate to the caller that the application has begun waiting for dtmf input? Similar to setting the beep attribute to true in the record element.

Thanks, JohnCl
mikethompson
1/10/2008 12:56 PM (EST)
Hi John,

There is not an attribute for a given field which will play a beep when the recognizer is ready for input.  However, if this is what you want to do, you can always play a beep.wav directly below the field like so:


<field name="whatever">

<!--Put your grammar here-->

<prompt>
  <audio src="beep.wav"/>
</prompt>

  <filled>
    <!--Whatever you want here-->
  </filled>
</field>

For your convenience, I have attached a beep audio file to this ticket for you to try out. :)

Best,
Mike Thompson
Voxeo Corporation
JOHNCL
1/15/2008 6:36 AM (EST)
Many thanks for the speedy response Mike!
Bertrand
2/9/2008 7:08 AM (EST)
Hi,

Using your example, I am trying to tweak the playAgain form so that the application can accept Yes/No OR respectiveley dtmp-1/dtmf-2.
In order to do that, I added the following grammar

    <grammar type="text/gsl">
      [dtmf-1 dtmf-2]
    </grammar>

to the playAgaiin form.
Alas it doesn't work...
I' sure it's possible to accept Yes or dtmf-1 as both possible answers.
How can that be done?
Thanks
Bertrand
2/10/2008 11:46 AM (EST)
Hi,

Please ignore the above question.
I found the way to do it and derived the example below from your "Pick a number" example.
In this version, the number can be provided via voice or dtmf.

Thanks,
Bertrand

<?xml version="1.0" encoding="UTF-8"?>
<vxml version = "2.1" >
<meta name="maintainer" content="your_email_address@wherever.com"/>

  <form id="guessNumber">
    <field name="guess" slot="guess">
    <grammar type="text/gsl">
      <![CDATA[[
        [one dtmf-1]    { <guess  "one">  }
        [two dtmf-2]    { <guess  "two">  }
        [three dtmf-3]  { <guess  "three"> }
        [four dtmf-4]  { <guess  "four">  }
[five dtmf-5]  { <guess  "five">  }
        [six dtmf-6]    { <guess  "six">  }
        [seven dtmf-7]  { <guess  "seven"> }
        [eight dtmf-8]  { <guess  "eight"> }
[nine dtmf-9]  { <guess  "nine">  }
[zero dtmf-0]  { <guess  "zero">  }
        ]]]>
      </grammar>

    <prompt>
      Guess what the computer is thinking! Pick a number between 0 and 9.
    </prompt>

    <noinput>
      <prompt>
        I did not hear you. Please try again.
      </prompt>
      <reprompt/>
    </noinput>

    <nomatch>
      <prompt>
        Is that a number? Please try again.
      </prompt>
      <reprompt/>
    </nomatch>

    </field>

    <filled namelist="guess" mode="all">
      <prompt>
        You said <value expr="guess" />. Your brain is enormous.
      </prompt>
      <goto next="#playAgain" />
    </filled>

  </form>

  <form id="playAgain">
    <field name="confirm" slot="confirm">
      <grammar type="text/gsl">
      <![CDATA[[
        [yes dtmf-1]  { <confirm  "yes"> }
        [no dtmf-2]    { <confirm  "no">  }
        ]]]>
      </grammar>
      <prompt bargein="false">
        Do you want to play again?
      </prompt>
    </field>
    <filled namelist="confirm" mode="all">
      <if cond="confirm == 'yes'">
        <goto next="#guessNumber" />
      <elseif cond="confirm == 'no'" />
      <prompt>
        Thank you! Goodbye!
      </prompt>
      </if>
    </filled>
  </form>
</vxml>
mikejstein
3/17/2008 2:05 PM (EDT)
Can DTMF tones be part of a <link> structure?

Something like :
<link next="SOMEPAGE">
  <grammar type="text/gsl">[dtmf-star]</grammar>
</link>

I've been trying that in my program, but it's not jumping to the link.

Thanks,
Mike

MattHenry
3/17/2008 2:09 PM (EDT)


Hi Mike,

This is totally legal, and should work fine: As long as you have an active recognition field in the <form> where you are trying to kick off the document/global-scoped link.

To explain, this wouldn't work at all, as the interpreter isn't listening for input:

<?xml version="1.0" encoding="UTF-8"?>
<vxml version = "2.1">

<link next="newPage.xml">
  <grammar type="text/gsl">[dtmf-star]</grammar>
</link>

<form>
<block>
  <audio src="someFile.wav"/>
</block>
</form>
</vxml>

~Matt
DeKey
4/8/2008 11:00 AM (EDT)
hi,
is there an easy way for the user to enter text?

i would like to achieve the following:
-hello user, please enter your first name...
-(some dtmf by the user)
-your name is ____

i ve seen the suggestion above:

[(dtmf-2)] = 'a'
[(dtmf-2 dtmf-2)] = 'b'
[(dtmf-2 dtmf-2 dtmf-2)] = 'c'
(etc)

but that's for single characters only isn't it? i am interested in strings of characters...

is there an obvious way to do that? any suggestions?
mikethompson
4/8/2008 1:48 PM (EDT)
Hello,

There is a simple way to do this with GRXML grammars, while a GSL grammar would get a little sticky.  I happen to have some sample code already whipped up which I think you will find quite useful.  It uses grXML, which is quickly becoming the new standard for grammars.  It also uses SISR return syntax, making this grammar 100% W3C compliant.  Kindly take a look at the script attached, and let me know if you have any questions about it.  One other thing I should mention is the fact this grammar uses # to complete the alpha combination.  This being said, you'll need to modify the VXML termchar to something other than #, or simply change # to something like * in your grammar.

Best,
Mike Thompson
Voxeo Corporation
DeKey
4/9/2008 4:42 AM (EDT)
hello and thank you for replying,

How can I download the script you refer to?
Excuse my ignorance but I am new to this site and besides the sample code of this article (vxml_dtmf.zip) I don't see any other script attached...
In case there is a problem with the page, if you don't mind please send it to dkolia@hotmail.com

Thank you!
voxeojeff
4/9/2008 10:26 AM (EDT)
Hi DeKey,

My apologies, I do see the file attached however it is most likely not accessible through our documentation annotations.  I'll go ahead and open a private account ticket for you and attach it there.  If you have any questions, you may reply to the newly created ticket and we will be more than happy to assist. :-)

Best regards,

Jeff
dki123
10/2/2008 3:30 AM (EDT)
Hi,

Is there any simple way to identify whether the input taken is by DTMF or Voice?

Thanking you in advance.
voxeoJeffK
10/2/2008 3:42 AM (EDT)
Hi,

Yes, you would access that via lastresult$.inputmode. This variable will return the mode in which the utterance was entered; the only available values are 'voice' and 'dtmf'.

Regards,
Jeff K.
dki123
10/3/2008 7:04 AM (EDT)
Hi Jeff,

Thanks a lot for your reply. It helped me solve the problem.

I have another question to ask.

I want to use different grammars for Voice and dtmf in my field. Now if input is through voice, it should be checked against voice grammar and in case of dtmf, dtmf grammar should be checked.
e.g.

.....
.....
<field name="namedtmf" type="digits" slot="namedtmf">
      <prompt>
        Please speak or key in your name followed by pound key.
      </prompt>
<grammar src="boys_name.grammar#BOY_NAME" type="text/gsl"/>         
      <grammar  type="text/gsl" mode="dtmf">
<![CDATA[[
      [dtmf-2 dtmf-3 dtmf-4 dtmf-5 dtmf-6  dtmf-7 dtmf-8 dtmf-9]
]]]>
      </grammar>

....
....

If I speak one two three, then it should be compared against boys_name.grammar and not dtmf grammar. boys_name.grammar doesn't have value 'one two three', and hence it should fire <nomatch> event.
But here, my code doesn't seem to work in that way.
Please guide me on where I made mistake.

Thanking you...
voxeoJeffK
10/3/2008 7:25 AM (EDT)
Hi,

The problem is in the <field> element you have specified type="digits". That built-in grammar also accepts voice matches for numeric input. So it is matching spoken "one two three". If you remove that attribute a nomatch will be thrown.

hope that helps
Jeff K.
dki123
10/3/2008 8:39 AM (EDT)
Jeff,

Then it doesn't allow me to enter multiple digits. :-)
I need to take few digits to map it to the name(s).
dki123
10/6/2008 5:47 AM (EDT)
Hi voxeo team,

May I request you to have some comments on problem mentioned above?
Please let me if I m doing wrong somewhere.

Thanks.
voxeojeremyr
10/6/2008 5:54 AM (EDT)
Hi,

Because you are using the built in digits grammar it allows for both DTMF and voice.  So what you will want to do is not use the built in digits grammar and use this grammar instead:
[code]
<grammar xml:lang="en-us" version="1.0" xmlns="http://www.w3.org/2001/06/grammar" root="TOPLEVEL" mode="dtmf">

<rule id="TOPLEVEL">
  <tag> out.main = "" </tag>
  <item repeat="1-">
      <ruleref uri="#ALPHANUM"/>
      <tag> out.main = out.main + rules.ALPHANUM.slot </tag>
  </item>
  <item>#</item>
</rule>

<rule id="ALPHANUM" scope="public">
  <item>
        <one-of>
          <item> 1 <tag> out.slot=1 </tag></item>
          <item> 2 <tag> out.slot=2 </tag></item>
          <item> 3 <tag> out.slot=3 </tag></item>
          <item> 4 <tag> out.slot=4 </tag></item>
          <item> 5 <tag> out.slot=5 </tag></item>
          <item> 6 <tag> out.slot=6 </tag></item>
          <item> 7 <tag> out.slot=7 </tag></item>
          <item> 8 <tag> out.slot=8 </tag></item>
          <item> 9 <tag> out.slot=9 </tag></item>
          <item> 0 <tag> out.slot=0 </tag></item>
      </one-of>
  </item>
</rule>
</grammar> [/code]

You will want to change this line to the maximum number of digits that you will allow.
[code]
<item repeat="1-"> [/code]

Regards,
Jeremy Richmond
Voxeo Support
jananiskumar
11/19/2008 12:04 AM (EST)
Hi, I want to write a grammar that accepts a number with minimum length as 7, maxlength as 8.

I should also allow the caller to press 0. all the other inputs of length 1 other than 0 should be treated as no match.

Can you please help me how I could achieve this? I am able to do the first grammar but not the second part.

Thanks
J
voxeoJeffK
11/19/2008 12:32 AM (EST)
Hi,

You can use two different grammars. The builtin grammar works well for min:7-max:8, and then we can add another grammar for just zero:

  <field name="guess" type="digits?minlength=7;maxlength=8">
    <grammar type="text/gsl">
      [ dtmf-0 ]
    </grammar>

hope this helps,
Jeff K
MattHenry
11/19/2008 10:26 AM (EST)


As another suggestion, you might also try using a <link> grammar for your dtmf-0 input, if you intend for this particular grammar to be document/application scoped.

http://docs.voxeo.com/voicexml/2.0/link.htm

Cheers,

~Matt

login
  tutorial Caller ID-Called ID  |  TOC  |  tutorial JavaScript and VXML  

© 2008 Voxeo Corporation  |  Voxeo IVR  |  VoiceXML & CCXML IVR Developer Site