Partager via


mode Attribute

  Microsoft Speech Technologies Homepage

Specifies the recognition mode. Optional.

HTML <listen mode="recoMode">
JScript listen.mode = "recoMode"

Remarks

The value assigned to the mode attribute can be any one of the following:

Value Description
automatic Automatic mode is used for recognitions in telephony or hands-free scenarios. In these voice-only scenarios, users have no direct control over the browser, and the recognition platform determines when to stop recognition and return results (typically once a complete path through the grammar has been recognized and the endsilence value has been exceeded).
multiple Multiple-mode recognition is used in "open-microphone" or dictation scenarios, that is, when the microphone stays on for an extended period of time. These scenarios, where intermediate results may need to be returned before recognition is stopped (called "open microphone"), not only require an explicit stop but also need to return multiple recognition results to the application before the recognition process is stopped.
single Single-mode recognition is typically used in tap-and-talk scenarios. A tap-and-talk scenario is one in users control the period of time they wish to speak to the device by tapping and holding their stylus on a form field. The browser uses a GUI event that occurs, for example, when the stylus is lifted, to control when recognition should stop and results are returned.

If the mode attribute is unspecified, the listen element defaults to automatic mode.

Example

The following script demonstrates the use of the mode attribute.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns:salt="http://www.saltforum.org/2002/SALT">
  <head>
    <object id="Speechtags" CLASSID="clsid:DCF68E5B-84A1-4047-98A4-0A72276D19CC" VIEWASTEXT></object>
  </head>
    
  <body>
    <?import namespace="salt" implementation="#Speechtags" />
    <salt:listen id="listen1" mode="automatic" reject=".65" onreco="Handleonreco()" onnoreco="Handleonnoreco()">
      <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="root">
          <rule id="root">
            <item repeat="0-1">from </item>
            <ruleref uri="#cities" />
          </rule>
          <rule id="cities">
            <one-of>
              <item>Seattle</item> 
              <item>Boston</item> 
              <item>Houston</item> 
              <item>New York</item> 
            </one-of>
          </rule>
        </grammar>
      </salt:grammar>
     </salt:listen>

    <input type="button" name="BtnListen" value="Start Listening" OnClick="StartListening()" id="StartListen">
    <input type="button" name="BtnCancel" value="Cancel" OnClick="CancelListen()" id="CancelListen"
    
    <br><br>
      This is an example of an automatic mode listen.<br>
      Click Start to begin; after speaking, the application will automatically stop.<br>
      Valid city names for recognition are Seattle, Boston, Houston, and New York.
    
    <br><br>
    <input type="text" name="TxtStatus" size = "80" value="Listening for test" id="RecoTxt">
    
    <script language="JScript">
    <!--     
      function StartListening() {
        RecoTxt.value  = "Starting to listen...";
        listen1.Start();
        RecoTxt.value  = "Listening...";
      }
      function CancelListen() {
        RecoTxt.value = "Canceled listen";
        listen1.Cancel();
      }
      function Handleonreco() {
        RecoTxt.value = "Received onreco.";
        smlResult = event.srcElement.recoresult;
        RecoTxt.value = smlResult.xml;
      }
      function Handleonnoreco() {
        RecoTxt.value = "Received onnoreco";
      }
    -->
    </script>
  </body>
</html>

See Also

listen Element | Recognition Mode: Automatic Example |  Recognition Mode: Single Example | Recognition Mode: Multiple Example