Compartir a través de


OnClientNoReco Property

  Microsoft Speech Technologies Homepage

Gets or sets the name of a client-side function that is called when the platform detects no recognition. Read/write.

Usage

ASP.NET markup: <speech:Reco OnClientNoReco="..." />
Get value: String = Reco.OnClientNoReco;
Set value: Reco.OnClientNoReco = String;
Data type: String
Required: No

Remarks

The purpose of this script is to examine the error code and to determine whether the RunSpeech dialog manager should continue execution on the current page or should navigate to the default error page. Different types of errors are distinguished by status codes. See the onerror and onnoreco events of the SALT listen element for a list of these codes.

The value of the OnClientNoReco property is the name of this custom client-side script function, without parameters or parentheses. The client-side dialog manager calls this function, using the following syntax, after detecting no recognition.

The script block that contains this function should be placed before the control that calls the function. For more information, see "Placement of Script Blocks" in Authoring Notes.

Syntax

function FunctionName ( int status )
{
     // Client-side code referenced by Reco.OnClientNoReco
}

Parameters

  • status
    The error code returned in the event object.

Return Value

None.

Example

The following example demonstrates a script routine that maintains a count of the error events that it has been assigned to handle. Because the routine does not evaluate the status parameter, it is the author's responsibility to assign the routine to error events only.

<form id="Form1" method="post" runat="server">
  ...
  <script>
  //
  // Continue execution after the first 3 Reco errors, then quit.
  //
  function RecErr ( status )
  {
    var AllowedErrors = 3;
    if(typeof(SpeechCommon.GetViewState("RecErrs")) == "undefined") {
      SpeechCommon.SetViewState("RecErrs", "0");
    } 
    SpeechCommon.SetViewState("RecErrs", parseInt(SpeechCommon.GetViewState("RecErrs"), 10) + 1);
    if(parseInt(SpeechCommon.GetViewState("RecErrs"), 10) > AllowedErrors) {
      return false;
    }
    return true;
  }
  </script>
  ...
  <speech:qa id="qaOrig" runat="server">
    <Prompt id="prompt1" InlinePrompt="What is your originating city?"></Prompt>
    <Reco id="recoOrig" InitialTimeout="3000" BabbleTimeout="10000" EndSilence="1000" Reject="0.5"
      OnClientError="RecErr" OnClientNoReco="RecErr" OnClientSilence="RecErr" >
      <Grammars>
        <speech:grammar src="grammars/cities.xml" runat="server"></speech:grammar>
      </Grammars>
    </Reco>
    <Answers>
      <speech:answer id="ansOrig" XPathTrigger="/sml/origcity" SemItem="siOrig" runat="server">
      </speech:answer>
    </Answers>
  </speech:qa>
  ...
</form>

See Also

Reco Class | Reco Constructor | Reco Members | Reco Properties | Reco Methods | Reco Events | Reco Remarks