Share via


bargein Attribute

  Microsoft Speech Technologies Homepage

Specifies whether the prompt is cut off when the user speaks or dual tone multi-frequency (DTMF) input is received. Optional.

HTML <prompt bargein="boolean">
JScript prompt.bargein = boolean

Remarks

The bargein attribute accepts a Boolean value (either true or false). If true, the prompt is stopped and the current subqueue is flushed when either speech or DTMF input is detected. If false, the prompt will not be stopped. The default value for the bargein attribute is true. In either case, the onbargein event is raised when input is detected.

Cutting off the prompt or spoken output allows the user to continue navigation without waiting for spoken output to finish. For example, if the user already knows which option or command to speak, there is no need to wait for the system to speak the full list of commands or options.

The bargein attribute is enabled by default, that is bargein is set to true. As soon as DTMF collection and/or recognition starts, the client platform is listening for either a DTMF tone or a speech input event. This type of interruption is also called delegated bargein or cut-through.

An optional param element with a name attribute of bargeintype can specify what causes a prompt to be cut off. The bargeintype parameter is a Microsoft-specific implementation. The following table describes each bargeintype and its behavior.

bargeintype Description
speech Any sound energy raises the onbargein event.
grammar A recognition that partially matches the grammar can raise the onbargein event. The confidence threshold that actually raises the onbargein event is the setting of the reject attribute of the listen element. This is the default bargein type.
final Only a successful valid recognition causes the onbargein event to occur.

Example

The following code demonstrates the use of the bargein attribute. The example has one button and a text box. Click Start Prompt to begin playing a long prompt. Because bargeintype is set to speech, any sound interrupts play. If the speech is found in the specified grammar (here as cities.grxml but any grammar will do), the recognized word or phrase appears in the text box. Otherwise, any other utterance or sound stops the prompt.

Do not wait too long before speaking or making a noise. The default initialtimeout attribute is set to 5000 milliseconds, or five seconds. Speech after this time has elapsed is not recognized.

<!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" bargein ="true" onbargein="HandleBargeIn()">
      <salt:param name="bargeintype">final</salt:param>
      This is a long prompt, intended to be 
      interrupted by the user's spoken input.
      Please interrupt this prompt.

    </salt:prompt>
    <salt:listen id="testreco" onreco="Handleonreco()">
      <salt:grammar id="cities" src="cities.grxml"></salt:grammar>
    </salt:listen>

    <input type="button" name="BtnStart" value="Start Prompt" OnClick="StartPlayback()" id="Button1">
    <input type="button" name="BtnStop" value="Stop Prompt" OnClick="StopPlayback()" id="BtnStop">

    <br><br>
    
    <input type="textbox" name="TxtBox1" value="Start Prompt" OnClick="StartPlayback()" id="TxtBox1">

    <script language="JScript">
    <!--
      function StartPlayback() {
        Prompt1.Start();
        StartListening();
      }
      function StopPlayback() {
        testreco.Stop();
        Prompt1.Stop();
      }
      function StartListening() {
        TxtBox1.value = "Starting to listen...";
        testreco.Start();
        TxtBox1.value = "Listening.";
      }
      function Handleonreco() {
        testreco.Stop();
        TxtBox1.value = event.srcElement.text;
      }
      function HandleBargeIn() {
        testreco.Stop();
        Prompt1.Stop();
        TxtBox1.value = "BargeIn"
      }
    -->
    </script>
  </body>
</html>

See Also

prompt Element |  onbargein Event | param Element