Share via


onnoreco Event

  Microsoft Speech Technologies Homepage

Occurs when the recognition engine is unable to return valid recognition results.

HTML <listen onnoreco="noRecoHandler()">
Scripting listen.onnoreco = noRecoHandler;
Named Script <SCRIPT FOR = listen EVENT = onnoreco>

Remarks

The recognition process stops automatically when an onnoreco event occurs. The onnoreco event does not support event-bubbling or event propagation.

The client-side onreco event occurs when user speech matches any active grammar rule or element. The client-side onnoreco event occurs only when all active grammar rules and elements fail to produce a match. Recognition of a single phrase in an utterance, such as "yes" or "no", triggers the onreco event, even if the rest of the utterance is unrecognizable.

The various situations that cause an onnoreco event are distinguished by status codes. Although the event handler does not receive properties directly, it can query the listen element for status and results information. Status information is contained in the status property while the text property and the recoresult property contain results information.

The following table provides a list of the status conditions that can occur during an onnoreco event:

Status Value Description
-11 Recognizer did not detect speech within the period specified by the initialtimeout attribute.
-13 Sound was detected but no speech was recognized.
-14 Some speech was detected and interpreted but rejected with insufficient confidence.
-15 Speech was detected and interpreted, but a complete recognition was unable to be returned between speech detection and the interval specified by the babbletimeout attribute.

Example

The following code demonstrates the use of the onnoreco event. Click the button to start the recognition. Speak a city name from the list of available cities. A successful recognition displays the Semantic Markup Language (SML) result. An unsuccessful recognition displays verification of the onnoreco event. Errors are not handled.

<!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="BtnStop" value="Stop" OnClick="StopListening()" id="StopListen"
    
    <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 StopListening() {
        RecoTxt.value = "Stopped listen";
        listen1.Stop();
      }
      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 |  babbletimeout Attribute |  initialtimeout Attribute | onreco Event | recoresult Property | status Property | text Property