Partilhar via


onerror Event

  Microsoft Speech Technologies Homepage

Occurs when a serious or fatal error occurs with the text-to-speech (voice output) process.

HTML <prompt.onerror="eventHandler()">
JScript prompt.onerror = eventHandler;
Named Script <SCRIPT FOR = prompt EVENT = onerror>

Remarks

Different types of errors are distinguished by status values. Although it does not receive properties directly, the event handler can query the status property of the element for data about the onerror event.

The following table shows the values of the status property that can be set when an error occurs.

Status Value Description
 -1 Failed to queue the prompt onto the speech subqueue or the PromptQueue object.
 -2 Failed to find a speech output resource (for distributed architectures).
 -3 An invalid property/attribute setting caused a problem within the prompt request.
 -4 Failed to resolve content. This is likely to be an unreachable Uniform Resource Identifier (URI), or malformed markup content.
 -5 Failed to pause audio playback. This is a Microsoft-specific SALT extension that applies to all Microsoft speech clients except Telephony Application Services.
 -6 Failed to resume audio playback. This is a Microsoft-specific SALT extension that applies to all Microsoft speech clients except Telephony Application Services.

Example

The following code demonstrates the use of the onerror event. The page has two buttons, and a text box for textual output. Two prompt elements are created. Prompt1 is a basic prompt with no special characteristics. Prompt2 supports error handling by defining the onerror event. Clicking the Start Prompt button speaks Prompt1's text which does not contain any errors. Prompt2 produces an error, because the file hello.wav cannot be found. After clicking Start Error, the page displays a note in the text box indicating that it has encountered an error.

<!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:prompt id="Prompt1" onerror = "DoError()" >
      This is error free text.
    </salt:prompt>

    <salt:prompt id="Prompt2" onerror = "DoError()" >
      <src="Hello.wav" />
    </salt:prompt>

    <input type="button" name="BtnStart" value="Start Prompt" OnClick="StartPrompt1()" id="StartBtn">

    <input type="button" name="BtnError" value="Start Error" OnClick="StartPrompt2()" id="ErrorBtn">
  
    <br><br>
    <input type="text" name="TxtOutput" size = "80" value="No error encountered" id="OutputTxt">
   
    <script language="JScript">
    <!--
      function StartPrompt1() {
        OutputTxt.value = "No error encountered";
        Prompt1.Start();
      }
       
      function StartPrompt2() {
        OutputTxt.value = "No error encountered";
        Prompt2.Start();
      }
       
      function DoError() {
        if (Prompt2.status == 0)
          OutputTxt.value = "No error encountered";
        else
          OutputTxt.value = "An error occurred - status value:" + Prompt2.status;
      }
    -->
    </script>
  </body>
</html>

See Also

prompt Element |  status Property | PromptQueue Object | Stop Method | Speech Application SDK Troubleshooting