SpeechRecognitionEngine.AudioLevelUpdated Evento
Definição
Gerado quando o SpeechRecognitionEngine relata o nível de sua entrada de áudio.Raised when the SpeechRecognitionEngine reports the level of its audio input.
public:
event EventHandler<System::Speech::Recognition::AudioLevelUpdatedEventArgs ^> ^ AudioLevelUpdated;
public event EventHandler<System.Speech.Recognition.AudioLevelUpdatedEventArgs> AudioLevelUpdated;
member this.AudioLevelUpdated : EventHandler<System.Speech.Recognition.AudioLevelUpdatedEventArgs>
Public Custom Event AudioLevelUpdated As EventHandler(Of AudioLevelUpdatedEventArgs)
Tipo de evento
Exemplos
O exemplo a seguir adiciona um manipulador para o AudioLevelUpdated evento a um SpeechRecognitionEngine objeto.The following example adds a handler for the AudioLevelUpdated event to a SpeechRecognitionEngine object. O manipulador gera o novo nível de áudio para o console.The handler outputs the new audio level to the console.
private SpeechRecognitionEngine recognizer;
// Initialize the SpeechRecognitionEngine object.
private void Initialize()
{
recognizer = new SpeechRecognitionEngine();
// Add an event handler for the AudioLevelUpdated event.
recognizer.AudioLevelUpdated +=
new EventHandler<AudioLevelUpdatedEventArgs>(recognizer_AudioLevelUpdated);
// Add other initialization code here.
}
// Write the audio level to the console when the AudioLevelUpdated event is raised.
void recognizer_AudioLevelUpdated(object sender, AudioLevelUpdatedEventArgs e)
{
Console.WriteLine("The audio level is now: {0}.", e.AudioLevel);
}
Comentários
O SpeechRecognitionEngine gera esse evento várias vezes por segundo.The SpeechRecognitionEngine raises this event multiple times per second. A frequência com que o evento é gerado depende do computador no qual o aplicativo está sendo executado.The frequency with which the event is raised depends on the computer on which the application is running.
Para obter o nível de áudio no momento do evento, use a AudioLevel Propriedade do associado AudioLevelUpdatedEventArgs .To get the audio level at the time of the event, use the AudioLevel property of the associated AudioLevelUpdatedEventArgs. Para obter o nível de áudio atual da entrada para o reconhecedor, use a propriedade do reconhecedor AudioLevel .To get the current audio level of the input to the recognizer, use the recognizer's AudioLevel property.
Ao criar um AudioLevelUpdated delegado, você identifica o método que manipulará o evento.When you create an AudioLevelUpdated delegate, you identify the method that will handle the event. Para associar o evento ao manipulador de eventos, adicione uma instância do delegado ao evento.To associate the event with your event handler, add an instance of the delegate to the event. O manipulador de eventos é chamado sempre que o evento ocorre, a menos que você remova o representante.The event handler is called whenever the event occurs, unless you remove the delegate. Para obter mais informações sobre delegados de manipulador de eventos, consulte eventos e delegados.For more information about event-handler delegates, see Events and Delegates.