Freigeben über


targetlocation Attribute

  Microsoft Speech Technologies Homepage

Specifies where the audiometer element appears, relative to the specified targetelement. 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" />

The following values can be used to specify where the audiometer appears relative to the page element named using the targetelement attribute.

Position Description
right Appears to the right of the element, aligned with the top edge of the element. Default.
below Appears below the element aligned with the left edge of the element.
over Appears above the top, left corner of the element.
title Appears in the title bar of the window in which the element appears.
cursor The top, left corner of the audiometer is positioned at the pointing device cursor location.

If the targetelement attribute is not specified, the targetlocation attribute has no meaning and is ignored. If the targetelement attribute is specified, but targetlocation is not, the default position is right.

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

The targetelement attribute cannot be specified 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 targetlocation 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

listen Element | targetelement Attribute