BargeInTypes Enumeration
This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.
Defines the values that set the BargeInType property.
Namespace: Microsoft.SpeechServer.Synthesis
Assembly: Microsoft.SpeechServer (in microsoft.speechserver.dll)
Syntax
'Declaration
<FlagsAttribute> _
Public Enumeration BargeInTypes
[FlagsAttribute]
public enum BargeInTypes
Members
Member name | Description |
---|---|
Dtmf | Playing of the prompt is stopped when DTMF input is detected. |
None | Bargein is disabled. |
Speech | Playing of the prompt is stopped when speech input is detected. |
Example
The following code example consists of a custom activity that prompts while listening for user speech that might stop the prompt. If the BargeInType property indicates speech bargein, the example extracts the time offset at which the bargein occurred.
using System;
using System.Collections.Generic;
using System.Text;
using System.Workflow.Activities;
using System.Workflow.ComponentModel;
using Microsoft.SpeechServer.Dialog;
using Microsoft.SpeechServer.Recognition;
using Microsoft.SpeechServer.Synthesis;
namespace BargeIn
{
/// <summary>
/// Activity deriving from SpeechCompositeActivity.
/// </summary>
public class CoreBargeIn : SpeechCompositeActivity
{
/// <summary>
/// Prompt played by the activity.
/// </summary>
public const string pt = "Please say a number between one and nine, while I drone on. ";
/// <summary>
/// Creates a new instance.
/// </summary>
public CoreBargeIn()
{
}
/// <summary>
/// Executes the activity.
/// </summary>
/// <param name="executionContext">The execution context</param>
protected override void ExecuteCore(ActivityExecutionContext executionContext)
{
Uri gu = new System.Uri(Workflow.ApplicationHost.LocalPath, "Grammars/Library.grxml");
Grammar g = new Microsoft.SpeechServer.Recognition.Grammar(gu, "Cardinal_1_to_9");
Workflow.SpeechRecognizer.LoadGrammarAsync(g);
Workflow.Synthesizer.BargeInType = BargeInTypes.Speech;
// Specify the SpeakCompleted event-handler and start the prompt
Workflow.Synthesizer.SpeakCompleted += Synthesizer_SpeakCompleted;
Workflow.Synthesizer.SpeakAsync(pt, SynthesisTextFormat.PlainText);
// Specify the RecognizeCompleted event-handler and start listening
Workflow.SpeechRecognizer.RecognizeCompleted += SpeechRecognizer_RecognizeCompleted;
Workflow.SpeechRecognizer.RecognizeAsync();
}
private void Synthesizer_SpeakCompleted(object sender, SpeakCompletedEventArgs e)
{
// Remove event-handler from SpeakCompleted
Workflow.Synthesizer.SpeakCompleted -= Synthesizer_SpeakCompleted;
if (e.BargeInType == BargeInTypes.Speech)
{
System.TimeSpan bargie = e.BargeInOffset;
}
}
private void SpeechRecognizer_RecognizeCompleted(object sender, RecognizeCompletedEventArgs e)
{
// Remove event-handler from RecognizeCompleted
Workflow.SpeechRecognizer.RecognizeCompleted -= SpeechRecognizer_RecognizeCompleted;
// End the custom activity
OnSpeechActivityClosed(e.Error);
}
}
}
Platforms
Development Platforms
Windows XP Professional with Service Pack 2 (SP2), Windows Server 2003, Windows Vista Ultimate Edition, Windows Vista Business Edition, Windows Vista Enterprise Edition
Target Platforms
Windows Server 2003