Last reviewed: 3/23/2024 12:34:28 PM

<record>

A <record> element records an audio sample.

Syntax

<record beep="boolean"
        cond="expression"
        dtmfterm="boolean"
        expr="expression"
        finalsilence="secondsormilliseconds"       
        maxtime="seconds"
        modal="boolean"
        name="var" 
        type="mediatype" />

Attributes

beep

If true, a tone is emitted just prior to recording. The default value is false.

cond

An expression that must evaluate to true after conversion to boolean in order for the form item to be visited.

dtmfterm

If true, any DTMF keypress not matched by an active grammar will be treated as a match of an active (anonymous) local DTMF grammar. The default value is true.

expr

The initial value of the form item variable; default is ECMAScript undefined. If initialized to a value, then the form item will not be visited unless the form item variable is cleared.

finalsilence

The interval of silence that indicates end of speech. The value is a Time Designation. The default value is a platform-specific value.

maxtime

The maximum duration to record. The value is a Time Designation. The default value is a platform-specific value.

modal

If this is true (the default) all non-local speech and DTMF grammars are not active while making the recording. If this is false, non-local speech and DTMF grammars are active.

name

The input item variable that will hold the recording.

type

The media format of the resulting recording. The default value is a platform-specific format which should be one of the following required formats.

Media Type Audio Format
audio/basic Raw (headerless) 8kHz 8-bit mono mu-law [PCM] single channel. (G.711)
audio/x-alaw-basic Raw (headerless) 8kHz 8 bit mono A-law [PCM] single channel. (G.711)
audio/x-wav WAV (RIFF header) 8kHz 8-bit mono mu-law [PCM] single channel.
audio/x-wav WAV (RIFF header) 8kHz 8-bit mono A-law [PCM] single channel.

Children

<audio>, <catch>, <enumerate>, <error>, <filled>, <grammar>, <help>, <noinput>, <nomatch>, <prompt>, <property>, and <val>.

Parents

<form>

Variables

name$.duration

The duration of the recording in milliseconds.

name$.size

The size of the recording in bytes.

name$.termchar

If the dtmfterm attribute is true, and the user terminates the recording by pressing a DTMF key, then this shadow variable is the key pressed (e.g. "#"). Otherwise it is undefined.

name$.maxtime

Boolean, true if the recording was terminated because the maxtime duration was reached.

Example

The following example illustrates recording audio.

<form>
    <property name="bargein" value="true"/>
    <block>
    <prompt>
        Riley is not available to take your call.
    </prompt>
    </block>
    <record  name="msg" beep="true" maxtime="10s"
    finalsilence="4000ms" dtmfterm="true" type="audio/x-wav">
    <prompt timeout="5s">
        Record a message after the beep.
    </prompt>
    <noinput>
        I didn't hear anything, please try again.
    </noinput>
    </record>

    <field name="confirm">
    <grammar type="application/srgs+xml" src="/grammars/boolean.grxml"/>
    <prompt>
        Your message is <audio expr="msg"/>.
    </prompt>
    <prompt>
        To keep it, say yes.  To discard it, say no.
    </prompt>
    <filled>
        <if cond="confirm">
        <submit next="save_message.pl" enctype="multipart/form-data"
            method="post" namelist="msg"/>
        </if>
        <clear/>
    </filled>
    </field>
</form>

Version Information

Supported in: VoiceXML 1.0, VoiceXML 2.0, and VoiceXML 2.1.