onbargein Event
Occurs when prompt playback is in progress and input is detected.
HTML | <prompt.onbargein="eventHandler()"> |
JScript | prompt.onbargein = eventHandler; |
Named Script | <SCRIPT FOR = prompt EVENT = onbargein> |
Remarks
If the bargein attribute is set to true, the onbargein event is raised whenever a prompt is interrupted by the user. A prompt is interrupted when input from noise, dual tone multi-frequency (DTMF) input, or speech from the user is detected.
The type of bargein is specified by a param element with a name attribute of bargeintype. The bargeintype parameter is a Microsoft-specific extension of SALT.
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. |
final | Only a successful valid recognition causes the onbargein event to occur. |
When speech recognition is activated and bargeintype equals final, the onbargein event occurs before the onreco event on the listen element. Also, when DTMF collection is activated and the numdigits equals 1, the onbargein event occurs before the onreco event on the dtmf element. The onbargein event always occurs immediately after either an onspeechdetected event or an onkeypress event is raised, regardless of the setting of bargeintype.
Although the event handler does not receive properties directly, it can query the prompt element for status information. The status property contains status information.
Example
The following code demonstrates the use of the onbargein event. This example has two buttons and a text box. The Stop Prompt button immediately interrupts the prompt; this button is provided as a convenience. Click Start Prompt to begin playing a long prompt. Because bargeintype is set to "speech," any sound interrupts play. An interruption is indicated by the text box that displays "Barge-in occurred." Do not wait too long before speaking or making a noise. The default initialtimeout attribute is set to 5000 milliseconds, or five seconds. Speech is not recognized after this time has elapsed.
<!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">speech</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="BtnStart1" 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="StartPlayback1()" id="TxtBox1">
<script language="JScript">
<!--
function StartPlayback() {
StartListening();
Prompt1.start();
}
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 = "Barge-in occurred"
}
-->
</script>
</body>
</html>
See Also
prompt Element | bargein Attribute | param Element | dtmf Element | listen Element