<record>

Records an audio sample.

Syntax

<record

      name="string"

      expr="js_expression"

      cond="js_expression"

      maxtime="time_interval"

      finalsilence="time_interval"

      type="MIME_type"

      beep="true"|"false"

      modal

Not implemented

      dtmfterm="true"|"false"

>

   Child Elements

</record>

Description

Input item that collects a recording from the user and stores the result in the input variable.

Attribute Description
name

Name of the input variable used to store the recording. The variable name may not be a JavaScript reserved keyword.

The input variable has dialog (form) scope; its name must be unique among all VoiceXML and JavaScript variables within the form's scope.

expr

JavaScript expression that assigns the initial value of the input variable. Optional (default is undefined).

If you set the input variable to a value other than undefined, you'll need to clear it before the <record> can execute.

cond

JavaScript boolean expression that also must evaluate to true for the <record> to execute. Optional (default is true).

If not specified, the value of the input variable alone determines whether or not the <record> can execute.

maxtime

Maximum duration of the recording. Optional (default is 10s).

Express a time interval as an unsigned number followed by s for time in seconds; ms for time in milliseconds (the default).

finalsilence

Duration of silence that will terminate the recording. Optional (default is 1.5s).

The minimum allowed value is 0.2 seconds. The maximum allowed value is 10 seconds.

Express a time interval as unsigned number followed by s for time in seconds; ms for time in milliseconds (the default).

Note: If the value of the finalsilence attribute is 0s, the interpreter does a fixed length record for maxtime seconds. The recording does not wait for speech input and does not throw a NOINPUT event. The recording can still be terminated using any dtmf key if the dtmfterm attribute is set to true.

type

MIME encoding of the submitted document. Optional (default is audio/wav).

The supported types and the format of the resulting recording are:

 •  audio/wav--WAV (RIFF header) 8 KHz 8-bit mono mu-law [PCM] single channel
 •  audio/basic--WAV (RIFF header) 8 KHz 8-bit mono mu-law [PCM] single channel
 •  audio/vnd.wave;codec=1--WAV (RIFF header) 8 KHz 16-bit mono Linear [PCM] single channel]
beep

Specifies whether to emit a beep just prior to recording. Optional (default is false).

modal

Not implemented.

dtmfterm

Specifies whether a DTMF keypress terminates the recording. Optional (default is true).

When set to true, the DTMF keypress is not part of the recording.

If no audio is collected during the execution of <record>, its input variable is unfilled. This allows the form item to be visited again by the FIA.

Properties of the Shadow Variable

Corresponding to the input variable name is a "shadow variable" called name$. After the recording is made, additional information is available in the following properties of this shadow variable:

Property Description

duration

The duration of the recording in milliseconds.

size

The size of the recording in bytes.

termchar

If the dtmfterm attribute is true, and the user terminates the recording by pressing a DTMF key, then this property is the key pressed (for example, #). Otherwise, the property is null.

maxtime

true if the recording was terminated because the maximum duration (specified by the maxtime attribute) was reached; false if the recording terminated within the maximum time.

recording

If the recordutterance or bevocal.audio.capture property is set to true and the user's speech matched the field grammar, the recording property contains an audio capture of the user's speech. If no audio is collected, this variable is undefined.

You can send the captured audio to a server using a <data> element. Doing so is useful if you need a record of the user's speech for legal reasons.

recordingsize

The size of the recording in bytes, or undefined if no audio is collected.

recordduration

The duration of the recording in milliseconds, or undefined if no audio is collected.

For a <record> element whose name is name, you access the property propName of the shadow variable with the syntax:

 name$.propName

For example, you access the duration property for the <record> named greeting as:

 greeting$.duration

Note: If the user hangs up during the recording, the interpreter throws a hang up event (connection.disconnect.hangup in VoiceXML 2.0; telephone.disconnect.hangup in VoiceXML 1.0). Any audio data recorded before hang up is available in the input variable and properties of the shadow variable are set as described above.

Tip:

 •  If a JavaScript expression contains any of the characters "<", ">", or "&", that character must be replaced with the corresponding escape sequence "&lt;", "&gt;", or "&amp;". For more information, see JavaScript Quick Reference.

Usage

Parents Children
<form>
<audio>
<catch>
<enumerate>
<error>
<filled>
<grammar>
<help>
<noinput>
<nomatch>
<prompt>
<property>
<value>

See Also

 •  VoiceXML 2.0 Specification: <record>

Examples

 <?xml version="1.0" ?>
 <!DOCTYPE vxml PUBLIC "-//BeVocal Inc//VoiceXML 2.0//EN"
  "http://cafe.bevocal.com/libraries/dtd/vxml2-0-bevocal.dtd">
 
 <vxml version="2.0" xmlns="http://www.w3.org/2001/vxml">
   <form id="form-record">
     <record name="greeting" beep="true" maxtime="10s" finalsilence="2000ms">
       <prompt> 
         Please record your greeting after the tone.
       </prompt> 
       <noinput> 
         i did not hear anything. <reprompt/> 
       </noinput> 
     </record>
     <field name="confirm" type="boolean">
       <prompt>
         your greeting is <audio expr="greeting"/> 
         to keep it say yes, to discard it say no.
       </prompt>
       <filled>
         <if cond="confirm">
           <prompt> ok, i will save your greeting </prompt>
           <submit method="post" namelist="greeting"
             next="greetingstore.jsp"/>
         <else/> 
           <prompt> ok, lets try again </prompt>
           <clear namelist="greeting confirm"/>
         </if>
       </filled>
     </field> 
   </form>
 </vxml>
   

[Show Frames]   [FIRST] [PREVIOUS] [NEXT]
BeVocal, Inc. Café Home | Developer Agreement | Privacy Policy | Site Map | Terms & Conditions
Part No. 520-0001-02 | © 1999-2007, BeVocal, Inc. All rights reserved | 1.877.33.VOCAL