SpeechRecognitionEngine.AudioSignalProblemOccurred 事件

定义

SpeechRecognitionEngine 检测在音频信号的问题的时候引发。

public:
 event EventHandler<System::Speech::Recognition::AudioSignalProblemOccurredEventArgs ^> ^ AudioSignalProblemOccurred;
public event EventHandler<System.Speech.Recognition.AudioSignalProblemOccurredEventArgs> AudioSignalProblemOccurred;
member this.AudioSignalProblemOccurred : EventHandler<System.Speech.Recognition.AudioSignalProblemOccurredEventArgs> 
Public Custom Event AudioSignalProblemOccurred As EventHandler(Of AudioSignalProblemOccurredEventArgs) 

事件类型

示例

以下示例定义一个事件处理程序,用于收集有关事件 AudioSignalProblemOccurred 的信息。

private SpeechRecognitionEngine recognizer;  

// Initialize the speech recognition engine.  
private void Initialize()  
{  
  recognizer = new SpeechRecognitionEngine();  

  // Add a handler for the AudioSignalProblemOccurred event.  
  recognizer.AudioSignalProblemOccurred +=   
    new EventHandler<AudioSignalProblemOccurredEventArgs>(  
      recognizer_AudioSignalProblemOccurred);  
}  

// Gather information when the AudioSignalProblemOccurred event is raised.  
void recognizer_AudioSignalProblemOccurred(object sender, AudioSignalProblemOccurredEventArgs e)  
{  
  StringBuilder details = new StringBuilder();  

  details.AppendLine("Audio signal problem information:");  
  details.AppendFormat(  
    " Audio level:               {0}" + Environment.NewLine +  
    " Audio position:            {1}" + Environment.NewLine +  
    " Audio signal problem:      {2}" + Environment.NewLine +  
    " Recognition engine audio position: {3}" + Environment.NewLine,  
    e.AudioLevel, e.AudioPosition,  e.AudioSignalProblem,  
    e.recoEngineAudioPosition);  

  // Insert additional event handler code here.  
}  

注解

若要获取哪个问题发生了,请使用 AudioSignalProblem 关联的 AudioSignalProblemOccurredEventArgs的 属性。

创建 AudioSignalProblemOccurred 委托时,需要标识将要处理该事件的方法。 若要将事件与事件处理程序关联,请将该委托的一个实例添加到事件中。 除非移除了该委托,否则每当发生该事件时就会调用事件处理程序。 有关事件处理程序委托的详细信息,请参阅 事件和委托

适用于

另请参阅