Share via


id Attribute

  Microsoft Speech Technologies Homepage

Uniquely identifies a listen element.

<listen  id = "listenName">

Remarks

The id attribute is a string value that uniquely names the listen element. The name must be a valid XML name and unique within the HTML document.

Example

The following code demonstrates the use of the id attribute.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns:salt="http://www.saltforum.org/2002/SALT">
  <head>
    <title>listen Test</title>
    <object id="Speechtags" CLASSID="clsid:DCF68E5B-84A1-4047-98A4-0A72276D19CC" VIEWASTEXT></object>
  </head>
  
  <body>
    <!-- declare the object on the page-->
    <?import namespace="salt" implementation="#Speechtags" />
    <salt:listen id="listen1" mode="automatic" endsilence="500" babbletimeout="5000" onreco="Handleonreco()"
    onnoreco="Handleonnoreco()"    onsilence="Handleonsilence()" onerror="Handleonerror()" 
    onbabbletimeout="Handleonerror()">
      <salt:grammar name="cities"> 
        <grammar version="1.0" tag-format="semantics-ms/1.0" lang="en-US" 
        xmlns="http://www.w3.org/2001/06/grammar" root="cities">
          <rule id="cities">
            <one-of>
              <item>Seattle</item> 
              <item>Boston</item> 
              <item>Houston</item> 
              <item>Dallas</item> 
            </one-of>
          </rule>
        </grammar>
      </salt:grammar>
      <salt:bind targetelement="boxReco" targetattribute="value" value="//cities"/>
    </salt:listen>
    
    <input type="button" name="BtnDe" value="Start" OnClick="Start()" id="Button"/>
    
    <br><br>
    This example uses an automatic mode listen.<br>
    Click Start to begin; after speaking, the application will automatically stop.<br>
    Valid city names for recognition: Seattle, Boston, Dallas, and Houston.

    <br><br>
    <table cellspacing=0 cols=2>
      <tr>
        <td>Recognition Status:</td> 
        <td><input type="text" size="40" name="boxStatus" value="(recognition status goes here)"
        id="boxStatus"/></td>
      </tr>

         <td>Recognition Text:</td> 
         <td><input type="text" size="40" name="boxReco" value="(recognition text goes here)"
         id="boxReco"/></td>
      </tr>
    </table>  

    <br><br>
    Semantic Markup Language (SML) Result:<br>
    <TEXTAREA cols="60" rows="3" ID=txtComments>(Semantic Markup Language (SML) results display here)
    </TEXTAREA>
    <script language="JScript">
    <!--
      function Start() {
        boxStatus.value = "";
        boxReco.value = "";
        txtComments.value = "";
        listen1.Start();
      }
      function Handleonreco(){
        boxStatus.value = listen1.status;
        boxReco.value = event.srcElement.text;
        txtComments.value = event.srcElement.recoresult.xml
      } 
      function Handleonnoreco(){
        boxStatus.value = "onnoreco fired " + listen1.status;
        boxReco.value = ""
      }
      function Handleonsilence(){
        boxStatus.value = "onsilence fired " + listen1.status;
        boxReco.value = ""
      }
      function Handleonerror(){
        boxStatus.value = "onerror fired " + listen1.status;
        boxReco.value = "";
      }
    -->  
    </script>
  </body>
</html>

See Also

listen Element