Freigeben über


targetelement Attribute

  Microsoft Speech Technologies Homepage

Specifies the name of the page element that is adjacent to where the audiometer element appears. Optional.

<audiometer targetelement="ctlName" targetlocation="location" />

Remarks

The audiometer element is a Microsoft-specific extension to Speech Application Language Tags (SALT). Consequently, it has its own namespace that must be included in order to enable functionality of the audiometer element. The namespace declaration is:

<html xmlns:multimodal="https://schemas.microsoft.com/speech/2002/12/salt/multimodal"/>

In addition, the following statement must also be included in the body to ensure property operation.

<?import namespace="multimodal" implementation="#SpeechTags" />

When targetelement is specified, targetlocation must also be specified to properly position the audiometer element relative to targetelement. If targetlocation is not specified, the default position is right.

If x and y attributes are specified, neither targetelement nor targetlocation have any meaning and are ignored.

The targetelement cannot be specified when using the Speech Add-in for Microsoft Pocket Internet Explorer because the audiometer always appears in the status bar.

Example

The following code demonstrates the use of the targetelement attribute.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns:multimodal="https://schemas.microsoft.com/speech/2002/12/salt/multimodal"
xmlns:salt="http://www.saltforum.org/2002/SALT"  >
  <head>
    <title>Audiometer Example</title>
  </head>
  <body onload="Prompt1.Start()">
    <!-- declare the object on the page-->
    <object id="SpeechTags" CLASSID="clsid:DCF68E5B-84A1-4047-98A4-0A72276D19CC" VIEWASTEXT></object>    
    <?import namespace="salt" implementation="#SpeechTags" />
    <?import namespace="multimodal" implementation="#SpeechTags" />
    
    <salt:prompt id="Prompt1">
      Please speak the name of a major US city after clicking the Start button.
    </salt:prompt>

    
    <salt:listen id="listen1" mode="automatic"  onreco="Handleonreco()" onnoreco="Handleonnoreco()" 
    onsilence="Handleonsilence()" onerror="Handleonerror()" onbabbletimeout="Handleonerror()">
      <multimodal:audiometer id="audiometerTag" targetelement="txtComments" targetlocation="right"
      height="20" width="50"/>
      <salt:grammar name="cities"> 
        <grammar version="1.0" tag-format="semantics-ms/1.0" root="cities" 
        lang="en-US" xmlns="http://www.w3.org/2001/06/grammar">
          <rule id="cities">
            <one-of>
              <item>Atlanta</item>
              <item>Baltimore</item>
              <item>Boston</item>
              <item>Chicago</item>
              <item>Dallas</item>
              <item>Denver</item>
              <item>Detroit</item>
              <item>Houston</item>
              <item>Las Vegas</item>
              <item>Los Angeles</item>
              <item>Miami</item>
              <item>Minneapolis</item>
              <item>New York City</item>
              <item>Philadelphia</item>
              <item>Pittsburgh</item>
              <item>Reno</item>
              <item>Salt Lake City</item>
              <item>San Francisco</item>
              <item>Seattle</item>
              <item>Washington, DC</item>
            </one-of>
          </rule>
        </grammar>
      </salt:grammar>
      <salt:bind targetelement="boxReco" targetattribute="value" value="//cities"/>
    </salt:listen>
    
    <table cellspacing="0" cellpadding="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>
      <tr>
        <td>Recognition Text:</td> 
        <td><input type="text" size="40" name="boxReco" value="(recognition text goes here)"
        id="boxReco"/></td>
      </tr>
    </table>      

    <br>
    Semantic Markup Language (SML) Result:<br>
    <TEXTAREA cols="60" rows="5" ID=txtComments>(Semantic Markup Language (SML) results are displayed here)
    </TEXTAREA>
    <p>
     <input type="button" name="BtnStart" value="Start" onmousedown="Start()"  id="BtnStart"/>    
       
    <script language="JScript">
    <!--
      function Start() {
        boxStatus.value = "(Listening...)";
        boxReco.value = "(Waiting response)";
        txtComments.value = "(Waiting response)";
        listen1.Start();
      }

      function Stop() {
        listen1.Stop();
        boxStatus.value = listen1.status;
        boxReco.value = event.srcElement.text;
      }

      function Handleonreco() {
        listen1.Stop();
        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 = ""
        txtComments.value = "";
      }

      function Handleonsilence() {
        boxStatus.value = "onsilence fired " + listen1.status;
        boxReco.value = ""
        txtComments.value = "";
      }

      function Handleonerror() {
        boxStatus.value = "onerror fired " + listen1.status;
        boxReco.value = "";
        txtComments.value = "";
      }
    -->  
    </script>
  </body>
</html>

See Also

audiometer Element | targetlocation Attribute