VoiceRecResultList

Metreos.Types.VoiceRec.VoiceRecResultList

Summary

The VoiceRecResultList type parses the XML result from the VoiceRecognition_Complete event parameter VR_XMLResult and provides a simpler set of methods and properties for accessing the data.

Usage

VoiceRecResultList provides utilities to help developers quickly access the results of a VoiceRecognition action. This type contains a public member, named ResultList, which is a collection of VoiceRecResult types. Each VoiceRecResult type is a match returned by the Nuance OSR server, with an accompanying score, meaning, and interpretation.

To initialize a VoiceRecResultList variable with the XML data from a VoiceRecognition_Complete event, set the InitializeWith property of a variable in the event handler to the event parameter VR_XMLResult.

Example 37.1. Parsing the results of VoiceRecResults


public static string Execute(Metreos.Types.VoiceRec.VoiceRecResultList results, LogWriter log)
{
    // results.ResultList can be null even in a good voice recognition attempt.   It may mean that there were no matches at all.
    if(results != null && results.ResultList != null)
    {
        foreach(Metreos.Types.VoiceRec.VoiceRecResult result in results.ResultList)
        {
            int score = result.Score;
            string meaning = result.Meaning;
            string interpretation = result.Interpretation;

            log.Write(TraceLevel.Info, "Score: {0}, Meaning: {1}, Interpretation: {2}", score, meaning, interpretation);

            // application specific parsing would go here, in this example...
        }
    }

    return String.Empty;
}


Remarks

Always set the DefaultValue to some value (the specific value does not matter; it can be '-1', 'a', 'NULL'; whatever you prefer), to deal gracefully with the case that VR_XMLResult is not available in the event. You can know in your script when VR_XMLResult is not specified in the event if the ResultList property is null.

Parseable Inputs
.NET TypeDescription
stringTakes the XML result string from a VoiceRecognition action, parses and builds a ResultList object.

No Public Methods

Accessible Public Properties
Property Name.NET TypeDescription
ResultListMetreos.Types.VoiceRec.ResultListA collection of VoiceRecResult types. This can be null in the case that no matches were made at all, so be careful and always check for that if parsing manually in code.