Volume 2, Issue 3 - April/May 2002

N-best recognition results

By Rob Marchand

(Continued from Part 1)

When the VoiceXML interpreter makes these available to your application, you should note that they will be sorted by confidence, and then by grammar priority when there is a tie. An interesting thing to keep in mind is that even when <nomatch> is generated, application$.lastresult will be populated with any results returned by the recognizer. This can be useful in making your application more intelligent when responding to problems.

In the example below, we've extended our field such that we want up to five results to be returned. In the <filled> block, we then say how many we received, and then use a script to construct a prompt which includes the actual confidence and utterances that we recognized. The grammar is somewhat contrived to give us a better chance at getting more than one result.

<?xml version = "1.0"?>
<vxml version = "2.0">
    function dumpResults(){
        var result = "";
        for ( var i = 0; i < application.lastresult$.length; i++ ){
            result += "Result " + String(i+1) + ": ";
            result += "Confidence is " + application.lastresult$[i].confidence + ". ";
            result += "Utterance  is " + application.lastresult$[i].utterance + ". ";
        return result;
                Welcome to the Voice X M L review pizza franchise
        <field name = "orderItem">
            <property name = "maxnbest" value = "5" />
                pizza | pizzas | pie | drinks | salad | wings
            <grammar mode = "dtmf">
                1 {pizza} | 2 {drinks} | 3 {salad} | 4 {wings}
                What would you like to order?
We have pizza, drinks, salad or wings. </prompt>
<noinput> Say pizza, drinks, salad, or wings. </noinput> <nomatch> You can say pizza, drinks, salad, or wings. </nomatch> <filled> You said <value expr = "orderItem" /> The recognizer returned <value expr = "application.lastresult$.length" /> results. <value expr = "dumpResults()" /> </filled> </field> </form> </vxml>


Most speech recognizers support N-best list generation, although they may have particular restrictions associated with them. Make sure that you consult vendor documentation. N-best support is also required by the VoiceXML 2.0 draft specification, so you might want to have a look at that document as well.

What's Next?

If there are particular things you'd like to see covered in a future First Words column, drop me a line at rob@voicegenie.com, and I'll try to write about it.

back to the top


Copyright © 2001-2002 VoiceXML Forum. All rights reserved.
The VoiceXML Forum is a program of the
IEEE Industry Standards and Technology Organization (IEEE-ISTO).