Application scope
The application scope contains variables that are shared across an entire application. An application variable state is reset each time the root document explicitly transitions to itself. See the VoiceXML Version 2.0 Specification for details.
application.lastresult$
Shadow variable application.lastresult$ exposes the results of the current recognition. The results are structured as an array of interpretations. The size of this array is limited by the maximum value of the maxnbest or property. For convenience, the first element in the array is aliased to the top-level, for example, lastresult$[0] is the same as lastresult$. The recognition results expose the read-only properties described in the following table.
|
Property |
Description |
|---|---|
|
confidence |
The confidence level in the recognized result from 0.0 -1.0. A value of 0.0 indicates minimum confidence, and a value of 1.0 indicates maximum confidence. |
|
inputmode |
The mode in which user input was provided (dtmf or voice). |
|
interpretation |
The interpretation of the last utterance, for example, a scalar value when using built-in grammars or a set of key-value pairs. |
|
markname The markname and marktime properties are only set when the application.lastresult$ object is assigned (for example a <link> is matched) and a <mark> has been executed. (optional) |
The name of the mark last executed by the SSML processor before barge-in occurred or the end of audio playback occurred. If no mark was executed, this variable is undefined. |
|
marktime (optional) |
The number of milliseconds that elapsed since the last mark was executed by the SSML processor until barge-in occurred or the end of audio playback occurred. If no mark was executed, this variable is undefined. |
|
The variable that stores a reference to the recording. Undefined if no audio is collected. You must set the recordutterance property to true to have utterance recording saved in application.lastresult$. Note: The utterance recording is also saved if you have enabled nuance.exposerecording, a Nuance extension implemented for VoiceXML 2.0. See the VoiceXML 2.1 Specification for more information about recording user utterances during recognition. |
|
|
The size of the utterance recording in bytes. Undefined if no audio is collected. The recordutterance property must be set to true to have the utterance recording saved in application.lastresult$. See the VoiceXML 2.1 Specification at |
|
|
Implemented in VoiceXML 2.1. The duration of the utterance recording in milliseconds. Undefined if no audio is collected. The recordutterance property must be set to true to have the utterance recording saved in application.lastresult$. See the VoiceXML 2.1 Specification at |
|
|
utterance |
The raw string of words that was recognized. |
The following script writes all the filled slots for the first interpretation to the console:
<script>
<![CDATA[ var interp = ""; for( var prop in
lastresult$.interpretation ) interp += prop + "=" +
lastresult$.interpretation[prop] + " ";
if( interp == "" )
{// The interpretation was a scalar value, such as a
builtin grammar, so just add it.
interp = lastresult$.interpretation;
}
out.println( "Interpretation was: " + interp );
// or browser.log( "trace:?level=D_INFO", "Interpretation was:
" + interp );]]>
</script>
Note: As mentioned above, the markname and marktime properties are only set when the application.lastresult$ object is assigned (for example, a <link> is matched) and a <mark> has been executed. See for more information.