Using shadow variables

The result of executing a field item is stored in the field's name attribute; however, there may be occasions in which you need other types of information about the execution, such as the string of words recognized by the speech recognition engine. Shadow variables provide this type of information. Table 1 documents the VoiceXML browser's support for shadow variables.

Table 1. Shadow variables.

This table describes for each VoiceXML element with a shadow variable, the shadow variable, its description, and its implementation details.

Element Shadow variable Description Implementation details
<field> x$.asraudio An audio file of the words that were spoken by the caller while recognition was taking place. This is an extension to the VoiceXML 2.0 specification. See Recording user input during speech recognition for more information.
x$.confidence The recognition confidence level from the speech recognition engine. Supported as documented in VoiceXML 2.0.
x$.inputmode The input mode for a given utterance: voice or DTMF. Supported as documented in VoiceXML 2.0.
x$.interpretation An ECMAscript variable containing the interpretation. Supported as documented in VoiceXML 2.0.
x$.recording The variable that stores a reference to the recording, or undefined if no audio is collected. Supported as documented in VoiceXML 2.1.
x$.recordingduration The duration of the recording in milliseconds, or undefined if no audio is collected. Supported as documented in VoiceXML 2.1.
x$.recordingsize The size of the recording in bytes, or undefined if no audio is collected. Supported as documented in VoiceXML 2.1.
x$.utterance A string that represents the actual words that were recognized by the speech recognition engine. The actual value of the shadow variable is dependent on how the grammar was written.
<record> x$.confidence The confidence level for the utterance if the recording is terminated by speech recognition input.
Note: Terminating <record> using grammars is not supported, so the $.confidence value should never be set.
Supported as documented in VoiceXML 2.0.
x$.duration The duration of the recording. Supported as documented in VoiceXML 2.0.
x$.maxtime Indicates whether the recording was terminated because the maxtime duration was reached. Supported as documented in VoiceXML 2.0.
x$.size The size of the recording, in bytes. Supported as documented in VoiceXML 2.0.
x$.termchar The DTMF key used to terminate the recording. Supported as documented in VoiceXML 2.0.
<transfer> x$.duration The duration of a successful call. Supported as documented in VoiceXML 2.0.
x$.inputmode The input mode of the terminating command: voice or DTMF. Supported as documented in VoiceXML 2.0.
x$.utterance A string that represents the words recognized by the speech recognition engine or the DTMF input used to terminate transfer. Supported as documented in VoiceXML 2.0.