Compartir a través de


record Element

  Microsoft Speech Technologies Homepage

Configures the recording of audio input.

Syntax

<record type=audioType />

The record element consists of the following member.

Attribute Description
type Specifies the type of audio file used to contain the recorded speech. Optional. If omitted, the default is a G.711 wave file, that is, "audio/wav;codec=g711"

Remarks

The record element is a child of the listen element.

If a listen element contains a record element and one or more grammar elements, the record element takes precedence and the grammar elements are ignored. If a listen element containing a record element is started but then stopped before any utterance occurs, an onnoreco event is raised even though the recording contains only silence.

When the record element is used to record to a file, the record element uses the attributes, methods, and events of the listen.

Example

The following code demonstrates the use of the record element.

<html xmlns:salt="http://www.saltforum.org/2002/SALT">
  <head>
    <object id="Speechtags" CLASSID="clsid:DCF68E5B-84A1-4047-98A4-0A72276D19CC" VIEWASTEXT></object> 
  </head>
  <body onload="RunAsk()">
    <?import namespace="salt" implementation="#SpeechTags" />
    <form id="f1" action="http://www.woodgrovebank.com/savewaveform.aspx" method="get">
      <input name="vmail" type="hidden" />
    </form>
    
    <table cellspacing="0" cols="2">
      <tr>
        <td>Recording duration:</td>
        <td><input id="iptRecDur" type="text"  size="50"></td>
      </tr>
      <tr>
        <td>Recording location:</td>
        <td><input id="iptRecLoc" type="text" size="50"></td>
      </tr>
      <tr>
        <td>Recording size:</td>
        <td><input id="iptRecSize" type="text" size="50"></td>
      </tr>
      <tr>
        <td>Recording type:</td>
        <td><input id="iptRecType" type="text" size="50" ></td>
      </tr>
</table>

    <salt:prompt id="p_record" oncomplete="l_recordvm.Start()">
      Please speak after the tone. You may press any key to end your recording.
    </salt:prompt>
    <salt:prompt id="p_save">
      Do you want to save this recording?
    </salt:prompt>

    <!-- Recording session - max 60 seconds recording -->
    <salt:listen beep="true" id="l_recordvm" initialtimeout="3000" endsilence="1500" babbletimeout="60000"
     onreco="saveAudio()" onnoreco="saveAudio()" onsilence="RunAsk()" >
      <salt:record type="audio//x-wav" />
    </salt:listen>

    <!-- listen for capturing whether user wants to save voice mail -->
    <salt:listen id="l_save" onreco="processSave()">
      <salt:grammar name="yesno"> 
        <grammar version="1.0" tag-format="semantics-ms/1.0" lang="en-US" 
        xmlns="http://www.w3.org/2001/06/grammar" root="root">
          <rule id="root">
            <ruleref uri="#yesno" />
          </rule>
          <rule id="yesno">
            <one-of>
              <item>Yes</item> 
              <item>No</item> 
            </one-of>
          </rule>
        </grammar>
      </salt:grammar>
    </salt:listen>      
      
    <script language="JScript">
    <!--
      function RunAsk() {
        p_record.Start();
      }
      // Ask user if they are satisfied with their recording
      function saveAudio () {
        showRecDetails();
        p_save.Start();
        l_save.Start();
      }
      // If user is satisfied post file name back to web server
      // otherwise start again
      function processSave () {
        smlResult = event.srcElement.recoresult;
        saidText = smlResult.selectSingleNode("/").text;
        if (saidText == "Yes") {
          alert("Recording has been saved at " + l_recordvm.recordlocation);
        } else {
          alert("Recording will not be saved.");
        RunAsk();
        }
      }

      function showRecDetails() {
        iptRecDur.value=l_recordvm.recordduration + " milliseconds";
        iptRecLoc.value=l_recordvm.recordlocation;
        iptRecSize.value=l_recordvm.recordsize + " bytes";  
        iptRecType.value=l_recordvm.recordtype;
      }
    -->  
    </script>
  </body>
</html>

See Also

listen Element |  type Attribute